A method, device, electronic device and medium for detecting the fitting line of a packaging box

By extracting the bonding lines in the packaging box template image and the image to be detected, and calculating the relative distance and angle, the problems of low detection accuracy and high leakage detection rate in the prior art are solved, and high-precision bonding lines detection is achieved.

CN114648499BActive Publication Date: 2025-06-17LCFC HEFEI ELECTRONICS TECH
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210238026.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-03-11
Publication Date
2025-06-17
Estimated Expiration
2042-03-11

AI Technical Summary

Technical Problem

In the prior art, when detecting defects in the packaging box bonding line, especially the high-curve bottom plate of the self-locking bottom carton, there are problems of low detection accuracy and high leakage detection rate.

Method used

By acquiring the template image and the image to be detected in the packaging box, extracting the first bonding line in the template image and the second bonding line in the image to be detected, calculating the relative distance and angle between the two, and determining whether the second bonding line is qualified.

Benefits of technology

The accuracy of bond line detection is improved and the leakage detection rate is reduced. Especially when the image deformation is large, the position and angle of the bond line can be accurately judged.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114648499B_ABST
    Figure CN114648499B_ABST
Patent Text Reader

Abstract

The present disclosure provides a method, apparatus, electronic device, and medium for detecting a fitting line of a packaging box, including obtaining a template image of the packaging box, where the template image includes at least one main board of the packaging box and at least one side board integrally connected to the main board through a connecting line; collecting a to-be-detected image of the packaging box corresponding to the template image; extracting a first fitting line from the template image and extracting a second fitting line from the to-be-detected image, where the first fitting line represents a standard position of one side of a fitting board attached to the side board close to the connecting line, and the second fitting line represents an actual position of one side of the fitting board attached to the side board close to the connecting line; when it is determined that the relative distance between the first fitting line in the template image and the second fitting line in the to-be-detected image meets a threshold, and it is determined that the angle between the second fitting line and a reference line on the main board of the to-be-detected image meets a threshold, then it is determined that the second fitting line is qualified.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the technical field of image detection, and particularly to a method, device, electronic device and medium for detecting the fitting line of a packing box. Background Art

[0002] Packing boxes are very commonly used. Before leaving the factory, a packing box often needs to be fitted with a fitting plate similar to a label. When the fitting plate is fitted on the packing box, a fitting line will be generated. If the fitting line is too deviated or crooked relative to the connecting line between the main board and the side board, it is likely to affect the normal use of the packing box.

[0003] Common methods for detecting an image to determine whether it meets the requirements include a defect detection method based on template comparison, a defect detection method based on deep learning, etc. The defect detection method based on template comparison only extracts the position of the fitting line in the image to be detected and compares it with a standard template to determine whether the fitting line has defects. The defect detection method based on deep learning is a method of inputting a large number of feature images into each network node of a neural network for convolution operation to extract image features and generating a series of model parameters that can stably detect features, training a model based on a deep network to obtain a neural network that can be used to detect fitting line defects. For the bottom plate with a relatively high arc of a self-locking bottom carton in the former, if there is a situation of high and low lines, the image to be measured is more likely to be deformed when collecting the image to be measured. Therefore, the fitting line with high and low line defects still presents a vertical situation in the image to be measured. Since the fitting line of the standard template is in the vertical direction, only by comparing whether the fitting line is vertical, the detection accuracy for the high and low line defects caused by fitting is relatively low, and the missed detection rate is relatively high. The latter, due to the need for a large number of data samples and the workload of manually annotating the data samples, results in a long working cycle, time-consuming and laborious. Summary of the Invention

[0004] The present disclosure provides a method and device for detecting the fitting line of a packing box to at least solve the above technical problems existing in the prior art.

[0005] On the one hand, the present disclosure provides a method for detecting the fitting line of a packing box, including:

[0006] Obtaining a template image of the packing box, where the template image includes at least one main board of the packing box and at least one side board integrally connected to the main board through a connecting line;

[0007] Collecting an image to be detected of the packing box corresponding to the template image;

[0008] Extracting a first fitting line from the template image and a second fitting line from the image to be detected, where the first fitting line represents the standard position of the side of the fitting plate attached to the side board close to the connecting line, and the second fitting line represents the actual position of the side of the fitting plate attached to the side board close to the connecting line;

[0009] When it is determined that the relative distance between the first fitting line in the template image and the second fitting line in the image to be detected meets the threshold, and it is determined that the angle between the second fitting line and the reference line on the main board of the image to be detected meets the threshold, it is determined that the second fitting line is qualified.

[0010] In an implementable manner, the determining the relative distance between the first fitting line in the template image and the second fitting line in the image to be detected includes:

[0011] Extract a first anchor point from the template image and a second anchor point from the image to be detected;

