Product inspection method and apparatus

By adjusting the image position using edge feature points, the problems of missed detections and complex template management caused by product variety switching in product inspection are solved, template reuse is realized, and inspection efficiency and accuracy are improved.

CN116579978BActive Publication Date: 2026-02-17BEIJING LUSTER LIGHTTECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310269427.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-03-15
Publication Date
2026-02-17
Estimated Expiration
2043-03-15

AI Technical Summary

Technical Problem

During product testing, when switching product types, the image to be tested may shift due to mechanical positioning. Existing methods require re-determining the location of the testing area, resulting in missed detections, complex template management, and low efficiency.

Method used

By extracting edge features from the template image and the target image, edge feature points are obtained. Based on these feature points, the image position is adjusted so that the product area overlaps with the detection area, thereby enabling template reuse and reducing the need to replace the template.

Benefits of technology

It improves the efficiency and accuracy of product testing, reduces workload and the burden of storing templates, and avoids missed detections.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116579978B_ABST
    Figure CN116579978B_ABST
Patent Text Reader

Abstract

The application discloses a product detection method and device, and belongs to the technical field of industrial detection. The product detection method comprises the following steps: image edge feature extraction is respectively performed on a template image and a first image corresponding to an obtained target product, a first edge feature point corresponding to the template image and a second edge feature point corresponding to the first image are obtained; the first image is corrected based on the first edge feature point and the second edge feature point, a second image is obtained, and all regions of a product region in the second image overlap with at least part of a first detection region; and the product region in the second image is detected based on the first detection region. The product detection method can normally detect the product region in the case of first image position change, realizes reuse of the template, reduces the workload and the burden of storing the template, and further improves the product detection efficiency, meanwhile, the product detection precision is improved without causing missed detection.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application belongs to the field of industrial testing technology, and in particular relates to a product testing method and apparatus. Background Technology

[0002] When using templates for industrial product inspection, switching product types can cause image shifts due to mechanical positioning. Common product inspection methods require re-establishing the positions of each inspection area to recreate the template. However, this re-modeling process is prone to errors, leading to missed detections. Furthermore, after multiple template creations, template use and management become complex, increasing workload and storage burden, resulting in low product inspection efficiency. Summary of the Invention

[0003] This application aims to address at least one of the technical problems existing in the prior art. To this end, this application proposes a product inspection method and apparatus. In actual inspection, when the product type changes, only the image position needs to be adjusted accordingly, without replacing the template. This achieves template reuse, reduces workload and the burden of storing templates, thereby improving the efficiency of product inspection and reducing the likelihood of missed detections, thus improving the accuracy of product inspection.

[0004] Firstly, this application provides a product testing method, the method comprising:

[0005] Image edge features of at least a portion of the template image and the first image corresponding to the acquired target product are extracted respectively to obtain a first edge feature point corresponding to the template image and a second edge feature point corresponding to the first image. The template image includes a first detection region; the first image includes a product region corresponding to the target product.

[0006] The first image is corrected based on the first edge feature point and the second edge feature point to obtain a second image, wherein the entire area of ​​the product area in the second image overlaps with at least a portion of the area of ​​the first detection area.

[0007] Based on the first detection area, the product area in the second image is detected.

[0008] According to the product detection method provided in the embodiments of this application, the position of the first image is adjusted so that the entire area of ​​the product region overlaps with at least a portion of the first detection region by analyzing the differences between some edge features in the extracted template image and the first image. Detection is then performed based on the overlapped image. This allows for template reuse when the product type changes during actual detection, reducing workload and the burden of storing templates, thereby improving the efficiency of product detection. At the same time, it reduces the likelihood of missed detections and improves the accuracy of product detection.

[0009] One embodiment of the product detection method of this application, wherein the step of correcting the first image based on the first edge feature points and the second edge feature points to obtain a second image includes:

[0010] Based on the first edge feature point and the second edge feature point, obtain the correction parameters between the first image and the template image;

[0011] Based on the correction parameters, the first image is corrected to obtain the second image.

[0012] One embodiment of the product detection method of this application includes obtaining correction parameters between the first image and the template image based on the first edge feature points and the second edge feature points, comprising:

[0013] The first edge tilt of the template image is determined based on the first edge feature points; the second edge tilt of the first image is determined based on the second edge feature points;

[0014] Based on the first edge feature point and the second edge feature point, determine the horizontal and / or vertical offset of the image edge corresponding to the at least part of the region between the first image and the template image;

[0015] The correction parameters are determined based on the first edge tilt, the second edge tilt, and the lateral and / or longitudinal offset.

[0016] One embodiment of the product detection method of this application, when the image edges of at least a portion of the template image are parallel to the image edges of at least a portion of the first image, includes obtaining correction parameters between the first image and the template image based on the first edge feature points and the second edge feature points, comprising:

[0017] Obtain the first average pixel position of the first edge feature point and the second average pixel position of the second edge feature point;

[0018] The correction parameter is obtained based on the deviation between the first average pixel position and the second average pixel position.

[0019] One embodiment of the product detection method of this application includes extracting image edge features of at least a portion of a template image and a first image corresponding to the acquired target product, and obtaining first edge feature points corresponding to the template image and second edge feature points corresponding to the first image, comprising:

[0020] At least one of Sobel processing and thresholding is performed on the image edges of at least a portion of the template image and the first image respectively to obtain the first edge feature point corresponding to the template image and the second edge feature point corresponding to the first image.

