Method and system for detecting and positioning packaging unit based on image analysis

By using image analysis and genetic algorithm optimization, the adaptability and accuracy issues of mechanical sensors in food packaging perforation positioning were solved, achieving high-precision, low-latency perforation coordinate calculation, which can meet the positioning needs of multiple types of packaging.

CN121095340APending Publication Date: 2025-12-09JIANGSU OCEAN UNIV +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511260554.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-09-04
Publication Date
2025-12-09

AI Technical Summary

Technical Problem

Existing mechanical sensors have poor adaptability, insufficient accuracy, and high maintenance costs in food packaging perforation positioning. They cannot be flexibly adapted to multiple product categories and are easily affected by the reflectivity, transparency, or surface texture of packaging materials, leading to positioning deviations.

Method used

An image analysis-based approach is adopted to screen the optimal lighting parameters through multiple sets of lighting parameter tests, determine the matching point group for drilling positioning using multi-angle/position test images, and optimize the feature point group by combining a genetic algorithm to achieve high-precision drilling coordinate calculation.

Benefits of technology

It improves the accuracy and stability of punching positioning, adapts to packaging position offsets or angle changes, reduces the impact of ambient light changes on positioning accuracy, and ensures the real-time accuracy of punching coordinates.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121095340A_ABST
    Figure CN121095340A_ABST
Patent Text Reader

Abstract

The invention relates to a packaging unit detecting and positioning method and system based on image analysis, and relates to the technical field of image detection.The method comprises the steps that multiple sets of illumination parameters for testing are determined; acquiring color test images of the plurality of food packages for testing under the plurality of groups of illumination parameters for testing, and determining an optimal illumination parameter; a plurality of color test images of the to-be-punched food packages under the optimal illumination parameters are obtained, and the positions of the to-be-punched food packages in any two color test images are different; determining a punching positioning matching point group of the to-be-punched food package based on the plurality of color test images of the to-be-punched food package under the optimal illumination parameters; acquiring a color real-time image of the food package to be punched under the optimal illumination parameter; and the real-time punching coordinate is determined based on the punching positioning matching point group and the color real-time image of the to-be-punched food package, and the method has the advantage of improving the punching positioning efficiency and accuracy of the food package.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of image detection, in particular to a packaging unit detection and positioning method and system based on image analysis. BACKGROUND

[0002] In the field of automated packaging production, accurate detection and positioning of packaging units are the core links to ensure product quality and improve production efficiency. Food packaging hole positioning refers to accurately controlling the hole position, hole size and distribution in the food packaging production process through technical means to ensure that the hole meets the product function requirements (such as air permeability, exhaust, easy tearing, hanging, etc.), while ensuring food safety, packaging integrity and production efficiency. The traditional food packaging hole positioning technology mainly relies on mechanical sensors (such as photoelectric switches, limit switches), which has the following defects: 1. Poor adaptability: mechanical sensors need to be customized for specific packaging sizes and shapes, and cannot be flexibly adapted to multiple product categories (such as irregular food, irregular packaging); 2. Insufficient accuracy: affected by the reflectivity, transparency or surface texture of the packaging material, the sensor is prone to false detection or missed detection, resulting in positioning deviation (error often exceeds ±1mm); 3. High maintenance cost: mechanical parts are prone to wear and tear and need to be calibrated regularly.

[0003] Therefore, it is necessary to provide a packaging unit detection and positioning method and system based on image analysis to improve the efficiency and accuracy of food packaging hole positioning. SUMMARY

[0004] The present application provides a packaging unit detection and positioning method based on image analysis, comprising: determining a plurality of test food packaging; determining a plurality of test light parameters; collecting color test images of the plurality of test food packaging under the plurality of test light parameters; determining the optimal light parameter based on the color test images of the plurality of test food packaging under the plurality of test light parameters; obtaining a plurality of color test images of the food packaging to be punched under the optimal light parameter, wherein the positions of the food packaging to be punched in any two color test images are different; determining the hole positioning matching point group of the food packaging to be punched based on the plurality of color test images of the food packaging to be punched under the optimal light parameter; obtaining a color real-time image of the food packaging to be punched under the optimal light parameter; determining the real-time hole coordinates based on the hole positioning matching point group of the food packaging to be punched and the color real-time image.

[0005] Further, the test lighting parameters include light source position, light source wavelength and light source angle of at least one light source; and the optimal lighting parameter is determined based on the test images of the plurality of test food packages under the plurality of test lighting parameters, including: determining a plurality of imaging quality evaluation indexes; for each test lighting parameter, determining an imaging quality score of the test lighting parameter based on the test images of each test food package under the plurality of test lighting parameters and the plurality of imaging quality evaluation indexes; and determining the optimal lighting parameter based on the imaging quality scores of the test lighting parameters.

[0006] Further, the imaging quality score of the test lighting parameter is determined based on the test images of each test food package under the plurality of test lighting parameters and the plurality of imaging quality evaluation indexes, including: for each test food package, determining a weight of the test food package based on contour features and color features of the test food package; for each color test image corresponding to the test lighting parameter, determining a score of the color test image in the plurality of imaging quality evaluation indexes; and determining the imaging quality score of the test lighting parameter based on the scores of each color test image corresponding to the test lighting parameter in the plurality of imaging quality evaluation indexes and the weight of the test food package corresponding to the color test image.

