For many bottled beverage products, the integrity of the seal assures consumers that the product has not been altered and is safe to drink.
Missing or protruding bottle caps lead to unnecessary waste of raw materials and costly rework, resulting in lost profits. Furthermore, an improperly sealed cap can cause consumers to doubt the manufacturer's quality control during production, leading to product returns and rework, further reducing profits. Our bottle cap seal integrity detection system can quickly identify missing caps and verify the integrity of the seal on each product, ensuring the completeness of the seal on every bottled product and solving practical production problems. In the previous lesson, we discussed an application example of global product appearance inspection in a machine vision solution. In this lesson, we will share how to implement the bottle cap seal integrity detection function.
I. Detection Principle
(I) Testing Requirements
Check whether the bottle cap is sealed after the bottled product has been filled.
(II) Software Algorithm
Two straight line measuring instruments are used to measure the straight line at the bottom of the bottle cap and the straight line at the top of the bottle cap, respectively. Then the dimension value between the two straight lines and the angle value between the two straight lines are calculated. If the bottle cap is not closed tightly or is tilted up, the dimension value will be greater than the standard dimension value, and the angle value will also change.
II. Software Implementation
(I) Software Implementation
1. Open ZDevelop software: Create a new project named "Bottle Cap Detection.zpj" → Create a new "HMI" file → Create a new "main.bas" file to write the interface response function → Create a new "global_variable.bas" file to store global variables and enable HMI automatic task execution → Create a new "InitLocator.bas" file to initialize measurement parameters → Create a new "draw.bas" file to update and draw ROI data → Create a new "camera.bas" file to implement camera acquisition function → Add the files to the project.
2. Design the HMI interface.
3. Associate HMI main interface control variables.
4. Click [Component] → [New Window] to create a new parameter setting window, design the window layout, and associate parameter setting window control variables.
5. This course uses two line measuring tools to detect the lines at the bottom and top of the bottle cap, respectively, and then calculates the distance and angle between the two lines. The complete code and example images for this course can be obtained via the link below.
Linear measurement instructions:
ZV_MRGENLINE(Linear Meter, Rotation Rectangle Center x-coordinate, Rotation Rectangle Center y-coordinate, Rotation Rectangle Width, Rotation Rectangle Height, Rotation Rectangle Angle, Interpolation Algorithm, Number of Subregions, representing the number of subregions into which the rotation rectangle is divided, Subregion Width, Unit Pixels, representing the width of each subregion)
Command to detect the angle between lines:
ZV_ANGLELL(x-coordinate of the first point of line 1, y-coordinate of the first point of line 1, x-coordinate of the second point of line 1, y-coordinate of the second point of line 1, x-coordinate of the first point of line 2, y-coordinate of the first point of line 2, x-coordinate of the second point of line 2, y-coordinate of the second point of line 2)
Command to calculate the distance between points and lines:
ZV_DISTPL(x-coordinate of point, y-coordinate of point, x-coordinate of first point on line, y-coordinate of first point on line, x-coordinate of second point on line, y-coordinate of second point on line)
III. Operation Demonstration
(I) Operating Procedures
To check the running effect: Download the project to the simulator → Use local image → Single acquisition → Bottle cap settings → Set the top ROI of the bottle cap and detect the straight line area → Set the bottom ROI of the bottle cap and detect the straight line area → Click test to check the detection effect → Click return to the main interface, then click run to check the continuous running effect → End.
(II) Effect Demonstration