[0021] One embodiment of the product detection method of this application includes performing at least one of Sobel processing and thresholding on the image edges of at least a portion of the template image and the first image to obtain a first edge feature point corresponding to the template image and a second edge feature point corresponding to the first image, comprising:

[0022] Sobel processing is performed on the image edges of at least a portion of the regions of the template image and the first image respectively to obtain a first edge image corresponding to the template image and a second edge image corresponding to the first image;

[0023] Thresholding is performed on the first edge image and the second edge image respectively to obtain multiple third edge feature points corresponding to the template image and multiple fourth edge feature points corresponding to the first image;

[0024] Taking the target third edge feature point among the plurality of third edge feature points as the center, replace the target third edge feature point with the pixel point corresponding to the maximum gray value within the target range to obtain the first edge feature point;

[0025] Centered on the target fourth edge feature point among the plurality of fourth edge feature points, the target fourth edge feature point is replaced with the pixel point corresponding to the maximum gray value within the target range to obtain the second edge feature point.

[0026] Secondly, this application provides a product testing device, which includes:

[0027] The first processing module is configured to extract image edge features from at least a portion of the template image and the first image corresponding to the acquired target product, respectively, to obtain a first edge feature point corresponding to the template image and a second edge feature point corresponding to the first image, wherein the template image includes a first detection region; and the first image includes a product region corresponding to the target product.

[0028] The second processing module is used to correct the first image based on the first edge feature point and the second edge feature point, and obtain a second image, wherein the entire area of ​​the product area in the second image overlaps with at least a portion of the area of ​​the first detection area.

[0029] The third processing module is used to detect the product area in the second image based on the first detection area.

[0030] According to the product inspection apparatus of this application, by analyzing the differences between some edge features in the extracted template image and the first image, the position of the first image is adjusted so that the entire area of ​​the product region overlaps with at least a portion of the first detection region. Detection is then performed based on the overlapped image. This allows for template reuse during actual inspection when the product type changes, reducing workload and the burden of storing templates, thereby improving the efficiency of product inspection. Simultaneously, it reduces the likelihood of missed detections and improves the accuracy of product inspection.

[0031] Thirdly, this application provides an electronic device including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the product testing method as described in the first aspect above.

[0032] Fourthly, this application provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the product testing method as described in the first aspect above.

[0033] Fifthly, this application provides a computer program product, including a computer program that, when executed by a processor, implements the product detection method as described in the first aspect above.

[0034] The above-described one or more technical solutions in the embodiments of this application have at least one of the following technical effects:

[0035] By analyzing the differences between the extracted template image and some edge features in the first image, the position of the first image is adjusted so that the entire product area overlaps with at least a portion of the first detection area. Detection is then performed based on the overlapped image. This allows for template reuse during actual detection when the product type changes, reducing workload and the burden of storing templates, thereby improving the efficiency of product detection. It also reduces the likelihood of missed detections and improves the accuracy of product detection.

[0036] Furthermore, by obtaining correction parameters between the first image and the template image based on the first and second edge feature points, and then correcting the first image based on the correction parameters, a second image is obtained. In practical applications, when switching product types, it is not necessary to create a new template image. When the positional changes between each image to be tested are small, correction can be directly performed based on the correction parameters between the first image and the template image. When the positional changes between each image to be tested are large, the correction parameters between each image to be tested and the template image can be calculated separately to correct the position of each image to be tested. This achieves template reuse, reduces workload, and improves the efficiency of product testing.

[0037] Furthermore, by obtaining the first average pixel position of the first edge feature point and the second average pixel position of the second edge feature point, and then obtaining the correction parameter based on the deviation between the first average pixel position and the second average pixel position, the correction parameter can be directly obtained based on the first average pixel position and the second average pixel position when the image edges of at least a part of the template image are parallel to the image edges of at least a part of the first image. The calculation process is simpler, the workload is reduced, and the efficiency of product inspection is improved.

[0038] Furthermore, by performing at least one of Sobel processing and thresholding on the image edges of at least a portion of the template image and the first image, the first edge feature points corresponding to the template image and the second edge feature points corresponding to the first image are obtained. This allows for accurate acquisition of the image edge information of the template image and the first image, enabling subsequent detection of the first image based on the edge information. This reduces the amount of data involved in the calculation, greatly saves processing time, and thus improves the efficiency and accuracy of product detection.

[0039] Additional aspects and advantages of this application will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of this application. Attached Figure Description

[0040] The above and / or additional aspects and advantages of this application will become apparent and readily understood from the description of the embodiments taken in conjunction with the following drawings, in which:

[0041] Figure 1 This is a schematic flowchart of the product testing method provided in the embodiments of this application;

[0042] Figure 2 This is one of the schematic diagrams illustrating the principle of the product testing method provided in the embodiments of this application;

[0043] Figure 3 This is a second schematic diagram illustrating the principle of the product testing method provided in the embodiments of this application;

[0044] Figure 4 This is the third schematic diagram illustrating the principle of the product testing method provided in the embodiments of this application;

[0045] Figure 5 This is the fourth schematic diagram illustrating the principle of the product testing method provided in the embodiments of this application;

[0046] Figure 6 This is a schematic diagram of the product testing device provided in the embodiments of this application;