[0007] Further, the weight of the test food package is determined based on the contour features and the color features of the test food package, including: calculating contour feature similarity and color feature similarity of any two test food packages; for each test food package, calculating a contour feature difference value based on the contour feature similarity of the test food package with other test food packages, and calculating a color feature difference value based on the color feature similarity of the test food package with other test food packages; and calculating the weight of the test food package based on the contour feature difference value and the color feature difference value of the test food package.

[0008] Further, the set of punch positioning matching points of the food package to be punched is determined based on the plurality of sets of color test images of the food package to be punched under the optimal lighting parameter, including: determining RGB values and pixel coordinates of a plurality of feature points based on a standard image of the food package to be punched; establishing a set of constraint conditions, wherein the set of constraint conditions includes RGB difference constraint, coordinate distance constraint and group point number constraint; generating a plurality of feature point groups based on the set of constraint conditions and the RGB values and pixel coordinates of the plurality of feature points; for each feature point group, determining an optimization value of the feature point group based on the plurality of sets of color test images of the food package to be punched under the optimal lighting parameter; and determining the set of punch positioning matching points of the food package to be punched based on the optimization value of each feature point group.

[0009] Further, based on the RGB values and pixel coordinates of the plurality of feature points, a plurality of feature point groups is generated, including: S11, for each feature point, calculating an RGB value difference value of the feature point based on the RGB value of the feature point and the RGB values of other feature points; S12, sorting the plurality of feature points according to the RGB value difference value of each feature point to generate a sorting table; S13, taking the first feature point in the sorting table as the current feature point; S14, generating a plurality of initial feature point groups of the current feature point based on the constraint condition set, performing internal deduplication on the plurality of initial feature point groups of the current feature point to generate a plurality of candidate feature point groups of the current feature point, performing external deduplication on the plurality of candidate feature point groups of the current feature point and the plurality of generated feature point groups to generate a plurality of feature point groups of the current feature point, and updating the plurality of generated feature point groups; S15, judging whether the updated plurality of generated feature point groups meet an end condition, if yes, outputting the plurality of feature point groups, and if no, executing S16; S16, removing the current feature point from the sorting table and executing S13.

[0010] Further, based on the plurality of sets of color test images of the food packaging to be punched under the optimal illumination parameters, an optimization value of the feature point group is determined, including: determining the positioning accuracy of the feature point group based on the plurality of sets of color test images of the food packaging to be punched under the optimal illumination parameters; and determining the optimization value of the feature point group based on the positioning accuracy of the feature point group and the number of feature points included in the feature point group.

[0011] Further, based on the optimization value of each feature point group, a punching positioning matching point group of the food packaging to be punched is determined, including: determining the punching positioning matching point group of the food packaging to be punched according to the optimization value of each feature point group and the constraint condition set by using the improved genetic algorithm.

[0012] Further, based on the punching positioning matching point group of the food packaging to be punched and the color real-time image, a real-time punching coordinate is determined, including: determining a relative position matrix of the punching position and the punching positioning matching point group based on the standard image of the food packaging to be punched; determining an RGB difference value matrix and a relative position matrix of the punching positioning matching point group based on the standard image of the food packaging to be punched; extracting the RGB value and pixel coordinates of each pixel point based on the color real-time image of the food packaging to be punched; determining real-time pixel coordinates of the punching positioning matching point group based on the RGB difference value matrix and the relative position matrix of the punching positioning matching point group and the RGB value and pixel coordinates of each pixel point; and determining the real-time punching coordinate based on the relative position matrix of the punching position and the punching positioning matching point group and the real-time pixel coordinates of the punching positioning matching point group.

[0013] The application provides a packaging unit detection positioning system based on image analysis, which applies the packaging unit detection positioning method based on image analysis, and comprises: a light test module, which is used for determining a plurality of test food packages, determining a plurality of sets of test light parameters, and collecting color test images of the plurality of test food packages under the plurality of sets of test light parameters; a parameter determination module, which is used for determining optimal light parameters based on the color test images of the plurality of test food packages under the plurality of sets of test light parameters; a matching point determination module, which is used for obtaining a plurality of color test images of a food package to be punched under the optimal light parameters, wherein the positions of the food package to be punched in any two color test images are different, and determining a punching positioning matching point group of the food package to be punched based on the plurality of color test images of the food package to be punched under the optimal light parameters; and a punching positioning module, which is used for obtaining a color real-time image of the food package to be punched under the optimal light parameters, and determining real-time punching coordinates based on the punching positioning matching point group of the food package to be punched and the color real-time image.

[0014] Compared with the prior art, the packaging unit detection positioning method and system based on image analysis provided by the present specification have at least the following beneficial effects: 1. The optimal light parameters are determined through a plurality of sets of light parameter tests, the influence of environmental light interference on image quality is reduced, and the positioning stability is improved; the punching positioning matching point group is determined by using a plurality of angle / position test images, the position offset or angle change in actual packaging production is adapted, and high-precision and low-delay punching coordinate calculation is realized based on the rapid feature comparison between the punching positioning matching point group and the real-time image.

