Defect detection method and device, electronic equipment and storage medium

By generating image feature templates from multiple sample images arranged in chronological order, the problem of poor defect detection accuracy in industrial product quality inspection is solved, and higher detection accuracy is achieved.

CN116309499BActive Publication Date: 2026-02-03SHANGHAI LEAD HUINENG TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

Existing technologies have poor defect detection accuracy in industrial product quality inspection and are greatly affected by factors such as light and dust.

Method used

By acquiring the current frame image containing the object to be detected and comparing it with an image feature template generated from multiple sample images arranged in chronological order, the impact of noise is reduced and the accuracy of defect detection is improved.

Benefits of technology

It effectively reduces the noise impact caused by factors such as light and dust, and improves the accuracy of defect detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116309499B_ABST
    Figure CN116309499B_ABST
Patent Text Reader

Abstract

Embodiments of the present application disclose a defect detection method and device, electronic equipment and storage medium. The method comprises: acquiring a current frame image containing a to-be-detected object; comparing the current frame image with at least one image feature template, and determining a defect detection result corresponding to the to-be-detected object according to a comparison result; wherein each image feature template is generated according to a corresponding target sample image sequence, and each group of target sample image sequences comprises a plurality of sample images arranged in a time sequence according to acquisition time, and the sample images comprise objects with defects. By arranging sample images in a time sequence over a period of time to form an image feature template, the embodiments of the present application can reduce the influence of noise caused by factors such as light and dust, so that the image feature template better reflects the characteristics of the objects with defects, thereby improving the accuracy of defect detection on the to-be-detected object.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of industrial detection, in particular to a defect detection method and device, electronic equipment and storage medium. BACKGROUND

[0002] With the continuous development of industrial products, the requirements for quality inspection of industrial products are also getting higher and higher. At present, the defects involved in the quality inspection of industrial products have dozens of categories, such as folding, displacement, scratches, stains, bubbles and the like. As for the defects of each category, they present various forms in visual effect, and the difference between categories and the strong ambiguity within categories are the main difficulties at present. At present, the defect detection of products has the problems of poor precision and the like. SUMMARY

[0003] The embodiments of the present application disclose a defect detection method and device, electronic equipment and storage medium, which can improve the precision of defect detection of products.

[0004] The first aspect of the embodiments of the present application provides a defect detection method, which comprises:

[0005] obtaining a current frame image containing a to-be-detected object;

[0006] comparing the current frame image with at least one image feature template, and determining a defect detection result corresponding to the to-be-detected object according to a comparison result; wherein each image feature template is generated according to a corresponding target sample image sequence, and each group of target sample image sequences comprises a plurality of sample images arranged in the order of acquisition time, and the sample images include objects with defects.

[0007] As an optional implementation, in the first aspect of the embodiments of the present application, the image feature template includes a pixel feature template and a grayscale template.

[0008] The comparison of the current frame image with at least one image feature template and the determination of the defect detection result corresponding to the to-be-detected object according to the comparison result comprise:

[0009] comparing the current frame image with at least one pixel feature template to obtain a first comparison result;

[0010] comparing the current frame image with at least one grayscale template to obtain a second comparison result;

[0011] determining the defect detection result corresponding to the to-be-detected object according to the first comparison result and the second comparison result.

[0012] As an optional implementation, in the first aspect of the embodiment of the present application, the comparing the current frame image with at least one pixel feature template comprises:

[0013] performing pixel feature extraction on the current frame image to obtain a pixel feature map corresponding to the current frame image;

[0014] calculating a feature similarity between the pixel feature map corresponding to the current frame image and at least one pixel feature template;

[0015] comparing the feature similarity between the pixel feature map and each pixel feature template with a similarity threshold to obtain a first comparison result;

[0016] wherein, if the feature similarity between the pixel feature map and a first pixel feature template is greater than the similarity threshold, it indicates that the current frame image matches the first pixel feature template, and the first pixel feature template is any one of the pixel feature templates.

[0017] As an optional implementation, in the first aspect of the embodiment of the present application, the pixel feature template comprises a local binary pattern (LBP) feature template generated according to a corresponding target sample image sequence;

[0018] the performing pixel feature extraction on the current frame image to obtain a pixel feature map corresponding to the current frame image comprises:

[0019] performing pixel feature extraction on the current frame image by using an LBP algorithm to obtain an LBP feature map corresponding to the current frame image.

[0020] As an optional implementation, in the first aspect of the embodiment of the present application, the comparing the current frame image with at least one pixel feature template comprises:

[0021] converting the current frame image into a gray image to obtain a current frame gray image;

[0022] determining a pixel difference value between a pixel value of each pixel point in the current frame gray image and a pixel value of a corresponding pixel point in a first gray template; the first gray template is any one of the gray templates;

[0023] counting a number of pixel points with a corresponding pixel difference value greater than a difference threshold in the current frame gray image to obtain a deviation result corresponding to the first gray template;

[0024] comparing the deviation result corresponding to each gray template with a deviation threshold to obtain a second comparison result;

[0025] If the deviation result corresponding to the first gray scale template is greater than the deviation threshold, it indicates that the current frame image matches the first gray scale template.

[0026] As an optional implementation, in the first aspect of the embodiment of the present application, the determining of the defect detection result corresponding to the object to be detected according to the comparison result comprises:

[0027] determining a first number of the pixel feature templates matching the current frame image according to the first comparison result, and determining a second number of the gray scale templates matching the current frame image according to the second comparison result;

[0028] determining a first defect score according to the first number;

[0029] determining a second defect score according to the second number;

[0030] determining the defect detection result corresponding to the object to be detected according to the first defect score and the second defect score.

[0031] As an optional implementation, in the first aspect of the embodiment of the present application, before comparing the current frame image with at least one image feature template, the method further comprises:

[0032] obtaining an initial sample image sequence of an object with a defect collected in a time period, the initial sample image sequence comprising a plurality of sample images arranged in order of collection time;

[0033] determining a first target sample image sequence corresponding to a first sample image in the initial sample image sequence, and selecting a plurality of sample images from the initial sample image sequence according to a fixed frame interval to obtain the first target sample image sequence, the first target sample image sequence being any target sample image sequence;

[0034] generating M image feature templates corresponding to N groups of target sample image sequences; N and M are positive integers, and M is greater than or equal to N.

[0035] As an optional implementation, in the first aspect of the embodiment of the present application, the image feature template comprises an LBP feature template.

[0036] The generating of the M image feature templates corresponding to the N groups of target sample image sequences comprises:

[0037] extracting features of each sample image in the second target sample image sequence by using the LBP algorithm to obtain an LBP feature map corresponding to each sample image in the second target sample image sequence; the second target sample image sequence is any target sample image sequence;

[0038] generating an LBP feature template corresponding to the second target sample image sequence according to the LBP feature map corresponding to each sample image in the second target sample image sequence.

[0039] As an optional implementation, in the first aspect of the embodiment of the present application, the image feature template includes a grayscale template;

[0040] The generating of the M image feature templates corresponding to the N groups of target sample image sequences includes:

[0041] converting sample images in a third target sample image sequence into grayscale images, the third target sample image sequence being any target sample image sequence;

