Get a copy of this complete guide on sensors which is perfect for training and future reference. It explains the principles and features behind each type of sensor such as photoelectric, ultrasonic etc.
Getting the correct lighting allows you to maximize contrast and ensure reliable inspection. You can also try out filters to reduce lighting anomalies. Take a look at the available lighting choices now.