[0047] Figure 7 This is a schematic diagram of the structure of the electronic device provided in the embodiments of this application. Detailed Implementation

[0048] The technical solutions of the embodiments of this application will be clearly described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application are within the scope of protection of this application.

[0049] The terms "first," "second," etc., used in the specification and claims of this application are used to distinguish similar objects and not to describe a specific order or sequence. It should be understood that such use of data can be interchanged where appropriate so that embodiments of this application can be implemented in orders other than those illustrated or described herein, and the objects distinguished by "first," "second," etc., are generally of the same class and the number of objects is not limited; for example, a first object can be one or more. Furthermore, in the specification and claims, "and / or" indicates at least one of the connected objects, and the character " / " generally indicates that the preceding and following objects are in an "or" relationship.

[0050] The following is combined with Figures 1 to 5 This application describes a product testing method according to an embodiment.

[0051] It should be noted that the entity executing the product testing method can be a server, a product testing device, or a user's terminal, including but not limited to mobile terminals and non-mobile terminals.

[0052] For example, mobile terminals include, but are not limited to, mobile phones, PDA smart terminals, tablets, and in-vehicle smart terminals; non-mobile terminals include, but are not limited to, PCs.

[0053] like Figure 1 As shown, the product testing method includes steps 110, 120 and 130.

[0054] Step 110: Extract image edge features from at least a portion of the template image and the first image corresponding to the target product, respectively, to obtain the first edge feature points corresponding to the template image and the second edge feature points corresponding to the first image. The template image includes a first detection region; the first image includes the product region corresponding to the target product.

[0055] In this step, the template image is a pre-trained image, such as... Figure 2 As shown.

[0056] Some areas are custom areas, for example, they can be ROI areas, such as... Figure 2 The rectangles corresponding to the ROIs are shown in the diagram. During execution, the ROI regions can be obtained using Python, MATLAB, etc., and this application does not impose any limitations on this.

[0057] Part of the region may be other feature regions, such as corner points in the image, or rectangles and circles with obvious features;

[0058] It is understandable that the template image and certain regions in the first image correspond to each other.

[0059] The first detection region is a pre-defined detection region in the template image, such as... Figure 2 The area shown is indicated by the dashed rectangle.

[0060] The target product is the product to be tested.

[0061] The first image corresponding to the target product is an image acquired by an image sensor, such as... Figure 3 As shown.

[0062] In related technologies, during the acquisition of the first image, when switching the product type to be tested, mechanical positioning may cause an offset between the first image and the template image, making it often impossible to use the same template image for product inspection.

[0063] The first image may include: the area corresponding to the product itself and the background image area.

[0064] The product area refers to the area corresponding to the product itself, such as... Figure 3 The elliptical region is shown.

[0065] The first edge feature point is used to characterize the image edge information of the template image.

[0066] The second edge feature point is used to characterize the image edge information of the first image.

[0067] Image edge feature extraction can be performed using MATLAB or pre-trained neural network models, or in any feasible manner, which is not limited in this application.

[0068] In some embodiments, step 110 may include:

[0069] At least one of Sobel processing and thresholding is performed on the image edges of at least a portion of the template image and the first image respectively to obtain the first edge feature points corresponding to the template image and the second edge feature points corresponding to the first image.

[0070] In this embodiment, the Sobel process is used to obtain the edge images of the template image and the first image, respectively.

[0071] Thresholding is a process that uniformly processes pixels that are greater than or less than a user-defined target threshold.

[0072] In actual execution, Sobel processing can be performed on the image edges of at least a portion of the template image and the first image to obtain the edge images of the template image and the first image respectively. Then, based on the target threshold, threshold processing is performed on the edge images of the template image and the first image respectively to obtain the first edge feature point corresponding to the template image and the second edge feature point corresponding to the first image.

[0073] According to the product detection method provided in the embodiments of this application, by performing at least one of Sobel processing and threshold processing on the image edges of at least a portion of the template image and the first image, the first edge feature points corresponding to the template image and the second edge feature points corresponding to the first image are obtained. This method can accurately obtain the image edge information of the template image and the first image, so that the first image can be detected based on the edge information in the future. This reduces the amount of data involved in the calculation, greatly saves the processing time, and thus improves the efficiency and accuracy of product detection.

[0074] In some embodiments, performing at least one of Sobel processing and thresholding on the image edges of at least a portion of the template image and the first image to obtain first edge feature points corresponding to the template image and second edge feature points corresponding to the first image may include:

[0075] Sobel processing is performed on at least a portion of the image edges of the template image and the first image respectively to obtain the first edge image corresponding to the template image and the second edge image corresponding to the first image;

[0076] Thresholding is performed on the first edge image and the second edge image respectively to obtain multiple third edge feature points corresponding to the template image and multiple fourth edge feature points corresponding to the first image;

[0077] Taking the target third edge feature point among multiple third edge feature points as the center, replace the target third edge feature point with the pixel point corresponding to the maximum gray value within the target range to obtain the first edge feature point;

[0078] Taking the target fourth edge feature point among multiple fourth edge feature points as the center, replace the target fourth edge feature point with the pixel point corresponding to the maximum gray value within the target range to obtain the second edge feature point.

[0079] In this embodiment, the first edge image is obtained by performing Sobel processing on the template image and is used to characterize the image edge information of the template image.

[0080] The second edge image is obtained by performing Sobel processing on the first image and is used to characterize the image edge information of the first image.