[0042] generating a grayscale template corresponding to the third target sample image sequence according to the grayscale images corresponding to the sample images in the third target sample image sequence.

[0043] The second aspect of the embodiment of the present application provides a defect detection device, and the device includes:

[0044] an image acquisition module, configured to acquire a current frame image containing a to-be-detected object;

[0045] a defect detection module, configured to compare the current frame image with at least one image feature template and determine a defect detection result corresponding to the to-be-detected object according to a comparison result; each image feature template is generated according to a corresponding target sample image sequence, and each group of target sample image sequences includes a plurality of sample images arranged in a time sequence, and the sample images include objects with defects.

[0046] The third aspect of the embodiment of the present application provides an electronic device including a memory and a processor, and the memory stores a computer program, and the computer program is executed by the processor to enable the processor to implement any defect detection method disclosed in the embodiment of the present application.

[0047] The fourth aspect of the embodiment of the present application provides a computer readable storage medium storing a computer program, and the computer program is executed by a processor to implement any defect detection method disclosed in the embodiment of the present application.

[0048] Compared with the related art, the embodiment of the present application has the following beneficial effects:

[0049] A current frame image containing an object to be detected is acquired, and then the current frame image is compared with at least one image feature template, and whether the object to be detected has a defect is determined according to a comparison result. Each image feature template compared with the current frame image is generated according to a corresponding target sample image sequence, and each set of target sample image templates includes a plurality of sample images arranged in a time sequence. The sample images arranged in the time sequence are used to generate the image feature template, which can reduce the noise caused by factors such as light and dust, so that the image feature template better reflects the characteristics of the object with defects, thereby improving the accuracy of defect detection on the object to be detected. BRIEF DESCRIPTION OF DRAWINGS

[0050] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed in the embodiments will be briefly introduced as follows. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor on the basis of these drawings.

[0051] Figure 1 FIG. 1 is a schematic diagram of an application scenario of a defect detection method disclosed in an embodiment;

[0052] Figure 2 FIG. 2 is a schematic diagram of a method flow of a defect detection method disclosed in an embodiment;

[0053] Figure 3 FIG. 3 is a schematic diagram of a method flow of another defect detection method disclosed in an embodiment;

[0054] Figure 4 FIG. 4 is a schematic diagram of a method flow of still another defect detection method disclosed in an embodiment;

[0055] Figure 5 FIG. 5 is a schematic diagram of a method flow of yet another defect detection method disclosed in an embodiment;

[0056] Figure 6 FIG. 6 is a schematic diagram of a structure of a defect detection device disclosed in an embodiment;

[0057] Figure 7 FIG. 7 is a schematic diagram of a structure of an electronic device disclosed in an embodiment. DETAILED DESCRIPTION

[0058] With reference to the drawings of the embodiments of the present application, the technical solutions in the embodiments of the present application will be clearly and completely described. Obviously, the described embodiments are only a part of the embodiments of the present application, but not all the embodiments of the present application. Based on the embodiments of the present application, all the other embodiments obtained by those of ordinary skill in the art without creative work fall within the scope of the present application.

[0059] It should be noted that the terms "comprising" and "having" and any variations thereof in the embodiments of the present application and the drawings are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device including a series of steps or units is not limited to the listed steps or units, but can optionally further include steps or units not listed, or can optionally further include other steps or units inherent to the process, method, product or device.

[0060] The existing curve detection technology generally compares the image of the industrial product to be detected with the pre-acquired image of the industrial product with defects to determine whether there is a defect. However, due to the influence of light, dust and dust in front of the camera, the pre-acquired image has a lot of noise, resulting in poor defect detection accuracy.

[0061] The embodiments of the present application disclose a defect detection method, device, electronic equipment and storage medium, which can improve the accuracy of defect detection of products. The following are described in detail.

[0062] Please refer to Figure 1 , Figure 1 is an application scenario diagram of a defect detection method disclosed in an embodiment. As shown in Figure 1 , it can include an electronic device 10, an object to be detected 20 and an image acquisition device 30. The electronic device 10 can be equipped with a processor, but is not limited thereto. The electronic device 10 can be in communication connection with the image acquisition device 30. The image acquisition device 30 can be arranged on an industrial product quality inspection station. The image acquisition device 30 can pre-acquire a plurality of sample images containing defects of the object, and send the sample images to the electronic device 10. The electronic device 10 constructs a plurality of target sample image sequences according to the plurality of sample images arranged in the order of acquisition time, and then generates one or more image feature templates according to the target sample image sequences. In the defect detection process, the electronic device 10 acquires a current frame image containing the object to be detected, and compares the current frame image with at least one image feature template, and determines the defect detection result of the object to be detected according to the comparison result. The current frame image containing the object to be detected can be acquired by the image acquisition device 30.

[0063] Please refer to Figure 2 , Figure 2Fig. 1 is a schematic diagram of a method flow of a defect detection method according to an embodiment of the present application, which can be applied to the electronic device 10 described above. As shown in Fig. 1, the method can include the following steps: Figure 2

[0064] 210, obtaining a current frame image containing an object to be detected.

[0065] In the embodiments of the present application, the electronic device obtains a current frame image containing an object to be detected. The object to be detected can be imaged by an image acquisition device outside the electronic device to obtain the current frame image, and the current frame image can be sent to the electronic device connected by communication; or the object to be detected can be imaged by an image acquisition component arranged on the electronic device to obtain the current frame image. The current frame image is an image used to reflect the object to be detected to determine whether the object to be detected has a defect.

[0066] 220, comparing the current frame image with at least one image feature template, and determining a defect detection result corresponding to the object to be detected according to a comparison result; wherein each image feature template is generated according to a corresponding target sample image sequence, and each group of target sample image sequences includes a plurality of sample images arranged in order of acquisition time, and the sample images include objects with defects.

[0067] In the embodiments of the present application, the electronic device compares the obtained current frame image with at least one image feature template. The image feature template is a template image reflecting the characteristics of the object with defects. The image feature template can be generated by the electronic device in advance. Each image feature template is generated according to a corresponding target sample image sequence, and each image feature template can correspond to a target sample image sequence. The target sample image sequence is an image set composed of a plurality of sample images arranged in order of acquisition time. The sample images in the target sample image sequence contain objects with defects. The objects with defects in the sample images are of the same type as the object to be detected, for example, the object to be detected is a battery cell, and the sample images include battery cells with defects. In addition, the defects of the objects in the sample images can be one or more of folding, displacement, scratches, bubbles, stains, etc., which are not limited here.

[0068] ​In the embodiments of the present application, the electronic device determines whether the to-be-detected object has a defect according to a comparison result of the current frame image and the at least one image feature template. If the current frame image is compared with one image feature template, the electronic device determines whether the to-be-detected object has a defect according to a comparison result of the current frame image and the image feature template. If the current frame image is compared with at least two image feature templates, the electronic device can determine whether the to-be-detected object has a defect according to comparison results of the current frame image and each image feature.

[0069] By using the above embodiments, the image feature template is made by arranging the target sample images in time sequence in a period of time, which can reduce the noise influence caused by light, dust and other factors, so that the image feature template better reflects the characteristics of the object with a defect, thereby improving the accuracy of defect detection on the to-be-detected object.

