Product appearance defect identification method, device, equipment and medium

Through automated detection technology, OpenCV and Douglas-Peucker algorithms are used to process product appearance images, extract the contour and calculate the area error ratio, solving the problems of low manual detection efficiency and poor accuracy, and achieving efficient and accurate product appearance defect detection.

CN119444675APending Publication Date: 2025-02-14DONGGUAN LVJUREN PURIFICATION TECH CO LTD
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202411423494.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-12
Publication Date
2025-02-14

AI Technical Summary

Technical Problem

In the prior art, product appearance defect detection mainly relies on manual labor, is inefficient and is susceptible to human subjective factors, resulting in a high rate of missed detection and false detection.

Method used

By obtaining the image to be identified for product appearance, it is processed as a binarized image, and using the OpenCV model for contour extraction, combining the Douglas-Peucker algorithm to extract the contour vertex coordinates, calculate the contour area and the enclosing box area, and determine the recognition result based on the area error ratio.

Benefits of technology

Automatic detection is realized, which significantly improves detection efficiency, reduces misjudgment and missed judgments, reduces labor costs, and improves the accuracy and consistency of detection results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119444675A_ABST
    Figure CN119444675A_ABST
Patent Text Reader

Abstract

The invention belongs to the technical field of machine vision detection, and discloses a product appearance defect identification method and device, equipment and a medium. The method comprises the following steps: obtaining a to-be-recognized image of a product appearance, and processing the to-be-recognized image into a binary image; carrying out contour extraction in the OpenCV model to obtain a contour boundary of the product defect in the to-be-identified image; using a Douglas-Peucker algorithm to extract contour vertex coordinates from the contour boundary, and calculating the contour area of the product defect based on the contour vertex coordinates; determining a minimum bounding box containing a contour boundary through a contour searching method, extracting vertex coordinates of the bounding box, and calculating the area of the bounding box based on the vertex coordinates of the bounding box; and based on the contour area and the bounding box area, calculating an area error ratio of the contour area to the bounding box area, and based on the area error ratio, determining an identification result including qualified product appearance and unqualified product appearance. The detection efficiency can be effectively improved, and the product omission ratio is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of machine vision detection technology, and in particular to a method, device, equipment and medium for identifying product appearance defects. Background Art

[0002] The comprehensive intelligent development of the manufacturing industry has put forward new requirements for the quality inspection of industrial products. In the current industrial production process, the quality of finished products is easily affected by various factors such as existing technology and working conditions. Among them, surface defects in appearance are the most intuitive manifestation of the quality of finished products. Therefore, in order to ensure the qualified rate of products, it is necessary to detect the surface defects of products before exporting them. However, the current defect detection mainly relies on manual work, which is inefficient and the detection results are easily affected by human subjective factors. Summary of the invention

[0003] To this end, the embodiments of the present application provide a method, device, equipment and medium for identifying product appearance defects, which effectively improves the detection efficiency, reduces the influence of human subjective factors, and improves the product missed detection rate and false detection rate.

[0004] In a first aspect, the present application provides a method for identifying product appearance defects.

[0005] This application is achieved through the following technical solutions:

[0006] A method for identifying product appearance defects, the method comprising:

[0007] Acquire an image to be identified of the product appearance, and process the image to be identified into a binary image;

[0008] Input the binary image into the OpenCV model to extract contours, and obtain contour boundaries of product defects in the image to be identified;

[0009] Extracting contour vertex coordinates from the contour boundary using the Douglas-Peucker algorithm, and calculating the contour area of ​​the product defect based on the contour vertex coordinates;

[0010] Determine a minimum bounding box containing a contour boundary by a contour search method, extract bounding box vertex coordinates based on the minimum bounding box containing the contour boundary, and calculate the bounding box area based on the bounding box vertex coordinates;

[0011] Based on the contour area and the bounding box area, an area error ratio between the contour area and the bounding box area is calculated, and a recognition result is determined based on the area error ratio, wherein the recognition result includes a qualified product appearance and an unqualified product appearance.

[0012] In a preferred example of the present application, it can be further configured that the image to be identified is processed into a binary image, including: inverting the background and foreground of the image to be identified to obtain an inverted image to be identified;

[0013] Convert the inverted image to be recognized into a grayscale image;

[0014] The pixel values ​​of the grayscale image are binarized to obtain a binarized image of the image to be identified.

