A method for automatically correcting the angle of a wine bottle
Patent Information
- Application Number
- CN202610077531.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2026-01-21
- Publication Date
- 2026-08-28
- Estimated Expiration
- 2046-01-21
AI Technical Summary
[0009]本发明的目的在于克服上述现有问题,提出一种酒瓶角度自动纠偏方法,解决现有技术中无法对目标物体的方向和角度进行精准识别,极大地影响角度调整精度的问题
一、与现有技术相比,本发明利用标准酒瓶底部天然特征作为识别基准,无需额外粘贴色标,避免了色标法的精度限制和工艺成本,同时利用提取匹配点,从匹配点对中精确计算旋转角度,提高了旋转角度的计算精度,不依赖特定颜色或材质,适用于各种酒瓶材质。
Smart Images

Figure CN122066770B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of industrial automation machine vision inspection and precision positioning correction technology, specifically relating to an automatic correction method for the angle of a wine bottle. Background Technology
[0002] Currently, the mainstream technical solutions for angular positioning of bottled products on automated production lines (such as ensuring the label faces outwards and the bottom pattern is aligned) include: 1. Mechanical stop bar positioning method: This method uses a fixed mechanical structure (such as a stop bar or star wheel) to physically contact the bottle during transport, forcibly moving it to a predetermined angle. While simple in structure, this method is prone to causing bottle wear or tipping, is unsuitable for high-speed, multi-variety production lines, and cannot achieve precise angle control.
[0003] 2. Positioning method based on color mark sensors: A color mark is affixed to a specific location on the bottle (such as the edge of the label), and a color mark sensor is used to detect the position of the color mark to determine the bottle's angle. This method is low-cost, but requires additional color marks, increasing material and process costs, and its accuracy is limited, easily affected by ambient light and color changes.
[0004] 3. Traditional template matching method: This method uses a standard image as a template and performs pixel-level grayscale correlation matching between the real-time captured bottle image and the template, finding the position of the maximum correlation value to calculate the offset angle. This method is computationally intensive, slow, and highly sensitive to changes in lighting, slight occlusion, and rotation, making it less robust in real-world high-speed production line environments.
[0005] 4. Deep learning-based methods: Convolutional Neural Networks (CNNs) are used for object detection or classification to determine angle. While this method offers high accuracy and adaptability, it requires a large amount of data for model training, resulting in high deployment costs, high computational resource demands, and limited model interpretability.
[0006] The drawbacks of existing technologies include: mechanical methods are inaccurate and easily damage the bottle; color mark methods require modification of materials; traditional template matching methods have poor anti-interference capabilities and are slow; and deep learning methods are costly and time-consuming. Therefore, there is a need for an angle detection and correction solution that can guarantee high precision and speed, as well as good robustness and low implementation cost.
[0007] Among existing methods for automatically correcting the angle of wine bottles, Chinese invention patent: a device and method for automatically adjusting bottle packaging boxes, application publication number: CN109928175A, discloses: placing the packaging box on a support of a mobile platform; adjusting the orientation of the packaging box on the support to a target orientation through a first adjustment structure, after adjustment, the corresponding packaging box is the target packaging box; driving the carrier frame to rise through a second adjustment structure, so that the target packaging box is detached from the support, and the target packaging box is located on the carrier frame.
[0008] The aforementioned existing technology has the following problems: Using existing technologies for angle adjustment, the aforementioned identification and adjustment methods cannot accurately identify the direction and angle of the target object under specific circumstances. When facing objects with relatively indistinct features, such as wine bottles, the identification accuracy is easily greatly reduced, thus significantly affecting the accuracy of angle adjustment. Summary of the Invention
[0009] The purpose of this invention is to overcome the aforementioned problems and propose an automatic bottle angle correction method to solve the problem that the existing technology cannot accurately identify the direction and angle of the target object, which greatly affects the accuracy of angle adjustment.
[0010] To achieve the above objectives, the technical solution adopted by the present invention is as follows: An automatic bottle angle correction method is characterized by: extracting a standard bottle bottom image as a visual feature image; using a matching strategy to match the extracted bottle bottom image to be corrected with the visual feature image to obtain a matching pair; using the matching pair and an image feature matching algorithm to calculate the correction angle; and rotating the bottle to be corrected to the correct position according to the correction angle to complete the correction.
[0011] The specific steps of the automatic bottle angle correction method are as follows: Step s1: Acquire a standard wine bottle bottom image as a template image; Step s2: Acquire an image of the bottom of the bottle to be corrected as the capture image; Step s3: Preprocess the template image and the captured image; Step s4: Extract the preprocessed template image and captured image to obtain the key points and their ORB descriptors of the template image and captured image; Step s5: Extract the key points and their ORB descriptors from the template image obtained in step s4 to obtain uniformly distributed key points and their ORB descriptors; Step s6: Match the evenly distributed keypoints and their ORB descriptors in the template image with the keypoints and their ORB descriptors in the captured image to form feature point pairs, and filter the feature point pairs to retain reliable feature point pairs; Step s7: Apply spatial proximity consistency constraints to reliable feature point pairs and filter to obtain the optimal matching point pairs; Step s8: Convert the corresponding coordinates of the optimal matching point pair from pixel coordinates to mathematical coordinates, and calculate the optimal partial affine transformation matrix based on the mathematical coordinates of the optimal matching point pair. Step s9: Calculate the rotation angle using the affine transformation matrix and store it in the industrial computer; Step s10: The rotation angle stored in the industrial computer is sent to the correction system above the bottle to be corrected. The correction system rotates the bottle to be corrected to the correct position according to the rotation angle, thus completing the correction.
[0012] In step s1, the template images are obtained by placing a wine bottle at a standard angle of 0 degrees on an industrial camera and capturing one template image every 10° of rotation, for a total of 36 template images.
[0013] In step s3, the preprocessing involves reducing the template image and the captured image to 50% of their original size.
[0014] In step s4, the template image and the key points of the captured image and their ORB descriptors are obtained by extracting the preprocessed template image and captured image using the detect_and_describe function.
[0015] In step s5, the uniformly distributed key points and their ORB descriptors are extracted from the template image key points and their ORB descriptors obtained in step s4 using the uniform_ORB_extract function.
[0016] In step s6, the key points and their ORB descriptors of the template image with uniform distribution are matched with the key points and their ORB descriptors of the captured image by calling the match_features function, using a brute-force matcher and the KNN nearest neighbor algorithm.
[0017] The feature point pairs are filtered using Lowe's Ratio Test to eliminate incorrect matches.
[0018] The matching feature point pairs are filtered using a uniqueness test and a consistency test algorithm to filter the key points and their ORB descriptors that match the template image and the captured image, eliminating fuzzy matches and incorrect matches.
[0019] The uniqueness test method comprises the following steps: Step s6.1: For each feature point in the template image, find candidate points in the captured image for the first nearest neighbor distance d1 and the second nearest neighbor distance d2 of the ORB descriptor; Step s6.2: Using the ratio threshold ρ, ensure that the best matching feature point pair is significant and unique in the feature space if and only if d1 < ρ * d2, and eliminate fuzzy matches.
[0020] The ratio threshold ρ is 0.7-0.8.
[0021] The ratio threshold ρ is 0.75.
[0022] The consistency check algorithm uses a feature point to measure the reprojection error. =||PA M(PB)||2 is less than the set threshold δ; incorrect matches are eliminated, and interior points that conform to the model are determined as reliable feature point pairs.
[0023] In step s7, the spatial proximity consistency constraint checks the consistency of displacement direction and scale of reliable feature point pairs with neighboring matching point pairs; counts the number of neighboring points that satisfy consistency; if the number of neighboring points is lower than the threshold T_inlier, the matching point is determined to be an outlier and removed; those not removed are the optimal matching point pairs.
[0024] The threshold T_inlier is 0.5≤T_inlie≤0.9.
[0025] The threshold T_inlier is 0.7.
[0026] In step s8, the coordinates of the optimal matching point pair are converted into mathematical coordinates by calling the estimate_rotation function.
[0027] In step s8, the optimal partial affine transformation matrix is calculated using a random sampling consensus algorithm based on the optimal matching point pairs converted to mathematical coordinates; the affine transformation matrix includes translation, rotation, and uniform scaling information.
[0028] The specific steps of the random sampling consensus algorithm are as follows: Step 8.1: Randomly select two or more sample sets from the matching points; Step 8.2: For each sample set, solve for a candidate matrix M_candidate that satisfies the partial affine transformation constraints; Step 8.3: For each M_candidate, calculate the reprojection error of all points and count the number of inliers to obtain the inlier set with the most inliers. The affine transformation matrix corresponding to the inlier set is the optimal solution M_best of the affine transformation matrix.
[0029] The optimal partial affine transformation matrix is calculated by using the affine transformation matrix inliers and then employing the least squares method to obtain the optimal solution M_best of the affine transformation matrix.
[0030] The optimal solution M_best of the affine transformation matrix is
[0031] ( t x , t y () represents the translation distance. θ For rotation angle, s To achieve uniform shrinkage.
[0032] In step s9, the affine transformation matrix M calculates the rotation angle θ using the following formula: θ_rad=arctan2(M[1,0],M[0,0]) θ_deg=degrees(θ_rad) θ_rad is used to extract the rotation component, and θ_deg is the rotation in radians.
[0033] In step s10, the industrial computer sends the rotation command to the PLC controller of the correction system above the wine bottle through the IO interface. The PLC controller controls the gripper to rotate the wine bottle to be corrected by the calculated angle θ_deg to the correct position, so that the bottom pattern is aligned with the standard template.
[0034] The correction system includes an imaging correction mechanism, an industrial computer, and a rotary actuator. The imaging correction mechanism and the rotary actuator are electrically connected to the industrial computer that controls the rotary correction. The imaging correction mechanism includes a bottle fixing station, a light source controller, and an industrial camera. A light source controller that illuminates the bottom of the bottle is installed at the bottle fixing station. An industrial camera that captures images of the bottom of the bottle is installed below the light source controller. The light source controller and the industrial camera are electrically connected to the industrial computer, and the light source controller and the industrial camera are synchronized. The rotary actuator includes a servo motor, a synchronous belt, a pneumatic device, and a gripper. The output shaft of the servo motor is connected to the rotating shaft of the synchronous belt, which drives the pneumatic device to rotate. The pneumatic device is connected to a gripper for gripping the bottle cap.
[0035] The bottle fixing station, light source controller, industrial camera, and gripper center are coaxial.
[0036] The pneumatic device includes an air pump, a solenoid valve, and a cylinder. The air pump is connected to the solenoid valve, the solenoid valve is connected to the cylinder, and the solenoid valve is electrically connected to an industrial computer.
[0037] The rotating shaft on the cylinder is connected to the gripper.
[0038] The servo motor is equipped with a PLC controller that is electrically connected to an industrial computer. The PLC controller controls the servo motor to perform correction.
[0039] The gripper has silicone on the inside.
[0040] The cylinder-driven gripper consists of two parts.
[0041] The digital I / O module in the industrial computer is electrically connected to the light source controller, solenoid valve, and PLC controller.
[0042] The advantages of using this invention are: I. Compared with the prior art, the present invention uses the natural features of the bottom of a standard wine bottle as an identification benchmark, eliminating the need for additional color marks and avoiding the accuracy limitations and process costs of the color mark method. At the same time, by extracting matching points, the rotation angle is accurately calculated from the matching point pairs, improving the calculation accuracy of the rotation angle. It does not depend on specific colors or materials and is applicable to various wine bottle materials.
[0043] Second, compared with the prior art, the present invention reduces the template image and the captured image to 50% of the original size, sacrificing a small amount of accuracy in exchange for a significant increase in processing speed, thus meeting the requirements of pipeline cycle time.
[0044] Third, compared with traditional ORB feature extraction, the feature points of this invention are more evenly distributed, avoiding concentration in areas with rich texture; the evenly distributed feature points ensure that enough matching point pairs can be obtained at different angles.
[0045] Fourth, this invention only includes information on rotation θ and uniform reduction s, which is more in line with the physical reality that the bottle rotates only in the horizontal plane, avoids the interference of translation components in a complete affine transformation, and makes the angle estimation more accurate and stable.
[0046] Fifth, this invention uses the K-nearest neighbor (K=2) algorithm and Lowe's Ratio Test (ratio threshold ρ=0.75) for matching and filtering, which improves matching efficiency; compared with traditional template matching, it greatly reduces the amount of computation and significantly reduces processing time.
[0047] VI. This invention combines a series of computer vision technologies, including ORB feature detection, KNN+Lowe's Ratio Test matching, and RANSAC motion estimation, and applies them to the specific scenario of bottle angle detection on an industrial production line. Its efficiency and robustness have been demonstrated through three levels of screening.
[0048] VII. The computational complexity of feature point detection (ORB) and descriptor matching (KNN) is highly correlated with the number of pixels in the image. Reducing the image size by half and the number of pixels to 1 / 4 can significantly reduce the computational load and enable the entire process to meet the real-time requirements of the pipeline. Attached Figure Description
[0049] Figure 1 This is a flowchart of the system workflow of the present invention; Figure 2 This is a schematic diagram illustrating the effect of the software algorithm of the present invention; Figure 3 This is a comparison image of the feature points extracted in this invention; Figure 4 This is the feature point pair matching diagram of the present invention; Figure 5 This is a schematic diagram of the overall structure of the device of the present invention; Figure 6 This is a schematic diagram of the template set of the present invention; Figure 7 This is a schematic diagram of the gripper structure of the present invention.
[0050] Reference numerals: 1. Imaging correction mechanism, 2. Industrial computer, 3. Rotary actuator, 4. Bottle fixing station, 5. Light source controller, 6. Industrial camera, 7. Servo motor, 8. Synchronous belt, 9. Pneumatic device, 10. Gripper, 11. Air pump, 12. Solenoid valve, 13. Cylinder, 14. PLC controller. Detailed Implementation
[0051] Example 1 An automatic bottle angle correction method is proposed, which extracts a standard bottle bottom image as a visual feature image, uses a matching strategy to match the extracted bottle bottom image to be corrected with the visual feature image to obtain a matching pair, uses the matching pair and image feature matching algorithm to calculate the correction angle, and the correction system rotates the bottle to be corrected to the correct position according to the correction angle to complete the correction.
[0052] The specific steps of the automatic bottle angle correction method are as follows: Step s1: Acquire a standard wine bottle bottom image as a template image; Step s2: Acquire an image of the bottom of the bottle to be corrected as the capture image; Step s3: Preprocess the template image and the captured image; Step s4: Extract the preprocessed template image and captured image to obtain the key points and their ORB descriptors of the template image and captured image; Step s5: Extract the key points and their ORB descriptors from the template image obtained in step s4 to obtain uniformly distributed key points and their ORB descriptors; Step s6: Match the evenly distributed keypoints and their ORB descriptors in the template image with the keypoints and their ORB descriptors in the captured image to form feature point pairs, and filter the feature point pairs to retain reliable feature point pairs; Step s7: Apply spatial proximity consistency constraints to reliable feature point pairs and filter to obtain the optimal matching point pairs; Step s8: Convert the corresponding coordinates of the optimal matching point pair from pixel coordinates to mathematical coordinates, and calculate the optimal partial affine transformation matrix based on the mathematical coordinates of the optimal matching point pair. Step s9: Calculate the rotation angle using the affine transformation matrix and store it in the industrial computer; Step s10: The rotation angle stored in the industrial computer is sent to the correction system above the bottle to be corrected. The correction system rotates the bottle to be corrected to the correct position according to the rotation angle, thus completing the correction.
[0053] In step s1, the template images are obtained by placing a wine bottle at a standard angle of 0 degrees on an industrial camera and capturing one image every 10° of rotation, for a total of 36 template images.
[0054] In step s3, the preprocessing involves reducing the template image and the captured image to 50% of their original size.
[0055] In step s4, the template image and the key points of the captured image and their ORB descriptors are obtained by extracting the preprocessed template image and captured image using the detect_and_describe function.
[0056] In step s5, the uniformly distributed key points and their ORB descriptors are extracted from the template image key points and their ORB descriptors obtained in step s4 using the uniform_ORB_extract function.
[0057] In step s6, the key points and their ORB descriptors of the template image with uniform distribution are matched with the key points and their ORB descriptors of the captured image by calling the match_features function, using a brute-force matcher and the KNN nearest neighbor algorithm.
[0058] The feature point pairs are filtered using Lowe's Ratio Test to eliminate incorrect matches.
[0059] The matching feature point pairs are filtered by using a uniqueness test and a consistency test algorithm to filter the key points and their ORB descriptors that match the template image and the captured image, eliminating fuzzy matches and incorrect matches.
[0060] The uniqueness test method comprises the following steps: Step s6.1: For each feature point in the template image, find candidate points in the captured image for the first nearest neighbor distance d1 and the second nearest neighbor distance d2 of the ORB descriptor; Step s6.2: Using the ratio threshold ρ, ensure that the best matching feature point pair is significant and unique in the feature space if and only if d1 < ρ * d2, and eliminate fuzzy matches.
[0061] The ratio threshold ρ is 0.7-0.8.
[0062] The ratio threshold ρ is 0.75.
[0063] The consistency check algorithm uses a feature point to measure the reprojection error. =||PA M(PB)||2 is less than the set threshold δ; incorrect matches are eliminated, and interior points that conform to the model are determined as reliable feature point pairs.
[0064] In step s7, the spatial proximity consistency constraint checks the consistency of displacement direction and scale of reliable feature point pairs with neighboring matching point pairs; counts the number of neighboring points that satisfy consistency; if the number of neighboring points is lower than the threshold T_inlier, the matching point is determined to be an outlier and removed; those not removed are the optimal matching point pairs.
[0065] The threshold T_inlier is 0.5≤T_inlie≤0.9.
[0066] The threshold T_inlier is 0.7.
[0067] In step s8, the coordinates of the optimal matching point pair are converted into mathematical coordinates by calling the estimate_rotation function.
[0068] In step s8, the optimal partial affine transformation matrix is calculated using a random sampling consensus algorithm based on the optimal matching point pairs converted to mathematical coordinates; the affine transformation matrix includes translation, rotation, and uniform scaling information.
[0069] The specific steps of the random sampling consensus algorithm are as follows: Step 8.1: Randomly select two or more sample sets from the matching points; Step 8.2: For each sample set, solve for a candidate matrix M_candidate that satisfies the partial affine transformation constraints; Step 8.3: For each M_candidate, calculate the reprojection error of all points and count the number of inliers to obtain the inlier set with the most inliers. The affine transformation matrix corresponding to the inlier set is the optimal solution M_best of the affine transformation matrix.
[0070] The optimal partial affine transformation matrix is calculated by using the affine transformation matrix inliers and then employing the least squares method to obtain the optimal solution M_best of the affine transformation matrix.
[0071] The optimal solution M_best of the affine transformation matrix is
[0072] ( t x , t y () represents the translation distance. θ For rotation angle, s To achieve uniform shrinkage.
[0073] In step s9, the affine transformation matrix M calculates the rotation angle θ using the following formula: θ_rad=arctan2(M[1,0],M[0,0]) θ_deg=degrees(θ_rad) θ_rad is used to extract the rotation component, and θ_deg is the rotation in radians.
[0074] In step s10, the industrial computer sends the rotation command to the PLC controller of the correction system above the bottle through the IO interface. The PLC controller controls the correction system to rotate the bottle to be corrected by the calculated angle θ_deg to the correct position, so that the bottom pattern is aligned with the standard template.
[0075] This invention provides a method for image matching and automatic correction of the bottom of a wine bottle. For example... Figure 1 As shown, its core idea is to extract natural and stable visual features (such as mold number, pattern, wear marks, etc.) from the bottom image of the bottle. The extraction strategy obtains evenly distributed and stable feature points, and an efficient and reliable matching strategy is used to quickly obtain the correct matching pair. Replacing the traditional manual color mark, the system uses an efficient image feature matching algorithm to calculate the precise rotation angle between the bottle body and the standard template in real time, and controls the downstream correction mechanism to complete the correction.
[0076] The detailed steps are as follows: like Figure 2 As shown, 1. System calibration and template establishment (offline stage): At the vision station on the production line, industrial cameras and light sources are fixed to ensure uniform and stable lighting in the shooting area.
[0077] A standard wine bottle, known as the "standard angle" (0 degrees), is placed under an industrial camera to capture a clear bottom image as a template image.
[0078] The system calls the `detect_and_describe` function, using feature detection algorithms such as ORB (Oriented Fast and Rotated BRIEF) to extract keypoints and descriptors (which may be repeated below) from the template image and store them in the system. The ORB algorithm combines high speed with good rotation and scale invariance.
[0079] 2. Online detection and angle calculation (online stage): The bottles to be corrected on the production line arrive at the vision inspection station along the conveyor belt, triggering the sensor and the industrial camera to capture the bottom image of the bottle to be corrected.
[0080] Image preprocessing: To improve processing speed, the system first reduces the template image and captured image to 50% of their original size.
[0081] like Figure 3 As shown, feature extraction involves calling the detect_and_describe function on the two preprocessed images to obtain their respective keypoints and ORB descriptors, which are then stored in the system.
[0082] Improved feature extraction and storage: The uniform_ORB_extract function proposed in this invention is called to process the preprocessed template image, obtain the uniformly distributed key points and their ORB descriptors, and store them in the system.
[0083] like Figure 4 As shown, feature matching involves calling the `match_features` function. A brute-force matcher (BFMatcher) and the K-nearest neighbors (KNN) algorithm are used for initial matching (matching what content), followed by Lowe's Ratio Test for filtering. This step effectively eliminates incorrect matches, retaining only the most reliable feature point pairs.
[0084] The two-level screening mechanism first performs initial screening based on the similarity of local feature descriptors, and then performs fine screening based on the global spatial geometric consistency.
[0085] Level 1: Uniqueness Test (Lowe's Ratio Test) Objective: To eliminate fuzzy matching caused by similar local features.
[0086] Method: For each feature point in the template image, find the two most similar candidate points in the captured image and calculate their descriptor distances d1 (best) and d2 (second best).
[0087] Reliable criterion: d1 < ρ * d2 if and only if ρ is typically taken as 0.75. This condition ensures that the best match is significant and unique in the feature space, thus filtering out ambiguous matches.
[0088] Level 2: Consistency Test (RANSAC) Objective: To eliminate mismatches with contradictory spatial locations from matches that pass the uniqueness test. Method: Assume there exists an optimal geometric transformation model (mainly rotation) from the captured image to the template image. The RANSAC algorithm is used to iteratively solve this model. Reliability Criterion: A matching point pair is considered a reliable interior point if its reprojection error... =||PA M(PB)||2 is less than the set threshold δ, that is <δ, ultimately, all interior points that conform to the optimal model are determined as reliable feature point pairs.
[0089] The first level ensures the local saliency of the matching, while the second level ensures the global geometric consistency of the matching. Through this two-level judgment, which prioritizes "local" over "global," the system can filter out the initial matches that may contain a lot of noise, ultimately retaining feature point pairs that are highly similar in local appearance and consistent with the optimal model in overall spatial transformation.
[0090] The K-Nearest Neighbors (KNN, K=2) algorithm is used to find two nearest neighbors in the template image for each descriptor of the captured image. Lowe's Ratio Test (ratio threshold ρ, typically 0.7-0.8) is applied to filter and eliminate fuzzy matches.
[0091] Formula: Distance (first nearest neighbor) < ratio threshold (0.75) * distance (second nearest neighbor) Spatial consistency verification (fine matching), after ratio testing, may still retain many mismatches. This invention introduces spatial proximity consistency constraints; for a pair of matching points (Kp1_i, Kp2_j), it checks whether the displacement direction and approximate scale of its neighboring matching point pairs (such as points with an Euclidean distance within d pixels) are consistent with it. The number of neighboring points satisfying consistency is counted; if the number is lower than the threshold T_inlier, the matching point is determined to be an outlier and removed. This step effectively eliminates localized, clustered mismatches, greatly improving the proportion of inliers and laying a solid foundation for subsequent RANSAC (RANSAC) estimation.
[0092] Rotation angle estimation: The `estimate_rotation` function is called. The coordinates of the selected optimal matching point pairs are converted from pixel coordinates to mathematical coordinates. Using RANSAC (Random Sample Consensus Algorithm), an optimal partial affine transformation matrix is estimated based on these matching point pairs.
[0093] The term "optimal" has a dual meaning here, and is achieved through the following steps: 1. "Optimal" in an algorithmic sense: Maximum consensus set estimation based on RANSAC Input: Mathematical coordinates of all reliable matching point pairs (source point set src_pts, target point set dst_pts).
[0094] Core algorithm: Continue to use the RANSAC framework, but the goal is to find the optimal parameters for partial affine transformation models.
[0095] Calculation process: a. Random sampling: The minimum sample set is randomly drawn from the matching points multiple times (for some affine transformations, theoretically 2 pairs of points are used, but for robustness, 3 or more pairs are often used).
[0096] b. Model parameter calculation: For each sample set, solve for a candidate matrix M_candidate that satisfies the partial affine transformation constraints. This is typically accomplished by solving a constrained least squares problem.
[0097] c. Inner-point consensus: For each M_candidate, calculate the reprojection error of all points and count the number of inner points.
[0098] "Optimal" determination: After iteration, the transformation matrix M_best that maximizes the number of interior points is considered the optimal solution in the algorithmic sense. It represents a geometric model that is spatially consistent with the most reliable matching points.
[0099] 2. "Optimal" in mathematical and business sense: the least squares solution that satisfies the constraints.
[0100] After determining the largest set of inliers, the algorithm uses all these inliers to re-estimate the transformation matrix using the least squares method.
[0101] Objective function: Minimize the sum of squared reprojection errors of all interior points.
[0102]
[0103] Imposing model constraints: When solving the above least squares problem, matrix M is required to have the following structure:
[0104] Substitute to get
[0105] in( a , b This implies rotation and scaling. t x , t y ) is a translation. This ensures that the matrix is a combination of a rotation-shrunk matrix and a translation vector, without any shearing terms.
[0106] The final output, M_final, which is based on the maximum set of interior points, fitted by constrained least squares, and whose matrix structure conforms to rigid body / similarity transformation, is the optimal partial affine transformation matrix required in step S8.
[0107] In this scheme, the "optimal partial affine transformation matrix" refers to a geometric transformation matrix that simultaneously satisfies the following three conditions: Optimal consistency: It defines the largest set of interior points, which is supported by the most reliable spatial evidence.
[0108] Optimal consistency quantification range and judgment criteria The core of "optimal consistency" is to find the transformation model that receives the broadest spatial evidence support. This is mainly defined objectively through an interior point ratio threshold and an algorithm termination condition.
[0109] Interior point ratio threshold range Definition: The interior point ratio refers to the ratio of the number of matching points that support a candidate transformation model to the total number of reliable matching points involved in the calculation.
[0110] Quantization range: The proportion of inliers should not be lower than a preset first threshold T_inlier. The value range of this threshold T_inlier is 0.5 ≤ T_inlier ≤ 0.9.
[0111] Preferred embodiment: In a typical application scenario of image correction at the bottom of a wine bottle, the preferred value of T_inlier is 0.7.
[0112] Technical implications: This range indicates that a model deemed "optimal" must be supported by more than half (50%), and preferably more than 70% (70%), of reliable spatial evidence. The lower limit of 0.5 ensures the model has general consistency, while the upper limit of 0.9 leaves reasonable margin for actual noise and error.
[0113] Optimal accuracy: On this set of interior points, the parameters minimize the sum of squares of the reprojection error.
[0114] Optimal quantization range and judgment criteria "Optimal accuracy" refers to finding parameters that minimize the fitting error within a given model form. This is defined by an error threshold and a mathematical optimization objective.
[0115] 1. Maximum allowable error for individual matching points (reprojection error threshold δ) Definition: When determining whether a matching point is an interior point, its reprojection error ε must be less than this threshold δ.
[0116] Quantization range: The threshold δ is in the range of 1.0 pixel ≤ δ ≤ 10.0 pixels.
[0117] Preferred embodiment: For industrial cameras with a resolution of 2 to 5 megapixels, the preferred value of δ is 3.0 pixels.
[0118] Technical implications: This range specifies that a matching point is considered valid evidence only if its location is very close to the model's predicted location (within 1 to 10 pixels of deviation). The preferred value of 3.0 pixels ensures both fault tolerance and matching accuracy.
[0119] The best physical meaning: its mathematical form is strictly constrained, representing only rotation, translation and uniform shrinkage, perfectly matching the physical reality of the planar motion of the wine bottle, thus allowing for a robust and accurate decomposition of the pure rotation angle θ=atan2(b,a).
[0120] The optimal partial affine transformation matrix can be precisely defined as: The transformation matrix M is obtained through the following steps: Base model selection: Using the initial reliable matching point pairs as input, perform RANSAC iterations with parameters K ranging from 500 to 5000; in each iteration, matching points with reprojection errors less than δ (δ ranges from 1.0 to 10.0 pixels) are identified as inliers; finally, the candidate model with the highest proportion of inliers and not lower than the threshold T_inlier (T1 ranges from 0.5 to 0.9) is selected as the base model, and its inlier set S_inliers is recorded. Parameter estimation: Using S inliers as input, solve the optimization problem that satisfies the structural constraints of the partial affine transformation matrix and minimizes the sum of squared reprojection errors. The resulting matrix M is the optimal partial affine transformation matrix. This matrix primarily contains translation (x, y), rotation (θ), and uniform scaling (s) information. The RANSAC algorithm can greatly overcome the interference of a small number of outlier matching points, ensuring the robustness of the estimation results.
[0121] The rotation angle θ is calculated from the transformation matrix M using the following formula: θ_rad=arctan2(M[1,0],M[0,0]) (Extract rotational components) θ_deg=degrees(θ_rad) (radians to degrees) This angle θ_deg is the rotation angle that the captured image needs to be corrected relative to the template image. The actual rotation command that needs to be applied to the correction mechanism is its negative value (-θ_deg).
[0122] 3. Perform corrective actions (online phase): The system sends the calculated rotation angle value (-θ_deg) to the PLC controller via the IO interface.
[0123] The PLC controller controls the downstream servo motor to drive the gripper, so that the wine bottle to be corrected at the correction station is precisely rotated by the calculated angle so that its bottom pattern is aligned with the standard template.
[0124] When θ_deg is 0 degrees, the correction system does not perform rotation.
[0125] After the correction is completed, the rotating dial at the bottom of the bottle will move the corrected bottle out of the correction station.
[0126] The hardware components of the entire system include: an industrial camera, a ring light source, an industrial computer, a PLC controller, and a servo-driven rotary correction mechanism.
[0127] Among them ORB (Oriented FAST and Rotated BRIEF): A local feature description algorithm that is an effective alternative to SIFT and SURF, with almost no patent restrictions and extremely high computational efficiency.
[0128] Rublee, Ethan, et al. "ORB: An efficient alternative to SIFT orSURF." 2011 International conference on computer vision. Ieee, 2011. Lowe's Ratio Test: Used to filter feature matching pairs and effectively eliminate fuzzy matches.
[0129] Lowe, DGDistinctive Image Features from Scale-InvariantKeypoints. International Journal of Computer Vision 60, 91–110 (2004). RANSAC (Random Sample Consensus): A robust model fitting algorithm that can estimate mathematical model parameters from data containing a large number of outliers.
[0130] Martin A.Fischler and Robert C. Bolles. "Random sample consensus: aparadigm for model fitting with applications to image analysis and automatedcartography." Communications of the ACM 24.6 (1981):381-395. The PLC controller used is the B&R APC910 series.
[0131] Eight industrial cameras (four in a group, two with backlights) are of model number: Daheng Imaging ME2P-1230-23U3C.
[0132] The lens uses a Sony IMX304 LQR global shutter CMOS sensor, with 12 megapixels and a resolution of 4096×3000.
[0133] The industrial PC uses an AMD Ryzen 7 5700X, 32GB RAM, and an NVIDIA GeForce RTX 4080.
[0134] Example 2 The correction system includes an imaging correction mechanism 1, an industrial computer 2, and a rotary actuator 3. The imaging correction mechanism 1 and the rotary actuator 3 are electrically connected to the industrial computer 2, which controls the rotary correction. The imaging correction mechanism 1 includes a bottle fixing station 4, a light source controller 5, and an industrial camera 6. The bottle fixing station 4 has a light source controller 5 that illuminates the bottom of the bottle at the bottle placement location. The industrial camera 6, which captures images of the bottom of the bottle, is located below the light source controller 5. The light source controller 5 and the industrial camera 6 are electrically connected to the industrial computer 2 and are synchronized. The rotary actuator 3 includes a servo motor 7, a synchronous belt 8, a pneumatic device 9, and a gripper 10. The output shaft of the servo motor 7 is connected to the rotating shaft of the synchronous belt 8, which drives the pneumatic device 9 to rotate. The pneumatic device 9 is connected to the gripper 10 for gripping the bottle cap.
[0135] The bottle fixing station 4, the light source controller 5, the industrial camera 6, and the gripper 10 are all coaxial.
[0136] The pneumatic device 9 includes an air pump 11, a solenoid valve 12, and a cylinder 13. The air pump 11 is connected to the solenoid valve 12, the solenoid valve 12 is connected to the cylinder 13, and the solenoid valve 12 is electrically connected to the industrial computer 2.
[0137] The rotating shaft on the cylinder 13 is connected to the gripper 10.
[0138] The servo motor 7 is equipped with a PLC controller that is electrically connected to the industrial computer 2. The PLC controller controls the servo motor 7 to perform correction.
[0139] The gripper 10 has silicone on its inner side.
[0140] The cylinder 13 drives two grippers 10.
[0141] The digital I / O module in the industrial computer 2 is electrically connected to the light source controller 5, the solenoid valve 12, and the PLC controller 14.
[0142] like Figure 5 As shown, 1. Correction station for the light source and imaging system: This workstation has a fixed position for placing the bottles to be corrected. The bottles are transported to this workstation by a conveyor line and precisely positioned.
[0143] A high-brightness light source controller 5 is installed directly below the bottle fixing station 4. This light source can flash instantaneously under the command of the industrial computer 2, providing uniform and shadowless illumination to the bottle.
[0144] An industrial camera 6 is positioned directly below the light source. Its optical axis is strictly coaxial with the center of the light source controller 5 and the center of the bottle fixing station 4, forming a top-down coaxial imaging optical path. The industrial camera 6 is used to accurately capture a complete image of the bottom of the bottle when the light source illuminance reaches its peak.
[0145] Industrial camera 6 uses the Daheng MERCURY2-USB3.0 large-area high-resolution industrial digital camera. This camera connects to industrial computer 2 via a USB3.0 interface and is powered by an external dedicated power adapter (12V DC industrial power supply) to ensure stable operation.
[0146] The light source controller 5 adopts the OPT-DPH20048E-4 brightness enhancement digital controller, with an output voltage of 48V DC and a maximum instantaneous output current of 20A. This controller is powered by an industrial power supply (AC 220V) and receives digital signals from the industrial computer 2 to trigger the light source to flash.
[0147] The industrial computer 2 is electrically connected to the industrial camera 6, the servo motor 7 of the rotary actuator 3, and the pneumatic device 9 via a digital I / O module.
[0148] like Figure 6 As shown, the industrial computer 2 has a pre-stored set of complete standard bottle bottom template images taken by an industrial camera. This template set uses a specific angle of the bottle as a 0° reference, and captures one image every 10° of rotation, for a total of 36 template images, completely covering the 360° circumference.
[0149] Rotary actuator 3: The rotary actuator 3 consists of a servo motor 7, a synchronous belt 8, a pneumatic device 9, and a gripper 10, with the following specific structure: Servo motor 7: A B&R Acopos P3 high-precision, high-performance servo motor 7 is adopted, which is connected to the industrial computer 2 through the PLC controller 14 to receive rotation commands. The power source of the servo motor 7 is industrial AC 220V power supply, which is converted into the required voltage and current by the PLC controller 14 to drive the motor.
[0150] Synchronous belt 8: The output shaft of the servo motor 7 is connected to the rotating shaft of the pneumatic device 9 via the synchronous belt 8 pulley to achieve power transmission and rotation. The synchronous belt 8 is made of rubber or polyurethane material, which has high wear resistance and precision, ensuring smooth rotation.
[0151] Pneumatic components include an air pump 11 (which provides compressed air), a solenoid valve 12, and a cylinder 13. The solenoid valve 12 receives signals from the industrial computer 2 via a digital I / O module, controlling the air pump 11 to drive the cylinder 13 to move, and the cylinder 13 drives the gripper 10 to clamp and release.
[0152] like Figure 7 As shown, the gripper 10 consists of two openable grippers 10. The grippers 10 are lined with flexible silicone material (KE-552B-U silicone with a hardness of 75°) to prevent damage to the bottle cap. The grippers 10 achieve the gripping action via cylinder 13 and are driven to rotate by pneumatic device 9 via servo motor 7. The grippers 10 are directly fixed to the rotating shaft, enabling precise rotation of the bottle body.
[0153] The rotary dial is used to pick up wine bottles from the conveyor line and transfer them to a dedicated correction station downstream.
[0154] The gripper 10 is used to fix the bottle cap of the wine bottle conveyed on the production line. After receiving the instruction from the industrial computer 2, the gripper 10 acts as a rotary actuator, holding the bottle mouth and rotating it precisely by the calculated angle θ, thereby driving the entire bottle body to adjust to the correct position and completing the correction.
[0155] Its workflow is as follows: The gripper picks up the wine bottle to be corrected on the production line - transfers it to the fixed point of the correction station - the light source lights up and the camera takes a picture - the image is transmitted to the industrial computer - the industrial computer performs multi-template matching and identifies the current absolute angle - calculates the shortest rotation path θ - the industrial computer sends a rotation command to the gripper - the gripper directly rotates the wine bottle to be corrected by an angle θ - the wine bottle to be corrected flows into the next process with the correct posture (the unpatterned side faces the same direction).
[0156] The industrial camera and light source are powered by external adapters and dedicated light source controllers, respectively, ensuring stable operation of the imaging system.
[0157] The coaxial integrated collaborative structure of "gripper-bottle body-light source-camera": a physical structure that integrates a rotary actuator, a coaxial light source controller and an industrial camera from top to bottom, and the resulting integrated workflow of "gripping-positioning-imaging-execution".
[0158] The gripper, as a direct rotation actuator, utilizes the gripper itself as the rotational actuator end, directly driving the bottle mouth to rotate while in a clamped state. This method avoids complex additional rotation mechanisms, simplifying the equipment structure.
[0159] A multi-template global matching recognition method: This method utilizes a comprehensive template library and performs global scanning matching to determine the absolute angle of the bottle, effectively resolving recognition ambiguities caused by pattern periodicity. Specifically, it creates a complete template library covering 360° at specific angular intervals (e.g., 10°) and performs global scanning matching on real-time images to determine the absolute angle of the bottle. This method effectively solves the recognition ambiguity problem caused by the periodicity of bottle patterns.
[0160] The rotation model based on shortest path decision-making: Protecting the "θ=n×360°+α" intelligent rotation model and its application in control, especially its core control logic with the minimum rotation amount as the optimization objective, ensures the high efficiency of the correction action.
Claims
1. A method for automatically correcting the angle of a wine bottle, characterized in that: The specific steps are as follows: Step s1: Acquire an image of the bottom of the wine bottle as a template image; Step s2: Acquire an image of the bottom of the bottle to be corrected as the capture image; Step s3: Preprocess the template image and the captured image; Step s4: Extract the preprocessed template image and captured image to obtain the key points and their ORB descriptors of the template image and captured image; Step s5: Extract the key points and their ORB descriptors from the template image obtained in step s4 to obtain uniformly distributed key points and their ORB descriptors; Step s6: Match the evenly distributed keypoints and their ORB descriptors in the template image with the keypoints and their ORB descriptors in the captured image to form feature point pairs, and filter the feature point pairs to retain reliable feature point pairs; Step s7: Apply spatial proximity consistency constraints to reliable feature point pairs and filter to obtain the optimal matching point pairs; Step s8: Convert the corresponding coordinates of the optimal matching point pair from pixel coordinates to mathematical coordinates, and calculate the optimal partial affine transformation matrix based on the mathematical coordinates of the optimal matching point pair. Step s9: Calculate the rotation angle using the affine transformation matrix and store it in the industrial computer; Step s10: The rotation angle stored in the industrial computer is sent to the correction system above the bottle to be corrected. The correction system rotates the bottle to be corrected to the correct position according to the rotation angle, thus completing the correction.
2. The automatic bottle angle correction method according to claim 1, characterized in that: In step s1, the template images are obtained by placing a wine bottle at a standard angle of 0 degrees on an industrial camera and capturing one image every 10° of rotation, for a total of 36 template images.
3. The automatic bottle angle correction method according to claim 2, characterized in that: In step s3, the preprocessing involves reducing the template image and the captured image to 50% of their original size.
4. The automatic bottle angle correction method according to claim 3, characterized in that: In step s4, the template image and the key points of the captured image and their ORB descriptors are obtained by extracting the preprocessed template image and captured image using the detect_and_describe function.
5. The automatic bottle angle correction method according to claim 4, characterized in that: In step s5, the uniformly distributed key points and their ORB descriptors are extracted from the template image key points and their ORB descriptors obtained in step s4 using the uniform_ORB_extract function.
6. The automatic bottle angle correction method according to claim 5, characterized in that: In step s6, the key points and their ORB descriptors of the template image with uniform distribution are matched with the key points and their ORB descriptors of the captured image by calling the match_features function, using a brute-force matcher and the KNN nearest neighbor algorithm.
7. The automatic bottle angle correction method according to claim 6, characterized in that: The feature point pairs are filtered using Lowe's Ratio Test to eliminate incorrect matches.
8. The automatic bottle angle correction method according to claim 6 or 7, characterized in that: The matching feature point pairs are filtered by using uniqueness and consistency tests to filter the key points and their ORB descriptors that match the template image and the captured image, eliminating fuzzy matches and incorrect matches.
9. The automatic bottle angle correction method according to claim 8, characterized in that: The uniqueness test method comprises the following steps: Step s6.1: For each feature point in the template image, find candidate points in the captured image for the first nearest neighbor distance d1 and the second nearest neighbor distance d2 of the ORB descriptor; Step s6.2: Using the ratio threshold ρ, ensure that the best matching feature point pair is significant and unique in the feature space if and only if d1 < ρ * d2, and eliminate fuzzy matches.
10. The automatic bottle angle correction method according to claim 9, characterized in that: The ratio threshold ρ is 0.7-0.
8.
11. The automatic bottle angle correction method according to claim 10, characterized in that: The ratio threshold ρ is 0.
75.
12. The automatic bottle angle correction method according to claim 8, characterized in that: The consistency check algorithm uses a feature point to measure the reprojection error. =||PA M(PB)||2 is less than the set threshold δ; incorrect matches are eliminated, and interior points that conform to the model are determined as reliable feature point pairs.
13. The automatic bottle angle correction method according to claim 7, characterized in that: In step s7, the spatial proximity consistency constraint checks the consistency of displacement direction and scale of reliable feature point pairs with neighboring matching point pairs; counts the number of neighboring points that satisfy consistency; if the number of neighboring points is lower than the threshold T_inlier, the matching point is determined to be an outlier and removed; those not removed are the optimal matching point pairs.
14. The automatic bottle angle correction method according to claim 13, characterized in that: The threshold T_inlier is 0.5≤T_inlie≤0.
9.
15. The automatic bottle angle correction method according to claim 12 or 13, characterized in that: The threshold T_inlier is 0.
7.
16. The automatic bottle angle correction method according to claim 15, characterized in that: In step s8, the coordinates of the optimal matching point pair are converted into mathematical coordinates by calling the estimate_rotation function.
17. The automatic bottle angle correction method according to claim 16, characterized in that: The optimal partial affine transformation matrix is computed using a random sample consensus algorithm based on the optimal matching point pairs converted to mathematical coordinates; the affine transformation matrix includes translation, rotation, and uniform scaling information.
18. The automatic bottle angle correction method according to claim 17, characterized in that: The specific steps of the random sampling consensus algorithm are as follows: Step 8.1: Randomly select two or more sample sets from the matching points; Step 8.2: For each sample set, solve for a candidate matrix M_candidate that satisfies the partial affine transformation constraints; Step 8.3: For each M_candidate, calculate the reprojection error of all points and count the number of inliers to obtain the inlier set with the most inliers. The affine transformation matrix corresponding to the inlier set is the optimal solution M_best of the affine transformation matrix.
19. The automatic bottle angle correction method according to claim 18, characterized in that: The optimal partial affine transformation matrix is calculated by using the affine transformation matrix inliers and then employing the least squares method to obtain the optimal solution M_best of the affine transformation matrix.
20. The automatic bottle angle correction method according to claim 19, characterized in that: The optimal solution M_best of the affine transformation matrix is ( t x , t y () represents the translation distance. θ For rotation angle, s To achieve uniform shrinkage.
21. The automatic bottle angle correction method according to claim 14, characterized in that: In step s9, the affine transformation matrix M calculates the rotation angle θ using the following formula: θ_rad=arctan2(M[1,0],M[0,0]) θ_deg=degrees(θ_rad) θ_rad is used to extract the rotation component, and θ_deg is the rotation in radians.
22. The automatic bottle angle correction method according to claim 21, characterized in that: In step s10, the industrial computer sends the rotation command to the PLC controller of the correction system above the wine bottle through the IO interface. The PLC controller controls the correction system to rotate the wine bottle to be corrected by the calculated angle θ_deg to the correct position, so that the bottom pattern is aligned with the standard template.
23. The automatic bottle angle correction method according to claim 1, characterized in that: The correction system includes an imaging correction mechanism (1), an industrial computer (2), and a rotary actuator (3); the imaging correction mechanism (1) and the rotary actuator (3) are electrically connected to the industrial computer (2) that controls the rotary correction; the imaging correction mechanism (1) includes a bottle fixing station (4), a light source controller (5), and an industrial camera (6). A light source controller (5) is provided at the bottle fixing station (4) where the bottle is placed to illuminate the bottom of the bottle. An industrial camera (6) is provided below the light source controller (5) to capture the image of the bottom of the bottle. The light source controller (5) and the industrial camera (6) are electrically connected to the industrial computer (2). The light source controller (5) and the industrial camera (6) are synchronized. The rotary actuator (3) includes a servo motor (7), a synchronous belt (8), a pneumatic device (9), and a gripper (10). The output shaft of the servo motor (7) is connected to the rotating shaft of the synchronous belt (8). The rotating shaft of the synchronous belt (8) drives the pneumatic device (9) to rotate. The pneumatic device (9) is connected to the gripper (10) for gripping the bottle cap.
24. The automatic bottle angle correction method according to claim 23, characterized in that: The bottle fixing station (4), the light source controller (5), the industrial camera (6) and the gripper (10) are coaxial.
25. The automatic bottle angle correction method according to claim 23 or 24, characterized in that: The pneumatic device (9) includes an air pump (11), a solenoid valve (12) and a cylinder (13). The air pump (11) is connected to the solenoid valve (12), the solenoid valve (12) is connected to the cylinder (13), and the solenoid valve (12) is electrically connected to the industrial computer (2).
26. The automatic bottle angle correction method according to claim 25, characterized in that: The rotating shaft on the cylinder (13) is connected to the gripper (10).
27. The automatic bottle angle correction method according to claim 26, characterized in that: The servo motor (7) is equipped with a PLC controller (14) that is electrically connected to the industrial computer (2).
28. The automatic bottle angle correction method according to claim 25, characterized in that: The gripper (10) is a gripper (10) with silicone on the inside.
29. The automatic bottle angle correction method according to claim 28, characterized in that: The cylinder (13) drives two grippers (10).
30. The automatic bottle angle correction method according to claim 20, characterized in that: The digital I / O module in the industrial computer (2) is electrically connected to the light source controller (5), the solenoid valve (12) and the PLC controller (14).
Citation Information
Patent Citations
Device and method for automatically adjusting bottle packaging box
CN109928175A
Vision-based wine bottle feeding angle correction method and system
CN120298352A