[0070] In one embodiment, please refer to Figure 3 , Figure 3 is a method flowchart of another defect detection method disclosed in an embodiment, which can be applied to the electronic device 10 described above. As shown in Figure 3 , the method can include the following steps:

[0071] 310, acquiring an initial sample image sequence of the object with a defect collected in a period of time, the initial sample image sequence including multiple sample images arranged in time sequence according to the collection time.

[0072] In the embodiments of the present application, before the electronic device compares the current frame image with the at least one image feature template, or before the electronic device acquires the current frame image corresponding to the to-be-detected object to perform defect detection on the to-be-detected object, the electronic device can continuously collect the object with a defect in a period of time to obtain multiple sample images containing the object with a defect, and the multiple sample images are arranged in time sequence according to the collection time. The multiple sample images form an initial sample image sequence.

[0073] 320, determining a first sample image corresponding to a first target sample image sequence in the initial sample image sequence, and selecting multiple sample images from the initial sample image sequence according to a fixed frame interval to obtain the first target sample image sequence, the first target sample image sequence being any target sample image sequence.

[0074] In the embodiments of the present application, for any one target sample image sequence, that is, the first target sample image sequence, the electronic device can determine the first frame sample image corresponding to the first target sample image sequence in the initial sample image sequence, and then select sample images from the initial sample image sequence at a fixed frame interval, and the selected multiple frames of sample images constitute the first target sample image sequence. Since the sample images in the initial sample image sequence are arranged in the order of acquisition time, and the selection of sample images from the initial sample image sequence for constructing the first target sample image sequence does not change the arrangement order of the sample images, the sample images in the first target sample image sequence are also arranged in the order of acquisition time. In this way, at least one target sample image sequence is obtained. If the number of target sample image sequences is more than 2 groups, the number of sample images included in each group of target sample image sequences can be the same or different.

[0075] For example, the electronic device obtains 100 frames of sample images of the object with defects in advance, and the 100 frames of sample images constitute an initial sample image sequence. The electronic device needs to construct 3 groups of target sample image sequences in advance, namely sequence 1, sequence 2 and sequence 3. The first frame sample image of the target sample image sequence of sequence 1 is the first frame of sample image; the first frame sample image of the target sample image sequence of sequence 2 is the second frame of sample image; the first frame sample image of the target sample image sequence of sequence 3 is the third frame of sample image; and the target sample image sequences of sequence 1, sequence 2 and sequence 3 are all selected from the initial sample image sequence at a frame interval of 3 frames, and the obtained target sample image sequence of sequence 1 is [1, 4, 7, 10, …, 97, 100]; the obtained target sample image sequence of sequence 2 is [2, 5, 8, 11, …, 98]; and the obtained target sample image sequence of sequence 3 is [3, 6, 9, 12, …, 99].

[0076] In some embodiments, after obtaining the initial sample image sequence, the electronic device can select a preset number of sample images from the initial sample image sequence to constitute a to-be-selected sample image sequence.

[0077] The electronic device determines the first frame sample image corresponding to the first target sample image sequence in the to-be-selected sample image sequence, and selects multiple frames of sample images from the to-be-selected sample image sequence at a fixed frame interval to obtain the first target sample image sequence.

[0078] For example, the preset frame number is 99 frames, and the initial sample image sequence includes 200 sample images. The electronic device can select the first 99 sample images from the initial sample image sequence to form the to-be-selected sample image sequence, or select the last 99 sample images from the initial sample image sequence to form the to-be-selected sample image sequence, or select 99 sample images from the first sample image in the initial sample image sequence according to a frame interval of 2 frames to form the to-be-selected sample image sequence, or randomly select 99 sample images from the initial sample image sequence and arrange them in the order of acquisition time to form the to-be-selected sample image sequence. Then, the sample images are selected from the to-be-selected sample image sequence according to the first target sample image sequence formation manner to form at least one target sample image sequence.

[0079] According to the above embodiment, the electronic device can preliminarily select sample images from the initial sample image sequence according to different selection manners according to the preset frame number to form the to-be-selected sample image sequence, and select sample images from the to-be-selected sample image sequence to form at least one target sample image sequence, which can reduce the calculation amount when the target sample image sequence is generated, and can preliminarily screen the initial sample image sequence to avoid poor sample image effects in the target sample image sequence.

[0080] 330. Generate M image feature templates corresponding to the N target sample image sequences; N and M are positive integers, and M is greater than or equal to N.

[0081] In the embodiments of the present application, after the electronic device generates N target image sequences, the electronic device can generate M image feature templates according to the N target sample image sequences. For each target sample image sequence, the electronic device can perform an image feature extraction operation on each sample image in the target sample image sequence, and merge each sample image after image feature extraction to obtain an image feature map, which is the image feature template corresponding to the target sample image sequence. In addition, M is greater than N. The electronic device can generate multiple image feature templates according to a target sample image sequence, and the generated image feature templates are all image feature templates corresponding to the target sample image sequence.

[0082] Using the above embodiments, based on an initial sample image sequence arranged chronologically over a period of time, sample images are selected at certain frame intervals to construct a target sample image sequence. Corresponding image feature templates are then generated based on this target sample image sequence. This reduces the noise impact caused by factors such as lighting and dust, allowing the image feature templates to better reflect the characteristics of the defective object, thereby improving the accuracy of defect detection. Furthermore, the electronic device generates M image feature templates (M > N) from N sets of target image sequences, which reduces computational load while increasing defect detection accuracy.

[0083] 340. Obtain the current frame image containing the object to be detected.

[0084] 350. Compare the current frame image with at least one image feature template, and determine the defect detection result corresponding to the object to be detected based on the comparison result.

[0085] In one embodiment, see Figure 4 , Figure 4 This is a schematic flowchart of another defect detection method disclosed in one embodiment. This method can be applied to the aforementioned electronic device 10. The image feature template includes a pixel feature template and a grayscale template. For example... Figure 4 As shown, the method may include the following steps:

[0086] 410. Obtain an initial sample image sequence collected for a defective object within a time period. The initial sample image sequence includes multiple frames of sample images arranged in chronological order of collection time.

[0087] 420. Determine the first frame sample image corresponding to the first target sample image sequence in the initial sample image sequence, and select multiple frame sample images from the initial sample image sequence at fixed frame intervals to obtain the first target sample image sequence, wherein the first target sample image sequence is any target sample image sequence.

[0088] 430. Generate K corresponding pixel feature templates based on K sets of target sample image sequences; K is a positive integer.

[0089] In this embodiment, after selecting several frames of sample images from an initial sample image sequence to generate multiple sets of target sample image sequences, the electronic device can select K sets of target sample image sequences based on different image feature extraction methods. Based on these K sets, the electronic device generates pixel feature templates corresponding to each set of target sample image sequences, resulting in K pixel feature templates. Specifically, for each of the K sets of target sample image sequences, the electronic device can perform feature extraction operations on each pixel in each frame of the sequence to obtain a sample image with extracted pixel features. Then, the electronic device merges the sample images with extracted pixel features from each frame to obtain a pixel feature map, which is the pixel feature template corresponding to the target sample image sequence.