[0015] 2. The RGB feature difference value is calculated and sorted, the feature points with high color uniqueness are preferentially processed, which helps to generate a feature point group with higher representativeness and discrimination, and improves the accuracy of subsequent feature matching tasks. The initial feature point group is generated based on the constraint condition set, and the internal and external de-duplication operations are performed, so that there is no repeated point in each feature point group and the groups are not repeated, thereby improving the quality and effectiveness of the feature point group. The feature points in the sorting table are processed through a loop until the end condition is met, so that all feature points have the opportunity to participate in the generation of the feature point group, and the feature information in the image is fully utilized. 3. The relative position matrix and the RGB difference matrix of the standard image are preset, and the real-time image pixel data is combined to realize accurate calculation of the punching position. The real-time pixel coordinate updating mechanism is used to adapt to the packaging position offset or deformation in the production process, so as to ensure the real-time accuracy of the punching coordinates. Based on the double feature matching of the RGB difference and the spatial position, the influence of environmental light changes or packaging surface differences on the positioning accuracy is reduced. BRIEF DESCRIPTION OF DRAWINGS

[0016] The specification will be further illustrated in the manner of exemplary embodiments, which will be described in detail with the aid of the accompanying drawings. These embodiments are not restrictive, and in these embodiments, the same reference numbers represent the same structures, in which: Figure 1 is a flow chart of a packaging unit detection positioning method based on image analysis shown in an embodiment of the present application; Figure 2 is a flow chart of generating a plurality of feature point groups shown in an embodiment of the present application; Figure 3 is a flow chart of determining real-time punching coordinates shown in an embodiment of the present application; Figure 4 is a module diagram of a packaging unit detection positioning system based on image analysis shown in an embodiment of the present application. DETAILED DESCRIPTION

[0017] In order to more clearly illustrate the technical solutions of the embodiments of the specification, the drawings needed to be used in the embodiment description will be briefly introduced below.

[0018] Figure 1 is a flow chart of a packaging unit detection positioning method based on image analysis shown in an embodiment of the present application, belonging to the technical field of image detection, as shown in Figure 1 , a packaging unit detection positioning method based on image analysis can include the following steps.

[0019] Step 110, determine a plurality of test food packages.

[0020] Specifically, the plurality of test food packages can be food packages produced on the production line that need to be punched and positioned.

[0021] Step 120, determine a plurality of test light parameters.

[0022] Among them, the test light parameters include the light source position, light source wavelength and light source angle of at least one light source.

[0023] Specifically, the light source position refers to the specific coordinate point of the light source in the three-dimensional space coordinate system, which is accurately measured in millimeters (mm). In the test scene, a rectangular coordinate system is usually established with the center of the tested object as the coordinate origin (0, 0, 0), and the light source position is determined by its coordinate values (x, y, z) on the x-axis, y-axis and z-axis. For example, when the light source is located 500 mm above the tested object, if the center of the object is taken as the origin, and the upward direction is defined as the positive direction of the z-axis, the light source position can be represented as (0, 0, 500). The light source position determines the coverage range and intensity distribution of the light on the food package. Different positions will cause significant differences in the area and degree of the package surface under the light.

[0024] The light source angle refers to the angle between the light emitted by the light source and the normal line of the surface of the object being tested, expressed in degrees (°). The normal line of the object surface is a straight line perpendicular to the object surface and passing through a certain point on the surface. The size of the light source angle directly affects the direction of incidence and the light intensity distribution of the light on the object surface. When the light source angle is 0°, the light is perpendicular to the object surface; as the light source angle increases, the light strikes the object surface at an increasingly oblique angle, causing the light intensity on the object surface to change, and also affecting the direction and distribution of the reflected light from the object surface.

[0025] Any two groups of test lighting parameters differ in at least one of the light source position, light source wavelength, and light source angle.

[0026] Step 130: Collecting color test images of the plurality of test food packages under the plurality of test lighting parameters.

[0027] Specifically, the color test images of the plurality of test food packages under the plurality of test lighting parameters can be collected by an image collection device fixed in position.

[0028] Step 140: Determining the optimal lighting parameter based on the color test images of the plurality of test food packages under the plurality of test lighting parameters.

[0029] Specifically, it includes: Determining a plurality of imaging quality evaluation indexes; For each test lighting parameter, determining an imaging quality score of the test lighting parameter based on the test images of each test food package under the plurality of test lighting parameters and the plurality of imaging quality evaluation indexes; Determining the optimal lighting parameter based on the imaging quality scores of the test lighting parameters.

[0030] Specifically, the plurality of imaging quality evaluation indexes can at least include sharpness, color restoration, and noise level. Sharpness is an important index for measuring the detail performance of an image.

[0031] In a food packaging image, a clear image can accurately present the detailed information such as text, patterns, and textures on the packaging. For example, for anti-counterfeiting packaging with microtext, a high-definition image can ensure that the text can be clearly identified. Sharpness can be evaluated by calculating parameters such as edge sharpness and contrast of the image. Color restoration reflects the closeness of the color of the image to the actual object color.

