Appearance defect detection method and device for irregular texture product
The good sample images are collected through the surface array camera, the detection model is trained and the detection image is preprocessed, which realizes rapid and accurate defect detection of irregular texture products, solves the problems of low manual detection efficiency and poor accuracy, and avoids false detection.
Patent Information
- Application Number
- CN202411779747.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-05
- Publication Date
- 2025-03-18
AI Technical Summary
In the production process of die-cut products, artificial visual inspection efficiency is low, the accuracy is poor, and defect detection of irregular texture products is difficult to achieve rapid and accurate detection, which affects industrial-grade applications.
The surface array camera is used to collect the good sample image, and the product outline shape positioning template is obtained through the edge positioning extraction function. The affine transformation function is used to align the good sample image to train and obtain the good product detection model. Then, through positioning pre-processing and detection pre-processing, the detection image is pre-processed, and the difference areas are selected by point by point by point by point.
It realizes fast and accurate defect detection of irregular texture products, avoids inefficient and low accuracy of manual detection, and completes modeling without defect samples, effectively avoids mis-checking of product texture parts.
Smart Images

Figure CN119648668A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of machine vision and die-cut product appearance defect detection, and more specifically to a method and device for detecting appearance defects of products with irregular textures. Background Art
[0002] At present, with the development of science and technology, in the process of mass production of die-cut products, due to the particularity of image processing application in the field of die-cut products:
[0003] 1) Manual visual inspection is inefficient, low-precision, and has high labor costs;
[0004] 2) There are many types of die-cutting products, and they are updated and iterated quickly;
[0005] 3) The number of defective samples is small, but the types of defects are many;
[0006] In addition, irregular texture detection areas are difficult to model and prone to false detection, making it difficult for current machine vision to meet the requirements of industrial-grade visual inspection applications for products with irregular texture features, affecting practical applications.
[0007] Therefore, how to achieve rapid and accurate detection of appearance defects in irregular texture detection areas when the number of die-cut product defect samples is small and the product types are wide is a problem that technical personnel in this field urgently need to solve. Summary of the invention
[0008] In view of this, the present invention provides a method and device for detecting appearance defects of products with irregular textures to solve some of the technical problems mentioned in the background technology.
[0009] In order to achieve the above object, the present invention adopts the following technical solution:
[0010] A method for detecting appearance defects of products with irregular textures, comprising the following steps:
[0011] S1. Collect N good sample images through the area array camera;
[0012] S2. Take one image from the good sample image as the reference image, and obtain the product contour shape positioning template through the edge positioning extraction function. The product contour shape positioning template is used to identify and locate and output the position and contour information of the product;
[0013] S3. Use the detection preprocessing function to preprocess all good sample images, obtain the position information of the good sample through the product contour shape positioning template, use the affine transformation function to align all positions of the good sample, and then introduce the improved function function training to obtain the good detection model;
[0014] S4. Collect the inspection image, pre-process it through the positioning pre-processing function, and use the product contour shape positioning template to obtain the target's position information; use the inspection pre-processing function to pre-process the inspection image, use the affine transformation function to transform the pre-processed image and the good product inspection model to the same reference position, compare point by point to screen out the difference parts as defects.
[0015] Preferably, the edge location extraction function in step S2 includes a location preprocessing function F f and edge extraction operations.
[0016] Preferably, the calculation method of the positioning preprocessing function is:
[0017] g′(x,y)=g(x,y)*Mult+Add
[0018]
[0019] Add=-Mult*Add
[0020] Wherein, g(x, y) is the grayscale value at the position (x, y) before preprocessing, g′(x, y) is the grayscale value at the position (x, y) after preprocessing, Mult is the scaling factor used to control the contrast, Add is the offset used to control the brightness, GMax and GMin are adjustment factors, and their value range is [0, 255];
[0021] Positioning preprocessing highlights the product contour positioning by adjusting factors; detection preprocessing highlights the difference contrast between the detection image and the template image by adjusting factors.
[0022] Preferably, the good product detection model is a threshold tolerance band of a good product sample image, including two template threshold maps.
[0023] Preferably, the good product detection model includes two template threshold maps:
[0024]
[0025] Among them, f u and f l is the template upper and lower threshold map included in the good product detection model, g k (x, y) is the pixel value of the kth image in the good sample at the pixel point (x, y), is the pixel value of the absolute median difference template at the pixel point (x, y), a u is the upper absolute threshold, a l is the lower absolute threshold, b u is the upper absolute median difference threshold, b l is the lower absolute median difference threshold.
[0026] Preferably, the method for screening out the difference parts by point-by-point comparison is:
[0027]
[0028] If the pixel value of the detection image at the (x, y) position is greater than the upper threshold map of the template contained in the good product detection model or less than the lower threshold map, it is a difference position.
[0029] Preferably, the affine transformation function is specifically:
[0030]
[0031] Among them, H t (i) is the translation matrix, H r (i) is the rotation matrix.
[0032] A system for detecting appearance defects of products with irregular textures, based on the method for detecting appearance defects of products with irregular textures, comprises: an area array camera, a positioning preprocessing module, a detection preprocessing module, a product contour shape positioning template, an affine transformation module, a trained good product detection model and a model training module;
[0033] An area array camera is used to collect N good sample images and inspection images;
[0034] A positioning preprocessing module, used to preprocess a reference image and a detection image selected from a good sample image through a positioning preprocessing function;
[0035] Detection preprocessing module, used to preprocess all good sample images and detection images;
[0036] Product contour shape positioning template, used to identify and output the position and contour information of the product;
[0037] An affine transformation module, used to align all positions of good product samples using an affine transformation function, and to transform the image after preprocessing the inspection image and the good product inspection model to the same reference position using an affine transformation function;
[0038] The trained good product detection model is used to compare point by point to select the difference parts as defects;
[0039] The model training module is used to obtain a good product detection model by introducing improved functional training.
[0040] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements a method for detecting appearance defects of a product with irregular texture.
[0041] A processing terminal comprises a memory and a processor. The memory stores a computer program that can be run on the processor. When the processor executes the computer program, the appearance defect detection method of an irregular texture product is implemented.
[0042] It can be seen from the above technical solutions that, compared with the prior art, the present invention discloses a method and device for detecting appearance defects of products with irregular textures. No defect samples are required, and modeling can be quickly completed by training a set of good product images. Different preprocessing methods are used in the identification and positioning and detection stages to achieve accurate positioning and high-precision detection. By training the detection model with multiple good products, false detection of the texture part of the product can be effectively avoided. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.
[0044] Figure 1 A schematic diagram of a method for detecting appearance defects of a product with irregular texture provided by the present invention;
[0045] Figure 2 A schematic diagram of the modeling process provided by the present invention;
[0046] Figure 3 A schematic diagram of a product provided by the present invention;
[0047] Figure 4 A schematic diagram of the defect detection preprocessing effect provided by the present invention;
[0048] Figure 5 A schematic diagram of the defect misdetection effect of the single-image training model provided by the present invention;
[0049] Figure 6 This is a schematic diagram of the correct defect detection effect provided by the present invention. DETAILED DESCRIPTION
[0050] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0051] The embodiment of the present invention discloses a method for detecting appearance defects of products with irregular textures, such as Figure 1 As shown, the following steps are included:
[0052] S1. Collect N W×H×C good sample images I through the area array camera smp , where W represents the width of the image, H represents the height of the image, and C represents the number of channels of the image;
[0053] S2. In the good sample image I smp Take one as the reference image I ref , extract the function F through edge location e , get the product contour shape positioning template M p , M p =F e (I ref ), product contour shape positioning template M p Used to identify and locate and output the position and contour information of the product;
[0054] S3. Use detection preprocessing function F d For all good sample images I smp Pre-processing, positioning template M by product contour shape p Obtain the position information of good samples and use the affine transformation function F H All positions of good samples are aligned, and then the improved function F is introduced t Train to obtain the good product detection model M g ,like Figure 2 As shown;
[0055] S4. Collect detection image I tst , by locating the preprocessing function F f Pre-process and use the product contour shape to locate the template M p Obtain the target's location information, including coordinates and angles; use the detection preprocessing function F d For the detection image I tst Preprocessing is performed using the affine transformation function F H The preprocessed image is compared with the good product detection model M g Change to the same reference position, compare point by point and select the difference part R as the defect.
[0056] In order to further implement the above technical solution, the edge location extraction function in step S2 includes a location preprocessing function F f and edge extraction operations.
[0057] In order to further implement the above technical solution, the calculation method of the positioning preprocessing function is:
[0058] g'(x, y)=g(x, y)*Mult+Add
[0059]
[0060] Add=-Mult*Add
[0061] Wherein, g(x, y) is the grayscale value at the position (x, y) before preprocessing, g(x, y) is the grayscale value at the position (x, y) after preprocessing, Mult is the scaling factor used to control the contrast, Add is the offset used to control the brightness, GMax and GMin are adjustment factors, and their value range is [0, 255];
[0062] Positioning preprocessing highlights the product contour positioning by adjusting factors; detection preprocessing highlights the difference contrast between the detection image and the template image by adjusting factors.
[0063] In order to further implement the above technical solution, the good product detection model is a threshold tolerance band of the good product sample image, which includes two template threshold maps.
[0064] In order to further implement the above technical solution, the good product detection model contains two template threshold maps:
[0065]
[0066] Among them, f u and f l is the template upper and lower threshold map included in the good product detection model, g k (x, y) is the pixel value of the kth image in the good sample at the pixel point (x, y), is the pixel value of the absolute median difference template at the pixel point (x, y), a u is the upper absolute threshold, a l is the lower absolute threshold, b u is the upper absolute median difference threshold, b l is the lower absolute median difference threshold, the reference threshold a is set to [10,50], and the absolute median difference threshold b is set to [0.3,1.5];
[0067] In this embodiment, multiple good product images are aligned by affine transformation technology, and the grayscale values at the same coordinate position of each image are averaged, that is, the first part of the f(x, y) formula; the absolute median difference of the grayscale values at the same coordinate position of each image is calculated, that is,
[0068] In order to further implement the above technical solution, the method of comparing and screening the difference parts R point by point is as follows:
[0069]
[0070] If the pixel value of the detection image at the (x, y) position is greater than the upper threshold map of the template contained in the good product detection model or less than the lower threshold map, it is a difference position.
[0071] In order to further implement the above technical solution, the affine transformation function is specifically:
[0072]
[0073] Among them, H t (i) is the translation matrix, H r (i) is the rotation matrix;
[0074] The translation matrix is:
[0075]
[0076] The rotation matrix is:
[0077]
[0078] Among them, (x, y) represents the coordinates of the original pixel point of the image to be tested, (x * ,y * ) represents the pixel coordinate position after affine transformation; the (x, y) and (x * ,y * )The grayscale value information is the same.
[0079] In this embodiment, Figure 3 The figure shows the reference image taken from the good sample image, so as to construct the product contour shape positioning template. Figure 4 The image is collected and tested through the detection preprocessing function F d The effect of defect detection preprocessing, where the red marks are glue shortage (above) and dirt (below). The detection results of the preprocessed image using a single image training model are as follows: Figure 5 As shown, there are cases where the texture area of the product is misdetected. The present invention trains the detection model M by using multiple good products. g Thus, defect detection is performed to obtain the correct defect detection effect diagram, such as Figure 6 , which can effectively avoid misdetection of product texture parts.
[0080] An appearance defect detection system for irregular texture products, based on an appearance defect detection method for irregular texture products, comprises: an array camera, a positioning preprocessing module, a detection preprocessing module, a product contour shape positioning template, an affine transformation module, a trained good product detection model and a model training module;
[0081] An area array camera is used to collect N good sample images and inspection images;
[0082] A positioning preprocessing module, used to preprocess a reference image and a detection image selected from a good sample image through a positioning preprocessing function;
[0083] The detection preprocessing module is used to preprocess all good sample images and detection images;
[0084] Product contour shape positioning template, used to identify and output the position and contour information of the product;
[0085] An affine transformation module, used to align all positions of good product samples using an affine transformation function, and to transform the image after preprocessing the inspection image and the good product inspection model to the same reference position using an affine transformation function;
[0086] The trained good product detection model is used to compare point by point to select the difference parts as defects;
[0087] The model training module is used to obtain a good product detection model by introducing improved functional training.
[0088] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements a method for detecting appearance defects of products with irregular textures.
[0089] A processing terminal comprises a memory and a processor. The memory stores a computer program that can be run on the processor. When the processor executes the computer program, a method for detecting appearance defects of products with irregular textures is implemented.
[0090] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.
[0091] The above description of the disclosed embodiments enables one skilled in the art to implement or use the present invention. Various modifications to these embodiments will be apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for detecting appearance defects of products with irregular textures, characterized in that: The following steps are involved: S1. Collect N good sample images through the area array camera; S2. Take one image from the good sample image as the reference image, and obtain the product contour shape positioning template through the edge positioning extraction function. The product contour shape positioning template is used to identify and locate and output the position and contour information of the product; S3. Use the detection preprocessing function to preprocess all good sample images, obtain the position information of the good sample through the product contour shape positioning template, use the affine transformation function to align all positions of the good sample, and then introduce the improved function function training to obtain the good detection model; S4. Collect the detection image, pre-process it through the positioning pre-processing function, and use the product contour shape positioning template to obtain the target location information; The inspection image is preprocessed using the inspection preprocessing function, and the preprocessed image and the good product inspection model are transformed to the same reference position using the affine transformation function. The difference parts are screened out as defects through point-by-point comparison.
2. The method for detecting appearance defects of products with irregular textures according to claim 1, characterized in that: The edge location extraction function in step S2 includes a location preprocessing function F f and edge extraction operations.
3. The method for detecting appearance defects of products with irregular textures according to claim 2, characterized in that: The calculation method of the positioning preprocessing function and the detection preprocessing function is: g′(x,y)=g(x,y)*Mult+Add Add=-Mult*GMin Wherein, g(x, y) is the grayscale value at the position (x, y) before preprocessing, g′(x, y) is the grayscale value at the position (x, y) after preprocessing, Mult is the scaling factor used to control the contrast, Add is the offset used to control the brightness, GMax and GMin are adjustment factors, and their value range is [0, 255]; Positioning preprocessing highlights the product contour positioning by adjusting factors; detection preprocessing highlights the difference contrast between the detection image and the template image by adjusting factors.
4. The method for detecting appearance defects of products with irregular textures according to claim 1, characterized in that: The good product detection model is the threshold tolerance band of the good product sample image, which includes two template threshold maps.
5. The method for detecting appearance defects of products with irregular textures according to claim 1, characterized in that: The two template threshold maps included in the good product detection model are as follows: Among them, f u and f l is the template upper and lower threshold map included in the good product detection model, g k (x, y) is the pixel value of the kth image in the good sample at the pixel point (x, y), is the pixel value of the absolute median difference template at the pixel point (x, y), a u is the upper absolute threshold, a l is the lower absolute threshold, b u is the upper absolute median difference threshold, b l is the lower absolute median difference threshold.
6. The method for detecting appearance defects of products with irregular textures according to claim 5, characterized in that: The method of screening out the difference parts by point-by-point comparison is: If the pixel value of the detection image at the (x, y) position is greater than the upper threshold map of the template contained in the good product detection model or less than the lower threshold map, it is a difference position.
7. The method for detecting appearance defects of products with irregular textures according to claim 1, characterized in that: The affine transformation function is specifically: Among them, H t (i) is the translation matrix, H r (i) is the rotation matrix.
8. An appearance defect detection system for irregular texture products, characterized in that: A method for detecting appearance defects of irregular texture products according to any one of claims 1 to 7, comprising: an area array camera, a positioning preprocessing module, a detection preprocessing module, a product contour shape positioning template, an affine transformation module, a trained good product detection model and a model training module; An area array camera is used to collect N good sample images and inspection images; A positioning preprocessing module, used to preprocess a reference image and a detection image selected from a good sample image through a positioning preprocessing function; The detection preprocessing module is used to preprocess all good sample images and detection images; Product contour shape positioning template, used to identify and output the position and contour information of the product; An affine transformation module, used to align all positions of good product samples using an affine transformation function, and to transform the image after preprocessing the inspection image and the good product inspection model to the same reference position using an affine transformation function; The trained good product detection model is used to compare point by point to select the difference parts as defects; The model training module is used to obtain a good product detection model by introducing improved functional training.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method for detecting appearance defects of a product with irregular texture as described in any one of claims 1 to 7 is implemented.
10. A processing terminal, comprising a memory and a processor, wherein the memory stores a computer program that can be run on the processor, characterized in that: When the processor executes the computer program, the method for detecting appearance defects of a product with irregular texture as described in any one of claims 1 to 7 is implemented.
Citation Information
Cited By
Defect image detection method and device for die cutting product and medium
CN122222921A
A method, apparatus, and medium for detecting a defect image of a die-cut product
CN122222921B