[0012] Calculate the standard distance between the first anchor point and the first fitting line and calculate the actual distance between the second anchor point and the second fitting line;

[0013] Determine that the difference between the standard distance and the actual distance is the relative distance.

[0014] In an implementable manner, the calculating the actual distance between the second anchor point and the second fitting line includes:

[0015] Select the starting point and the ending point on the second fitting line, compare the distances between the starting point and the ending point and the second anchor point in the horizontal direction respectively, and select the larger value as the actual distance.

[0016] In an implementable manner, the determining the angle between the second fitting line and the reference line on the main board includes:

[0017] Extract a reference line from the image to be detected, the reference line is the upper edge line of the main board, calculate the angle between the second fitting line and the reference line to determine the angle between the second fitting line and the reference line on the main board.

[0018] In an implementable manner, the extracting the first anchor point from the template image includes:

[0019] Define a region centered on the connecting line, and use the central position of any mark within the main board part in this region as the first anchor point.

[0020] In an implementable manner, the extracting the second anchor point from the image to be detected includes:

[0021] Based on the template image, extract the second anchor point corresponding to the position of the first anchor point on the template image from the image to be detected.

[0022] In an implementable manner, the extracting the second fitting line from the image to be detected includes:

[0023] Extract multiple line segments with lengths meeting a threshold from the image to be detected, and obtain the second fitting line after preprocessing the multiple line segments. The preprocessing includes removing line segments with incorrect directions and filtering the shadows of the line segments.

[0024] On the other hand, the present disclosure provides a fitting line detection device for a packaging box, including:

[0025] An acquisition module for acquiring a template image of the packaging box, where the template image includes at least one main board of the packaging box and at least one side board integrally connected to the main board through a connecting line;

[0026] It is further configured to collect a to-be-detected image of the packaging box corresponding to the template image;

[0027] An extraction module for extracting a first fitting line from the template image and extracting a second fitting line from the to-be-detected image. The first fitting line represents the standard position of one side of the fitting board attached to the side board close to the connecting line, and the second fitting line represents the actual position of one side of the fitting board attached to the side board close to the connecting line;

[0028] A processing module for determining that when the relative distance between the first fitting line in the template image and the second fitting line in the to-be-detected image meets the threshold and the angle between the second fitting line and a reference line on the main board of the to-be-detected image meets the threshold, it is determined that the second fitting line is qualified.

[0029] On yet another aspect, the present disclosure provides an electronic device, including: a memory and a processor. The memory stores a computer program executable by the processor, and when the processor executes the computer program, the above-mentioned fitting line detection method for the packaging box is implemented.

[0030] On still another aspect, the present disclosure provides a medium, on which a computer program is stored. When the computer program is read and executed, the above-mentioned fitting line detection method for the packaging box is implemented.

[0031] Based on the above solutions, the present disclosure provides a fitting line detection method for a packaging box. By acquiring a template image with the first fitting line meeting the standard position, collecting a to-be-detected image of the packaging box corresponding to the template image and obtaining the second fitting line, and comparing the relative distance between the first fitting line and the second fitting line, it can be quickly determined whether the second fitting line on the to-be-detected image is qualified; then collecting a reference line on the main board of the to-be-detected image in the same dimension and calculating whether the angle between the second fitting line and the reference line meets the threshold, it can be determined whether there is a situation of high or low line for the second fitting line, avoiding the situation of missed detection due to ignoring defects when the second fitting line is still in the same vertical direction as the standard due to image deformation, and the detection accuracy is relatively high. Description of the Drawings

[0032] Figure 1 The following is a schematic flow chart of the method for detecting the fitting line of a packing box provided by an embodiment of the present disclosure;

[0033] Figure 2 The following is a schematic flow chart of the method for detecting the fitting line of a packing box provided by another embodiment of the present disclosure;

[0034] Figure 3 The following is a schematic framework diagram of the method for detecting the fitting line of a packing box provided by another embodiment of the present disclosure;

[0035] Figure 4 The following is a schematic diagram of a template image provided by another embodiment of the present disclosure;

[0036] Figure 5 The following is a schematic comparison diagram of the second fitting line shadow and the filtered shadow of the image to be detected provided by another embodiment of the present disclosure;

[0037] Figure 6 The following is a schematic diagram of the skew of the second fitting line of the image to be detected provided by another embodiment of the present disclosure;

[0038] Figure 7 The following is a schematic diagram of the right deviation of the second fitting line of the image to be detected provided by another embodiment of the present disclosure;

[0039] Figure 8 The following is a schematic diagram of the left deviation of the second fitting line of the image to be detected provided by another embodiment of the present disclosure;