[0081] The multiple third edge feature points were obtained after thresholding the first edge image.

[0082] The multiple fourth edge feature points were obtained after thresholding the second edge image.

[0083] The target third edge feature point can be user-defined. For example, the target pixel can be set to 50, 60 or 70, and then the third edge feature point corresponding to the target pixel can be selected as the target third edge feature point. This application does not limit this.

[0084] The fourth edge feature point of the target can also be based on user-defined features, and the customization method is the same as that of the third edge feature point of the target, which will not be elaborated here.

[0085] The pixels within the target range can be obtained by moving the target's third edge feature point and / or fourth edge point to the left and right by a number of pixels from the target's center.

[0086] The target number can be 5, 6, or 7, etc., and can be customized by the user; this application does not impose any restrictions.

[0087] The first edge feature point is the pixel corresponding to the maximum gray value within the target range among multiple third edge feature points.

[0088] The second edge feature point is the pixel corresponding to the maximum gray value within the target range among multiple fourth edge feature points.

[0089] In actual execution, the ROI can be used to select the regions with obvious image edges in the template image and the first image, or other features in the template image and the first image can be used as positioning information, such as corner points in the template image and the first image, or rectangles and circles with obvious features, etc., which can be based on user customization and are not limited in this application. In this embodiment, the ROI can be used to select the regions with obvious image edges in the template image and the first image.

[0090] The Sobel processing is applied to the image edges of the ROI region to obtain the first edge image corresponding to the template image and the second edge image corresponding to the first image;

[0091] Then, thresholding is performed on the first edge image and the second edge image respectively to obtain multiple third edge feature points corresponding to the template image and multiple fourth edge feature points corresponding to the first image;

[0092] The following example uses the acquisition method of the first edge feature point. The target pixel count can be set to 50, the target quantity to 5, and the edge feature point with a pixel count of 50 can be selected as the target third edge feature point. Figure 5 The 7th pixel in the target area is used as the center. Then, the target area is moved 5 pixels to the left and 5 pixels to the right. The pixel corresponding to the maximum gray value within the target area is used to replace the third edge feature point of the target, thus obtaining the first edge feature point. Figure 5 The 9th pixel in the image.

[0093] The method for obtaining the second edge feature point is the same as that for the first edge feature point, and will not be repeated here.

[0094] According to the product detection method provided in the embodiments of this application, by performing Sobel processing and thresholding on the image edges of at least a portion of the template image and the first image to obtain multiple edge feature points, and then using the pixel point corresponding to the maximum gray value within the target range as the first edge feature point and / or the second edge feature point, more realistic image edge information corresponding to the template image and the first image can be obtained, so that the first image can be detected based on the edge information in the future. This reduces the image processing area, saves processing time, and thus improves the efficiency of product detection.

[0095] Step 120: Correct the first image based on the first edge feature point and the second edge feature point, and obtain the second image, wherein the entire area of ​​the product region in the second image overlaps with at least a portion of the area of ​​the first detection region.

[0096] In this step, the second image is the image obtained after correcting the first image.

[0097] The second image includes the product area corresponding to the target product, and the entire product area in the second image overlaps with at least a portion of the first detection area.

[0098] like Figure 4 As shown, the entire product area in the second image overlaps with at least a portion of the first detection area.

[0099] In actual execution, the first image can be corrected based on the location information of the effective area of ​​the template image and the effective area in the first image, or the first image can be corrected based on the correction parameters between the first image and the template image. This can be based on user-defined parameters, and this application does not limit it.

[0100] For example, in some embodiments, step 120 may include:

[0101] Based on the first edge feature point and the second edge feature point, obtain the correction parameters between the first image and the template image;

[0102] Based on the correction parameters, the first image is corrected to obtain the second image.

[0103] In this embodiment, the first edge feature point is used to characterize the image edge information of the template image.

[0104] The second edge feature point is used to characterize the image edge information of the first image.

[0105] The correction parameters are used to correct the first image so that the entire area of ​​the product region in the corrected first image overlaps with at least a portion of the first detection region.

[0106] The correction parameters are determined based on the first edge feature point and the second edge feature point.

[0107] The second image is obtained by correcting the first image, and the entire product area in the second image overlaps with at least a portion of the first detection area.

[0108] According to the product inspection method provided in this application embodiment, correction parameters between a first image and a template image are obtained based on a first edge feature point and a second edge feature point. Then, the first image is corrected based on the correction parameters to obtain a second image. In practical applications, when switching product types, it is not necessary to create a new template image. When the positional changes between each image to be inspected are small, correction can be directly performed based on the correction parameters between the first image and the template image. When the positional changes between each image to be inspected are large, the correction parameters between each image to be inspected and the template image can be calculated separately to correct the position of each image to be inspected. This achieves template reuse, reduces workload, and thus improves the efficiency of product inspection.

[0109] In some embodiments, obtaining correction parameters between the first image and the template image based on the first edge feature points and the second edge feature points may include:

[0110] The first edge tilt of the template image is determined based on the first edge feature points; the second edge tilt of the first image is determined based on the second edge feature points;

[0111] Based on the first edge feature point and the second edge feature point, determine the horizontal and / or vertical offsets corresponding to the image edges of at least a portion of the region between the first image and the template image;

