Detection method and device, electronic equipment and readable storage medium
By acquiring registered images under multiple exposure conditions and calculating the similarity, the appropriate threshold is determined, which solves the problem of product misjudgment caused by inaccurate thresholds in the existing technology and achieves accurate product detection.
Patent Information
- Application Number
- CN202511324879.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-17
- Publication Date
- 2025-10-21
- Estimated Expiration
- 2045-09-17
AI Technical Summary
In the prior art, the detection system has the problem of incorrect product judgment due to artificially set thresholds.
By acquiring registered images under multiple exposure conditions, calculating the similarity to determine the appropriate threshold, and combining the similarity of the image to be detected, accurate judgment of product type can be achieved.
It is possible to determine the appropriate threshold value based on the actual situation of the products on the production line, accurately judge the product type, and reduce the possibility of human misjudgment.
Smart Images

Figure CN120823205A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of image technology, and in particular relates to a detection method, device, electronic device and readable storage medium. Background Art
[0002] Currently, inspection systems for products on production lines capture images of the products, analyze them, and then determine their condition based on thresholds. However, these thresholds are manually set, leading to errors in product determination. Summary of the Invention
[0003] The embodiments of the present application provide a detection method, device, electronic device, and readable storage medium, which can solve the problem of product judgment errors caused by inaccurate thresholds.
[0004] In a first aspect, the present invention provides a detection method, comprising: In response to a first user operation, obtaining a first registration image under at least two exposure conditions, where the first registration image includes an image area of a qualified product, and the at least two exposure conditions include an optimal exposure condition and at least one candidate exposure condition, where the candidate exposure condition is determined based on the optimal exposure condition, and each candidate exposure condition has different parameters; In response to a second operation by the user, obtaining a second registration image under at least two exposure conditions, where the second registration image is a background image that does not include the product; calculating a first similarity between the first registration image and the second registration image under each exposure condition; determining a first threshold value according to the first similarity of each of the exposure conditions; Acquire a first image to be detected; Calculating a second similarity between the first image to be detected and the first registration image; The detection type to which the first to-be-detected image belongs is determined according to the first threshold and the second similarity.
[0005] In a second aspect, an embodiment of the present application provides a detection device, comprising: a processing module configured to, in response to a first user operation, obtain a first registration image under at least two exposure conditions, wherein the first registration image includes an image area of a qualified product, and the at least two exposure conditions include an optimal exposure condition and at least one candidate exposure condition, wherein the candidate exposure condition is determined based on the optimal exposure condition, and each candidate exposure condition has different parameters; further configured to obtain, in response to a second operation by the user, a second registration image under at least two exposure conditions, where the second registration image is a background image that does not include the product; a detection calculation module, configured to calculate a first similarity between the first registration image and the second registration image under each exposure condition; further configured to determine a first threshold value according to the first similarity of each of the exposure conditions; A detection and evaluation module, configured to obtain a first image to be detected; further configured to calculate a second similarity between the first image to be detected and the first registration image; It is also used to determine the detection type to which the first image to be detected belongs based on the first threshold and the second similarity.
[0006] In a third aspect, an embodiment of the present application provides an electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the method described in any one of the first aspects above is implemented.
[0007] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method as described in any one of the above-mentioned first aspects is implemented.
[0008] In a fifth aspect, an embodiment of the present application provides a computer program product, which, when executed on an electronic device, enables the electronic device to execute any one of the methods described in the first aspect above.
[0009] Compared with the prior art, the embodiments of the present application have the following beneficial effects: The embodiment of the present application obtains a first registration image under at least two exposure conditions in response to a first operation of the user, where the first registration image includes an image area of a qualified product; obtains a second registration image under at least two exposure conditions in response to a second operation of the user, where the second registration image is a background image that does not include the product; calculates a first similarity between the first registration image and the second registration image under each exposure condition; determines a first threshold value based on the first similarity of each exposure condition; is able to determine a suitable threshold value based on the actual situation of the product on the production line, providing a basis for accurately determining the type of the product, and obtains a first image to be detected; calculates a second similarity between the first image to be detected and the first registration image; and determines the detection type to which the first image to be detected belongs based on the first threshold value and the second similarity, thereby accurately judging the situation of the product.
[0010] It can be understood that the beneficial effects of the second to fifth aspects mentioned above can be found in the relevant description of the first aspect mentioned above, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the embodiments or descriptions of the prior art. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0012] Figure 1 This is a schematic diagram of a first flow chart of a detection method provided in one embodiment of the present application; Figure 2 is an example diagram of an initial image provided by an embodiment of the present application; Figure 3 This is a first example diagram of the first registration diagram provided in one embodiment of the present application; Figure 4 This is a second example diagram of the first registration diagram provided in one embodiment of the present application; Figure 5 is an example diagram of a first image to be detected provided by an embodiment of the present application; Figure 6 This is a second flow chart of the detection method provided in one embodiment of the present application; Figure 7 This is a third example diagram of the first registration diagram provided in one embodiment of the present application; Figure 8 This is a first example diagram of the second registration diagram provided in one embodiment of the present application; Figure 9 This is a first example diagram of the third registration diagram provided in one embodiment of the present application; Figure 10 This is a first example image of the second image to be detected provided in one embodiment of the present application; Figure 11 is a second example image of a second image to be detected provided in an embodiment of the present application; Figure 12 This is a fourth example diagram of the first registration diagram provided in one embodiment of the present application; Figure 13 This is a second example diagram of the second registration diagram provided in one embodiment of the present application; Figure 14 This is a second example diagram of the third registration diagram provided in one embodiment of the present application; Figure 15 This is a third example image of the second image to be detected provided in one embodiment of the present application; Figure 16 This is a fourth example image of the second image to be detected provided in an embodiment of the present application; Figure 17 This is the fifth example diagram of the first registration diagram provided in one embodiment of the present application; Figure 18 This is a third example diagram of the second registration diagram provided in one embodiment of the present application; Figure 19 This is a third example diagram of the third registration diagram provided in one embodiment of the present application; Figure 20 This is a fifth example image of the second image to be detected provided in one embodiment of the present application; Figure 21 This is a sixth example image of the second image to be detected provided in an embodiment of the present application; Figure 22 This is a first example diagram of a detection situation provided by an embodiment of the present application; Figure 23 This is a second example diagram of a detection situation provided by an embodiment of the present application; Figure 24 is a structural diagram of a detection device provided in one embodiment of the present application; Figure 25 It is a structural diagram of an electronic device provided in one embodiment of the present application. DETAILED DESCRIPTION
[0013] In the following description, specific details such as specific system structures and techniques are provided for purposes of illustration rather than limitation to facilitate a thorough understanding of the embodiments of the present application. However, it will be apparent to those skilled in the art that the present application may be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to avoid obscuring the description of the present application with unnecessary detail.
[0014] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, integers, steps, operations, elements and / or components, but does not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or collections thereof.
[0015] It will also be understood that the term "and / or" used in this specification and the appended claims refers to and includes any and all possible combinations of one or more of the associated listed items.
[0016] As used in this specification and the appended claims, the term "if" can be interpreted as "when" or "upon" or "in response to determining" or "in response to detecting," depending on the context. Similarly, the phrase "if it is determined" or "if [described condition or event] is detected" can be interpreted as meaning "upon determination" or "in response to determining" or "upon detection of [described condition or event]" or "in response to detecting [described condition or event]," depending on the context.
[0017] In addition, in the description of the present application specification and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.
[0018] References to "one embodiment" or "some embodiments" in this specification mean that a particular feature, structure, or characteristic described in conjunction with that embodiment is included in one or more embodiments of the present application. Thus, phrases such as "in one embodiment," "in some embodiments," "in other embodiments," and "in other embodiments" appearing in various places in this specification do not necessarily refer to the same embodiment, but rather mean "one or more but not all embodiments," unless otherwise specifically emphasized. The terms "including," "comprising," "having," and variations thereof all mean "including but not limited to," unless otherwise specifically emphasized.
[0019] In one embodiment, Figure 1 As shown, the method includes: S11: In response to a first operation of the user, obtaining a first registration image under at least two exposure conditions.
[0020] The first registration image includes an image area of a qualified product, and the at least two exposure conditions include an optimal exposure condition and at least one candidate exposure condition. The candidate exposure condition is determined based on the optimal exposure condition, and the parameters of each candidate exposure condition are different.
[0021] In a possible implementation, step S11 includes: S111: In response to a first operation of the user, an initial image of a qualified product is captured.
[0022] In the application, the user places a qualified product in the shooting area of the camera device, clicks "register", and instructs the camera device to perform a shooting operation. In response to the user's first operation, the electronic device controls the camera device to capture an initial image of the qualified product.
[0023] Among them, products include workpieces, components, parts, etc.
[0024] S112: Extracting an image area of a qualified product from the initial image, and adjusting the brightness of the image area of the qualified product to a target brightness, to obtain a first registration image with an optimal exposure condition.
[0025] In applications, insufficient initial image clarity can affect subsequent feature extraction. However, adjusting the overall image brightness fails to distinguish the product from the background, hindering its prominence and resulting in poor extraction of the product's image area. Therefore, image brightness is adjusted without using the product and background brightness as feedback, and without introducing background brightness as interference. Instead, the product's position in the initial image is identified. Then, based on the brightness of the image area of qualified products as feedback, the exposure conditions are adjusted to bring the brightness of the qualified product's image area to the target brightness. Once the target brightness is reached, the exposure conditions are optimized and the first registration map of the optimal exposure conditions is obtained. The exposure conditions can be exposure time.
[0026] In one possible implementation, the method for locating products is the gradient method. The gradient calculation obtains the gradient amplitude of each pixel point in the image, and then uses an adaptive method to filter out some gradients to obtain the larger gradient of the product edge. The image area of the workpiece can be determined by the gradient of the closed edge.
[0027] The target brightness is determined based on a brightness that can better display product details. For example, the target brightness is 128.
[0028] As shown in the figure, Figure 2 In order to include the initial image of the qualified product, the qualified product in the initial image is not clear enough and the details are not obvious enough, so the initial image is adjusted. Figure 3 This is the first registration image. The brightness of the qualified product in the first registration image is the target brightness, the details are obvious, and the regional image of the qualified product is distinguishable from the background.
[0029] S113: Determine at least one candidate exposure condition based on the optimal exposure condition.
[0030] In practice, while optimal brightness is achieved to highlight product details, it may be affected by external lighting. Calibration is performed by examining images from multiple exposure conditions, selecting the exposure condition with the least external influence. This results in an exposure condition that is resistant to external interference and maintains stable detection. Exposure conditions near the optimal exposure condition are selected to obtain at least one candidate exposure condition.
[0031] The optimal exposure condition may be an optimal exposure time, and a preset number of exposure times lower than the optimal exposure time and a preset number of exposure conditions higher than the optimal exposure time are selected to obtain candidate exposure times from dark to bright.
[0032] For example, the preset number is four. The formula for calculating the maximum and minimum values is: , n is the nth exposure time, a = 2.8561, b = 0.3, Tmin is the minimum exposure time, Tmax is the maximum exposure time, and Tbest is the optimal exposure time. a and b are empirically determined. The formula for calculating candidate exposure times is: (Tbest / 2.8561) / 0.3 + (n-1)(Tbest / 2.8561). The first candidate exposure time is: (Tbest / 2.8561), the second candidate exposure time is: (Tbest / 2.8561) / 0.3 + (Tbest / 2.8561), and so on to obtain the desired exposure time. The optimal exposure time is 864us. According to the formula, we can get (1) 302us, (2) 393us, (3) 511us, (4) 664us, (5) 864us, (6) 1123us, (7) 1459us, (8) 1896us, and (9) 1896us. Due to the setting of the minimum exposure time and the maximum exposure time, the exposure time (9) is limited to 1896us.
[0033] S114: For each candidate exposure condition, collect images of qualified products to obtain a first registration image of the candidate exposure condition.
[0034] In the application, after obtaining the candidate exposure conditions, the shooting device performs a shooting operation to collect the first registration image of each candidate exposure condition.
[0035] S12: In response to a second operation of the user, obtaining a second registration image under at least two exposure conditions.
[0036] The second registration image is a background image that does not include the product.
[0037] In the app, the user removes a qualified product from the camera's capture area and clicks "Register," instructing the camera to capture the product. In response to the user's second operation, the electronic device controls the camera to capture images excluding the product under each exposure condition, obtaining a second registration image for each exposure condition.
[0038] In one possible implementation, the user can adjust the shooting area of the camera device, which can reduce the possibility of adjusting the position of the camera device due to changes in product types.
[0039] S13: Calculating a first similarity between the first registration image and the second registration image under each exposure condition.
[0040] In a possible implementation, step S13 includes: S131: For each exposure condition, extract first features of the first registration image and the second registration image.
[0041] In the application, for each exposure condition, the first and second registration images are differentially processed. The background information of the first registration image is removed, and the position of qualified products is located using a gradient algorithm. The image area of the qualified products is extracted, and the features of the qualified products in the first registration image are extracted to obtain the first feature of the first registration image. The image features of the second registration image are extracted to obtain the first feature of the second registration image.
[0042] Among them, the first feature includes features of different dimensions, including contour features, brightness features, edge point features, etc., so as to stably and accurately detect the condition of the product.
[0043] S132: For each first feature, calculate a first feature similarity between the first feature of the first registration image and the first feature of the second registration image, and determine a weight of the first feature according to the first feature similarity.
[0044] In applications, if the feature dimensions of each first feature are the same or different, and all first features are given the same weight, or highly similar first features are mistakenly assigned high weights, the overall similarity between the first and second registration images will be inaccurate. Therefore, by increasing the weights of second features with low similarity and decreasing the weights of second features with high similarity, this intelligently assigns feature weights, amplifying defects and differences. This allows detection of defects, rotational changes, and other conditions, ensuring stable and accurate classification of qualified products.
[0045] For example, the first features are feature 1 and feature 2. The weight of feature 1 = (preset maximum similarity - first feature similarity of feature 1) / (preset maximum similarity - first feature similarity of feature 1) + (preset maximum similarity - first feature similarity of feature 2).
[0046] S133: Determine a first similarity based on the weight of each first feature and the first feature similarity.
[0047] In the application, the first feature similarities are weighted and summed to obtain the first similarity.
[0048] S14: Determine a first threshold according to the first similarity of each exposure condition.
[0049] In the application, an average fluctuation similarity of each exposure condition is determined based on the first similarity of each exposure condition. A target exposure condition is selected from each exposure condition, with both the smallest possible first similarity and the smallest possible average fluctuation similarity. A first threshold is determined based on the first similarity of the target exposure condition.
[0050] Specifically, each exposure condition is sorted according to its parameters to obtain a sorted exposure condition sequence; in the sorted exposure condition sequence, for each exposure condition, the similarity difference between the first similarity of the exposure condition and the first similarity of the adjacent exposure condition is calculated, and the average fluctuation similarity is determined according to each similarity difference; based on the first similarity and the average fluctuation similarity of each exposure condition, a target exposure condition is determined, and the target exposure condition is that the first similarity is less than a fifth threshold and the average fluctuation similarity is less than a sixth threshold, the fifth threshold is determined based on the first third number of smallest first similarities, and the sixth threshold is determined based on the first fourth number of smallest average fluctuation similarities; the second threshold is determined based on the first similarity of the target exposure condition.
[0051] In a possible implementation, a formula for calculating the first threshold is: first threshold=(first similarity of target exposure condition+preset highest similarity) / 2.
[0052] S15: Acquire a first image to be detected.
[0053] In the application, the inspection and evaluation is entered, and the camera device performs a shooting operation, collects images of the shooting area, obtains the first image to be inspected, and realizes the inspection of products on the production line.
[0054] S16: Calculate a second similarity between the first image to be detected and the first registration image.
[0055] In the application, features of the first image to be detected and the first registration image are extracted. For each feature, similarity is calculated between the feature of the first image to be detected and the feature of the first registration image. Weights are calculated based on the similarities of each feature, and a second similarity is determined based on the similarities of each feature and the weights.
[0056] In one possible implementation, the entire image is used as the scoring area using the holistic method to extract the features of the first image to be detected. Figure 4 This is the first registered image of the noodle category. Figure 5 This is the first image of the noodle type to be tested. In practice, the placement of noodles on the production line can easily change, resulting in significant differences in the spacing between noodles compared to the first registered image. This difference in shape can lead to inaccurate positioning. Therefore, a holistic approach uses the entire image as the scoring area.
[0057] S17: Determine the detection type to which the first to-be-detected image belongs according to the first threshold and the second similarity.
[0058] In an application, when the second similarity is greater than or equal to the first threshold, it is determined that the product to be inspected in the first image to be inspected is a qualified product.
[0059] When the second similarity is less than the first threshold, it is determined that the first image to be detected is a background image.
[0060] It should be noted that a threshold is calculated based on the first and second registration images. This threshold is used to determine whether the product in the first image to be inspected is a qualified product or whether the product is absent and represents a background image. This detection method uses a two-point tuning mode. The two-point tuning mode registers two images. Because the images are sampled based on a surface, the product lies within a single plane. Varying product positions between captures do not affect detection. This mode can detect the presence of a product using features such as brightness, even in situations where the background is clean and stable, the product's shape may vary significantly, or the product's posture is prone to rotation or not. Because the presence of a product is detected, the presence of the product is not detected. Rotated products can be inspected directly, allowing for simultaneous detection of any orientation defects.
[0061] This embodiment obtains a first registration image under at least two exposure conditions in response to a first operation of the user, where the first registration image includes an image area of a qualified product; obtains a second registration image under at least two exposure conditions in response to a second operation of the user, where the second registration image is a background image that does not include the product; calculates a first similarity between the first registration image and the second registration image under each exposure condition; determines a first threshold value based on the first similarity of each exposure condition; is able to determine a suitable threshold value based on the actual situation of the product on the production line, providing a basis for accurately determining the type of the product, and obtains a first image to be detected; calculates a second similarity between the first image to be detected and the first registration image; and determines the detection type to which the first image to be detected belongs based on the first threshold value and the second similarity, thereby accurately judging the situation of the product.
[0062] In one embodiment, Figure 6 As shown, the method further includes: S21: In response to a third operation of the user, obtaining a third registration image under at least two exposure conditions.
[0063] The third registration image includes an image area of unqualified products.
[0064] In the app, the user places a non-conforming product in the camera's capture area and clicks "Register," instructing the camera to capture the product. In response to the user's third operation, the electronic device captures images of the non-conforming product under each exposure condition, obtaining a third registration image for each exposure condition.
[0065] Among them, unqualified products are products that belong to the same category as qualified products but are unqualified, or products that do not belong to the same category as qualified products, so that subsequent testing can detect whether the product to be tested is an unqualified product or a product of another category.
[0066] S22: Calculating a third similarity between the first registration image and the third registration image under each exposure condition.
[0067] In one possible embodiment, step S22 includes: S221: For each exposure condition, extract the second features of qualified products in the first registration image and the second features of unqualified products in the third registration image.
[0068] In the application, for each exposure condition, the third registration image is differentially processed with the second registration image. The background information of the third registration image is removed, and a gradient algorithm is used to locate the position of the defective products. The image area of the defective products is extracted, and the second feature of the defective products in the third registration image is extracted. Similarly, the second feature of the qualified products in the first registration image is extracted.
[0069] Among them, the second feature includes features of different dimensions, including contour features, brightness features, edge point features, etc., so as to stably and accurately detect the product situation.
[0070] S222: For each second feature, calculate the second feature similarity between the second feature of the qualified product and the second feature of the unqualified product, and determine the weight of the second feature according to the second feature similarity.
[0071] In the application, for each second feature, the similarity of the second feature between qualified products and unqualified products is calculated to obtain the second feature similarity.
[0072] If the feature dimensions of each second feature are different or the same, and all second features have the same weight, or highly similar second features are mistakenly assigned high weights, the overall similarity between the first and third registration images will be inaccurate. For example, when there are minor defects, highly similar second features will make it impossible to distinguish between unqualified and qualified products, resulting in a high overall similarity between unqualified and qualified products, making it impossible to stably distinguish between the two. Therefore, by increasing the weight of low-similarity second features and decreasing the weight of highly similar second features, intelligently assigning feature weights, amplifying defects and differences, and being able to detect defects, rotational changes, and other situations, to achieve stable and accurate classification of qualified and unqualified products.
[0073] For example, the second features are feature 1, feature 2, feature 3, feature 4, and feature 5. The second feature similarity of feature 1 is 400, the second feature similarity of feature 2 is 1000, the second feature similarity of feature 3 is 200, the second feature similarity of feature 3 is 900, and the second feature similarity of feature 4 is 600. 1000 is the preset highest similarity.
[0074] The weight of feature 1 is (1000-400) / ((1000-400)+(1000-1000)+(1000-200)+(1000-900)+(1000-600))=0.32%. Similarly, the weight of feature 2 is 0%, the weight of feature 3 is 0.42%, and the weight of feature 4 is 0.05%, with a total weight of 0.21%. Since the highly similar feature 2 cannot distinguish between qualified and unqualified products, feature 2 is intelligently deleted by assigning it a weight of 0%, improving detection stability.
[0075] S223: Determine a third similarity based on the weight of each second feature and the second feature similarity.
[0076] In the application, the weighted sum of the second feature similarities is performed to obtain the third similarity.
[0077] For example, the third similarity = (weight of feature 1 × second feature similarity of feature 1) + (weight of feature 2 × second feature similarity of feature 2) + (weight of feature 3 × second feature similarity of feature 3) + (weight of feature 4 × second feature similarity of feature 4) + (weight of feature 5 × second feature similarity of feature 5).
[0078] S23: Determine a second threshold according to the third similarity of each exposure condition.
[0079] In a possible implementation, step S23 includes: S231: Sort the exposure conditions according to their parameters to obtain a sorted exposure condition sequence.
[0080] For example, sorting from dark to bright, the exposure condition sequence after sorting is obtained: (1) 302us, (2) 393us, (3) 511us, (4) 664us, (5) 864us, (6) 1123us, (7) 1459us, (8) 1896us, (9) 1896us.
[0081] S232: In the sorted exposure condition sequence, for each exposure condition, calculate a similarity difference between the third similarity of the exposure condition and the third similarity of an adjacent exposure condition, and determine an average fluctuation similarity based on each similarity difference.
[0082] In the application, for each exposure condition, a similarity difference between the exposure condition and two adjacent exposure conditions is calculated, and the average fluctuation similarity of the exposure condition is determined based on the two similarity differences.
[0083] For example, the third similarity of exposure condition 1 is 550, the third similarity of exposure condition 2 is 500, the third similarity of exposure condition 3 is 450, the third similarity of exposure condition 4 is 500, the third similarity of exposure condition 5 is 550, the third similarity of exposure condition 6 is 650, the third similarity of exposure condition 7 is 300, the third similarity of exposure condition 8 is 400, and the third similarity of exposure condition 9 is 700. The third similarity of exposure condition 7 is 300, and the average fluctuation similarity with exposure conditions 6 and 8 is 225. The third similarity of exposure condition 8 is 400, and the average fluctuation similarity with exposure conditions 7 and 9 is 200.
[0084] S233: Determine the target exposure condition according to the third similarity of each exposure condition and the average fluctuation similarity.
[0085] Among them, the target exposure condition is that the third similarity is less than the third threshold and the average fluctuation similarity is less than the fourth threshold, the third threshold is determined based on the third similarities of the first number of smallest values, and the fourth threshold is determined based on the average fluctuation similarities of the second number of smallest values.
[0086] The first number and the second number are determined according to specific circumstances so as to obtain a target exposure condition in which the third similarity is as small as possible and the average fluctuation similarity is as small as possible.
[0087] In applications, a smaller third similarity value allows for better differentiation between qualified and unqualified products. Furthermore, a smaller average fluctuation similarity value indicates that brightness changes caused by ambient lighting will not cause significant fluctuations in detection, potentially impacting subsequent test results. Among the various exposure conditions, a target exposure condition with the smallest possible third similarity value and average fluctuation similarity value is selected to identify exposure conditions that clearly highlight product details under ambient lighting.
[0088] For example, the third similarity of exposure condition 7 is 300, and its average fluctuation similarity with exposure conditions 6 and 8 is 225. The third similarity of exposure condition 8 is 400, and its average fluctuation similarity with exposure conditions 7 and 9 is 200. Since the third similarity of exposure condition 8 is the second smallest and the average fluctuation similarity of exposure condition 8 is smaller than the average fluctuation similarity of exposure condition 7, exposure condition 8 is determined to be the target exposure condition.
[0089] S234: Determine a second threshold according to the third similarity of the target exposure condition.
[0090] In a possible implementation, a formula for calculating the second threshold is: second threshold=(third similarity of target exposure conditions+preset highest similarity) / 2.
[0091] For example, 700=(400+1000) / 2.
[0092] S24: Acquire a second image to be detected.
[0093] In the application, the detection and evaluation is entered, and the camera device performs a shooting operation to collect an image of the shooting area to obtain a second image to be detected.
[0094] S25: Calculate a fourth similarity between the second image to be detected and the first registration image.
[0095] In a possible implementation, step S25 includes: S251: Perform product positioning on the second image to be detected.
[0096] In one possible implementation, a search method is used to locate products and narrow the scoring area. This method uses a cross-correlation algorithm and a contour algorithm for positioning. The contour algorithm uses gradients to calculate the position information of a product's edge points to obtain a series of point sets that represent the product's contour information. During the search, this series of point sets is used to search for the location with the most corresponding edge points, using a point search method. The contour algorithm is simple and efficient, with high positioning accuracy and a short positioning time. For example, using the contour algorithm on a 480 MHz MCU takes 200 μs to locate a product.
[0097] During use, the positioning algorithm can be selected based on the user's required response time. For example, when the user requires a shorter response time, the electronic device will select a faster algorithm instead of the gradient algorithm, or replace the cross-correlation algorithm with a contour positioning algorithm, which can adapt to high-frame-rate camera equipment for high-speed detection.
[0098] S252: If a product is detected in the second image to be detected, the product to be detected is extracted, and a third feature of the product to be detected is extracted.
[0099] In the application, the product to be inspected is compared with qualified products to detect the product's rotational direction. When detecting the product's rotational direction, the electronic device uses affine transformation to calculate images of multiple rotational directions and extract the third feature of the product to be inspected from the image of each rotational direction.
[0100] When detecting a product orientation defect, the electronic device directly obtains the third feature of the product to be detected in the second image to be detected.
[0101] By extracting the product to be tested, excluding background information and being free from background interference, it provides a basis for subsequent accurate calculation of similarity and determination of detection type.
[0102] S253: Compare the third feature of the product to be tested with the third feature of the qualified product to obtain a fourth similarity.
[0103] In the application, the third feature of the qualified product of the first registration image is extracted.
[0104] When detecting the rotation direction of the product, for the product to be detected in each rotation direction, the electronic device compares the third feature of the product to be detected with the third feature of the qualified product, calculates the third feature similarity of each third feature and determines the weight of the third feature based on the similarity of each third feature, and performs weighted summation based on the weight of each third feature and the third feature similarity to obtain a fourth similarity.
[0105] When detecting a product orientation defect, the electronic device directly compares the third feature of the product to be inspected in the second image to be inspected with the third feature of the qualified product, and similarly determines the fourth similarity.
[0106] Or, S254: if the product is not detected in the second image to be detected, extract the fourth feature of the second image to be detected.
[0107] In the application, when the product is not located, the electronic device directly extracts the image features of the second image to be detected to obtain the fourth feature, and also extracts the fourth feature of the qualified product in the first registration image.
[0108] S255: Compare the fourth feature of the second image to be inspected with the fourth feature of the qualified product to obtain a fourth similarity.
[0109] In the application, for each fourth feature, the electronic device compares the fourth feature of the second image to be tested with the fourth feature of the qualified product, calculates the fourth feature similarity of each fourth feature and determines the weight of the fourth feature based on the similarity of each fourth feature, and performs weighted summation based on the weight of each fourth feature and the fourth feature similarity to obtain the fourth similarity.
[0110] It is understandable that during the test assessment, through product positioning and the similarity of characteristics between the product to be tested and the qualified product, the differences are entered into the test when the weights are allocated so that the test type of the product to be tested can be accurately detected.
[0111] S26: Determine the detection type to which the second to-be-detected image belongs according to the second threshold and the fourth similarity.
[0112] In an application, when the fourth similarity is greater than or equal to the second threshold, it is determined that the product to be inspected in the second image to be inspected is a qualified product.
[0113] When the product is detected and the fourth similarity is less than the second threshold, it is determined that the product to be detected in the second image to be detected is an unqualified product or a certain type of product.
[0114] When no product is detected and the fourth similarity is less than the second threshold, it is determined that the second image to be detected is a background image.
[0115] When detecting product rotation, the image with the greatest similarity is selected from the fourth similarity scores of images in each rotational direction. The type of the second image to be detected is determined based on the maximum similarity. This allows for the detection of qualified or unqualified products after product rotation, while also simultaneously determining the rotation angle.
[0116] When inspecting for directional defects, the type of the second image to be inspected is determined based on the fourth similarity. Simultaneously, the presence of a directional defect is determined based on the similarity of contour features and other characteristics. A low similarity in contour features indicates a directional defect, while a high similarity indicates no directional defect.
[0117] For better understanding, each example diagram is used for explanation. Figure 7 is the first registered image of a certain type, Figure 8 A second registration image of a certain type, Figure 9 A third registration image of a certain type. Figure 10 The product to be inspected in the second image to be inspected of a certain type is detected as a qualified product, where 966 is the fourth similarity and 837 is the second threshold. Figure 11 The product to be inspected in the second image to be inspected of a certain type is an unqualified product, wherein 568 is the fourth similarity and 837 is the second threshold.
[0118] Figure 12 The first registration diagram for another class, Figure 13 A second registration diagram for another type, Figure 14 A third registration diagram for another class. Figure 15 The product to be inspected in the second image to be inspected of a certain type is detected as a qualified product, where 903 is the fourth similarity and 692 is the second threshold. Figure 16 The product to be inspected in the second image to be inspected of a certain type is an unqualified product, wherein 349 is the fourth similarity and 692 is the second threshold.
[0119] When detecting the rotation direction of a product, the product can also be detected after it has been rotated. Figure 17 The first registration diagram for another class, Figure 18 A second registration diagram for another type, Figure 19 A third registration diagram for another class. Figure 20 The product to be detected in the second image to be detected of a certain type is a qualified product, wherein 878 is the fourth similarity and 509 is the second threshold. Figure 21 The product to be detected in the second image to be detected of a certain type is a qualified product, wherein 830 is the fourth similarity and 509 is the second threshold.
[0120] It should be noted that a threshold is calculated based on the first and third registration images. This threshold is used to determine whether the product in the second image to be inspected is qualified or unqualified, or to determine whether the second image to be inspected is a background image. This detection method uses a three-point tuning mode. The three-point tuning mode registers three images and can detect product defects, types, and rotation directions based on features such as shape and brightness, even in the presence of background interference and uniform product shapes. This detection of product defects can also detect whether the product has been rotated and simultaneously determine the product's rotation angle.
[0121] This embodiment obtains a third registration image under at least two exposure conditions in response to a third operation of the user, where the third registration image includes an image area of an unqualified product; calculates a third similarity between the first registration image and the third registration image under each exposure condition; determines a second threshold value based on the third similarity of each exposure condition; is able to determine a suitable threshold value based on the actual situation of the product on the production line, providing a basis for accurately determining the type of the product, and obtains a second image to be detected; calculates a fourth similarity between the second image to be detected and the first registration image; and determines the detection type to which the second image to be detected belongs based on the second threshold value and the fourth similarity, thereby accurately judging the situation of the product.
[0122] It is understandable that the user instructs the device to collect registered images through two or three operations. The device automatically and intelligently screens out appropriate detection conditions based on multiple registered images, and then calculates the appropriate threshold. Then, based on the appropriate threshold, the detection type of the image to be detected is detected, thereby achieving simple, accurate and efficient detection of the presence or absence of products, rotation direction, product defects, etc., reducing the requirements for operators (users). Operators can operate the equipment for detection without adjusting or training any parameters, making the detection operation simple, and there is no need to collect a large amount of product data and calibrate it for detection, making the detection simple and efficient.
[0123] In one embodiment, the method further includes: Stores data during the detection process, including registered image data, image feature data, feature weight data, and threshold data.
[0124] This embodiment implements power-off protection by storing data during the detection process, and at the same time facilitates users to directly select or switch data after the device is powered on, enabling quick setting of parameters for product detection, thereby reducing the time for detection deployment.
[0125] In one embodiment, the method further includes: The first target value, the first target image to be detected corresponding to the first target value, and the second target value, the second target image to be detected corresponding to the second target value in the detection process are displayed. The first target value is an extreme value among multiple second similarities, and the second target value is an extreme value among multiple fourth similarities.
[0126] Displays guidance animation, similarity statistics, images corresponding to similarity statistics, and each registered image.
[0127] In the application, the image with the highest similarity is displayed during the inspection process to inform the user whether any abnormal workpieces have entered the production line during operation. Alternatively, the maximum similarity and its image are output during the period when the product is detected as unqualified, and the minimum similarity and its image are output during the period when the product is detected as qualified, so that the user can know the maximum similarity and its image during the process of detecting qualified products to unqualified products, and the minimum similarity and its image during the process of detecting unqualified products to qualified products.
[0128] For example, during the test and evaluation, Figure 22 is the image with the greatest similarity during the detection process, MAX represents the object with the greatest similarity during the detection process, and MIN represents the object with the least similarity during the detection process.
[0129] Figure 23 The image with the lowest similarity when the current product is detected as unqualified. BTM represents the minimum similarity when detecting unqualified products, PEAK represents the maximum similarity when detecting qualified products, and Pmin represents the minimum similarity and image in the PEAK history process, which allows users to understand the maximum threshold setting when detecting qualified products. Bmax represents the maximum similarity and image in the BTM history process, which allows users to understand the minimum threshold setting when detecting unqualified products to prevent false detection.
[0130] This embodiment enables users to observe the status of the production line operation process by displaying the first target image to be detected corresponding to the first target value in the detection process and the second target value, and the second target image to be detected corresponding to the second target value, thereby providing a basis for users to make targeted adjustments and optimize the detection methods, and guiding users to perform operations through a series of demonstration animations to enable users to quickly deploy, further reducing the requirements for operators and improving the detection speed.
[0131] It should be understood that the order of execution of the steps in the above embodiments does not imply a specific order of execution. The order of execution of each process should be determined by its function and inherent logic, and should not constitute any limitation on the implementation process of the embodiments of this application. Furthermore, the data collection in the above embodiments is legal, and its use or implementation does not involve any infringement on the public interest.
[0132] Corresponding to the method described in the above embodiment, for the sake of convenience of explanation, only the part related to the embodiment of the present application is shown.
[0133] In one embodiment, Figure 24 : is a schematic diagram of the structure of a detection device provided in one embodiment of the present application. The device includes: The processing module 10 is configured to obtain, in response to a first user operation, a first registration image under at least two exposure conditions, where the first registration image includes an image region of a qualified product, and the at least two exposure conditions include an optimal exposure condition and at least one candidate exposure condition, where the candidate exposure condition is determined based on the optimal exposure condition, and each candidate exposure condition has different parameters. It is also used to obtain a second registration image under at least two exposure conditions in response to a second operation of the user, where the second registration image is a background image that does not include the product.
[0134] A detection and calculation module 11 is used to calculate a first similarity between the first registration image and the second registration image under each exposure condition; It is also used to determine a first threshold according to the first similarity of each exposure condition.
[0135] A detection and evaluation module 12 is configured to obtain a first image to be detected; Also used to calculate a second similarity between the first image to be detected and the first registration image; It is also used to determine the detection type to which the first image to be detected belongs according to the first threshold and the second similarity.
[0136] In one embodiment, the processing module is further configured to obtain a third registration image under at least two exposure conditions in response to a third operation of the user, where the third registration image includes an image area of an unqualified product.
[0137] The detection and calculation module is further configured to calculate a third similarity between the first registration image and the third registration image under each exposure condition; and determine a second threshold value according to the third similarity under each exposure condition.
[0138] The detection evaluation module is further configured to obtain a second image to be detected; calculate a fourth similarity between the second image to be detected and the first registered image; and determine a detection type to which the second image to be detected belongs based on the second threshold and the fourth similarity.
[0139] In one embodiment, the processing module is specifically configured to, in response to a first operation of a user, capture an initial image of a qualified product, where the initial image includes an image area of the qualified product; extract the image area of the qualified product from the initial image, and adjust the brightness of the image area of the qualified product to a target brightness to obtain a first registration map of an optimal exposure condition; determine at least one candidate exposure condition based on the optimal exposure condition; and capture an image of the qualified product for each candidate exposure condition to obtain a first registration map of the candidate exposure condition.
[0140] In one embodiment, the detection and calculation module is specifically configured to extract first features of the first registration image and the second registration image for each exposure condition; calculate, for each first feature, a first feature similarity between the first feature of the first registration image and the first feature of the second registration image, and determine a weight of the first feature based on the first feature similarity; and determine a first similarity based on the weight of each first feature and the first feature similarity.
[0141] In one embodiment, the detection and calculation module is specifically used to extract the second features of qualified products in the first registration image and the second features of unqualified products in the third registration image for each exposure condition; for each second feature, calculate the second feature similarity between the second feature of the qualified product and the second feature of the unqualified product, and determine the weight of the second feature based on the second feature similarity; determine the third similarity based on the weight of each second feature and the second feature similarity.
[0142] In one embodiment, the detection and calculation module is specifically used to sort each exposure condition according to the parameters of each exposure condition to obtain a sorted exposure condition sequence; in the sorted exposure condition sequence, for each exposure condition, calculate the similarity difference between the third similarity of the exposure condition and the third similarity of the adjacent exposure condition, and determine the average fluctuation similarity based on each similarity difference; determine the target exposure condition based on the third similarity and the average fluctuation similarity of each exposure condition, the target exposure condition being that the third similarity is less than a third threshold and the average fluctuation similarity is less than a fourth threshold, the third threshold being determined based on the third similarities of the first first number of smallest values, and the fourth threshold being determined based on the average fluctuation similarities of the first second number of smallest values; and determine the second threshold based on the third similarity of the target exposure condition.
[0143] In one embodiment, the detection and evaluation module is specifically used to locate the object in the second image to be detected; if the object is detected in the second image to be detected, extract the object to be detected and extract the third feature of the object to be detected; compare the third feature of the object to be detected with the third feature of the qualified product to obtain a fourth similarity; or, if the object is not detected in the second image to be detected, extract the fourth feature of the second image to be detected; compare the fourth feature of the second image to be detected with the fourth feature of the qualified product to obtain a fourth similarity.
[0144] In one embodiment, the device further includes a storage module.
[0145] The storage module is used to store data during the detection process, including registered image data, image feature data, feature weight data, and threshold data.
[0146] In one embodiment, the device further includes a display module.
[0147] A display module is configured to display a first target value, a first target image to be detected corresponding to the first target value, and a second target value, and a second target image to be detected corresponding to the second target value during a detection process, wherein the first target value is an extreme value among a plurality of second similarities, and the second target value is an extreme value among a plurality of fourth similarities; It is also used to display guidance animations, similarity statistics, images corresponding to similarity statistics, and various registration images.
[0148] In one embodiment, the device further includes a setting module.
[0149] The setting module is used to provide setting options, wherein the setting options include response time setting options, threshold adjustment setting options, detection range setting options, and tuning algorithm setting options.
[0150] Figure 25 This is a schematic diagram of the structure of an electronic device provided in one embodiment of the present application. Figure 25 As shown, the electronic device 2 of this embodiment includes: at least one processor 20 ( Figure 25 Only one is shown in the figure), a memory 21 and a computer program 22 stored in the memory 21 and executable on the at least one processor 20, wherein the processor 20 implements the steps of any of the above-mentioned method embodiments when executing the computer program 22.
[0151] The electronic device 2 may include, but is not limited to, a processor 20 and a memory 21. Those skilled in the art will understand that Figure 25 This is merely an example of the electronic device 2 and does not constitute a limitation on the electronic device 2 . The electronic device 2 may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, the electronic device 2 may also include input and output devices, network access devices, etc.
[0152] The processor 20 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. A general-purpose processor may be a microprocessor or any conventional processor.
[0153] In some embodiments, the memory 21 may be an internal storage unit of the electronic device 2, such as a hard disk or memory of the electronic device 2. In other embodiments, the memory 21 may also be an external storage device of the electronic device 2, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) card, a Flash Card, etc. equipped on the electronic device 2. Furthermore, the memory 21 may include both an internal storage unit of the electronic device 2 and an external storage device. The memory 21 is used to store an operating system, application programs, a boot loader, data, and other programs, such as the program code of the computer program. The memory 21 may also be used to temporarily store data that has been output or is about to be output.
[0154] It should be noted that the information interaction, execution process, etc. between the above-mentioned devices / units are based on the same concept as the method embodiment of this application. Their specific functions and technical effects can be found in the method embodiment section and will not be repeated here.
[0155] Those skilled in the art can clearly understand that, for the convenience and brevity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In actual applications, the above-mentioned functions can be distributed and completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated into one processing unit, or each unit can exist physically alone, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.
[0156] An embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in the above-mentioned various method embodiments can be implemented.
[0157] An embodiment of the present application provides a computer program product. When the computer program product is run on an electronic device, the electronic device can implement the steps of the above-mentioned method embodiments when executing the computer program product.
[0158] If the integrated unit is implemented as a software functional unit and sold or used as a standalone product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application can implement all or part of the process steps in the above-mentioned method embodiments by using a computer program to instruct the relevant hardware. The computer program can be stored in a computer-readable storage medium. When executed by a processor, the computer program can implement the steps of each of the above-mentioned method embodiments. The computer program includes computer program code, which can be in source code form, object code form, executable file, or some intermediate form. The computer-readable medium can include at least: any entity or device capable of carrying the computer program code to the camera / terminal device, recording medium, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media. Examples include USB flash drives, removable hard drives, magnetic disks, or optical disks. In some cases, the computer-readable medium cannot be an electrical carrier signal or telecommunication signal.
[0159] In the above embodiments, the description of each embodiment has its own focus. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant description of other embodiments.
[0160] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0161] In the embodiments provided in this application, it should be understood that the disclosed devices / network equipment and methods can be implemented in other ways. For example, the device / network equipment embodiments described above are merely illustrative. For example, the division of the modules or units is merely a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0162] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.
[0163] The above-described embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present application, and should all be included in the scope of protection of the present application.
Claims
1. A detection method, characterized in that: include: In response to a first user operation, obtaining a first registration image under at least two exposure conditions, where the first registration image includes an image area of a qualified product, and the at least two exposure conditions include an optimal exposure condition and at least one candidate exposure condition, where the candidate exposure condition is determined based on the optimal exposure condition, and each candidate exposure condition has different parameters; In response to a second operation by the user, obtaining a second registration image under at least two exposure conditions, where the second registration image is a background image that does not include the product; calculating a first similarity between the first registration image and the second registration image under each exposure condition; determining a first threshold value according to the first similarity of each of the exposure conditions; Acquire a first image to be detected; Calculating a second similarity between the first image to be detected and the first registration image; The detection type to which the first to-be-detected image belongs is determined according to the first threshold and the second similarity.
2. The method according to claim 1, characterized in that Also includes: In response to a third operation by the user, acquiring a third registration image under at least two exposure conditions, wherein the third registration image includes an image area of a non-conforming product; calculating a third similarity between the first registration image and the third registration image under each of the exposure conditions; determining a second threshold value according to a third similarity of each of the exposure conditions; Acquire a second image to be detected; Calculating a fourth similarity between the second image to be detected and the first registration image; The detection type to which the second image to be detected belongs is determined according to the second threshold and the fourth similarity.
3. The method according to claim 1, characterized in that The acquiring, in response to a first operation of the user, a first registration image under at least two exposure conditions, includes: In response to a first operation by the user, capturing an initial image of the qualified product, wherein the initial image includes an image area of the qualified product; Extracting an image region of the qualified product from the initial image, and adjusting the brightness of the image region of the qualified product to a target brightness, to obtain a first registration image under the optimal exposure condition; determining at least one candidate exposure condition according to the optimal exposure condition; For each of the candidate exposure conditions, an image of the qualified product is collected to obtain the first registration image of the candidate exposure condition.
4. The method according to any one of claims 1 to 3, characterized in that The calculating a first similarity between the first registration image and the second registration image under each exposure condition includes: extracting first features of the first registration image and the second registration image for each exposure condition; For each of the first features, calculating a first feature similarity between the first feature of the first registration image and the first feature of the second registration image, and determining a weight of the first feature according to the first feature similarity; The first similarity is determined according to the weight of each first feature and the first feature similarity.
5. The method according to claim 2, characterized in that The calculating the third similarity between the first registration image and the third registration image under each exposure condition includes: extracting, for each exposure condition, the second features of the qualified products in the first registration image and the second features of the unqualified products in the third registration image; For each of the second features, calculating a second feature similarity between the second feature of the qualified product and the second feature of the unqualified product, and determining a weight of the second feature according to the second feature similarity; The third similarity is determined according to the weight of each second feature and the similarity of the second feature.
6. The method according to claim 2, characterized in that The determining the second threshold according to the third similarity of each exposure condition includes: Sorting the exposure conditions according to the parameters of the exposure conditions to obtain a sorted exposure condition sequence; In the sorted exposure condition sequence, for each exposure condition, calculating a similarity difference between the third similarity of the exposure condition and the third similarity of an adjacent exposure condition, and determining an average fluctuation similarity based on each similarity difference; determining a target exposure condition based on the third similarity and the average fluctuation similarity of each exposure condition, wherein the target exposure condition is that the third similarity is less than a third threshold and the average fluctuation similarity is less than a fourth threshold, the third threshold being determined based on the first number of smallest third similarities, and the fourth threshold being determined based on the second number of smallest average fluctuation similarities; The second threshold is determined according to a third similarity of the target exposure condition.
7. The method according to claim 5 or 6, characterized in that The calculating a fourth similarity between the second image to be detected and the first registration image includes: performing object positioning on the second image to be detected; If an object is detected in the second image to be detected, extracting the object to be detected and extracting a third feature of the object to be detected; Comparing the third feature of the object to be inspected with the third feature of the qualified product to obtain the fourth similarity; or, if no object is detected in the second image to be detected, extracting a fourth feature of the second image to be detected; The fourth feature of the second image to be inspected is compared with the fourth feature of the qualified product to obtain the fourth similarity.
8. A detection device, characterized in that: include: a processing module configured to, in response to a first user operation, obtain a first registration image under at least two exposure conditions, wherein the first registration image includes an image area of a qualified product, and the at least two exposure conditions include an optimal exposure condition and at least one candidate exposure condition, wherein the candidate exposure condition is determined based on the optimal exposure condition, and each candidate exposure condition has different parameters; further configured to obtain, in response to a second operation by the user, a second registration image under at least two exposure conditions, where the second registration image is a background image that does not include the product; a detection calculation module, configured to calculate a first similarity between the first registration image and the second registration image under each exposure condition; further configured to determine a first threshold value according to the first similarity of each of the exposure conditions; A detection and evaluation module, configured to obtain a first image to be detected; further configured to calculate a second similarity between the first image to be detected and the first registration image; It is also used to determine the detection type to which the first image to be detected belongs based on the first threshold and the second similarity.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the method according to any one of claims 1 to 7 is implemented.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Label classification method and device, electronic equipment and storage medium
CN113435499A
Defect detection method and device, electronic equipment and computer readable storage medium
CN114596242A
Target image retrieval method and system
CN115510260A
Class detection method, device and equipment based on self-learning
CN115861633A
Image registration method and device, computer equipment and storage medium
CN116543028A