[0032] The color of food packaging often has important marketing and identification effects, and accurate color restoration can truly show the appearance and quality of the food. Color restoration can be measured by calculating indicators such as color difference and color saturation of the image.

[0033] Noise refers to random interference signals present in an image, which can reduce the quality and clarity of the image. In food packaging images, noise can manifest as grain-like speckles or blurred textures on the image. Images with low noise levels can provide a cleaner and clearer visual effect, which is beneficial for subsequent image analysis and processing. Noise levels can be evaluated by calculating parameters such as signal-to-noise ratio, mean square error, etc.

[0034] In some embodiments, based on the test images of each test food packaging under multiple sets of test lighting parameters and multiple imaging quality evaluation indicators, the imaging quality score of the test lighting parameters is determined, including: For each test food packaging, based on the contour features and color features of the test food packaging, the weight of the test food packaging is determined; For each color test image corresponding to the test lighting parameters, the score of the color test image in the multiple imaging quality evaluation indicators is determined; Based on the score of each color test image corresponding to the test lighting parameters in the multiple imaging quality evaluation indicators and the weight of the test food packaging corresponding to the color test image, the imaging quality score of the test lighting parameters is determined.

[0035] In some embodiments, based on the contour features and color features of the test food packaging, the weight of the test food packaging is determined, including: The contour feature similarity and color feature similarity of any two test food packagings are calculated; For each test food packaging, based on the contour feature similarity of the test food packaging with other test food packagings, the contour feature difference value is calculated, and based on the color feature similarity of the test food packaging with other test food packagings, the color feature difference value is calculated; Based on the contour feature difference value and the color difference value of the test food packaging, the weight of the test food packaging is calculated.

[0036] Specifically, the contour matching algorithm can be used to compare the contours of two test food packagings and calculate the matching degree between them. The higher the matching degree, the greater the contour feature similarity. The feature vectors of the contours of the test food packagings, such as the length, curvature, and convex hull of the contour, can also be extracted, and then the distance between the feature vectors (such as Euclidean distance) is calculated to measure the contour feature similarity. The smaller the distance, the greater the contour feature similarity.

[0037] The color feature similarity can be calculated by extracting color histogram, color moment and other features of the standard images of the two test food packaging, wherein the standard image refers to a reference image that can accurately and stably represent the features of the test food packaging. It is obtained under specific and ideal conditions, excluding factors that may affect color presentation such as light changes, shooting angles, background interference, and does not exist deformation, providing a unified and reliable benchmark for subsequent color feature similarity calculation. The color histogram counts the frequency of different colors in the image, and the color feature similarity is calculated by comparing the differences of the color histograms of the two images (such as using Bhattacharyya distance, histogram intersection method, etc.). Color moment extracts statistical features such as mean and variance of image color, and measures the similarity by calculating the difference between these features.

[0038] The contour feature difference value and the color difference value of the test food packaging can be averaged to obtain the weight of the test food packaging.

[0039] The weight of the test food packaging can be calculated according to the following formula: ; wherein, is the weight of the i-th test food packaging, is the contour feature difference value of the i-th test food packaging, is the color difference value of the i-th test food packaging, is the color feature similarity between the i-th test food packaging and the j-th test food packaging, is the total number of test food packaging.

[0040] In the above formula, represents the sum of the contour feature similarities between the i-th food packaging and the remaining n-1 food packaging. The larger the sum value is, the more similar the contour of the i-th packaging is to other packaging. And is obtained by transforming the sum value. When the sum of the contour feature similarities is large, the denominator is large, the value of is small, indicating that the contour of the packaging is small in difference from other packaging; on the contrary, when the sum of the contour feature similarities is small, the denominator is small, the value of

[0041] is large, indicating that the contour of the packaging is large in difference from other packaging. The calculation principle of the color difference value is similar to that of the contour feature difference value, which will not be described here. ; wherein, is the imaging quality score of the m-th set of test lighting parameters, the score of the i-th test food packaging corresponding to the lighting parameter for the m-th group of tests at the k-th imaging quality evaluation index, the total number of imaging quality evaluation indexes.

[0042] The above formula comprehensively considers the weight of the test food packaging and the scores of the corresponding images at multiple imaging quality evaluation indexes to comprehensively and objectively evaluate the imaging quality of the lighting parameter. The average score of the color test image of the packaging at K imaging quality evaluation indexes is calculated, and the performance of the packaging image at different quality dimensions is comprehensively considered. Because different evaluation indexes may be related to each other and have different focuses, an average can be obtained. For example, an image may have a higher score in clarity, but a lower score in color restoration. After averaging, the overall quality level can be more objectively reflected. By summing, the imaging quality performance of all packages under different weights can be considered, so that the imaging quality of the group of lighting parameters on the whole test sample can be more accurately evaluated.

[0043] The test lighting parameter with the highest imaging quality score can be used as the optimal lighting parameter.