[0112] The correction parameters are determined based on the first edge tilt, the second edge tilt, and the lateral and / or longitudinal offset.

[0113] In this embodiment, the first edge tilt is the tilt of the image edge of the template image, which can be determined based on the first edge feature points.

[0114] The second edge tilt is the tilt of the image edge of the first image, and can be determined based on the second edge feature points.

[0115] The offset corresponding to the image edges of at least a portion of the region between the first image and the template image can be a horizontal offset or a vertical offset.

[0116] In actual execution, the first edge feature point may include the first starting point P. st =(x st ,y st ) and the first termination point P ed =(x ed ,y ed ).

[0117] It can be based on the first starting point P st =(x st ,y st ) and the first termination point Ped =(x ed ,y ed The first edge tilt θ1 of the template image can be determined by the following formula:

[0118]

[0119] Where θ1 is the first edge inclination, y ed Let y be the ordinate of the first endpoint. st Let x be the ordinate of the first starting point. ed Let x be the x-coordinate of the first endpoint. st is the x-coordinate of the first starting point.

[0120] The second edge feature point may include the second starting point P. Mst =(x Mst ,y Mst ) and the second termination point P Med =(x Med ,y Med ).

[0121] It can be based on the second starting point P Mst =(x Mst ,y Mst ) and the second termination point P Med =(x Med ,y Med The second edge tilt θ2 of the first image can be determined by the following formula:

[0122]

[0123] Where θ2 is the second edge inclination, y Med Let y be the ordinate of the second endpoint. Mst Let x be the ordinate of the second starting point. Med Let x be the x-coordinate of the second endpoint. Mst is the x-coordinate of the second starting point.

[0124] Based on the first and second edge feature points, the horizontal and / or vertical offset θ corresponding to the image edges of at least a portion of the region between the first image and the template image can be determined by the following formula:

[0125]

[0126] Where θ is the horizontal and / or vertical offset, θ2 is the second edge tilt, and y Med Let y be the ordinate of the second endpoint. Mst Let x be the ordinate of the second starting point. Med Let x be the x-coordinate of the second endpoint.Mst Let θ1 be the x-coordinate of the second starting point and y be the slope of the first edge. ed Let y be the ordinate of the first endpoint. st Let x be the ordinate of the first starting point. ed Let x be the x-coordinate of the first endpoint. st is the x-coordinate of the first starting point.

[0127] Then, based on the first edge tilt, the second edge tilt, and the lateral and / or longitudinal offset, the correction parameter M is determined.

[0128] The correction parameter M can be determined based on the following formula:

[0129]

[0130] Where M is the correction parameter, θ is the horizontal and / or vertical offset, and y Med Let y be the ordinate of the second endpoint. Mst Let x be the ordinate of the second starting point. Med Let x be the x-coordinate of the second endpoint. Mst Let y be the x-coordinate of the second starting point. ed Let y be the ordinate of the first endpoint. st Let x be the ordinate of the first starting point. ed Let x be the x-coordinate of the first endpoint. st is the x-coordinate of the first starting point.

[0131] During the research and development process, the inventors discovered that some related technologies use the offset obtained by locating the center of the marker point in the image under test and the standard position to detect the error of the image under test. However, this method requires locating the marker point on the image and has limited applicability.

[0132] In this application, the image edges can be used directly as localization features to calculate the correction parameters between the first image and the template image. This does not require the images to have marker points, making it applicable to a wider range of scenarios.

[0133] According to the product detection method provided in the embodiments of this application, the first edge tilt of the template image, the second edge tilt of the first image, and the lateral and / or longitudinal offset corresponding to the image edges of at least a portion of the region between the first image and the template image are determined based on the first edge feature points and the second edge feature points. Then, correction parameters are determined based on the first edge tilt, the second edge tilt, and the offset. The edges of the image can be used as positioning features for positioning, and then the correction parameters between the first image and the template image can be calculated. It does not require the presence of marker points on the image, has a wide range of applicable scenarios, and can obtain more comprehensive pose information between the template image and the first image, thus improving the final detection accuracy and effect.

[0134] In some embodiments, when the image edges of at least a portion of the template image are parallel to the image edges of at least a portion of the first image, a correction parameter between the first image and the template image is obtained based on a first edge feature point and a second edge feature point, including:

[0135] Obtain the first average pixel position of the first edge feature point and the second average pixel position of the second edge feature point;

[0136] Correction parameters are obtained based on the deviation between the first average pixel position and the second average pixel position.

[0137] In this embodiment, the first edge feature point may include multiple first feature points, which are used to characterize the edge information of the template image.

[0138] The first average pixel position is the average pixel value among multiple first feature points.

[0139] The second edge feature points may include multiple second feature points, which are used to characterize the edge information of the first image.

[0140] The second average pixel position is the average pixel value among multiple second feature points.

[0141] The deviation between the first average pixel position and the second average pixel position includes at least one of lateral deviation and vertical deviation.

[0142] The correction parameters between the first image and the template image can be determined based on the deviation between the first average pixel position and the second average pixel position.

[0143] In actual execution, the first average pixel position can be represented as P. p =(x p ,y p The second average pixel position can be represented as P. m =(x m ,y m ).

[0144] When the image edges of at least a portion of the template image are parallel to the image edges of at least a portion of the first image, the lateral deviation between the first average pixel position and the second average pixel position can be expressed by the following formula:

[0145] d V =|x m -x p |

[0146] Where, d V For lateral deviation, x mx is the x-coordinate of the second average pixel position. p is the x-coordinate of the first average pixel position.

[0147] The vertical deviation between the first average pixel position and the second average pixel position can be expressed by the following formula:

[0148] d H =|y m -y p |

[0149] Where, d H For longitudinal deviation, y m Let y be the ordinate of the second average pixel position. p The ordinate is the position of the first average pixel.

[0150] According to the product inspection method provided in the embodiments of this application, by obtaining the first average pixel position of the first edge feature point and the second average pixel position of the second edge feature point, and then obtaining the correction parameter based on the deviation between the first average pixel position and the second average pixel position, the correction parameter can be directly obtained based on the first average pixel position and the second average pixel position when the image edges of at least a part of the template image are parallel to the image edges of at least a part of the first image. The calculation process is simpler, the workload is reduced, and the efficiency of product inspection is improved.

[0151] Step 130: Based on the first detection area, detect the product area in the second image.

[0152] In this step, the first detection area is a pre-defined detection area in the template image.

[0153] The product area refers to the area of ​​the target product that needs to be tested.

[0154] The entire product area in the second image overlaps with at least a portion of the first detection area.

[0155] In actual execution, the first detection area in the template image can be directly used to detect the product area in the second image.

[0156] During the research and development process, the inventors discovered that in related technologies, when switching product types, it is necessary to redetermine the location of each detection area in order to rebuild the template. This method cannot perform normal detection during the remodeling process, which can easily lead to missed detections. Furthermore, after building the template multiple times, the use and management of the template becomes more complicated, increasing the workload and the burden of storing the template.

[0157] In this application, when switching product types, it is not necessary to create new template images. When the positional changes between each image to be tested are small, corrections can be made directly based on the correction parameters between the first image and the template image. When the positional changes between each image to be tested are large, correction parameters between each image to be tested and the template image can be calculated separately to correct the position of each image to be tested. This allows for normal detection of the product area even when the position of the first image changes, realizing template reuse, reducing workload and the burden of storing templates, thereby improving the efficiency of product detection, while also reducing the likelihood of missed detections and improving the accuracy of product detection.

[0158] According to the product detection method provided in the embodiments of this application, the position of the first image is adjusted so that the entire area of ​​the product region overlaps with at least a portion of the first detection region by analyzing the differences between some edge features in the extracted template image and the first image. Detection is then performed based on the overlapped image. This allows for template reuse when the product type changes during actual detection, reducing workload and the burden of storing templates, thereby improving the efficiency of product detection. At the same time, it reduces the likelihood of missed detections and improves the accuracy of product detection.

[0159] The product testing apparatus provided in this application is described below. The product testing apparatus described below can be referred to in correspondence with the product testing method described above.

[0160] The product testing method provided in this application can be executed by a product testing device. This application uses a product testing device executing the product testing method as an example to illustrate the product testing device provided in this application.

[0161] This application also provides a product testing device.

[0162] like Figure 6 As shown, the product testing device includes: a first processing module 610, a second processing module 620, and a third processing module 630.

[0163] The first processing module 610 is used to extract image edge features of at least a portion of the template image and the first image corresponding to the acquired target product, respectively, to obtain the first edge feature points corresponding to the template image and the second edge feature points corresponding to the first image. The template image includes a first detection region; the first image includes a product region corresponding to the target product.

[0164] The second processing module 620 is used to correct the first image based on the first edge feature point and the second edge feature point, and to obtain the second image, wherein the entire area of ​​the product area in the second image overlaps with at least a portion of the area of ​​the first detection area.

[0165] The third processing module 630 is used to detect the product area in the second image based on the first detection area.

[0166] According to the product inspection apparatus provided in the embodiments of this application, the position of the first image is adjusted so that the entire area of ​​the product area overlaps with at least a portion of the first detection area by analyzing the differences between some edge features in the extracted template image and the first image. Detection is then performed based on the overlapped image. This allows for template reuse when the product type changes during actual inspection, reducing workload and the burden of storing templates, thereby improving the efficiency of product inspection. At the same time, it reduces the likelihood of missed detections and improves the accuracy of product inspection.

[0167] In some embodiments, the second processing module 620 can also be used to obtain correction parameters between the first image and the template image based on the first edge feature points and the second edge feature points;

[0168] Based on the correction parameters, the first image is corrected to obtain the second image.

[0169] According to the product inspection apparatus provided in this application embodiment, correction parameters between a first image and a template image are obtained based on a first edge feature point and a second edge feature point. Then, the first image is corrected based on the correction parameters to obtain a second image. In practical applications, when switching product types, it is not necessary to create a new template image. When the positional changes between each image to be inspected are small, correction can be directly performed based on the correction parameters between the first image and the template image. When the positional changes between each image to be inspected are large, the correction parameters between each image to be inspected and the template image can be calculated separately to correct the position of each image to be inspected. This achieves template reuse, reduces workload, and improves the efficiency of product inspection.

[0170] In some embodiments, the apparatus may further include a fourth processing module, configured to determine a first edge tilt of the template image based on a first edge feature point; and to determine a second edge tilt of the first image based on a second edge feature point;

[0171] Based on the first edge feature point and the second edge feature point, determine the horizontal and / or vertical offsets corresponding to the image edges of at least a portion of the region between the first image and the template image;

[0172] The correction parameters are determined based on the first edge tilt, the second edge tilt, and the lateral and / or longitudinal offset.

[0173] According to the product detection device provided in the embodiments of this application, the first edge tilt of the template image, the second edge tilt of the first image, and the lateral and / or longitudinal offset of the image edges corresponding to at least a portion of the regions between the first image and the template image are determined based on the first edge feature points and the second edge feature points. Then, correction parameters are determined based on the first edge tilt, the second edge tilt, and the offset. The edges of the image can be used as positioning features for positioning, and the correction parameters between the first image and the template image can be calculated. No marker points are required on the image, making it applicable to a wide range of scenarios. It can also obtain more comprehensive pose information between the template image and the first image, thus improving the final detection accuracy and effect.

[0174] In some embodiments, the device may further include a fifth processing module for obtaining a first average pixel position of the first edge feature point and a second average pixel position of the second edge feature point.

[0175] Correction parameters are obtained based on the deviation between the first average pixel position and the second average pixel position.

[0176] According to the product inspection device provided in the embodiments of this application, by obtaining the first average pixel position of the first edge feature point and the second average pixel position of the second edge feature point, and then obtaining the correction parameter based on the deviation between the first average pixel position and the second average pixel position, the correction parameter can be directly obtained based on the first average pixel position and the second average pixel position when the image edge of at least a part of the template image is parallel to the image edge of at least a part of the first image. The calculation process is simpler, the workload is reduced, and the efficiency of product inspection is improved.

[0177] In some embodiments, the first processing module 610 may also be used to perform at least one of Sobel processing and thresholding processing on the image edges of at least a portion of the template image and the first image respectively, to obtain the first edge feature point corresponding to the template image and the second edge feature point corresponding to the first image.

[0178] According to the product inspection apparatus provided in the embodiments of this application, by performing at least one of Sobel processing and threshold processing on the image edges of at least a portion of the template image and the first image, the first edge feature points corresponding to the template image and the second edge feature points corresponding to the first image are obtained. This enables accurate acquisition of the image edge information of the template image and the first image, so that the first image can be inspected based on the edge information in the future. This reduces the amount of data involved in the calculation, greatly saves processing time, and thus improves the efficiency and accuracy of product inspection.

[0179] In some embodiments, the apparatus may further include a sixth processing module, configured to perform Sobel processing on the image edges of at least a portion of the template image and the first image respectively, to obtain a first edge image corresponding to the template image and a second edge image corresponding to the first image;

[0180] Thresholding is performed on the first edge image and the second edge image respectively to obtain multiple third edge feature points corresponding to the template image and multiple fourth edge feature points corresponding to the first image;

[0181] Taking the target third edge feature point among multiple third edge feature points as the center, replace the target third edge feature point with the pixel point corresponding to the maximum gray value within the target range to obtain the first edge feature point;

[0182] Taking the target fourth edge feature point among multiple fourth edge feature points as the center, replace the target fourth edge feature point with the pixel point corresponding to the maximum gray value within the target range to obtain the second edge feature point.

[0183] According to the product inspection apparatus provided in the embodiments of this application, by performing Sobel processing and thresholding on the image edges of at least a portion of the template image and the first image to obtain multiple edge feature points, and then using the pixel point corresponding to the maximum gray value within the target range as the first edge feature point and / or the second edge feature point, more realistic image edge information corresponding to the template image and the first image can be obtained, so that the first image can be inspected based on the edge information in the future. At the same time, the local image obtained based on the ROI region is used to replace the edge information of the whole image, reducing the image processing area, saving processing time, and thus improving the efficiency of product inspection.

[0184] The product testing device in this application embodiment can be an electronic device or a component within an electronic device, such as an integrated circuit or a chip. The electronic device can be a terminal or other devices besides a terminal. For example, the electronic device can be a mobile phone, tablet computer, laptop computer, PDA, in-vehicle electronic device, mobile internet device (MID), augmented reality (AR) / virtual reality (VR) device, robot, wearable device, ultra-mobile personal computer (UMPC), netbook, or personal digital assistant (PDA), etc. It can also be a server, network attached storage (NAS), personal computer (PC), television set (TV), ATM, or self-service machine, etc. This application embodiment does not specifically limit the device.

[0185] The product testing device in this application embodiment can be a device with an operating system. This operating system can be Android, iOS, or other possible operating systems; this application embodiment does not specifically limit it.

[0186] The product testing device provided in this application embodiment can achieve... Figures 1 to 5 The various processes implemented in the method implementation examples will not be described again here to avoid repetition.

[0187] In some embodiments, such as Figure 7 As shown, this application embodiment also provides an electronic device 700, including a processor 701, a memory 702, and a computer program stored in the memory 702 and executable on the processor 701. When the program is executed by the processor 701, it implements the various processes of the above-described product detection method embodiment and achieves the same technical effect. To avoid repetition, it will not be described again here.

[0188] It should be noted that the electronic devices in the embodiments of this application include the mobile electronic devices and non-mobile electronic devices described above.

[0189] On the other hand, this application also provides a computer program product, which includes a computer program stored on a non-transitory computer-readable storage medium. The computer program includes program instructions. When the program instructions are executed by a computer, the computer can execute the various processes of the above-described product detection method embodiments and achieve the same technical effect. To avoid repetition, it will not be described again here.

[0190] In another aspect, this application also provides a non-transitory computer-readable storage medium storing a computer program thereon. When the computer program is executed by a processor, it implements the various processes of the above-described product testing method embodiments and can achieve the same technical effect. To avoid repetition, it will not be described again here.

[0191] In another aspect, this application embodiment provides a chip, which includes a processor and a communication interface. The communication interface is coupled to the processor, and the processor is used to run programs or instructions to implement the various processes of the above product testing method embodiments and achieve the same technical effect. To avoid repetition, it will not be described again here.

[0192] It should be understood that the chip mentioned in the embodiments of this application may also be referred to as a system-on-a-chip, system chip, chip system, or system-on-a-chip, etc.

[0193] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.

[0194] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.

[0195] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application.

Claims

1. A product testing method, characterized in that, include: Image edge features of at least a portion of the template image and the first image corresponding to the acquired target product are extracted respectively to obtain a first edge feature point corresponding to the template image and a second edge feature point corresponding to the first image. The template image includes a first detection region; the first image includes a product region corresponding to the target product. The first image is corrected based on the first edge feature point and the second edge feature point to obtain a second image, wherein the entire area of ​​the product area in the second image overlaps with at least a portion of the area of ​​the first detection area. Based on the first detection area, the product area in the second image is detected; The step of correcting the first image based on the first edge feature points and the second edge feature points to obtain the second image includes: Based on the first edge feature point and the second edge feature point, obtain the correction parameters between the first image and the template image; Based on the correction parameters, the first image is corrected to obtain the second image; The step of obtaining correction parameters between the first image and the template image based on the first edge feature points and the second edge feature points includes: The first edge tilt of the template image is determined based on the first edge feature points; the second edge tilt of the first image is determined based on the second edge feature points; Based on the first edge feature point and the second edge feature point, determine the horizontal and / or vertical offset of the image edge corresponding to the at least part of the region between the first image and the template image; The correction parameters are determined based on the first edge tilt, the second edge tilt, and the lateral and / or longitudinal offset.

2. The product testing method according to claim 1, characterized in that, When the image edges of at least a portion of the template image are parallel to the image edges of at least a portion of the first image, obtaining the correction parameters between the first image and the template image based on the first edge feature points and the second edge feature points includes: Obtain the first average pixel position of the first edge feature point and the second average pixel position of the second edge feature point; The correction parameter is obtained based on the deviation between the first average pixel position and the second average pixel position.

3. The product testing method according to claim 1 or 2, characterized in that, The step of extracting image edge features from at least a portion of the template image and the first image corresponding to the acquired target product, respectively, to obtain the first edge feature points corresponding to the template image and the second edge feature points corresponding to the first image, includes: At least one of Sobel processing and thresholding is performed on the image edges of at least a portion of the template image and the first image respectively to obtain the first edge feature point corresponding to the template image and the second edge feature point corresponding to the first image.

4. The product testing method according to claim 3, characterized in that, The step of performing at least one of Sobel processing and thresholding on the image edges of at least a portion of the template image and the first image to obtain a first edge feature point corresponding to the template image and a second edge feature point corresponding to the first image includes: Sobel processing is performed on the image edges of at least a portion of the regions of the template image and the first image respectively to obtain a first edge image corresponding to the template image and a second edge image corresponding to the first image; Thresholding is performed on the first edge image and the second edge image respectively to obtain multiple third edge feature points corresponding to the template image and multiple fourth edge feature points corresponding to the first image; Taking the target third edge feature point among the plurality of third edge feature points as the center, replace the target third edge feature point with the pixel point corresponding to the maximum gray value within the target range to obtain the first edge feature point; Centered on the target fourth edge feature point among the plurality of fourth edge feature points, the target fourth edge feature point is replaced with the pixel point corresponding to the maximum gray value within the target range to obtain the second edge feature point.

5. A product testing device, characterized in that, include: The first processing module is configured to extract image edge features from at least a portion of the template image and the first image corresponding to the acquired target product, respectively, to obtain a first edge feature point corresponding to the template image and a second edge feature point corresponding to the first image, wherein the template image includes a first detection region; and the first image includes a product region corresponding to the target product. The second processing module is used to correct the first image based on the first edge feature point and the second edge feature point, and obtain a second image, wherein the entire area of ​​the product area in the second image overlaps with at least a portion of the area of ​​the first detection area. The third processing module is used to detect the product area in the second image based on the first detection area; The second processing module is also used for: Based on the first edge feature point and the second edge feature point, obtain the correction parameters between the first image and the template image; Based on the correction parameters, the first image is corrected to obtain the second image; The second processing module is also used for: The first edge tilt of the template image is determined based on the first edge feature points; the second edge tilt of the first image is determined based on the second edge feature points; Based on the first edge feature point and the second edge feature point, determine the horizontal and / or vertical offset of the image edge corresponding to the at least part of the region between the first image and the template image; The correction parameters are determined based on the first edge tilt, the second edge tilt, and the lateral and / or longitudinal offset.

6. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the product testing method as described in any one of claims 1-4.

7. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the product testing method as described in any one of claims 1-4.

8. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by the processor, it implements the product testing method as described in any one of claims 1-4.

Citation Information

Patent Citations

  • Edge defect detection method and device, model, equipment and readable storage medium

    CN111369545A

  • Target object surface quality detection method and device, system, equipment and medium

    CN115170537A