The use of smart cameras in industrial automation has opened up great opportunities to improve accuracy, efficiency, and productivity in the object detection and sorting process. The problems faced in object detection and sorting systems are the variability of environmental conditions, such as changing lighting and varying conveyor speeds, which can affect the accuracy of object detection. Therefore, this study aims to optimize the object detection and sorting process using the Festo SBOI-Q-R3C-WB smart camera through advanced image processing techniques, machine learning algorithms, and parameter adjustments such as sensor feature analysis, pattern matching, and lighting settings (300–1000 lux) and image filters. Experiments were conducted with cylindrical objects, varying conveyor speeds (0.5–2 m/s), and lighting intensity to evaluate system performance. The results showed that optimization of the Region of Interest (ROI) and the Canny Edge Detection algorithm successfully increased the detection accuracy from 82% (baseline) to 95%. The increase in lighting (optimal at 700 lux) and the use of adaptive contrast filters provided an additional 15% performance, resulting in a final accuracy of 98%. Statistical analysis using a paired t-test (α = 0.05) showed that the reduction in sorting errors was significant, from 8.5% (conventional system) to 1.7% (optimal system), with a p-value < 0.001. The system was also able to adapt to changes in conveyor speed up to 2 m/s and variations in object shape, with consistent accuracy above 95%. These findings prove that the integration of Festo's smart camera with optimized algorithms is a reliable solution for industrial automation, especially in dynamic sorting applications. Further developments could include the integration of deep learning for more complex object detection and increased processing speed through edge computing