[0015] In a preferred example of the present application, it can be further configured that the binary image is input into the OpenCV model for contour extraction to obtain the contour boundary of the product defect in the image to be identified, including:

[0016] Input the binary image into the OpenCV model and convert the pixel values ​​of the binary image into a two-dimensional matrix through a recursive algorithm;

[0017] Traversing each pixel point in the two-dimensional matrix, checking whether the pixel point and its neighboring pixel points belong to the same object, and when any neighboring pixel point and the pixel point are not in the same object, determining that the pixel point is a boundary point;

[0018] Connect all boundary points to obtain the contour boundary of the product.

[0019] In a preferred example of the present application, it can be further configured that the contour vertex coordinates are extracted from the contour boundary using the Douglas-Peucker algorithm, including:

[0020] Determine a curve segment AB on the contour boundary, and connect a straight line segment L between the end points A and B of the curve segment AB;

[0021] Determine the node n on the curve segment AB that has the largest distance from the straight line segment L and the perpendicular distance D between the node n and the straight line segment L L-n ;

[0022] The vertical distance D L-n Compared with the preset threshold, if the vertical distance D L-n When it is less than or equal to a preset threshold, the curve segment AB is replaced by the straight line segment L;

[0023] If the vertical distance D L-n When it is greater than a preset threshold, the curve segment AB is split into two curve segments AM and MB, and alternative straight lines of the curve segment AM and the curve segment MB are determined respectively;

[0024] Until all the curve segments are replaced by straight line segments, the coordinates of the contour vertices are extracted, and the contour area of ​​the product defect is calculated based on the contour vertex coordinates.

[0025] In a preferred example of the present application, it can be further configured that the recognition result is determined based on the area error ratio, and the recognition result includes whether the product appearance is qualified or not, including:

[0026] Comparing the area error ratio with a preset error judgment threshold, if the area error ratio is less than or equal to the preset error judgment threshold, judging that the product appearance is qualified;

[0027] If the area error ratio is greater than a preset error judgment threshold, the product appearance is judged to be unqualified.

[0028] In a preferred example of the present application, it can be further configured to include:

[0029] Obtain probability distribution data of actual product outline dimensions, and determine an error judgment threshold based on the probability distribution data.

[0030] In a preferred example of the present application, it can be further set that the error judgment threshold is expressed as:

[0031]

[0032] S d =(μ dw -3σ dw )(μ dh -3σ dh ),

[0033] S q =(μ qw -3σ qw )(μ qh -3σ qh ),

[0034] Among them, S q Indicates the contour area of ​​the product with qualified appearance, μ qw represents the mean width of qualified products, σ qw Indicates the standard deviation of the width of qualified products, μ qh represents the mean height of qualified products, σ qh Indicates the standard deviation of the height of qualified products, S d Indicates the contour area of ​​the product that does not meet the quality standards, μ dw represents the mean width of defective products, σ dw Indicates the standard deviation of the width of defective products, μ dh represents the mean height of defective products, σ dh Indicates the standard deviation of the height of rejected products.

[0035] In a second aspect, the present application provides a device for identifying product appearance defects.

[0036] This application is achieved through the following technical solutions:

[0037] A device for identifying product appearance defects, the device being used to perform the identification method described in the first aspect, the device comprising:

[0038] An image acquisition module is used to acquire an image to be identified of the product appearance and process the image to be identified into a binary image;

[0039] A boundary contour extraction module is used to input the binary image into the OpenCV model to perform contour extraction, so as to obtain the contour boundary of the product defect in the image to be identified;

[0040] A contour area confirmation module, used to extract contour vertex coordinates from the contour boundary using a Douglas-Peucker algorithm, and calculate the contour area of ​​the product defect based on the contour vertex coordinates;

[0041] A bounding box area confirmation module is used to determine a minimum bounding box containing a contour boundary by a contour search method, extract bounding box vertex coordinates based on the minimum bounding box containing the contour boundary, and calculate the bounding box area based on the bounding box vertex coordinates;

[0042] The recognition result confirmation module is used to calculate the area error ratio of the contour area and the bounding box area based on the contour area and the bounding box area, and determine the recognition result based on the area error ratio, wherein the recognition result includes whether the product appearance is qualified or not.