[0040] Figure 9 The following is a schematic diagram of the height difference line of the second fitting line of the image to be detected provided by another embodiment of the present disclosure;

[0041] Figure 10 The following is a schematic diagram of the device for detecting the fitting line of a packing box provided by an embodiment of the present disclosure.

[0042] In the figure: 1. Main board, 2. Connecting wire, 3. Fitting board, 4. First fitting line, 5. First anchor point, 6. Second fitting line, 7. Second anchor point, 8. Upper edge line. Detailed implementation manners

[0043] To make the objectives, features, and advantages of the present disclosure more obvious and understandable, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present disclosure. Apparently, the described embodiments are only a part of the embodiments of the present disclosure, rather than all the embodiments. Based on the embodiments of the present disclosure, all other embodiments obtained by those skilled in the art without creative efforts shall fall within the protection scope of the present disclosure.

[0044] To improve the accuracy of detecting the fitting line defects of the packaging box and reduce the missed detection rate, as Figure 1 shown, an embodiment of the present disclosure provides a method for detecting the fitting line of a packaging box, including:

[0045] Step 101, obtaining a template image of the packaging box, where the template image includes at least one main board of the packaging box and at least one side board integrally connected to the main board through a connecting line;

[0046] The packaging box is formed by folding an unfolded board, and the unfolded board includes a main board and integrally connected side boards. The side boards are arranged on both sides of the main board. When the unfolded board is folded into a packaging box, the main boards are arranged opposite to each other to form two faces of the packaging box body, and the side boards are folded to form the side covers of the body. Among them, a fitting board is attached to the side board. In the present disclosure, the line segment corresponding to the side of the fitting board close to the connecting line is called the fitting line.

[0047] In the present disclosure, the template image of the packaging box includes at least one main board and one side board integrally connected to the main board through a connecting line. The corresponding template image can be obtained according to the fitting board to be detected, and then the template image includes at least the side board to which the fitting board should be attached and at least one main board integrally connected to the side board through a connecting line.

[0048] In one example, the template image further includes a first fitting line, and the first fitting line represents the standard position of the side of the fitting board attached to the side board close to the connecting line, that is, it is used to represent the standard position of the fitting board. When the first fitting line coincides with the connecting line, the connecting line can be used as the first fitting line; the first fitting line can also be aligned with the connecting line and have a certain distance.

[0049] In one example, the template image can be a standard image proportional to the corresponding packaging box, such as a design drawing or an image that has already attached a fitting board and has a standard fitting position (the photographed object in the image has not deformed).

[0050] Step 102, collecting a to-be-detected image of the packaging box corresponding to the template image;

[0051] In Step 101, the corresponding template image is obtained according to the fitting board to be detected. Then, each part of the packaging box in the to-be-detected image collected in this step needs to correspond to each part in the template image. The difference is that the template image is a standard image, while the to-be-detected image is an image taken of the packaging box with the fitting board actually attached, and deformation may occur.

[0052] Step 103, extracting the first fitting line from the template image and extracting the second fitting line from the to-be-detected image. The first fitting line represents the standard position of the side of the fitting board attached to the side board close to the connecting line, and the second fitting line represents the actual position of the side of the fitting board attached to the side board close to the connecting line;

[0053] When extracting the fitting line, the template image and the image to be detected can be mapped into the same coordinate system. First, taking the template image as a reference, for example, using the upper edge line on the main board as the alignment standard, align the template image and the image to be detected, and then establish a coordinate system.

[0054] Extract the second fitting line from the image to be detected. The second fitting line is the actual fitting line generated when the fitting board on the packaging box corresponding to the image to be detected is attached to the side board. Therefore, it represents the actual position of the side of the fitting board attached to the side board near the connection line.

[0055] In one example, extracting the second fitting line includes extracting multiple line segments from the image to be detected whose lengths meet the threshold, and preprocessing the multiple line segments. The preprocessing includes removing line segments with incorrect directions (for example, according to the placement position of the image, it is determined that the fitting line should be in the vertical direction in the coordinate system, so the horizontal line segments are line segments with incorrect directions) and filtering the shadows of the line segments. It should be emphasized that after removing the line segments with incorrect directions, the remaining second fitting line. To avoid the second fitting line being shaded due to the influence of light during the acquisition of the image to be detected, it is necessary to filter the shadows of the second fitting line.

[0056] Step 104: When it is determined that the relative distance between the first fitting line in the template image and the second fitting line in the image to be detected meets the threshold, and it is determined that the angle between the second fitting line and the reference line on the main board of the image to be detected meets the threshold, then it is determined that the second fitting line is qualified;

