Integration of Computer Vision and CNC Machining for Automated Object Measurement and Customized Packaging
Abstract
— This paper presents an integrated computer vision — Computer Numerical Control (CNC) workflow that measures an object ’ s planar footprint and automatically generates G-code to cut customized cardboard packaging, thereby reducing manual sizing and setup in low-cost manufacturing environments. Specifically, a monocular camera within a controlled enclosure captures a single image, after which contour extraction, centroid estimation, and pixel-to-millimeter calibration are applied to convert pixel distances into metric length and height estimates; these measurements are then translated into CNC laser toolpaths and validated in Laser G-code Real-Time Blink Loop (LaserGRBL) prior to cutting. The approach was evaluated on 59 heterogeneous objects against calliper/ruler measurements, yielding sub-millimetric performance (Mean Absolute Error (MAE): 0.793 mm in length and 0.861 mm in height; RMSE: 1.057 mm and 1.394 mm, respectively). Moreover, most items exhibited errors below 2%, confirming suitability for practical packaging tolerances; nevertheless, occasional outliers (e.g., a 7.49% height error for a small snap-fastener case) indicate that further gains may be achieved through improved illumination control and enhanced contour robustness. Overall, these findings evidence a scalable route to on-demand packaging automation that effectively bridges perception and fabrication for small enterprises.