[0044] If the weights of all test food packaging are the same, the evaluation result may be disturbed by some ordinary packaging, resulting in inaccurate overall evaluation of the imaging quality of the lighting parameter. Food packaging with large contour feature difference values and color difference values can more truly reflect the actual effect of the lighting parameter due to their uniqueness. Giving them a larger weight can reduce the interference of the average effect and make the evaluation result closer to the actual situation.

[0045] Step 150, obtaining multiple color test images of the food packaging to be punched under the optimal lighting parameter.

[0046] Among them, the positions of the food packaging to be punched in any two color test images are different. In order to simulate different conveyor transportation situations. In the real food packaging production and punching process, food packaging is usually transported by a conveyor belt. Because the operation of the conveyor belt is not absolutely smooth, the position of the food packaging during the conveying process will change constantly, and there may be forward and backward offset, left and right shaking, angle inclination, etc. In step 150, multiple color test images of the food packaging to be punched under the optimal lighting parameter are obtained, which are different in position. This is to simulate the actual conveyor transportation situation. In this way, the imaging effect of the optimal lighting parameter when the food packaging is in different positions in the actual production environment can be more truly reflected, thereby providing more reliable and more actual image data support for subsequent punching operations.

[0047] In step 160, based on the plurality of color test images of the food packaging to be punched under the optimal illumination parameter, a set of punching positioning matching points of the food packaging to be punched is determined.

[0048] Specifically, the method comprises: determining the RGB values and pixel coordinates of the plurality of feature points based on the standard image of the food packaging to be punched; establishing a set of constraints, wherein the set of constraints comprises an RGB difference constraint, a coordinate distance constraint, and a point number constraint in a group; generating a plurality of feature point groups based on the set of constraints and the RGB values and pixel coordinates of the plurality of feature points; for each feature point group, determining an optimization value of the feature point group based on the plurality of sets of color test images of the food packaging to be punched under the optimal illumination parameter; determining a set of punching positioning matching points of the food packaging to be punched based on the optimization value of each feature point group.

[0049] Specifically, the RGB difference constraint represents that the absolute value of the difference between the RGB values of any two feature points in the feature point group is greater than an RGB difference threshold (e.g., 50). The coordinate distance constraint can represent that the pixel distance between any two feature points in the feature point group is greater than a pixel distance threshold (e.g., 30). The point number constraint in a group can represent that the number of feature points included in the feature point group is in a value range, for example, (5, 20), etc.

[0050] Figure 2 is a flowchart for generating a plurality of feature point groups shown in an embodiment of the present application, as Figure 2 shown, in some embodiments, based on the RGB values and pixel coordinates of the plurality of feature points, the plurality of feature point groups are generated, comprising: S11, for each feature point, based on the difference between the RGB value of the feature point and the RGB value of another feature point, calculating an RGB value difference value of the feature point, wherein the RGB value difference value of the feature point can be the mean value of the difference between the RGB value of the feature point and the RGB value of another feature point; S12, according to the RGB value difference value of each feature point, sorting the plurality of feature points to generate a sorting table, wherein the greater the RGB value difference value, the higher the feature point ranking; S13, taking the feature point with the highest ranking in the sorting table as the current feature point; S14, generate a plurality of initial feature point groups of the current feature point based on the constraint set, for example, select points that satisfy the RGB difference constraint and the coordinate distance constraint with the current feature point from the remaining feature points as candidate feature points, sample the candidate feature points according to the point number constraint in the group, and combine the current feature point to generate a plurality of initial feature point groups, as an example, for the RGB difference constraint, traverse all the remaining feature points, calculate the RGB value difference between the current feature point and the remaining feature points, if the difference is greater than the set RGB difference threshold, add the feature point to the current initial feature point group, remove the current feature point from the sorting table, and execute S13. S15, determine whether the updated generated plurality of feature point groups satisfies the end condition, if yes, output the plurality of feature point groups, if no, execute S16, wherein the end condition can be that the number of feature point groups reaches a preset value (for example, 20 groups); S16, remove the current feature point from the sorting table, and execute S13.

[0051] The above process prioritizes feature points with high color uniqueness by calculating RGB feature difference values and sorting, which helps to generate more representative and distinctive feature point groups, improving the accuracy of subsequent feature matching tasks. Based on the constraint set, initial feature point groups are generated, and internal and external redundancy operations are performed to ensure that there are no duplicate points in each feature point group and that the groups are not repeated, improving the quality and effectiveness of the feature point groups. By processing the feature points in the sorting table in a loop until the end condition is met, it ensures that all feature points have the opportunity to participate in the generation of feature point groups, making full use of the feature information in the image.

[0052] In some embodiments, based on a plurality of color test images of the food packaging to be punched under the optimal lighting parameters, the optimization value of the feature point group is determined, including: Based on a plurality of color test images of the food packaging to be punched under the optimal lighting parameters, the positioning accuracy of the feature point group is determined; Based on the positioning accuracy of the feature point group and the number of feature points included in the feature point group, the optimization value of the feature point group is determined.

[0053] Specifically, for each set of color test images, the calculated actual hole location in the color test image is compared with the pre-calibrated true hole location, and the error between the two is calculated. The true hole location can be pre-calibrated manually. As an example, the straight-line distance between the calculated actual hole location in the color test image and the pre-calibrated true hole location can be used as the positioning error of the color test image.