[0057] Extract the first anchor point from the template image. Since the deformation of the central position is relatively small compared to the edge during image acquisition, the first anchor point can be selected at a position on the main board near the connection line. A region can be delimited with the connection line as the center, and any point within the main board part of this region can be used as the first anchor point. Preferably, the center position of any mark within the main board part of this region is used as the first anchor point.

[0058] Extract the second anchor point from the image to be detected. First, taking the template image as a reference, use the template matching method to extract the second anchor point corresponding to the position of the first anchor point on the template image from the image to be detected, and calculate the standard distance between the first anchor point and the first fitting line and the actual distance between the second anchor point and the second fitting line.

[0059] In a scenario where the image to be detected is deformed due to the structure and thickness of the cardboard box and the error during image acquisition, by calculating the actual distance between the second anchor point and the second fitting line under the same standard of the image to be detected, and comparing it with the standard distance between the first anchor point and the first fitting line under the same standard of the template image, the relative distance between the first fitting line and the second fitting line is obtained, so as to determine whether the second fitting line is qualified. Compared with directly comparing the second fitting line of the image to be detected with the first fitting line of a standard image that has not deformed or has very little deformation in the prior art, the accuracy of the comparison is effectively improved. Especially when the deformation during image acquisition caused by a self-locking bottom cardboard box is large, the detection accuracy is better.

[0060] In one example, by selecting the starting point and the ending point on the second fitting line, comparing the distances between the starting point and the ending point and the second anchor point in the horizontal direction respectively, and selecting the larger value as the actual distance.

[0061] Determine the difference between the standard distance and the actual distance as the relative distance.

[0062] It should be emphasized that other two points on the second fitting line can also be selected, such as the first point close to the starting point and the second point close to the ending point.

[0063] In one example, extract a reference line from the image to be detected. The reference line can be the upper edge line of the main board, and calculate the angle between the second fitting line and the reference line to determine the angle between the second fitting line and the reference line on the main board.

[0064] In addition to left-right offset, there may still be other defects in the second fitting line, such as skew or height difference in lines. The height difference in lines means that from a certain reference plane, the side board is lower than the main board, and the main board is skewed relative to the side board. When the deformation of the image to be detected is large, the second fitting line extracted from the image to be detected may still be parallel to the absolute vertical direction. In this case, it is impossible to make a comparison with the absolute vertical direction or the first fitting line of the template image. Therefore, a reference line can be selected on the main board with the same deformation situation, such as the upper edge line and the folding line perpendicular to the connecting line, etc. That is, in the operation standard, any line segment on the main board that should be perpendicular to the second fitting line can be extracted as the reference line.

[0065] The following combines Figures 2 - 9 to elaborate on the above solution in detail:

[0066] Step 201, obtain a template image, extract the first fitting line 4 and the first anchor point 5 on the template image, and determine the position information of the first fitting line 4 and the position information of the first anchor point 5;

[0067] The packing box is folded from a flat plate. The flat plate includes a main board 1 and side boards integrally connected thereto. The side boards are disposed on both sides of the main board 1. When the flat plate is folded into a packing box, the main boards 1 are oppositely arranged to form two faces of the packing box body, and the side boards are folded to form the side covers of the body.

[0068] Therefore, as Figure 4 shown, the template image of the packing box at least includes a main board 1, a side board integrally connected to the main board 1 through a connecting line 2, and a first fitting line 4 at a standard position on one side that coincides with or is close to the connecting line 2. It should be understood that for the fitting board 3, the fitting position of the first fitting line 4 on the template image is within the standard range. Within this standard range, the first fitting line 4 is aligned with the connecting line 2. When the distance between the first fitting line 4 and the connecting line 2 is 0, the first fitting line 4 coincides with the connecting line 2. The standard range should be set according to the specific usage requirements of the packing box or industry standards. On the side board in the template image, a fitting board 3 can be attached to display the first fitting line 4. However, since the first fitting line 4 in the template image is within the standard range and may even coincide with the connecting line 2, therefore, on the side board in the template image, a fitting board 3 can be attached, or a fitting board 3 can not be attached, and even the first fitting line 4 can not be displayed, using the position of the connecting line 2 as the first fitting line 4. Specifically, as long as the reference function of the template image can be performed as follows, there is no specific limitation.

[0069] The first anchor point 5 can be any point on the main board 1 or the side board in the template image. However, in order to reduce the deformation error occurring during image acquisition, improve the accuracy, and at the same time facilitate the extraction of the first anchor point 5, the first anchor point 5 can be selected at a position on the main board 1 close to the connecting line 2. In addition, the first anchor point 5 can also select an existing mark on the main board 1 and determine the center position of the mark as the first anchor point 5.

[0070] Blob (Binary large object) analysis can be used to binarize the image to obtain the connected regions, and then combined with the method of image morphological processing (including basic operations of binary images, such as erosion or dilation, etc.) to extract the first fitting line 4 and the first anchor point 5 from the template image.