[0043] On the third aspect, the present application is realized through the following technical solutions:

[0044] A computer device comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of any one of the above-mentioned methods for identifying product appearance defects when executing the computer program.

[0045] In a fourth aspect, the present application provides a computer-readable storage medium.

[0046] This application is achieved through the following technical solutions:

[0047] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of any one of the above-mentioned methods for identifying product appearance defects.

[0048] In summary, compared with the prior art, the technical solution provided in the embodiment of the present application has at least the following beneficial effects:

[0049] This application obtains the image to be identified of the product appearance, processes the image to be identified into a binary image; uses the OpenCV model to extract the contour, and obtains the contour boundary of the product defect in the image to be identified; uses the Douglas-Peucker algorithm to extract the contour vertex coordinates from the contour boundary, and calculates the contour area of ​​the product defect based on the contour vertex coordinates; determines the minimum bounding box containing the contour boundary by the contour search method, and extracts the bounding box vertex coordinates, and calculates the bounding box area based on the bounding box vertex coordinates; based on the contour area and the bounding box area, calculates the area error ratio of the contour area and the bounding box area, and determines the recognition result based on the area error ratio, and the recognition result includes the qualified product appearance and the unqualified product appearance. By obtaining the image to be identified and inputting it into the OpenCV model for automated detection, a large number of images can be identified and processed in a very short time, far exceeding the rate of manual detection, and significantly improving the detection efficiency; automated detection is based on fixed algorithms and standards, can maintain a high degree of accuracy and consistency, reduce misjudgment and missed judgment; reduce dependence on manual labor and reduce labor costs. BRIEF DESCRIPTION OF THE DRAWINGS

[0050] Figure 1 A schematic diagram of a process for identifying product appearance defects provided in an embodiment of the present application;

[0051] Figure 2 A schematic diagram of extracting contour vertex coordinates from a contour boundary provided in an embodiment of the present application;

[0052] Figure 3 A schematic diagram of a flow chart of a method for extracting contour vertex coordinates from a contour boundary provided in an embodiment of the present application;

[0053] Figure 4 A schematic diagram of the structure of a device for identifying product appearance defects provided in one embodiment of the present application;

[0054] Description of reference numerals:

[0055] Image acquisition module-11, boundary contour extraction module-21, contour area confirmation module-31, bounding box area confirmation module-41, recognition result confirmation module-51. DETAILED DESCRIPTION

[0056] This specific embodiment is merely an explanation of the present application and is not a limitation of the present application. After reading this specification, those skilled in the art may make modifications to the present embodiment without any creative contribution as needed, but such modifications are protected by the patent law as long as they are within the scope of the claims of the present application.

[0057] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0058] In addition, the term "and / or" in this application is only a description of the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this application, unless otherwise specified, generally indicates that the associated objects before and after are in an "or" relationship.

[0059] In this application, the terms "first", "second", etc. are used to distinguish identical or similar items with basically the same effects and functions. It should be understood that there is no logical or temporal dependency between "first", "second", and "nth", nor is there any limitation on quantity and execution order.

[0060] The embodiments of the present application are further described in detail below in conjunction with the accompanying drawings. Figure 1 As shown, the method for identifying product appearance defects proposed in this application includes:

[0061] S10: Obtain an image to be identified of the product appearance, and process the image to be identified into a binary image.

[0062] Use an industrial camera to capture an image of the product appearance as the image to be identified, connect to the industrial camera through the interface provided by the industrial camera, such as Camera Link, GigE Vision, etc., obtain the image to be identified, and store the image to be identified in the file system. Specifically, the image to be identified can be read from the file system through cv2.imread in the OpenCV model. Highlight the contour and shape features of the target of interest, making the target more prominent in the image, which is convenient for subsequent identification and analysis, and process the image to be identified into a binary image containing only two colors (black and white).

[0063] It should be noted that the OpenCV model is a cross-platform computer vision and machine learning software library released under the Apache 2.0 license (open source), which can run on Linux, Windows, Android and Mac OS operating systems. It is lightweight and efficient - consisting of a series of C functions and a small number of C++ classes, while providing interfaces for languages ​​such as Python, Ruby, and MATLAB, and implementing many common algorithms in image processing and computer vision.

[0064] S20: Input the binary image into the OpenCV model for contour extraction to obtain the contour boundary of the product defect in the image to be identified.