[0090] In some embodiments, the pixel feature template can be a Local Binary Patterns (LBP) feature template.

[0091] The specific process of generating the corresponding LBP feature template in the step of generating K pixel feature templates based on K sets of target sample image sequences by an electronic device may include the following steps:

[0092] The LBP algorithm in Local Binary Pattern is used to extract features from each frame of the second target sample image sequence to obtain the LBP feature map corresponding to each frame of the second target sample image sequence; the second target sample image sequence is any sequence of target sample images.

[0093] Based on the LBP feature map corresponding to each frame of the second target sample image sequence, an LBP feature template corresponding to the second target sample image sequence is generated.

[0094] In this embodiment, for any set of target sample image sequences, namely the second target sample image sequence, the electronic device can first use the LBP algorithm to perform feature extraction processing on each frame of the target sample image sequence to obtain the LBP feature map corresponding to each frame of the second target sample image sequence. Then, the electronic device can determine the LBP feature map corresponding to the second target sample image sequence based on the LBP feature map corresponding to each frame of the second target sample image sequence. This LBP feature map is the LBP feature template corresponding to the second target sample image sequence.

[0095] To obtain the LBP feature map corresponding to each frame of sample images, the LBP operator (neighborhood size) can be defined as a 3x3 region or other larger irregular region. The center pixel value is used as a threshold, and the pixel values ​​in its neighborhood are compared with the threshold. If the neighborhood pixel value is greater than or equal to the threshold, it is marked as 1; otherwise, it is marked as 0. Starting from the top-left pixel, rotate clockwise and compare each pixel with the threshold sequentially to obtain an 8-bit binary number (all 0s and 1s). Convert this binary number to decimal; the decimal number should be between 0 and 255. Save this decimal number as the pixel value of the center point of the window. After traversing the entire frame of sample images, a new image is obtained, which is the LBP feature map corresponding to the sample image.

[0096] The electronic device determines the LBP feature map corresponding to the second target sample image sequence based on the LBP feature map corresponding to each frame of the second target sample image sequence, so as to obtain the LBP feature template corresponding to the second target sample image sequence. This can be achieved by the electronic device performing average feature processing on each LBP feature map corresponding to each frame of the second target sample image sequence. In other words, each LBP feature in each LBP feature map is averaged to obtain the LBP feature map after feature averaging. This LBP feature map is the LBP feature map corresponding to the second target sample image sequence.

[0097] The electronic device determines the LBP feature map corresponding to the second target sample image sequence based on the LBP feature map corresponding to each frame of the second target sample image sequence to obtain the LBP feature template corresponding to the second target sample image sequence. Alternatively, the electronic device can filter the LBP feature map based on the LBP features in each LBP feature map corresponding to each frame of the second target sample image sequence, and perform averaging on each LBP feature in the filtered LBP feature map to obtain the LBP feature map after feature averaging. This LBP feature map is the LBP feature map corresponding to the second target sample image sequence.

[0098] The electronic device determines the LBP feature map corresponding to the second target sample image sequence based on the LBP feature map corresponding to each frame of the second target sample image sequence to obtain the LBP feature template corresponding to the second target sample image sequence. Alternatively, the electronic device performs feature fusion processing on each LBP feature in each LBP feature map according to the preset weight corresponding to each LBP feature map in the second target sample image sequence, and obtains the LBP feature map after feature fusion processing. This LBP feature map is the LBP feature map corresponding to the second target sample image sequence.

[0099] Using the above embodiments, since LBP features are illumination-invariant and rotation-invariant, using LBP feature maps as image feature templates can well adapt to the effects of different illumination and micro-jitter changes, thereby improving the accuracy of subsequent defect detection.

[0100] 440. Generate L corresponding grayscale templates based on L sets of target sample image sequences; L is a positive integer.

[0101] In this embodiment, depending on the image feature extraction method, the electronic device can select K sets of target sample image sequences from the initial sample image sequence to generate pixel feature templates corresponding to the K sets of target sample image sequences. Simultaneously, it can also select L sets of target sample image sequences from the initial sample image sequence and generate grayscale templates corresponding to each set of target sample image sequences based on the L sets of target sample image sequences, thus obtaining grayscale templates. The target sample image sequences corresponding to the K pixel feature templates generated by the electronic device can be the same as the target sample image sequences corresponding to the L grayscale feature templates.

[0102] For a sequence of L target sample images, the electronic device can perform grayscale feature extraction operations on each frame of the sample image in each group of target sample image sequences to obtain a sample image with extracted grayscale features. Then, the electronic device merges the sample images with extracted grayscale features from each frame to obtain a grayscale feature map, which is the grayscale feature template corresponding to the target sample image sequence.

[0103] In some embodiments, the specific process of generating the corresponding grayscale templates in the step of generating L corresponding grayscale templates based on L sets of target sample image sequences by an electronic device may include the following steps:

[0104] Convert the sample images in the third target sample image sequence into grayscale images. The third target sample image sequence can be any target sample image sequence.

[0105] Generate a grayscale template corresponding to the third target sample image sequence based on the grayscale image corresponding to the sample image in the third target sample image sequence.

[0106] In this embodiment, for any set of target sample image sequences, namely the third target sample image sequence, the electronic device can convert each frame of the target sample image sequence into a grayscale image, thereby obtaining the grayscale image corresponding to each frame of the third target sample image sequence. Then, the electronic device can determine the grayscale image corresponding to the third target sample image sequence based on the grayscale image corresponding to each frame of the third target sample image sequence; this grayscale image is the grayscale template corresponding to the third target sample image sequence.

[0107] To obtain the grayscale image corresponding to each frame of sample image, the electronic device can calculate the grayscale value of each pixel based on the RGB value of each pixel in the sample image using methods such as floating-point method, integer method, shift method, average method, green-only method, or gamma correction algorithm, thereby obtaining the grayscale image corresponding to each frame of sample image.

[0108] The electronic device determines the grayscale image corresponding to the third target sample image sequence based on the grayscale image corresponding to each frame of the third target sample image sequence, so as to obtain the grayscale template corresponding to the third target sample image sequence. This can be achieved by the electronic device performing grayscale averaging on each grayscale image, that is, averaging the grayscale value of each pixel in each grayscale image to obtain the grayscale image after grayscale averaging, which is the grayscale image corresponding to the third target sample image sequence.

[0109] The electronic device determines the grayscale image corresponding to the third target sample image sequence based on the grayscale image corresponding to each frame of the third target sample image sequence to obtain the grayscale template corresponding to the third target sample image sequence. Alternatively, the electronic device can filter the grayscale images based on the grayscale values ​​contained in each grayscale image, and perform average processing on the grayscale values ​​of each pixel in the filtered grayscale images. The final grayscale image obtained is the grayscale image corresponding to the third target sample image sequence.

[0110] The electronic device determines the grayscale image corresponding to the third target sample image sequence based on the grayscale image corresponding to each frame of the third target sample image sequence to obtain the grayscale template corresponding to the third target sample image sequence. Alternatively, the electronic device can perform a fusion process based on the grayscale image corresponding to each frame of the third target sample image sequence, according to the preset weight corresponding to each grayscale image, combining the grayscale value of each pixel in each grayscale image with the corresponding preset weight, to obtain the fused grayscale image, which is the grayscale image corresponding to the third target sample image sequence.