[0071] A coordinate system is constructed in the template image. Among them, the template image is a quadrilateral, and a coordinate system can be established with any point of the quadrilateral as the origin. For example, a coordinate system is established with the lower left corner as the origin, and the position information of the first anchor point 5 is determined as S(x0,y0), the position information of the first point of the first fitting line 4 is determined as S(x1,y1), and the position information of the second point of the first fitting line 4 is determined as S(x2,y2).

[0072] Among them, the first point of the first fitting line 4 can be the starting point of the first fitting line 4 or any point on the first fitting line 4 close to the starting point, and the second point of the first fitting line 4 can be the ending point of the first fitting line 4 or any point on the first fitting line 4 close to the ending point, as long as the first point and the second point of the first fitting line 4 can be distinguished in terms of position information.

[0073] Step 202: Obtain the image to be detected, extract the second fitting line 6 and the second anchor point 7 on the image to be detected, and determine the position information of the second fitting line 6 and the position information of the second anchor point 7.

[0074] The image to be detected is obtained from the packaging box corresponding to the template image. A fitting plate 3 is attached to the side plate of the image to be detected. It should be understood that except for the position information of the fitting plate 3, the rest of the structure of the image to be detected is the same as that of the template image.

[0075] Taking the template image as a reference, the second anchor point 7 on the image to be detected is obtained through the template matching method.

[0076] Through the FLD (Fast Line Detector), that is, the fast line detector, multiple line segments that meet the set conditions are extracted from the image to be detected. Among them, the set condition is the threshold range of the line segment length, and this threshold range can be determined according to the length of the fitting line generated by the fitting plate 3 on packaging boxes of different models. For example, if it is determined that the length of the fitting line generated by the fitting plate 3 used on such packaging boxes is 5, the length threshold can be set to be greater than 4.5 and less than 5.5. The values here are only for example to illustrate, and the specific length or set conditions should be adjusted according to the actual situation and are not specifically limited here.

[0077] In an example, preprocessing is performed on the detected multiple line segments. The preprocessing includes removing interference information, such as removing horizontal line segments and only retaining vertical line segments. Since most of the fitting lines of packaging boxes are vertical line segments, after screening by the length threshold and removing horizontal line segments, the remaining vertical line segments are the actual fitting lines. In order to distinguish from the first fitting line 4 within the standard range, the second fitting line 6 remaining after preprocessing is here. However, it should be emphasized that only an example in this application scenario is provided here, and the specific way of removing interference information should be flexibly set according to the actual application scenario and is not specifically limited here.

[0078] The preprocessing also includes filtering the shadow of the second fitting line 6. For example, in the current application scenario, such as Figure 5As shown, the light source projects from left to right. Since the bonding plate 3 has a certain thickness, a shadow will be generated on the right side of the second bonding line 6. When obtaining the image to be detected, this shadow will be displayed on the image to be detected. Therefore, it is necessary to filter this shadow in order to obtain a more accurate second bonding line 6. Only an example in this application scenario is provided here. The specific orientation of the shadow relative to the second bonding line 6 should be flexibly set according to the actual application scenario and will not be specifically limited here.

[0079] After adjusting the image to be detected to be the same size as the template image and aligning them, a coordinate system is created on the image to be detected. The setting of the origin of this coordinate system needs to be the same as that of the template image. For example, a coordinate system is established with the lower left corner of the packaging box area in the image to be detected as the origin. Since the image to be detected is adjusted based on the template image, the image to be detected and the template image can be regarded as using the same coordinate system and having determined the same origin.

[0080] It should be emphasized that the template image can be a standard image in proportion to the corresponding packaging box, or it can be an image collected by a camera. For example, in order to improve the accuracy of subsequent detection, the template image and the image to be detected can be collected under the same standard, obtain packaging boxes of the same specification size, flatten the packaging boxes to the same state, take or scan them with the main board 1 as the image center at the same angle, and operate on the image to be detected with the template image as the reference benchmark. For example, align the obtained template image and the image to be detected with the horizontal side where the main board 1 is perpendicular to the connecting line 2 as the benchmark. Even if there are still deformations caused by the flattened state of the packaging box or due to shooting characteristics, the template image and the image to be detected are in the same acquisition dimension, and the interference to the acquisition and calculation of the same position information is relatively low.

[0081] Determine the position information of the second anchor point 7 as C(x0, y0), determine the position information of the first point of the second bonding line 6 as C(x1, y1), and determine the position information of the second point of the second bonding line 6 as C(x2, y2).