[0065] S30: Using the Douglas-Peucker algorithm, the contour vertex coordinates are extracted from the contour boundary, and the contour area of ​​the product defect is calculated based on the contour vertex coordinates.

[0066] S40: Determine the minimum bounding box containing the contour boundary by a contour search method, extract the coordinates of the bounding box vertices based on the minimum bounding box containing the contour boundary, and calculate the area of ​​the bounding box based on the coordinates of the bounding box vertices. The bounding box is an outer rectangular frame containing the contour boundary.

[0067] S50: Based on the contour area and the bounding box area, the area error ratio of the contour area and the bounding box area is calculated, and the recognition result is determined based on the area error ratio. The recognition result includes whether the product appearance is qualified or not.

[0068] By using the method proposed in this application to realize automatic detection of images to be identified in the OpenCV model, a large number of images can be recognized and processed in a very short time, far exceeding the rate of manual detection, and significantly improving detection efficiency; automated detection is based on fixed algorithms and standards, can maintain a high degree of accuracy and consistency, reduce misjudgments and missed judgments; reduce dependence on manual labor and reduce labor costs.

[0069] In some feasible embodiments, processing the image to be identified into a binary image in step S10 specifically includes:

[0070] The background and foreground of the image to be identified are inverted to obtain the inverted image to be identified; the inverted image to be identified is converted into a grayscale image; the pixel values ​​of the grayscale image are binarized to obtain a binary image of the image to be identified. In the specific implementation process, the current RGB value of each pixel of the image to be identified is first extracted, and the value of each color channel is calculated according to RGB′=255-RGB to obtain the inverted color value RGB′ of each color channel. In the actual implementation process, image inversion can be performed by using cv2.bitwise_not in the OpenCV module.

[0071] The inverted image to be identified is processed into a grayscale image; color information is removed. In the actual implementation process, the colored image to be identified can be converted from the BGR color space to the grayscale color space by using the cv2.cvtColor() function in the OpenCV module to obtain a grayscale image. In order to more easily analyze and process the image and enhance the contrast of the target contour, the pixel value of the grayscale image is simplified to two levels (usually 0 and 255, i.e. black and white). First, the threshold of binarization is set. In this application, the threshold of binarization is automatically calculated by the global threshold method. The pixel value of the grayscale image is compared with the threshold using the cv2.threshold() function of OpenCV. When the pixel value of the pixel is greater than or equal to the threshold of binarization, the grayscale value of the pixel is set to 255 (i.e. white); when the pixel value of the pixel is less than the threshold of binarization, the grayscale value of the pixel is set to 0 (i.e. black). The binarized image to be identified is saved.

[0072] In some feasible implementations, in step S20, the binary image is input into the OpenCV model for contour extraction to obtain the contour boundary of the product defect in the image to be identified, specifically including:

[0073] Input the binary image into the OpenCV model, find connected pixels in the binary image to determine the contour of each object, and convert the pixel values ​​of the binary image into a two-dimensional matrix through a recursive algorithm; traverse each pixel in the two-dimensional matrix to check whether the pixel and its neighboring pixels belong to the same object. When any neighboring pixel and the pixel are not in the same object, the pixel is judged to be a boundary point; connect all boundary points to obtain the contour boundary of the product. In the actual implementation process, the binary image can be input into the OpenCV module and the cv2.findContours function can be used to determine the contour boundary.

[0074] In some feasible implementations, in step S30, the Douglas-Peucker algorithm is used to extract the contour vertex coordinates from the contour boundary. Figure 2 and Figure 3 As shown, specifically including:

[0075] S301: determining a curve segment AB on the contour boundary, connecting a straight line segment L between endpoints A and B of the curve segment AB, and the straight line segment L can be regarded as a chord of the curve segment AB;

[0076] S302: Determine the node n on the curve segment AB that has the largest distance from the straight line segment L, and calculate the vertical distance D between the node n and the straight line segment L L-n ;

[0077] S303: The vertical distance D L-n Compared with the preset threshold, if the vertical distance D L-n When it is less than or equal to a preset threshold, the curve segment AB is replaced by the straight line segment L; wherein the preset threshold (threshold) can be set according to actual needs.