[0111] Using the above embodiments, since grayscale images only reflect brightness and do not reflect color changes, using grayscale images as image feature templates can well adapt to the effects of different color changes and improve the accuracy of subsequent defect detection.

[0112] 450. Obtain the current frame image containing the object to be detected.

[0113] 460. Compare the current frame image with at least one pixel feature template to obtain the first comparison result.

[0114] 470. Compare the current frame image with at least one grayscale template to obtain a second comparison result.

[0115] In this embodiment, since the image feature template includes at least a pixel feature template and a grayscale template, after the electronic device acquires the current frame image containing the object to be detected, it compares the current frame image with at least one pixel feature template to obtain a first comparison result; and compares the current frame image with at least one grayscale template to obtain a second comparison result.

[0116] For the specific method of comparing the current frame image with the pixel feature template, multiple similarity intervals can be preset, with each similarity interval corresponding to a first comparison result. The electronic device calculates the similarity between the current frame image and a pixel feature template, and obtains the first comparison result with that pixel feature template based on the similarity interval in which the similarity value lies. If comparing with multiple pixel feature templates, the average of the obtained multiple similarities is taken, and the first comparison result is determined based on the similarity interval in which the average similarity value lies.

[0117] The specific method for comparing the current frame image with the grayscale template can also be pre-defined by multiple similarity intervals, each corresponding to a second comparison result. The electronic device calculates the similarity between the current frame image and a grayscale template, and obtains the second comparison result with that grayscale template based on the similarity interval in which the similarity value lies. If comparing with multiple grayscale templates, the average of the multiple similarities is taken, and the second comparison result is determined based on the similarity interval in which the average similarity value lies.

[0118] 480. Based on the first comparison result and the second comparison result, determine the defect detection result corresponding to the object to be tested.

[0119] In this embodiment of the application, the electronic device determines the detection result corresponding to the object to be detected based on a first comparison result between the current frame image and at least one pixel feature template, and based on a second comparison result between the current frame image and at least one grayscale template.

[0120] For example, the first comparison result has three possibilities: no defect, possibly defective, and defective; the second comparison result also has three possibilities: no defect, possibly defective, and defective. Accordingly, based on the first comparison result and the second comparison result, nine defect detection scenarios are preset: 1. If both the first and second comparison results are "no defect," then the detection result is "no defect"; 2. If both the first and second comparison results are "no defect" and "possibly defective," then the detection result is "no defect"; 3. If both the first and second comparison results are "no defect" and "defective," then the detection result is "defective"; 4. If both the first and second comparison results are "possibly defective" and "no defect," then the detection result is "no defect"; 5. If both the first and second comparison results are "possibly defective," then the detection result is "defective"; 6. If both the first and second comparison results are "possibly defective," then the detection result is "defective"; 7. If both the first and second comparison results are "defective" and "no defect," then the detection result is "defective"; 8. If both the first and second comparison results are "defective" and "possibly defective," then the detection result is "defective"; 9. If both the first and second comparison results are "defective," then the detection result is "defective." Based on the aforementioned preset conditions, the electronic device can determine the defect detection status of the object to be tested based on the first comparison result and the second comparison result.

[0121] Using the above embodiments, the image feature template includes a pixel feature template and a grayscale template. Based on the comparison results between the current frame image and these two templates, the defect detection status of the current frame image is determined. This enables the determination of whether the object to be detected has defects from multiple different aspects, thereby improving the accuracy of defect detection.

[0122] In one embodiment, see Figure 5 , Figure 5 This is a schematic flowchart of another defect detection method disclosed in one embodiment. This method can be applied to the aforementioned electronic device 10. The image feature template includes a pixel feature template and a grayscale template. For example... Figure 5 As shown, the method may include the following steps:

[0123] 501. Obtain the current frame image containing the object to be detected.

[0124] 502. Extract pixel features from the current frame image to obtain the pixel feature map corresponding to the current frame image.

[0125] 503. Calculate the feature similarity between the pixel feature map corresponding to the current frame image and at least one pixel feature template.

[0126] 504. Compare the feature similarity between the pixel feature map and each pixel feature template with a similarity threshold to obtain the first comparison result. Wherein, if the feature similarity between the pixel feature map and the first pixel feature template is greater than the similarity threshold, it indicates that the current frame image matches the first pixel feature template, where the first pixel feature template is any pixel feature template.

[0127] In this embodiment, after acquiring a current frame image containing the object to be detected, the electronic device can extract pixel features from the current frame image to obtain a pixel feature map corresponding to the current frame image. Then, the electronic device can calculate the feature similarity between the pixel feature map corresponding to the current frame image and each pixel template, and compare the obtained feature similarity with a preset similarity threshold to obtain a first comparison result between the current frame image and the pixel feature template. Specifically, the electronic device can compare the pixel features in the pixel feature map corresponding to the current frame image with the pixel features in the pixel feature template to determine whether they match; then, the feature similarity between the current frame image and the pixel feature template is determined based on the number of matching pixel features.

[0128] Furthermore, for any pixel feature template, namely the first pixel feature template, if the feature similarity between the pixel feature map corresponding to the current frame image and the first pixel feature template is greater than the similarity threshold, then the electronic device can determine that the current frame image matches the first pixel feature template; if the feature similarity between the pixel feature map corresponding to the current frame image and the first pixel feature template is less than or equal to the similarity threshold, then the electronic device can determine that the current frame image does not match the first pixel feature template.

[0129] Using the above embodiments, the similarity between the pixel feature map corresponding to the current frame image and the pixel feature template is compared with a set similarity threshold to determine the first comparison result. This first comparison result can better reflect the situation between the current frame image and the pixel feature template, thereby improving the accuracy of subsequent defect detection and judgment.

[0130] In some embodiments, the pixel feature template includes a Local Binary Pattern (LBP) feature template generated based on the corresponding target sample image sequence.

[0131] The step of an electronic device extracting pixel features from the current frame image to obtain a pixel feature map corresponding to the current frame image may include the following steps:

[0132] The LBP algorithm in Local Binary Mode is used to extract pixel features from the current frame image to obtain the LBP feature map corresponding to the current frame image.

[0133] The step of an electronic device calculating the feature similarity between a pixel feature map corresponding to the current frame image and at least one pixel feature template may include the following steps:

[0134] Calculate the feature similarity between the LBP feature map corresponding to the current frame image and at least one LBP feature template;

[0135] The step of an electronic device comparing the feature similarity between a pixel feature map and each pixel feature template with a similarity threshold to obtain a first comparison result may include the following steps:

[0136] The feature similarity between the LBP feature map and each LBP feature template is compared with a similarity threshold to obtain the first comparison result.