[0082] Among them, the first point of the second bonding line 6 can be the starting point of the second bonding line 6, or any point on the second bonding line 6 close to the starting point. The second point of the second bonding line 6 can be the end point of the second bonding line 6, or any point on the second bonding line 6 close to the end point, as long as the first point and the second point of the second bonding line 6 can be distinguished in terms of position information.

[0083] Step 203, calculate the standard distance between the first bonding line 4 and the first anchor point 5 in the template image, calculate the actual distance between the second bonding line 6 and the second anchor point 7 in the image to be detected, and judge whether the second bonding line 6 meets the detection requirements according to the standard distance and the actual distance;

[0084] When calculating the standard distance between the first fitting line 4 and the first anchor point 5 in the template image, since the first fitting line 4 is within the standard range and is aligned with the connection line 2, the horizontal distance between the first fitting line 4 and the first anchor point 5 can be calculated as the standard distance. A point can be arbitrarily selected on the first fitting line 4, and the distance between the horizontal coordinate of this point and the horizontal coordinate of the first anchor point 5 is calculated as the standard distance. Usually, the horizontal axis of the coordinate system is the horizontal coordinate axis, so the horizontal coordinate is the abscissa.

[0085] For example, the first point or the second point of the first fitting line 4 determined in step 201 can be used to calculate the standard distance between the first fitting line 4 and the first anchor point 5 in the template image according to the following formula:

[0086] Ls = abs(S(x1) - S(x0)) or abs(S(x2) - S(x0))

[0087] Ls is the standard distance, S(x1) is the horizontal coordinate of the first point of the first fitting line 4, S(x2) is the horizontal coordinate of the second point of the first fitting line 4, S(x0) is the horizontal coordinate of the first anchor point 5, and abs is to take the absolute value.

[0088] When calculating the actual distance between the second fitting line 6 and the second anchor point 7 in the image to be detected, according to the first point or the second point of the second fitting line 6 determined in step 202, the actual distance between the second fitting line 6 and the second anchor point 7 in the template image is calculated according to the following formula:

[0089] Lc = abs(min(C(x1), C(x2)) - C(x0))

[0090] Lc is the actual distance, C(x1) is the horizontal coordinate of the first point of the second fitting line 6, C(x2) is the horizontal coordinate of the second point of the second fitting line 6, C(x0) is the horizontal coordinate of the second anchor point 7, min is to take the minimum value, and abs is to take the absolute value.

[0091] According to the actual application situation, an offset threshold for fault tolerance is set, and then the difference between the standard distance and the actual distance is calculated. The relationship between the difference and the offset threshold is judged. If the difference is greater than the offset threshold, it is considered that the second fitting line 6 may be shifted to the right, shifted to the left, or skewed, as shown in Figure 6 、 Figure 7 and Figure 8 shown, which does not meet the detection requirements; if the difference is less than the offset threshold, it is considered that the second fitting line 6 meets the detection requirements, that is, it is within the standard range.

[0092] However, even if the judgment is made based on the relationship between the difference value and the offset threshold, there is still a possibility that the second fitting line 6 does not meet the detection requirements. For example, the first point of the second fitting line 6 exactly falls on the connection line 2, and the second point is closer to the second anchor point 7 relative to the first point. Through the above calculations, a conclusion that the second fitting line 6 meets the detection requirements will still be drawn, resulting in the problem of missed detection. Therefore, further judgment is needed.

[0093] Step 204: Extract the reference line on the image to be detected and determine the position information of the reference line.

[0094] Among them, in the template image, the reference line is set perpendicular to the connection line 2. Since the fitting line within the marked range should be aligned with the connection line 2, it should also be in a perpendicular state to the reference line.

[0095] The reference line can be the upper edge line 8 of the main board 1, the folding line on the main board 1 that is perpendicular to the connection line 2, or the lower edge line of the main board 1. That is, in the operation standard, any line segment that satisfies the perpendicular setting of the connection line 2 and the fitting line is acceptable.

[0096] In order to more conveniently extract the reference line from the image to be detected, the upper edge line 8 of the main board 1 that is more clearly displayed on the image to be detected can be determined as the reference line. The position information of the first point of the upper edge line 8 of the main board 1 is obtained as E(x1, y1), and the position information of the second point is obtained as E(x2, y2).

[0097] Step 205: Calculate the included angle between the second fitting line 6 and the reference line, and determine whether the second fitting line 6 meets the detection requirements.

[0098] Construct the general equation of the second fitting line 6 as a1*x + b1*y + c1 = 0, and construct the general equation of the reference line as a2*x + b2*y + c2 = 0. Since the first point and the second point of the second fitting line 6 have been determined, and the first point and the second point of the reference line have been determined, according to the principle that two points determine a line, the included angle α between the second fitting line 6 and the reference line can be calculated according to the following formula:

[0099]