[0078] S304: If the vertical distance D L-n When it is greater than a preset threshold, the curve segment AB is split into two curve segments AM and MB, and the replacement straight lines of the curve segments AM and MB are determined respectively, that is, the above steps S301 to S303 need to be performed for the curve segment AM, and the above steps S301 to S303 need to be performed for the curve segment MB.

[0079] S305: until all curve segments are replaced by straight line segments, extract the coordinates of the contour vertices, and calculate the contour area of ​​the product defect based on the coordinates of the contour vertices. Specifically, when all curve segments are processed, the broken lines formed by connecting each segmentation node in sequence are used as approximate replacement line segments of the curve. Geometric features are extracted from the final broken line segments, and the geometric features are used to describe the shape and attributes. Based on the geometric features, the coordinates of the contour vertices can be determined, and then the contour area of ​​the product defect can be calculated.

[0080] Specifically, the Sierpinski formula is used to calculate the contour area S according to the above contour vertex coordinates: L The Shoelace Theorem can be used to calculate the area of ​​a polygon using coordinate points. Specifically:

[0081]

[0082] Among them, (x i ,y i ) are the vertex coordinates of the outline quadrilateral, arranged in clockwise or counterclockwise order.

[0083] In some feasible embodiments, after extracting the feature information of all bounding boxes (also called circumscribed moments) of the contour boundary by the contour search method in step S40, the bounding box with the smallest area is extracted as the minimum bounding box of the contour boundary, including the center point coordinates (x, y), the order of the four vertices, the rectangle width Width, the rectangle height Height and the rectangle rotation angle θ of the minimum bounding box. The feature information of the minimum bounding box can be extracted by cv2.minAreaRect in the OpenCV module, and then the cv2.boxPoints function in the OpenCV module is used to extract the coordinates of the bounding box vertices from the above feature information. The specific calculation formula can be expressed as:

[0084] L2=(1 / 2)*h*sinθ,

[0085] L3=(1 / 2)*w*sinθ,

[0086] L1=(1 / 2)*w*cosθ-L2,

[0087] L4=(1 / 2)*h*cosθ,

[0088] L5=h*sinθ,

[0089] L6=(1 / 2)*h*cosθ,

[0090] L7=L3;

[0091] The coordinates of the four vertices P0(x0,y0), P1(x1,y1), P2(x2,y2), and P3(x3,y3) are:

[0092] P0(x0,y0):x0=x-L1,y0=y+L3+L4,

[0093] P1(x1,y1): x1=x-(L1+L5), y1=y-(L6-L7),

[0094] P2(x2,y2): x2=x1+w*cosθ, y2=y1-h*sinθ,

[0095] P3(x3,y3): x3=x0+w*cosθ, y3=y0-h*sinθ,

[0096] Among them, (x, y) represents the coordinates of the center point of the minimum bounding box, w represents the width of the minimum bounding box, and h represents the height of the minimum bounding box.

[0097] After obtaining the vertex coordinates of the minimum bounding box, the area of ​​the minimum bounding box is calculated using the Sierpinski formula.

[0098] In some feasible implementations, the recognition result is determined based on the area error ratio, and the recognition result includes whether the product appearance is qualified or unqualified, including:

[0099] The area error ratio is compared with the preset error judgment threshold. If the area error ratio is less than or equal to the preset error judgment threshold, the product appearance is judged to be qualified; if the area error ratio is greater than the preset error judgment threshold, the product appearance is judged to be unqualified.

[0100] Specifically, the probability distribution data of the actual product outline size is obtained, and the error judgment threshold is determined based on the probability distribution data. By dynamically adjusting the threshold according to the actual test data of each batch of products, the true quality status of the batch of products can be more accurately reflected. The process of dynamically adjusting the threshold is itself a process of continuous improvement. Through the analysis and feedback of the test data, enterprises can promptly discover problems in the production process and take corresponding corrective and preventive measures. This cycle of continuous improvement helps enterprises continuously optimize production processes and improve product quality and production efficiency.

[0101] Among them, the calculation method of the error judgment threshold τ is expressed as:

[0102]

[0103] S d =(μ dw -3σ dw )(μ dh -3σ dh ),

[0104] S q =(μ qw -3σ qw )(μ qh -3σ qh ),