[0137] In this embodiment, the pixel feature template is specifically an LBP feature template. After acquiring the current frame image corresponding to the object to be detected, the electronic device uses the LBP algorithm to extract LBP features from the current frame image to obtain the LBP feature map corresponding to the current frame image. Then, the electronic device calculates the feature similarity between the LBP feature map corresponding to the current frame image and the LBP feature template, and compares the feature similarity with a similarity threshold. If the feature similarity between the LBP feature map corresponding to the current frame image and the first LBP feature template is greater than the similarity threshold, then the electronic device can determine that the current frame image matches the first LBP feature template; if the feature similarity between the LBP feature map corresponding to the current frame image and the first LBP feature template is less than or equal to the similarity threshold, then the electronic device can determine that the current frame image does not match the first LBP feature template. The first LBP feature template can be any LBP feature template.

[0138] Using the above embodiments, since LBP features are illumination-invariant and rotation-invariant, using LBP feature maps as image feature templates can well adapt to the effects of different illumination and micro-jitter changes. Furthermore, through the above comparison method, the first comparison result can well reflect the situation between the current frame image and the LBP feature template, thereby improving the accuracy of subsequent defect detection and judgment.

[0139] In some embodiments, the step of the electronic device performing the calculation of the feature similarity between the LBP feature map corresponding to the current frame image and at least one LBP feature template, and comparing the feature similarity between the LBP feature map and each LBP feature template with a similarity threshold to obtain a first comparison result may include:

[0140] The electronic device calculates the cosine distance between the LBP feature map corresponding to the current frame image and at least one LBP feature template, and compares the cosine distance between the LBP feature map and each LBP feature template with a cosine distance threshold to obtain a first comparison result.

[0141] In this embodiment, the pixel feature template is specifically an LBP feature template. After acquiring the current frame image corresponding to the object to be detected, the electronic device uses the LBP algorithm to extract LBP features from the current frame image to obtain the LBP feature map corresponding to the current frame image. Then, the electronic device calculates the cosine distance between the LBP feature map corresponding to the current frame image and the LBP feature template, and compares the cosine distance with a cosine distance threshold. If the cosine distance between the LBP feature map corresponding to the current frame image and the first LBP feature template is greater than the cosine distance threshold, the electronic device can determine that the current frame image matches the first LBP feature template; if the cosine distance between the LBP feature map corresponding to the current frame image and the first LBP feature template is less than or equal to the cosine distance threshold, the electronic device can determine that the current frame image does not match the first LBP feature template. The first LBP feature template can be any LBP feature template.

[0142] Using the above embodiments, cosine distance is used as the similarity evaluation standard, which can better reflect the relationship between the current frame image and the LBP feature template, thereby improving the accuracy of defect detection.

[0143] 505. Convert the current frame image to a grayscale image to obtain the current frame grayscale image.

[0144] 506. Determine the pixel value of each pixel in the current frame grayscale image and the pixel value of the corresponding pixel in the first grayscale template; the first grayscale template can be any grayscale template.

[0145] 507. Count the number of pixels in the current frame grayscale image whose corresponding pixel difference is greater than the difference threshold, so as to obtain the deviation result corresponding to the first grayscale template.

[0146] 508. Compare the deviation results corresponding to each grayscale template with the deviation threshold to obtain a second comparison result. Wherein, if the deviation result corresponding to the first grayscale template is greater than the deviation threshold, it indicates that the current frame image matches the first grayscale template.

[0147] In this embodiment, after acquiring a current frame image containing the object to be detected, the electronic device converts the current frame image into a grayscale image to obtain a grayscale image of the current frame. However, if the current frame image is already in grayscale format, the electronic device may not need to perform the grayscale conversion.

[0148] The electronic device can calculate the difference between the pixel value (or grayscale value) of each pixel in the current frame's grayscale image and the pixel value (or grayscale value) of the corresponding pixel in each grayscale template, thus obtaining the pixel difference. The electronic device compares each pixel difference with a preset difference threshold to count the number of pixels whose pixel difference is greater than the threshold. Based on this number of pixels, the deviation result of the first grayscale template is determined. The electronic device then compares the deviation result of the grayscale template with a preset deviation threshold to obtain a second comparison result between the current frame image and the grayscale template. The electronic device can preset multiple pixel number intervals, each corresponding to a deviation value. Based on the number of pixels whose pixel difference is greater than the difference threshold, the electronic device determines the interval containing the pixel number, and thus determines the deviation value of the grayscale template, comparing the deviation value of the grayscale template with the deviation threshold.

[0149] Furthermore, for any grayscale template, namely the first grayscale template, if the deviation of the first grayscale template is determined to be greater than the similarity threshold based on the number of pixels between the current frame grayscale image and the first grayscale template, then the electronic device can determine that the current frame image matches the first grayscale template; if the feature similarity between the grayscale image corresponding to the current frame image and the first grayscale template is less than or equal to the similarity threshold, then the electronic device can determine that the current frame image does not match the first grayscale template.

[0150] Using the above embodiment, the pixel value of each pixel in the grayscale image of the current frame after conversion is compared with the pixel value of the corresponding pixel in the grayscale template to determine the deviation between the current frame grayscale image and the grayscale template. Then, the deviation is compared with the deviation threshold to determine the second comparison result between the current frame image and the grayscale template. This second comparison result can better reflect the situation between the current frame image and the grayscale template, thereby improving the accuracy of subsequent defect detection and judgment.

[0151] In some embodiments, the step of the electronic device counting the number of pixels in the current frame grayscale image whose corresponding pixel difference is greater than a difference threshold to obtain the deviation result corresponding to the first grayscale template, and comparing the deviation result corresponding to each grayscale template with the deviation threshold to obtain the second comparison result, may include:

[0152] The electronic device iterates through the pixels in the current frame's grayscale image, calculates the area of ​​regions where the pixel difference is greater than a difference threshold, and obtains the deviation area corresponding to the first grayscale template. The deviation area corresponding to each grayscale template is then compared with an area threshold to obtain a second comparison result. If the deviation area corresponding to the first grayscale template is greater than the area threshold, it indicates that the current frame image matches the first grayscale template.

[0153] In this embodiment, the area of ​​the region where the corresponding pixel difference is greater than the difference threshold can more accurately reflect the deviation between the current frame grayscale image and the grayscale template, thereby improving the accuracy of subsequent defect detection and judgment.

[0154] 509. Determine a first number of pixel feature templates that match the current frame image based on the first comparison result, and determine a second number of grayscale templates that match the current frame image based on the second comparison result.

[0155] 510. Determine the first defect score based on the first quantity; determine the second defect score based on the second quantity.

[0156] 511. Determine the defect detection result corresponding to the object to be inspected based on the first defect score and the second defect score.

[0157] For example, there are two pixel feature templates, template a and template b, and three grayscale templates, template c, template d, and template e. The electronic device obtains the following results: a first comparison between the current frame image and template a shows a match; a first comparison between the current frame image and template b shows a mismatch; a second comparison between the current frame image and template c shows a match; a second comparison between the current frame image and template d shows a match; and a second comparison between the current frame image and template e shows a mismatch. If the current frame image matches a template, 1 point is awarded; if it does not match, 0 points are awarded. Therefore, the electronic device can determine the first defect score as 1 point and the second defect score as 2 points. The score threshold is 3 points. If the sum of the first and second defect scores is greater than or equal to 3 points, the object to be detected is considered to have a defect; if the sum of the first and second defect scores is less than 3 points, the object to be detected is considered not to have a defect. Thus, the electronic device can determine that the object to be detected has a defect.