[0100] E(x1) is the horizontal coordinate of the first point of the reference line, E(x2) is the horizontal coordinate of the second point of the reference line, E(y1) is the vertical coordinate of the first point of the reference line, E(y2) is the vertical coordinate of the second point of the reference line, C(x1) is the horizontal coordinate of the first point of the second fitting line 6, C(x2) is the horizontal coordinate of the second point of the second fitting line 6, C(y1) is the vertical coordinate of the first point of the second fitting line 6, and C(y2) is the vertical coordinate of the second point of the second fitting line 6.

[0101] Set the included angle threshold β according to the actual situation. When abs(α - 90) is greater than β, it is determined that the second fitting line 6 does not meet the detection requirements. As Figure 9 shown, there are defects such as skewed pasting or high and low lines.

[0102] An embodiment of the present disclosure also provides a fitting line detection device. As Figure 10 shown, the device includes:

[0103] An acquisition module 10 for acquiring a template image of a packaging box, where the template image includes at least one main board 1 of the packaging box and at least one side board integrally connected to the main board 1 through a connecting line 2;

[0104] The acquisition module 10 is further configured to collect a to-be-detected image of the packaging box corresponding to the template image;

[0105] An extraction module 20 for extracting a first fitting line 4 from the template image and extracting a second fitting line 6 from the to-be-detected image. The first fitting line 4 represents the standard position of the side of the fitting board 3 attached to the side board close to the connecting line 2, and the second fitting line 6 represents the actual position of the side of the fitting board 3 attached to the side board close to the connecting line 2;

[0106] A processing module 30 for determining that when the relative distance between the first fitting line 4 in the template image and the second fitting line 6 in the to-be-detected image meets a threshold, and determining that the angle between the second fitting line 6 and a reference line on the main board 1 of the to-be-detected image meets a threshold, it is determined that the second fitting line 6 is qualified.

[0107] The present invention also provides a computer-readable storage medium storing a computer program for executing the fitting line detection method of the packaging box according to the present invention.

[0108] On the other hand, the present invention provides an electronic device, including:

[0109] A processor;

[0110] A memory for storing executable instructions of the processor;

[0111] The processor is configured to read the executable instructions from the memory and execute the instructions to implement the fitting line detection method of the packaging box according to the present invention.

[0112] In addition to the above methods and devices, an embodiment of the present application may also be a computer program product, which includes computer program instructions that, when run by a processor, cause the processor to execute the steps in the methods according to various embodiments of the present application described in the above "Exemplary Method" section of this specification.

[0113] The computer program product may be written in any combination of one or more programming languages for programming code to perform the operations of the embodiments of the present application. The programming languages include object-oriented programming languages such as Java, C++, etc., and also include conventional procedural programming languages such as the "C" language or similar programming languages. The programming code may be executed entirely on the user computing device, partially on the user device, executed as a stand-alone software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server.

[0114] In addition, an embodiment of the present application may also be a computer-readable storage medium having computer program instructions stored thereon, and when the computer program instructions are run by a processor, the processor is caused to execute the steps in the methods according to various embodiments of the present application described in the above "Exemplary Method" section of this specification.

[0115] The computer-readable storage medium may employ any combination of one or more readable media. The readable media may be a readable signal medium or a readable storage medium. The readable storage medium may, for example, include but is not limited to an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the above. More specific examples (non-exhaustive list) of the readable storage medium include: an electrical connection having one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.

[0116] The basic principles of the present application have been described above in conjunction with specific embodiments. However, it should be noted that the advantages, advantages, effects, etc. mentioned in the present application are only examples and not limitations, and it cannot be considered that these advantages, advantages, effects, etc. are essential for each embodiment of the present application. In addition, the above-disclosed specific details are only for the purposes of illustration and easy understanding, and not for limitation. The above details do not limit the present application to necessarily adopt the above specific details for implementation.

[0117] The block diagrams of the devices, apparatuses, equipment, and systems involved in the present application are only illustrative examples and are not intended to require or imply that they must be connected, arranged, and configured in the manner shown in the block diagrams. As those skilled in the art will recognize, these devices, apparatuses, equipment, and systems can be connected, arranged, and configured in any manner. Words such as "including", "comprising", "having", etc. are open-ended terms that mean "including but not limited to" and can be used interchangeably with each other. The word "or" and "and" used herein refer to the phrase "and / or" and can be used interchangeably with it, unless the context clearly indicates otherwise. The word "such as" used herein refers to the phrase "such as but not limited to" and can be used interchangeably with it.

[0118] It should also be noted that in the devices, equipment, and methods of the present application, each component or each step can be decomposed and / or recombined. These decompositions and / or recombinations should be regarded as equivalent solutions of the present application.