[0105] Among them, S q Indicates the contour area of ​​the product with qualified appearance, μ qw represents the mean width of qualified products, σ qw Indicates the standard deviation of the width of qualified products, μ qh represents the mean height of qualified products, σ qh Indicates the standard deviation of the height of qualified products, S d Indicates the contour area of ​​the product that does not meet the quality standards, μ dw represents the mean width of defective products, σ dw Indicates the standard deviation of the width of defective products, μ dh represents the mean height of defective products, σ dh Indicates the standard deviation of the height of rejected products.

[0106] Another embodiment of the present application also provides a device for identifying product appearance defects, the device is used to perform the above-mentioned identification method, such as Figure 4 As shown, the recognition device includes: an image acquisition module 11, a boundary contour extraction module 21, a contour area confirmation module 31, a bounding box area confirmation module 41, and a recognition result confirmation module 51;

[0107] The image acquisition module 11 is used to acquire the image to be identified of the product appearance and process the image to be identified into a binary image;

[0108] The boundary contour extraction module 21 is used to input the binary image into the OpenCV model to perform contour extraction, and obtain the contour boundary of the product defect in the image to be identified;

[0109] A contour area confirmation module 31 is used to extract contour vertex coordinates from the contour boundary using the Douglas-Peucker algorithm, and calculate the contour area of ​​the product defect based on the contour vertex coordinates;

[0110] The bounding box area confirmation module 41 is used to determine the minimum bounding box containing the contour boundary by a contour search method, extract the coordinates of the bounding box vertices based on the minimum bounding box containing the contour boundary, and calculate the bounding box area based on the coordinates of the bounding box vertices;

[0111] The recognition result confirmation module 51 is used to calculate the area error ratio of the contour area and the bounding box area based on the contour area and the bounding box area, and determine the recognition result based on the area error ratio. The recognition result includes whether the product appearance is qualified or not.

[0112] The specific definition of the device for identifying product appearance defects provided in this embodiment can be found in the embodiment of the method for identifying product appearance defects above, and will not be repeated here. Each module in the above identification device can be implemented in whole or in part by software, hardware, and a combination thereof. Each of the above modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to each of the above modules.

[0113] An embodiment of the present application provides a computer device, which may include a processor, a memory, a network interface, and a database connected via a system bus. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external terminal via a network connection. When the computer program is executed by the processor, the processor executes the steps of the method for identifying product appearance defects as in any of the above embodiments.

[0114] The working process, working details and technical effects of the computer device provided in this embodiment can be found in the embodiment of the method for identifying product appearance defects above, and will not be described in detail here.

[0115] The embodiment of the present application provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the product appearance defect identification method as described in any of the above embodiments are implemented. The computer-readable storage medium refers to a carrier for storing data, which may include but is not limited to a floppy disk, an optical disk, a hard disk, a flash memory, a USB flash drive and / or a memory stick, etc., and the computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices.

[0116] The working process, working details and technical effects of the computer-readable storage medium provided in this embodiment can be found in the embodiment of the method for identifying product appearance defects described above, and will not be described in detail here.

[0117] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).

[0118] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0119] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example. In actual applications, the above-mentioned functions can be distributed and completed by different functional units and modules as needed, that is, the internal structure of the system described in the present application is divided into different functional units or modules to complete all or part of the functions described above.

Claims

1. A method for identifying product appearance defects, characterized in that: include: Acquire an image to be identified of the product appearance, and process the image to be identified into a binary image; Input the binary image into the OpenCV model to extract contours, and obtain contour boundaries of product defects in the image to be identified; Extracting contour vertex coordinates from the contour boundary using the Douglas-Peucker algorithm, and calculating the contour area of ​​the product defect based on the contour vertex coordinates; Determine a minimum bounding box containing a contour boundary by a contour search method, extract bounding box vertex coordinates based on the minimum bounding box containing the contour boundary, and calculate the bounding box area based on the bounding box vertex coordinates; Based on the contour area and the bounding box area, an area error ratio between the contour area and the bounding box area is calculated, and a recognition result is determined based on the area error ratio, the recognition result including a qualified product appearance and an unqualified product appearance.

2. The method for identifying product appearance defects according to claim 1, characterized in that: Processing the image to be identified into a binary image includes: Inverting the background and foreground of the image to be identified to obtain an inverted image to be identified; Convert the inverted image to be recognized into a grayscale image; The pixel values ​​of the grayscale image are binarized to obtain a binarized image of the image to be identified.