[0054] The positioning accuracy of a feature point group can be calculated based on the positioning error of each set of color test images. The smaller the positioning error of each set of color test images, the higher the positioning accuracy of the feature point group.

[0055] For example, the localization accuracy of a feature point group can be calculated using the following formula: ; in, Let be the localization accuracy of the i-th feature point group. Let be the positioning error of the m-th color test image. This represents the number of groups of color test images.

[0056] The above formula, by Summing the localization errors of a group of images allows for a comprehensive assessment of the overall localization deviation of the feature point group across different image scenarios. A large sum indicates that the feature point group generally has a large localization error across multiple image groups, resulting in poor overall localization performance; conversely, a small sum indicates that the feature point group generally has a small localization error across multiple image groups, resulting in good overall localization performance. The addition of 1 is to avoid a denominator of 0. If only the total localization error is used as the denominator, when the localization errors of all test images... When both denominators are 0, the denominator is 0, and the formula is meaningless. By adding 1, we ensure that the denominator is always greater than 0, so that the formula can be calculated correctly in all cases.

[0057] The optimal value of a feature point group can be determined based on its localization accuracy and the number of feature points it includes. The higher the localization accuracy of the feature point group and the fewer feature points it includes, the larger its optimal value.

[0058] In some embodiments, determining the punching positioning matching point set for the food packaging to be punched, based on the optimized value of each feature point group, includes: By using an improved genetic algorithm, the punching positioning matching point set for the food packaging to be punched is determined based on the optimized value of each feature point group and the constraint condition set.

[0059] Specifically, the feature point group is converted into a chromosome form that can be processed by the genetic algorithm. Binary encoding, real number encoding, etc. can be used. For example, if the feature point group is composed of multiple feature points, each feature point has two-dimensional coordinate information, real number encoding can be used, and the x and y coordinates of each feature point are arranged in sequence to form a real number string, which represents a chromosome corresponding to a feature point group. The optimized value of each feature point group is directly used as the fitness value. Individuals with higher fitness are selected from the current population to have the opportunity to enter the next generation population, while individuals with lower fitness are eliminated to simulate the "survival of the fittest" principle in natural selection. By exchanging part of the genes of two or more individuals, new individuals are generated, the diversity of the population is increased, the search space is expanded, and the global optimal solution is found. Randomly change some genes of the individual to further increase the diversity of the population, avoid the algorithm falling into a local optimal solution, and output the feature point group with the largest optimization value as the punching positioning matching point group of the food packaging to be punched until the termination condition (for example, the maximum number of iterations, the fitness value reaches the preset threshold, the population fitness value does not improve significantly for a certain number of generations, etc.) is met. Among them, the operations such as crossover and mutation need to meet the constraint condition set.

[0060] In step 160, a color real-time image of the food packaging to be punched under the optimal lighting parameter is obtained.

[0061] Specifically, the color real-time image of the food packaging to be punched under the optimal lighting parameter can be obtained by the image acquisition device described in step 130.

[0062] In step 170, the real-time punching coordinates are determined based on the punching positioning matching point group and the color real-time image of the food packaging to be punched.

[0063] Figure 3 is a flowchart for determining the real-time punching coordinates in an embodiment of the present application, as shown in Figure 3 As shown in some embodiments, step 170 specifically includes: determining the relative position matrix of the punching position and the punching positioning matching point group based on the standard image of the food packaging to be punched; determining the RGB difference matrix and the relative position matrix of the punching positioning matching point group based on the standard image of the food packaging to be punched; extracting the RGB value and pixel coordinates of each pixel point based on the color real-time image of the food packaging to be punched; determining the real-time pixel coordinates of the punching positioning matching point group based on the RGB difference matrix and the relative position matrix of the punching positioning matching point group and the RGB value and pixel coordinates of each pixel point; Determine the real-time punching coordinate based on the relative position matrix of the punching position and the punching positioning matching point group and the real-time pixel coordinates of the punching positioning matching point group.

[0064] Specifically, the relative position matrix of the punching position and the punching positioning matching point group is used to describe the positional relationship of the punching position relative to each point in the punching positioning matching point group. For example, in a two-dimensional plane, a matrix containing the difference values can be constructed by calculating the difference values of the punching position coordinates and the coordinates of each matching point, which reflects the relative positional relationship between them.

[0065] The RGB difference matrix is obtained by calculating the RGB color difference between each feature point in the matching point group and the surrounding background or other reference points. For example, for each feature point i in the matching point group, a certain range of background pixel points around it can be selected, and the average difference of the RGB values of the feature point and the background pixel points is calculated. The difference values of all feature points included in the punching positioning matching point group of the food packaging to be punched form a matrix, which is the RGB difference matrix.

[0066] For each feature point of each punching positioning matching point group, based on the RGB color difference of the feature point in the standard image and the RGB color difference of each pixel point in the color real-time image, the similar pixel point of the feature point is obtained. For example, the absolute value of the difference between the RGB color difference of the feature point in the standard image and the RGB color difference of the pixel point is calculated. If the absolute value of the difference is less than the absolute value threshold (for example, 5), it is determined as a similar pixel point.