[0158] In addition, after obtaining the first and second quantities, the electronic device can determine a first score and a second score based on the quantity ranges in which the first and second quantities fall. Then, the electronic device combines these scores with preset first and second weights, respectively, to determine the defect detection result corresponding to the object to be detected based on the combined score.

[0159] By using the above embodiments, it is possible to determine whether the object to be tested has defects based on the voting score method, thereby improving the rationality of defect determination.

[0160] Please see Figure 6 , Figure 6 This is a schematic diagram of a defect detection device disclosed in one embodiment, which can be applied to electronic device 10. For example...Figure 6 As shown, the defect detection device 600 may include an image acquisition module 610 and a defect detection module 620.

[0161] Image acquisition module 610 acquires the current frame image containing the object to be detected;

[0162] The defect detection module 620 is used to compare the current frame image with at least one image feature template and determine the defect detection result corresponding to the object to be detected based on the comparison result; wherein, each image feature template is generated based on the corresponding target sample image sequence, and each set of target sample image sequences includes multiple frames of sample images arranged in chronological order of acquisition time, and the sample images include objects with defects.

[0163] In some embodiments, the image feature template includes a pixel feature template and a grayscale template.

[0164] The defect detection module 620 is also used for:

[0165] The current frame image is compared with at least one pixel feature template to obtain a first comparison result;

[0166] The current frame image is compared with at least one grayscale template to obtain a second comparison result;

[0167] Based on the first comparison result and the second comparison result, the defect detection result corresponding to the object to be tested is determined.

[0168] In some embodiments, the defect detection module 620 is further configured to:

[0169] Pixel features are extracted from the current frame image to obtain the pixel feature map corresponding to the current frame image;

[0170] Calculate the feature similarity between the pixel feature map corresponding to the current frame image and at least one pixel feature template;

[0171] The feature similarity between the pixel feature map and each pixel feature template is compared with a similarity threshold to obtain the first comparison result;

[0172] If the feature similarity between the pixel feature map and the first pixel feature template is greater than the similarity threshold, it indicates that the current frame image matches the first pixel feature template, where the first pixel feature template is any pixel feature template.

[0173] In some embodiments, the pixel feature template includes a Local Binary Pattern (LBP) feature template generated based on the corresponding target sample image sequence.

[0174] The defect detection module 620 is also used for:

[0175] The LBP algorithm in Local Binary Mode is used to extract pixel features from the current frame image to obtain the LBP feature map corresponding to the current frame image.

[0176] Calculate the feature similarity between the LBP feature map corresponding to the current frame image and at least one LBP feature template;

[0177] The feature similarity between the LBP feature map and each LBP feature template is compared with a similarity threshold to obtain the first comparison result.

[0178] In some embodiments, the defect detection module 620 is further configured to:

[0179] Convert the current frame image to a grayscale image to obtain the current frame grayscale image;

[0180] Determine the pixel difference between the pixel value of each pixel in the current frame's grayscale image and the pixel value of the corresponding pixel in the first grayscale template; the first grayscale template can be any grayscale template.

[0181] Count the number of pixels in the current frame's grayscale image whose pixel difference is greater than the difference threshold, in order to obtain the deviation result corresponding to the first grayscale template;

[0182] The deviation results corresponding to each grayscale template are compared with the deviation threshold to obtain a second comparison result;

[0183] If the deviation result corresponding to the first grayscale template is greater than the deviation threshold, it indicates that the current frame image matches the first grayscale template.

[0184] In some embodiments, the defect detection module 620 is further configured to:

[0185] A first number of pixel feature templates matching the current frame image is determined based on the first comparison result, and a second number of grayscale templates matching the current frame image is determined based on the second comparison result.

[0186] The first defect score is determined based on the first quantity;

[0187] The second defect score is determined based on the second quantity;

[0188] The defect detection result corresponding to the object to be inspected is determined based on the first defect score and the second defect score.

[0189] In some embodiments, Figure 6 The defect detection device shown also includes:

[0190] The template acquisition module 630 is used to acquire an initial sample image sequence collected within a time period for a defective object before comparing the current frame image with at least one image feature template. The initial sample image sequence includes multiple frames of sample images arranged in chronological order of acquisition time.

[0191] The first frame sample image corresponding to the first target sample image sequence is determined in the initial sample image sequence, and multiple frames of sample images are selected from the initial sample image sequence at fixed frame intervals to obtain the first target sample image sequence, where the first target sample image sequence is any target sample image sequence.

[0192] M image feature templates are generated based on N sets of target sample image sequences; N and M are positive integers, and M is greater than or equal to N.

[0193] In some embodiments, the image feature template includes a Local Binary Pattern (LBP) feature template.

[0194] Template retrieval module 630 is also used for:

[0195] After obtaining multiple sets of target sample image sequences, feature extraction processing is performed on each frame of the second target sample image sequence using the LBP algorithm to obtain the LBP feature map corresponding to each frame of the second target sample image sequence; the second target sample image sequence can be any target sample image sequence.

[0196] Based on the LBP feature map corresponding to each frame of the second target sample image sequence, an LBP feature template corresponding to the second target sample image sequence is generated.

[0197] In some embodiments, the image feature template includes a grayscale template.

[0198] Template retrieval module 630 is also used for:

[0199] After obtaining multiple sets of target sample image sequences, the sample images in the third target sample image sequence are converted into grayscale images. The third target sample image sequence is any target sample image sequence.

[0200] Generate a grayscale template corresponding to the third target sample image sequence based on the grayscale image corresponding to the sample image in the third target sample image sequence.

[0201] Please see Figure 7 , Figure 7 This is a schematic diagram of the structure of an electronic device disclosed in one embodiment. For example... Figure 7 As shown, the electronic device 700 may include:

[0202] Memory 710 storing executable program code;

[0203] Processor 720 coupled to memory 710;

[0204] The processor 720 calls the executable program code stored in the memory 710 to execute any of the defect detection methods disclosed in the embodiments of this application.

[0205] This application discloses a computer-readable storage medium storing a computer program that causes a computer to execute any of the defect detection methods disclosed in this application.

[0206] This application discloses a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program, and the computer program is operable to cause a computer to execute any of the defect detection methods disclosed in this application.

[0207] It should be understood that the phrase "one embodiment" or "an embodiment" throughout the specification means that a specific feature, structure, or characteristic related to the embodiment is included in at least one embodiment of this application. Therefore, "in one embodiment" or "in an embodiment" appearing throughout the specification does not necessarily refer to the same embodiment. Furthermore, these specific features, structures, or characteristics can be combined in any suitable manner in one or more embodiments. Those skilled in the art should also recognize that the embodiments described in the specification are optional embodiments, and the actions and modules involved are not necessarily essential to this application.

[0208] In the various embodiments of this application, it should be understood that the sequence number of each process does not necessarily imply the order of execution. The execution order of each process should be determined by its function and inherent strategy, and should not constitute any limitation on the implementation process of the embodiments of this application.