3. The method for identifying product appearance defects according to claim 2, characterized in that: The binary image is input into the OpenCV model for contour extraction to obtain the contour boundary of the product defect in the image to be identified, including: Input the binary image into the OpenCV model and convert the pixel values ​​of the binary image into a two-dimensional matrix through a recursive algorithm; Traversing each pixel point in the two-dimensional matrix, checking whether the pixel point and its neighboring pixel points belong to the same object, and when any neighboring pixel point and the pixel point are not in the same object, determining that the pixel point is a boundary point; Connect all boundary points to obtain the contour boundary of the product.

4. The method for identifying product appearance defects according to claim 1, characterized in that: The Douglas-Peucker algorithm is used to extract the contour vertex coordinates from the contour boundary, including: Determine a curve segment AB on the contour boundary, and connect a straight line segment L between the end points A and B of the curve segment AB; Determine the node n on the curve segment AB that has the largest distance from the straight line segment L and the perpendicular distance D between the node n and the straight line segment L L-n ; The vertical distance D L-n Compared with the preset threshold, if the vertical distance D L-n When it is less than or equal to a preset threshold, the curve segment AB is replaced by the straight line segment L; If the vertical distance D L-n When it is greater than a preset threshold, the curve segment AB is split into two curve segments AM and MB, and alternative straight lines of the curve segment AM and the curve segment MB are determined respectively; Until all the curve segments are replaced by straight line segments, the coordinates of the contour vertices are extracted, and the contour area of ​​the product defect is calculated based on the contour vertex coordinates.

5. The method for identifying product appearance defects according to claim 1, characterized in that: Determining a recognition result based on the area error ratio, the recognition result including whether the product appearance is qualified or unqualified, includes: Comparing the area error ratio with a preset error judgment threshold, if the area error ratio is less than or equal to the preset error judgment threshold, judging that the product appearance is qualified; If the area error ratio is greater than a preset error judgment threshold, the product appearance is judged to be unqualified.

6. The method for identifying product appearance defects according to claim 5, characterized in that: Also includes: Obtain probability distribution data of actual product outline dimensions, and determine an error judgment threshold based on the probability distribution data.

7. The method for identifying product appearance defects according to claim 6, characterized in that: The error judgment threshold is expressed as: S d =(μ dw -3s dw )(m dh -3s dh ), S q =(μ qw -3s qw )(m qh -3s qh ), Among them, S q Indicates the contour area of ​​the product with qualified appearance, μ qw represents the mean width of qualified products, σ qw Indicates the standard deviation of the width of qualified products, μ qh represents the mean height of qualified products, σ qh Indicates the standard deviation of the height of qualified products, S d Indicates the contour area of ​​the product that does not meet the quality standards, μ dw represents the mean width of defective products, σ dw Indicates the standard deviation of the width of defective products, μ dh represents the mean height of defective products, σ dh Indicates the standard deviation of the height of rejected products.

8. A device for identifying product appearance defects, characterized in that: Used to perform the method according to any one of claims 1 to 7, comprising: An image acquisition module is used to acquire an image to be identified of the product appearance and process the image to be identified into a binary image; A boundary contour extraction module is used to input the binary image into the OpenCV model for contour extraction to obtain the contour boundary of the product defect in the image to be identified; A contour area confirmation module, used to extract contour vertex coordinates from the contour boundary using a Douglas-Peucker algorithm, and calculate the contour area of ​​the product defect based on the contour vertex coordinates; A bounding box area confirmation module is used to determine a minimum bounding box containing a contour boundary by a contour search method, extract bounding box vertex coordinates based on the minimum bounding box containing the contour boundary, and calculate the bounding box area based on the bounding box vertex coordinates; The recognition result confirmation module is used to calculate the area error ratio of the contour area and the bounding box area based on the contour area and the bounding box area, and determine the recognition result based on the area error ratio, wherein the recognition result includes whether the product appearance is qualified or not.

9. A computer device, characterized in that: The method comprises a memory, a processor and a computer program stored in the memory, wherein the processor executes the computer program to implement the steps of the method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.

Citation Information

Cited By

  • Capacitor rubber plug defect detection method and device based on visual features and storage medium

    CN120198363A

  • Methods, apparatus and equipment for detecting the position and size of reinforcing sheets on flexible printed circuit boards

    CN122670734A