[0067] A pixel point is sampled from the similar pixel point of each feature point to form an RGB similar pixel point group, and the relative position matrix of the RGB similar pixel point group is determined in a similar manner to the determination of the relative position matrix of the punching positioning matching point group, which will not be described here.

[0068] For each RGB similar pixel point group, the Euclidean distance between the relative position matrix of the RGB similar pixel point group and the relative position matrix of the punching positioning matching point group is calculated, and the coordinates of the pixel points included in the RGB similar pixel point group with the smallest Euclidean distance are taken as the real-time pixel coordinates of the punching positioning matching point group.

[0069] Since the relative position matrix of the punching position and the matching point group and the pixel coordinates of the matching point group in the real-time image are known, according to the principle of matrix operation and coordinate transformation, the pixel coordinates of the punching position in the real-time image, i.e. the real-time punching coordinate, can be obtained by adding the difference values in the relative position matrix to the real-time pixel coordinates of the matching point group.

[0070] The relative position matrix and the RGB difference matrix of the standard image preset are combined with real-time image pixel data to realize accurate calculation of the punching position. The real-time pixel coordinate updating mechanism can adapt to packaging position deviation or deformation in the production process, thereby ensuring real-time accuracy of the punching coordinates. Based on the RGB difference and spatial position double feature matching, the influence of environmental light changes or packaging surface differences on the positioning accuracy is reduced.

[0071] Figure 4 is a module diagram of a packaging unit detection and positioning system based on image analysis shown in an embodiment of the present application, as shown in Figure 4 A packaging unit detection and positioning system based on image analysis can include an illumination test module, a parameter determination module, a matching point determination module, and a punching positioning module.

[0072] The illumination test module is configured to determine a plurality of test food packages, determine a plurality of sets of test illumination parameters, and acquire color test images of the plurality of test food packages under the plurality of sets of test illumination parameters. The parameter determination module is configured to determine optimal illumination parameters based on the color test images of the plurality of test food packages under the plurality of sets of test illumination parameters. The matching point determination module is configured to acquire a plurality of color test images of a food package to be punched under the optimal illumination parameters, wherein the positions of the food package to be punched in any two color test images are different, and determine a set of punching positioning matching points of the food package to be punched based on the plurality of color test images of the food package to be punched under the optimal illumination parameters. The punching positioning module is configured to acquire a color real-time image of the food package to be punched under the optimal illumination parameters, and determine real-time punching coordinates based on the set of punching positioning matching points of the food package to be punched and the color real-time image.

[0073] A packaging unit detection and positioning system based on image analysis can be used to perform a packaging unit detection and positioning method based on image analysis, which is not described here.

[0074] Finally, it should be understood that the embodiments described in the specification are only used to illustrate the principles of the embodiments of the specification. Other variations can also be within the scope of the specification. Therefore, as an example but not limitation, alternative configurations of the embodiments of the specification can be considered consistent with the teachings of the specification. Accordingly, the embodiments of the specification are not limited to the embodiments explicitly introduced and described in the specification.

Claims

1. A method for detecting and locating packaging units based on image analysis, characterized in that, include: Identify multiple food packaging options for testing; Determine multiple sets of lighting parameters for testing; Collect color test images of multiple food packages under various sets of test lighting parameters; Based on color test images of multiple food packages under multiple sets of test lighting parameters, the optimal lighting parameters are determined. Multiple color test images of the food packaging to be punched under optimal lighting parameters are obtained, wherein the position of the food packaging to be punched differs between any two color test images; Based on multiple color test images of the food packaging to be punched under optimal lighting parameters, the punching positioning matching point set of the food packaging to be punched is determined. Acquire a real-time color image of the food packaging to be punched under optimal lighting parameters; Based on the punching positioning matching point group and color real-time image of the food packaging to be punched, the real-time punching coordinates are determined.

2. The method for detecting and locating packaging units based on image analysis according to claim 1, characterized in that, The lighting parameters used in the test include the position, wavelength, and angle of at least one light source; Based on test images of multiple food packages under various lighting parameters, the optimal lighting parameters were determined, including: Determine multiple imaging quality evaluation indicators; For each set of test illumination parameters, the imaging quality score of the test illumination parameters is determined based on the test images of each food package under multiple sets of test illumination parameters and multiple imaging quality evaluation indicators. The optimal illumination parameters are determined based on the imaging quality score of the illumination parameters used in the test.

3. The method for detecting and locating packaging units based on image analysis according to claim 2, characterized in that, Based on test images of each food package under multiple sets of testing illumination parameters and multiple imaging quality evaluation indicators, an imaging quality score for the testing illumination parameters is determined, including: For each test food package, the weight of the test food package is determined based on its outline and color features; For each color test image corresponding to the test illumination parameters, determine the score of the color test image on multiple imaging quality evaluation indicators; The imaging quality score of the testing illumination parameters is determined based on the scores of each color test image corresponding to the testing illumination parameters on multiple imaging quality evaluation indicators and the weight of the testing food packaging corresponding to the color test image.