[0209] The units described above as separate components may or may not be physically separate. The components shown as units may or may not be physical units; they can be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0210] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0211] If the aforementioned integrated units are implemented as software functional units and sold or used as independent products, they can be stored in a computer-accessible memory. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a memory and includes several requests to cause a computer device (which can be a personal computer, server, or network device, specifically a processor in the computer device) to execute some or all of the steps of the methods described in the various embodiments of this application.

[0212] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be implemented by a program instructing related hardware. The program can be stored in a computer-readable storage medium, including read-only memory (ROM), random access memory (RAM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), one-time programmable read-only memory (OTPROM), electrically-Erasable Programmable Read-Only Memory (EEPROM), compact disc read-only memory (CD-ROM) or other optical disc storage, disk storage, magnetic tape storage, or any other computer-readable medium capable of carrying or storing data.

[0213] The foregoing has provided a detailed description of a defect detection method, apparatus, electronic device, and storage medium disclosed in the embodiments of this application. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the embodiments above are merely for the purpose of helping to understand the method and its core ideas. Furthermore, those skilled in the art will recognize that, based on the ideas of this application, there will be changes in the specific implementation methods and application scope. Therefore, the content of this specification should not be construed as a limitation of this application.

Claims

1. A defect detection method, characterized in that, The method includes: Get the current frame image containing the object to be detected; The current frame image is compared with at least one image feature template, and the defect detection result corresponding to the object to be detected is determined based on the comparison result; wherein each image feature template is generated based on the corresponding target sample image sequence, and each set of target sample image sequences includes multiple frames of sample images arranged in chronological order of acquisition time, and the sample images include objects with defects; The image feature template includes a pixel feature template and a grayscale template; The step of comparing the current frame image with at least one image feature template and determining the defect detection result corresponding to the object to be detected based on the comparison result includes: The current frame image is compared with at least one of the pixel feature templates to obtain a first comparison result; The current frame image is compared with at least one of the grayscale templates to obtain a second comparison result; Based on the first comparison result and the second comparison result, the defect detection result corresponding to the object to be detected is determined; Before comparing the current frame image with at least one image feature template, the method further includes: Acquire an initial sample image sequence collected over a period of time for a defective object, the initial sample image sequence comprising multiple frames of sample images arranged in chronological order of acquisition time; The first frame sample image corresponding to the first target sample image sequence is determined in the initial sample image sequence, and multiple frames of sample images are selected from the initial sample image sequence at fixed frame intervals to obtain the first target sample image sequence, wherein the first target sample image sequence is any of the target sample image sequences. M corresponding image feature templates are generated based on the N sets of target sample image sequences; N and M are positive integers, and M is greater than or equal to N.

2. The method according to claim 1, characterized in that, The step of comparing the current frame image with at least one of the pixel feature templates includes: Pixel features are extracted from the current frame image to obtain the pixel feature map corresponding to the current frame image; Calculate the feature similarity between the pixel feature map corresponding to the current frame image and at least one of the pixel feature templates; The feature similarity between the pixel feature map and each pixel feature template is compared with a similarity threshold to obtain a first comparison result; Wherein, if the feature similarity between the pixel feature map and the first pixel feature template is greater than the similarity threshold, it indicates that the current frame image matches the first pixel feature template, and the first pixel feature template is any of the pixel feature templates.

3. The method according to claim 2, characterized in that, The pixel feature template includes a Local Binary Pattern (LBP) feature template generated based on the corresponding target sample image sequence; The step of extracting pixel features from the current frame image to obtain the pixel feature map corresponding to the current frame image includes: The LBP algorithm is used to extract pixel features from the current frame image to obtain the LBP feature map corresponding to the current frame image.

4. The method according to claim 2, characterized in that, The step of comparing the current frame image with at least one of the grayscale templates includes: Convert the current frame image into a grayscale image to obtain the current frame grayscale image; Determine the pixel difference between the pixel value of each pixel in the current frame grayscale image and the pixel value of the corresponding pixel in the first grayscale template; the first grayscale template can be any of the aforementioned grayscale templates. The number of pixels in the current frame grayscale image whose pixel difference is greater than the difference threshold is counted to obtain the deviation result corresponding to the first grayscale template. The deviation results corresponding to each grayscale template are compared with the deviation threshold to obtain a second comparison result; Wherein, if the deviation result corresponding to the first grayscale template is greater than the deviation threshold, it indicates that the current frame image matches the first grayscale template.

5. The method according to any one of claims 1 to 4, characterized in that, The step of determining the defect detection result corresponding to the object to be detected based on the comparison result includes: Based on the first comparison result, a first number of pixel feature templates matching the current frame image are determined, and based on the second comparison result, a second number of grayscale templates matching the current frame image are determined. The first defect score is determined based on the first quantity; The second defect score is determined based on the second quantity; The defect detection result corresponding to the object to be detected is determined based on the first defect score and the second defect score.

6. The method according to claim 1, characterized in that, The image feature template includes an LBP feature template; The step of generating M corresponding image feature templates based on the N sets of target sample image sequences includes: The LBP algorithm is used to extract features from each frame of the second target sample image sequence to obtain the LBP feature map corresponding to each frame of the second target sample image sequence; the second target sample image sequence can be any of the target sample image sequences. Based on the LBP feature map corresponding to each frame of the second target sample image sequence, an LBP feature template corresponding to the second target sample image sequence is generated.

7. The method according to claim 1, characterized in that, The image feature template includes a grayscale template; The step of generating M corresponding image feature templates based on the N sets of target sample image sequences includes: Convert the sample images in the third target sample image sequence into grayscale images, wherein the third target sample image sequence is any of the target sample image sequences; A grayscale template corresponding to the third target sample image sequence is generated based on the grayscale image corresponding to the sample image in the third target sample image sequence.

8. A defect detection device, characterized in that, The device includes: The image acquisition module acquires the current frame image containing the object to be detected; The defect detection module is used to compare the current frame image with at least one image feature template, and determine the defect detection result corresponding to the object to be detected based on the comparison result; wherein, each image feature template is generated based on the corresponding target sample image sequence, and each set of target sample image sequences includes multiple frames of sample images arranged in chronological order of acquisition time, and the sample images include objects with defects; The image feature template includes a pixel feature template and a grayscale template; The defect detection module is further configured to compare the current frame image with at least one of the pixel feature templates to obtain a first comparison result; compare the current frame image with at least one of the grayscale templates to obtain a second comparison result; and determine the defect detection result corresponding to the object to be detected based on the first comparison result and the second comparison result. The template acquisition module is used to acquire an initial sample image sequence collected within a time period for a defective object. The initial sample image sequence includes multiple frames of sample images arranged in chronological order of acquisition time. The module determines the first frame sample image corresponding to a first target sample image sequence from the initial sample image sequence and selects multiple frames of sample images from the initial sample image sequence at fixed frame intervals to obtain the first target sample image sequence, where the first target sample image sequence is any of the target sample image sequences. The module generates M corresponding image feature templates based on N sets of the target sample image sequences, where N and M are positive integers, and M is greater than or equal to N.

9. An electronic device, characterized in that, The method includes a memory and a processor, wherein the memory stores a computer program that, when executed by the processor, causes the processor to perform the method as described in any one of claims 1 to 7.

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

Citation Information

Patent Citations

  • Automatic classification method and system for panel production and manufacturing defects

    CN111160432A