Design and testing of a bottle liquid level detection system based on the integration of YOLOv8 and image processing
Abstract
Address the low efficiency of manual inspection on beverage filling lines and the poor adaptability of traditional vision methods in complex scenarios, this study presents an intelligent liquid level detection system that integrates YOLOv8 with image processing. The hardware uses an industrial CMOS camera and an LED backlight to build the image acquisition platform. First, the YOLOv8s model was employed for object detection of the bottle body and liquid level regions. It was trained on a self-built dataset of 650 multi-scene images, achieving a mean average precision (mAP@0.5) of 0.995.Next, a performance matrix analysis was conducted on four edge detection operators—Sobel, Prewitt, Laplacian, and Canny— within the detection bounding boxes. The Sobel operator was selected as the optimal and combined with adaptive binarization, high-pass filtering, and the Hough transform to achieve sub-pixel-level localization of the liquid level line. Finally, a pixel-to-physical-height conversion model was established through camera calibration, and a host computer interface was developed using PyQt5. Experiments demonstrate that the system achieves an average absolute measurement error of 0.11 mm and an average relative error of 0.61%, with a detection success rate of 95.4% across 300 complex scene images. This method combines the strong generalization capabilities of deep learning with the high positioning accuracy of image processing, providing a reliable solution for intelligent quality inspection on bottling lines.