4. The method for detecting and locating packaging units based on image analysis according to claim 3, characterized in that, Based on the outline and color features of the food packaging used for testing, the weights of the food packaging for testing are determined, including: Calculate the similarity of the outline features and the similarity of the color features between any two test food packages; For each test food package, the contour feature difference value is calculated based on the contour feature similarity between the test food package and other test food packages, and the color feature difference value is calculated based on the color feature similarity between the test food package and other test food packages. The weights of the test food packaging are calculated based on the contour feature difference values ​​and color difference values.

5. A method for detecting and locating packaging units based on image analysis according to any one of claims 1-4, characterized in that, Based on multiple sets of color test images of the food packaging to be punched under optimal illumination parameters, the punching positioning matching point set of the food packaging to be punched is determined, including: Based on a standard image of the food packaging to be punched, the RGB values ​​and pixel coordinates of multiple feature points are determined; Establish a set of constraints, which includes RGB difference constraints, coordinate distance constraints, and intra-group point count constraints. Based on the constraint set and the RGB values ​​and pixel coordinates of multiple feature points, multiple feature point groups are generated. For each feature point group, the optimized value of the feature point group is determined based on multiple sets of color test images of the food packaging to be punched under optimal lighting parameters. Based on the optimized value of each feature point group, the punching positioning matching point group of the food packaging to be punched is determined.

6. The method for detecting and locating packaging units based on image analysis according to claim 5, characterized in that, Based on the RGB values ​​and pixel coordinates of multiple feature points, multiple feature point groups are generated, including: S11. For each feature point, calculate the RGB value difference of the feature point based on the difference between the RGB value of the feature point and the RGB values ​​of other feature points. S12. Sort multiple feature points according to the difference in RGB values ​​of each feature point to generate a sorting table; S13. Take the feature point that is first in the sorting table as the current feature point; S14. Based on the constraint set, generate multiple initial feature point groups for the current feature point, perform internal deduplication on the multiple initial feature point groups for the current feature point, generate multiple candidate feature point groups for the current feature point, perform external deduplication on the multiple candidate feature point groups for the current feature point and the multiple generated feature point groups, generate multiple feature point groups for the current feature point, and update the multiple generated feature point groups. S15. Determine whether the updated generated feature point groups meet the termination condition. If yes, output the multiple feature point groups. If not, execute S16. S16. Remove the current feature point from the sorting table and execute S13.

7. The method for detecting and locating packaging units based on image analysis according to claim 6, characterized in that, Based on multiple sets of color test images of the food packaging to be punched under optimal illumination parameters, the optimized values ​​of feature point sets are determined, including: Based on multiple sets of color test images of the food packaging to be punched under optimal lighting parameters, the positioning accuracy of the feature point group is determined. The optimal value of the feature point group is determined based on the localization accuracy of the feature point group and the number of feature points included in the feature point group.

8. The method for detecting and locating packaging units based on image analysis according to claim 7, characterized in that, Based on the optimized values ​​of each feature point group, the punching positioning matching point group for the food packaging to be punched is determined, including: By using an improved genetic algorithm, the punching positioning matching point set for the food packaging to be punched is determined based on the optimized value of each feature point group and the constraint condition set.

9. The method for detecting and locating packaging units based on image analysis according to claim 8, characterized in that, Based on the punching positioning matching point set and real-time color image of the food packaging to be punched, the real-time punching coordinates are determined, including: Based on a standard image of the food packaging to be punched, determine the relative position matrix between the punching location and the matching point group for punching positioning; Based on a standard image of the food packaging to be punched, determine the RGB difference matrix and relative position matrix of the punching positioning matching point group; Based on the real-time color image of the food packaging to be punched, extract the RGB value and pixel coordinates of each pixel; Based on the RGB difference matrix and relative position matrix of the punch positioning matching point group, as well as the RGB value and pixel coordinates of each pixel, the real-time pixel coordinates of the punch positioning matching point group are determined. The real-time punching coordinates are determined based on the relative position matrix of the punching position and the punching positioning matching point group and the real-time pixel coordinates of the punching positioning matching point group.

10. A detection and positioning system for packaging units based on image analysis, characterized in that, The method for detecting and locating packaging units based on image analysis according to any one of claims 1-9 includes: The illumination test module is used to identify multiple food packages for testing, determine multiple sets of illumination parameters for testing, and acquire color test images of multiple food packages for testing under multiple sets of illumination parameters for testing. The parameter determination module is used to determine the optimal illumination parameters based on color test images of multiple food packages under multiple sets of test illumination parameters. The matching point determination module is used to acquire multiple color test images of the food packaging to be punched under optimal lighting parameters. Among them, the position of the food packaging to be punched in any two color test images is different. Based on the multiple color test images of the food packaging to be punched under optimal lighting parameters, the punching positioning matching point group of the food packaging to be punched is determined. The punching positioning module is used to acquire a real-time color image of the food packaging to be punched under optimal lighting parameters, and to determine the real-time punching coordinates based on the punching positioning matching point group of the food packaging to be punched and the real-time color image.