[0119] The above description of the disclosed aspects is provided to enable any person skilled in the art to make or use the present application. Various modifications to these aspects will be readily apparent to those skilled in the art, and the general principles defined herein can be applied to other aspects without departing from the scope of the present application. Therefore, the present application is not intended to be limited to the aspects shown herein, but rather to the broadest scope consistent with the principles and novel features disclosed herein.

[0120] The above description has been given for purposes of illustration and description. In addition, this description is not intended to limit the embodiments of the present application to the forms disclosed herein. Although multiple example aspects and embodiments have been discussed above, those skilled in the art will recognize certain variations, modifications, changes, additions, and sub-combinations thereof.

Claims

1. A method for detecting the fitting line of a packaging box, characterized in that, including: obtaining a template image of a packing box, the template image including at least one main board of the packing box and at least one side board integrally connected to the main board through a connecting line; collecting a to-be-detected image of the packing box corresponding to the template image; extracting a first fitting line from the template image and extracting a second fitting line from the to-be-detected image, the first fitting line representing a standard position of one side of a fitting board attached to the side board close to the connecting line, and the second fitting line representing an actual position of one side of the fitting board attached to the side board close to the connecting line; when it is determined that the relative distance between the first fitting line in the template image and the second fitting line in the to-be-detected image meets a threshold value, and it is determined that the angle between the second fitting line and a reference line on the main board of the to-be-detected image meets a threshold value, then it is determined that the second fitting line is qualified; the determining the relative distance between the first fitting line in the template image and the second fitting line in the to-be-detected image includes: extracting a first anchor point from the template image; taking the template image as a reference, extracting a second anchor point corresponding to the position of the first anchor point on the template image from the to-be-detected image; calculating a standard distance between the first anchor point and the first fitting line and calculating an actual distance between the second anchor point and the second fitting line; determining the difference between the standard distance and the actual distance as the relative distance.

2. The method for detecting the fitting line of a packaging box according to claim 1, characterized in that, the calculating the actual distance between the second anchor point and the second fitting line includes: selecting a starting point and an ending point on the second fitting line, comparing the distances between the starting point and the ending point and the second anchor point in the horizontal direction respectively, and selecting the larger value as the actual distance.

3. The method for detecting the fitting line of a packaging box according to claim 1, characterized in that, the determining the angle between the second fitting line and the reference line on the main board includes: extracting a reference line from the to-be-detected image, the reference line being the upper edge line of the main board, and calculating the angle between the second fitting line and the reference line to determine the angle between the second fitting line and the reference line on the main board.

4. The method for detecting the fitting line of a packaging box according to claim 1, characterized in that, the extracting the first anchor point from the template image includes: defining a region centered on the connecting line, and taking the center position of any mark in the main board part of the region as the first anchor point.

5. The method for detecting the fitting line of a packaging box according to claim 1, characterized in that, the extracting the second fitting line from the to-be-detected image includes: extracting multiple line segments with lengths meeting a threshold value from the to-be-detected image, and obtaining the second fitting line after preprocessing the multiple line segments, the preprocessing including removing line segments with wrong directions and filtering the shadows of the line segments.

6. A device for detecting the fitting line of a packaging box, characterized in that, including: an obtaining module, configured to obtain a template image of a packing box, the template image including at least one main board of the packing box and at least one side board integrally connected to the main board through a connecting line; and further configured to collect a to-be-detected image of the packing box corresponding to the template image; an extracting module, configured to extract a first fitting line from the template image and extract a second fitting line from the to-be-detected image, the first fitting line representing a standard position of one side of a fitting board attached to the side board close to the connecting line, and the second fitting line representing an actual position of one side of the fitting board attached to the side board close to the connecting line; A processing module, configured to determine that the second fitting line is qualified when the relative distance between the first fitting line in the template image and the second fitting line in the image to be detected meets a threshold, and when it is determined that the angle between the second fitting line and a reference line on the main board of the image to be detected meets the threshold; The processing module is further configured to extract a first anchor point from the template image; Based on the template image, a second anchor point corresponding to the position of the first anchor point on the template image is extracted from the image to be detected; Calculate the standard distance between the first anchor point and the first fitting line and calculate the actual distance between the second anchor point and the second fitting line; Determine that the difference between the standard distance and the actual distance is the relative distance.

7. An electronic device, characterized in that, Comprising: A memory and a processor, the memory stores a computer program executable by the processor, and when the processor executes the computer program, the method for detecting the fitting line of the packing box according to any one of claims 1-5 above is implemented.

8. A medium, characterized in that, A computer program is stored on the medium, and when the computer program is read and executed, the method for detecting the fitting line of the packing box according to any one of claims 1-5 above is implemented.

Citation Information

Patent Citations

  • Object detection method and device

    CN112686848A