A method, device, storage medium, and electronic device for determining the position of a defect

By acquiring the positioning area and calibration position relationship on the target image, combining pixel intersection and feature information, the problem of defect judgment of product designated areas is solved, and fast and accurate defect position determination is achieved, improving product processing quality and process optimization.

CN114549465BActive Publication Date: 2025-07-18CHENGDU UNION BIG DATA TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210165132.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-02-18
Publication Date
2025-07-18
Estimated Expiration
2042-02-18

AI Technical Summary

Technical Problem

In the prior art, it is difficult to judge whether the defect exists in the product designated area. Especially when the defect is high speed or the defect is small, it is difficult to extract the product designated area and the defect area, making it difficult to accurately determine whether the defect exists in the product designated area.

Method used

By acquiring the positioning area on the target image, acquiring the detection area based on the positioning area and the calibration position relationship, and acquiring the detection area where the defect area is located based on the detection area and the defect area, determining the defect position using pixel filling and feature information, and improving the determination accuracy of the defect position by using pixel intersection and feature information.

Benefits of technology

It realizes the rapid and accurate acquisition of the detection area where the defect area is located, solves the problem of judging whether the defect exists in the designated area of the product, and improves the targetedness of product processing quality and processing technology optimization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114549465B_ABST
    Figure CN114549465B_ABST
Patent Text Reader

Abstract

The present application discloses a method for determining the defect position, which relates to the field of artificial intelligence technology and solves the problem that it is relatively difficult to judge whether a defect exists in a specified area of a product. The method includes the following steps: obtaining a positioning area on a target image; obtaining a detection area on the target image according to the positioning area and the calibration position relationship, where the calibration position relationship is the position relationship between the positioning area and the detection area on the target image; obtaining the detection area where the defect area is located according to the detection area and the defect area, where the defect area is the area where the defect is located obtained from the target image. In the above implementation manner, the present application can indirectly obtain the detection area that is difficult to extract due to contamination through the calibration position relationship, thereby converting the problem of obtaining the detection area into the problem of obtaining the corresponding positioning area, and finally achieving the purpose of judging whether a defect exists in the specified area of the product.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of artificial intelligence technology, and particularly to a method, device, storage medium and electronic device for determining the defect position. Background Art

[0002] During the industrial manufacturing process, due to factors such as process and hardware differences, various defects will occur on the product. Defects occurring at different positions have different impacts on different regions and also on the overall product. For some defects, only the part existing in the designated area of the product will affect the quality.

[0003] In the prior art, it is difficult to extract the designated area and the defect area of the product under conditions such as high speed or very small defects. Further judging whether the defect exists in the designated area of the product is even more difficult. Therefore, there is an urgent need for a method to obtain whether the defect exists in the designated area of the product. Summary of the Invention

[0004] The main purpose of this application is to provide a method, device, storage medium and electronic device for determining the defect position, aiming to solve the problem that it is difficult to judge whether the defect exists in the designated area of the product in the prior art.

[0005] To achieve the above purpose, the technical solutions adopted in the embodiments of this application are as follows:

[0006] In a first aspect, an embodiment of this application provides a method for determining the defect position, including the following steps:

[0007] Obtain a positioning area on the target image;

[0008] Obtain a detection area on the target image according to the positioning area and the calibration position relationship; wherein, the calibration position relationship is the position relationship between the positioning area and the detection area on the target image;

[0009] Obtain the detection area where the defect area is located according to the detection area and the defect area; wherein, the defect area is the area where the defect is located obtained from the target image.

[0010] In a possible implementation manner of the first aspect, the detection area is filled with a first pixel set, and the defect area is filled with a second pixel set; the step of obtaining the detection area where the defect area is located according to the detection area and the defect area includes:

[0011] Obtain the intersection of the first pixel set and the second pixel set to determine the detection area where the defect area is located.

[0012] The detection area and defect area are filled with a pixel filling method with high recognition and easy to distinguish. The detection area where the defect area is located can be quickly identified through the intersection of the pixel area. The pixel filling operation is simple, and the depth and category of the pixel are easy to adjust. When obtaining the intersection of the pixel set, the extraction will not be affected by too many area contour lines, so that the defect location can be determined more accurately.

[0013] In a possible implementation manner of the first aspect, after the step of acquiring the detection area where the defect area is located according to the detection area and the defect area, the method further includes:

[0014] According to the pixel information of the detection area and the defect area, the feature information of the detection area where the defect area is located is obtained.

[0015] After obtaining the inspection area where the defective area is located, by obtaining characteristic information of the area such as the shape contour, defect area, etc. that can reflect the characteristics of the defect, after the defect location is determined, targeted research and analysis can be made on the processing technology problems and processing technology optimization directions based on the characteristic information to avoid similar problems from occurring again, so as to improve the processing quality of the product.

[0016] In a possible implementation manner of the first aspect, before the step of acquiring the positioning area on the target image, the method further includes:

[0017] Get the calibration position relationship.

[0018] Before determining the defect location, the calibrated position relationship is obtained in advance, so that the defect location can be determined more quickly. Especially for the case where the image is too large, after the position relationship is calibrated in advance, the detection area on the entire image is acquired based on the same calibrated position relationship and can be reused until the entire image is completely searched, ensuring the consistency and comprehensiveness of the detection area acquisition.

[0019] In a possible implementation manner of the first aspect, before the step of acquiring the positioning area on the target image, the method further includes:

[0020] Construct a two-dimensional coordinate system of the target image;

[0021] The steps of obtaining the calibration position relationship include:

[0022] In a two-dimensional coordinate system, obtain the calibration position relationship.

[0023] By constructing a two-dimensional coordinate system, each region can be characterized by its specific position on the target image in coordinate form, and the size of the region can be intuitively reflected by the vertex coordinates of the region. The calibration position relationship can also be represented based on the coordinate relationship, which can more clearly and intuitively reflect the relative position between the defect region and the detection region.

[0024] In a possible implementation manner of the first aspect, the steps of obtaining the calibration position relationship include:

[0025] Draw a positioning region on the target image;

[0026] Obtain a shape template according to the drawn positioning region, and obtain the central coordinates of the shape template;

[0027] Draw a detection region on the target image and obtain the central coordinates of the detection region;

[0028] Obtain the calibration position relationship according to the central coordinates of the shape template and the central coordinates of the detection region.

[0029] For the detection region of the target image with a complex shape and irregular contour, which can be achieved by threshold extraction. By drawing the positioning region and the detection region in advance, and using the easily obtained positioning region as the basis to obtain the shape template for positioning query, and then obtaining the calibration position relationship according to the central coordinates of the drawn detection region and the shape template.

[0030] In a possible implementation manner of the first aspect, the steps of obtaining the calibration position relationship include:

[0031] Draw a positioning region on the target image and obtain the central coordinates of the positioning region;

[0032] Draw a detection region on the target image;

[0033] Obtain a shape template according to the drawn detection region, and obtain the central coordinates of the shape template;

[0034] Obtain the calibration position relationship according to the central coordinates of the positioning region and the central coordinates of the shape template.

[0035] For the detection region of the target image that is difficult to extract through thresholds or closed edges, the extraction of the detection region can be achieved by locating other obvious regions. That is, the shape template for positioning query is established through the detection region. Each region has a rectangular contour structure, and the four vertices of the rectangle can be expressed in the coordinate system. However, according to the shape of the rectangle, it can be known that only a set of vertices on the diagonal needs to be obtained to determine the position of the entire rectangle.

[0036] In a possible implementation of the first aspect, the step of acquiring the detection area on the target image according to the positioning area and the calibration position relationship includes:

[0037] Get the vertex coordinates of the positioning area;

[0038] Obtaining search coordinates according to vertex coordinates of the positioning area and image information of the target image;

[0039] Search on the target image according to the search coordinates and search direction to obtain the positioning area;

[0040] The detection area is obtained based on the relationship between the positioning area and the calibration position.

[0041] Since the outline of the positioning area is marked as a rectangle, obtaining its vertex coordinates can clearly characterize the position of the positioning area in the coordinate system, and due to the characteristics of the rectangle, it is only necessary to obtain the vertex coordinates of the two ends of the diagonal of the rectangle to deduce the location of the entire rectangle. The image information of the target image refers to information that can reflect the characteristics of the image, which is conducive to determining the search coordinates for searching on the target image. The image information includes size information and period length information, etc., wherein the size information can reflect the image size, such as the length and width of the image, and the period length information can reflect whether the image is regularly arranged, that is, whether the distribution of the detection area is regular, so as to facilitate determining the search coordinates according to the period length information. By searching on the target image based on the initial positioning area, all positioning areas are searched out, that is, the positioning areas are arranged in a matrix on the target image according to the search coordinates and search directions, and then all detection areas are obtained by calibrating the position relationship.

[0042] In a possible implementation manner of the first aspect, the image information of the target image includes size information and period length information.

[0043] In a possible implementation manner of the first aspect, before the step of acquiring the detection area where the defect area is located according to the detection area and the defect area, the method further includes:

[0044] Get the defect area of the target image.

[0045] Defects can be obtained through recognizable cameras and scanning devices, and the identified defect areas can be marked through mapping software. Defects can also be identified through trained models. The model is obtained based on multiple existing image training. The model can quickly identify defects in the target image and improve the efficiency of subsequent comparison with the inspection area. The defect area can be calibrated using the same calibration method as the inspection area and positioning area, so that the defect area can be visualized and has a higher degree of recognition.

[0046] In a second aspect, an embodiment of the present application provides a defect location determination device, comprising:

[0047] An acquisition module, which is used to acquire a positioning area on a target image;

[0048] A conversion module, which is used to obtain a detection area on the target image according to the positioning area and the calibration position relationship, where the calibration position relationship is the position relationship between the positioning area and the detection area on the target image;

[0049] A determination module, which is used to obtain the detection area where the defect area is located according to the detection area and the defect area; where the defect area is the area where the defect is located obtained from the target image.

[0050] In a third aspect, an embodiment of the present application provides a computer-readable storage medium storing a computer program, which when loaded and executed by a processor, implements the defect position determination method provided in any one of the above first aspects.

[0051] In a fourth aspect, an embodiment of the present application provides an electronic device, including a processor and a memory, where

[0052] The memory is used to store a computer program;

[0053] The processor is used to load and execute the computer program so that the electronic device executes the defect position determination method provided in any one of the above first aspects.

[0054] In a fifth aspect, an embodiment of the present application provides a computer program product, including a computer program, which when executed, is used to execute the defect position determination method provided in any one of the above first aspects.

[0055] Compared with the prior art, the beneficial effects of the present application are:

[0056] A defect position determination method, device, storage medium and electronic device provided by an embodiment of the present application obtain a positioning area on a target image; obtain a detection area on the target image according to the positioning area and the calibration position relationship; where the calibration position relationship is the position relationship between the positioning area and the detection area on the target image; obtain the detection area where the defect area is located according to the detection area and the defect area; where the defect area is the area where the defect is located obtained from the target image. The method of the present application pre-obtains the calibration position relationship through the positioning area and the detection area, and this calibration position relationship is used subsequently to achieve the extraction of the detection area that is relatively difficult to directly obtain in the target image. By converting it through the calibration position relationship to the extraction of the positioning area that is relatively easy to obtain, the purpose of accurately and quickly indirectly obtaining the detection area is achieved. Finally, through the obtained detection area and the defect area of the obtained target image, the detection area where the defect area is located can be obtained, that is, the defective part in the specified area of the product. Description of the Drawings

[0057] Figure 1 Schematic diagram of the electronic device structure of the hardware operating environment involved in the embodiment of the present application;

[0058] Figure 2 Schematic flowchart of a method for determining the defect position provided by the embodiment of the present application;

[0059] Figure 3 Schematic diagram of the modules of a device for determining the defect position provided by the embodiment of the present application;

[0060] Figure 4 Image of the target image with defects provided by the embodiment of the present application;

[0061] Figure 5 Image of the positioning area when obtaining the calibration position relationship in the embodiment of the present application;

[0062] Figure 6 Based on Figure 5 Image of the shape template obtained from the positioning area;

[0063] Figure 7 Image of the detection area when obtaining the calibration position relationship in the embodiment of the present application;

[0064] Figure 8 Image when multiple detection areas are obtained in the embodiment of the present application;

[0065] Figure 9 Image of the defect area provided by the embodiment of the present application;

[0066] Figure 10 Image of the detection area where the defect area is located provided by the embodiment of the present application.

[0067] Reference signs in the figure: 101 - processor, 102 - communication bus, 103 - network interface, 104 - user interface, 105 - memory. Detailed Description of the Embodiment

[0068] It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0069] The main solution of the embodiment of the present application is: to propose a method, device, storage medium and electronic device for determining the defect position, by obtaining a positioning area on the target image; obtaining a detection area on the target image according to the positioning area and the calibration position relationship, where the calibration position relationship is the position relationship between the positioning area and the detection area on the target image; obtaining the detection area where the defect area is located according to the detection area and the defect area, where the defect area is the area where the defect is located obtained from the target image.

[0070] In the prior art, due to factors such as process and hardware differences, various defects will occur on the product, and the effects of some product defects on different regions are different. Judging by manpower will consume a large amount of resources, and in the case of high speed, small defects or large images, it is also difficult for the human eye to distinguish them, resulting in difficulty in judging whether there are defects in the specified area of the product.

[0071] Therefore, the present application provides a solution. First, a positioning area is obtained on the target image, then, according to the calibration position relationship between the positioning area and the detection area on the target image, the detection area on the target image is obtained, and finally, according to the detection area and the defective area on the target image, the detection area where the defective area is located is obtained. This solves the problem that it is relatively difficult to judge whether there are defects in the specified area of the product in the prior art.

[0072] Refer to the attached Figure 1 attachment, Figure 1 is a schematic structural diagram of an electronic device for the hardware operating environment of the solution of the embodiment of the present application. The electronic device may include: a processor 101, such as a Central Processing Unit (CPU), a communication bus 102, a user interface 104, a network interface 103, and a memory 105. Among them, the communication bus 102 is used to realize the connection and communication between these components. The user interface 104 may include a display screen (Display) and an input unit such as a keyboard (Keyboard). Optionally, the user interface 104 may further include a standard wired interface and a wireless interface. The network interface 103 may optionally include a standard wired interface and a wireless interface (such as a Wireless-FIdelity (WI-FI) interface). The memory 105 may optionally be a storage device independent of the aforementioned processor 101. The memory 105 may be a high-speed random access memory (Random Access Memory, RAM) memory, or may be a stable non-volatile memory (Non-Volatile Memory, NVM), such as at least one disk memory; the processor 101 may be a general-purpose processor, including a central processor, a network processor, etc., or may also be a digital signal processor, an application-specific integrated circuit, a field programmable gate array, or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.

[0073] Those skilled in the art can understand that the structure shown in the attached Figure 1 does not constitute a limitation on the electronic device, and may include more or fewer components than shown in the figure, or combine some components, or have different component arrangements.

[0074] As shown in the attached Figure 1As shown in the figure, the memory 105 as a storage medium may include an operating system, a data storage module, a network communication module, a user interface module, and an electronic program.

[0075] In the Figure 1 shown electronic device, the network interface 103 is mainly used for data communication with a network server; the user interface 104 is mainly used for data interaction with a user; the processor 101 and the memory 105 in the electronic device of the present invention can be arranged in the electronic device, and the electronic device calls the defect position determination device stored in the memory 105 through the processor 101, and executes the defect position determination method provided by the embodiment of the present application.

[0076] Referring to the Figure 2 , based on the hardware device of the foregoing embodiment, an embodiment of the present application provides a defect position determination method, including the following steps:

[0077] S20: Obtain a positioning area on the target image.

[0078] In a specific implementation process, the target image refers to an image for determining whether a defect exists in a specified area of a product. The product can capture its image information through a camera or an image processing software such as Photoshop as the target image. The size of the image can be specified based on user requirements, and unnecessary parts can be cropped in advance, or the image can be marked and framed to clarify the detection range and improve the detection efficiency; the positioning area refers to an area obtained based on the target image for query and search. The positioning area is easy to mark and extract, and can search the target image through the positioning area, thereby avoiding detecting the target area by training a corresponding area detection model.

[0079] S30: Obtain a detection area on the target image according to the positioning area and the calibration position relationship; wherein, the calibration position relationship is the position relationship between the positioning area and the detection area on the target image.

[0080] In the specific implementation process, the detection area refers to a specific area on the target image, that is, the designated area of the product. Since in actual operation, the detection area is often contaminated by defects, resulting in the inability to extract or difficult extraction of the detection area, the direct acquisition of the detection area is transformed into the acquisition of the corresponding positioning area, so as to indirectly acquire the detection area. The calibration position relationship refers to the position relationship between the detection area and the positioning area on the target image. By pre-determining a set of corresponding detection areas and positioning areas, the relationship between the two is obtained, so as to use the same standard to determine all the positioning areas in the subsequent search process and match them to obtain all the corresponding detection areas. The calibration position relationship can be determined according to the coordinate relationship provided in other embodiments of the present application, or by marking positioning points on the positioning area and the detection area, and the calibration position relationship can also be obtained by indicating the relative deflection direction and relative distance between the positioning points.

[0081] S40: Obtain the detection area where the defect area is located according to the detection area and the defect area; wherein, the defect area is the area where the defect is located obtained from the target image.

[0082] In the specific implementation process, the defect area refers to the area where the defect of the product appears. The acquisition method of the defect area can also be obtained by camera shooting or scanning equipment, and then the processed product image is marked according to the defect determination principle in the industry through simulation software or detection software. The marking method of the defect area can be filling pixels, marking contours, etc. By obtaining the detection area and the defect area, the detection area where the defect area is located can be determined. For example, in the case of using the contour picking method to mark the defect area, the detection area can also be marked in the same way. By determining the area where the contours of the detection area and the defect area intersect, the detection area where the defect area is located can be determined, that is, the detection area with defects.

[0083] In the above implementation manner, through the pre-established calibration position relationship between the positioning area and the detection area, after obtaining the positioning area, the detection area can be obtained according to the calibration position relationship. Finally, by combining the detection area and the defect area of the target image, the detection area where the defect area is located can be obtained, realizing the judgment of whether the defect exists in the designated area of the product. In the embodiment of the present application, the acquisition of the detection area that is not easy to directly obtain due to pollution is transformed into the acquisition of the positioning area. The problem of obtaining the detection area is transformed into the acquisition of the positioning area, and the positioning area is a more obvious and easier-to-extract area determined on the target image. In this way, the acquisition of each area and the comparison and judgment between areas become easier.

[0084] In one embodiment, an implementation method for detecting regions and defect regions using pixel filling is proposed. Specifically, the detection region is filled with a first pixel set, and the defect region is filled with a second pixel set. According to the pixel filling method, step S40: Obtain the detection region where the defect region is located based on the detection region and the defect region, including:

[0085] S401: Obtain the intersection of the first pixel set and the second pixel set to determine the detection region where the defect region is located.

[0086] In the specific implementation process, since the detection region where the finally determined defect region is located needs to be visually displayed, pixel filling means with high recognition and easy to distinguish are used to fill the detection region and the defect region. The pixels can be the same type of pixels or different pixels. The intersection area of the pixels will have differences in depth and color after superimposing the pixels, so as to more quickly identify the detection region where the defect is located. And according to the intersection of the pixels, the pixel sets other than the intersection area can be cancelled to avoid interference from other regions and clarify the target region required for detection. Different from the contour marking method, although the above purpose can also be achieved, the lines between the contours are superimposed, which will make the contour information of the intersection area more complicated and affect the extraction of the intersection area.

[0087] In one embodiment, after step S40: Obtain the detection region where the defect region is located based on the detection region and the defect region, the defect position determination method provided by the embodiment of the present application further includes:

[0088] S50: Obtain the feature information of the detection region where the defect region is located according to the pixel information of the detection region.

[0089] In the specific implementation process, the feature information refers to the information that can reflect the defect characteristics such as the outer contour, defect depth, and area. In this embodiment, it refers to the feature information of the defect located on the detection region. The outer contour of the defect is such as width, length, presence or absence of sharp corners, etc., the area of the defect, and the degree of defect generation at this place. These features are all important reference data for later research on the location of processing technology problems and optimization and adjustment of processing technology. After confirming the position of the defect, the detection region where the defect that affects the product quality is located is extracted. According to the collected defect feature information, comprehensive research and analysis of the product processing content can be carried out based on it.

[0090] In one embodiment, taking the defect area data that is more important for later evaluation as an example, step S50: Obtain the feature information of the detection region where the defect region is located according to the pixel information of the detection region and the defect region, including:

[0091] S501: Fill a third pixel set for the detection region where the defect region is located.

[0092] In this embodiment, the third pixel set is filled in the intersection of the first pixel set and the second pixel set to distinguish the intersection from the original set.

[0093] S502: Traverse the pixel blocks of the third pixel set.

[0094] In this embodiment, the pixel blocks in the third pixel set are used as the minimum area units of the set. By traversing to obtain the quantity information thereof, the area information of the detection region where the defect is located can be obtained.

[0095] S503: Obtain the area information of the detection region where the defect region is located according to the traversed pixel block information.

[0096] In this embodiment, before traversing, it is necessary to divide the pixel blocks until all the pixel blocks in the set are complete, so as to ensure that the set is filled with complete pixel blocks, making the area information obtained by traversing the pixel blocks more accurate. According to the quantity information of the pixel blocks obtained by traversing, the area of the detection region where the defect region is located can be determined.

[0097] In one embodiment, step S20: Before the step of obtaining the positioning region on the target image, the defect position determination method further includes: constructing a two-dimensional coordinate system of the target image.

[0098] By constructing a two-dimensional coordinate system, each region can be characterized by its specific position on the target image in the form of coordinates, and the calibration position relationship is also represented by the coordinate relationship, which can more clearly and intuitively reflect the relative position between the defect region and the detection region. The two-dimensional coordinate system can be established with the center position of the target image as the origin, the horizontal axis as the X-axis, and the vertical axis as the Y-axis. In this way, the target image is evenly divided into four regions, and the four regions are located in the four different quadrants of the coordinate system. The position information of the region on the target image can be quickly determined through the coordinate information of the region. For example, if both the horizontal and vertical coordinates are positive, then the region exists in the upper right region of the target image. In other embodiments, the establishment of the two-dimensional coordinate system can also be changed accordingly according to the actual situation.

[0099] In one embodiment, step S20: Before obtaining the positioning region on the target image, the defect position determination method further includes:

[0100] S10: Obtain the calibration position relationship.

[0101] Based on the establishment of the two-dimensional coordinate system, step S10: Obtain the calibration position relationship, including:

[0102] Under the two-dimensional coordinate system, obtain the calibration position relationship.

[0103] In one embodiment, step S10: Obtain the calibration position relationship, including:

[0104] S101: Draw a positioning area on the target image;

[0105] In this embodiment, the positioning area can be obtained by manually coloring and drawing on the target image.

[0106] S102: Obtain a shape template according to the drawn positioning area, and obtain the central coordinates of the shape template.

[0107] In this embodiment, based on the positioning area, an image is cropped to generate a shape template for positioning query, and the central coordinates of the shape template are obtained in the two-dimensional coordinate system.

[0108] S103: Draw a detection area on the target image and obtain the central coordinates of the detection area.

[0109] In this embodiment, the detection area is manually pre-drawn and further extracted by threshold extraction. If the threshold cannot be extracted, the detection area can be colored using drawing software to more accurately extract the detection area and obtain the central coordinates of the detection area. It should be noted that the areas in the foregoing steps are all rectangular in contour structure, and the four vertices of the rectangle can all be expressed in the coordinate system. However, according to the shape of the rectangle, only a set of vertices on the diagonal needs to be obtained to determine the position of the entire rectangle.

[0110] S104: Obtain the calibration position relationship according to the central coordinates of the shape template and the central coordinates of the detection area.

[0111] In the specific implementation process, according to the obtained central position coordinates of the shape template and the central position coordinates of the detection area, the position relationship is calculated, that is, the calibration position relationship is obtained. The expression of the calibration position relationship can be based on one of the central position coordinates of the shape template and the central position coordinates of the detection area, and the coordinate expression of the calibration position relationship can be obtained through the corresponding difference in the horizontal and vertical coordinates: (x1, y1). For example, taking the central position coordinates of the detection area as the reference, subtracting the corresponding central coordinates of the shape template, the obtained calibration position relationship represents that the central position of the shape template is translated x1 units along the direction parallel to the X axis and y1 units on the Y axis to obtain the central position coordinates of the detection area, where the positive and negative of x1 and y1 respectively represent that the translation is along the positive and negative directions of the corresponding coordinate axes.

[0112] This embodiment is mainly aimed at the detection area of the target image with a complex shape and irregular contour, which can be achieved by threshold extraction. For the detection area of the target image that is difficult to extract through threshold or closed edge, the extraction of the detection area can be achieved by locating other obvious areas, that is, the shape template for location query is established through the detection area. Specifically, step S10: Obtain the calibration position relationship, including:

[0113] Draw a positioning area on the target image and obtain the central coordinates of the positioning area;

[0114] Draw a detection area on the target image;

[0115] Obtain a shape template according to the drawn detection area and obtain the central coordinates of the shape template;

[0116] Obtain the calibration position relationship according to the central coordinates of the positioning area and the central coordinates of the shape template.

[0117] The above steps are to obtain the shape template in step S10 of the foregoing embodiment by using the drawn detection area. The other steps and effects are the same as those of the foregoing embodiment and will not be elaborated here.

[0118] In one embodiment, step S30: Obtain the detection area on the target image according to the positioning area and the calibration position relationship, including:

[0119] S301: Obtain the vertex coordinates of the positioning area.

[0120] In this embodiment, since the contour of the positioning area is marked as a rectangle, obtaining its vertex coordinates can clearly represent the position of the positioning area in the coordinate system. And due to the characteristics of the rectangle, only the vertex coordinates at both ends of the diagonal of the rectangle need to be obtained to calculate the entire rectangle.

[0121] S302: Obtain the search coordinates according to the vertex coordinates of the positioning area and the image information of the target image.

[0122] In this embodiment, the image information of the target image refers to the information that can reflect the characteristics of the image, which is conducive to determining the search coordinates for searching on the target image. The image information includes size information, period length information, etc. The size information can reflect the size of the image, such as the length and width of the image. The period length information can reflect whether the image is arranged regularly, that is, whether the distribution of the detection area is regular, which is convenient for determining the search coordinates according to the period length information. The search coordinates refer to the distance size for searching on the target image. For example, if the vertex coordinates of the starting positioning area are upper left (Row1, Column1) and lower right (Row2, Column2), and the size of the target image is (width, height), then the search coordinates can be positioned as upper left (Row1 - 32, 0) and lower right (Row2 + 32, width), that is, perform a full-width search horizontally and a search with a vertical offset of 32 pixels in the target image, which can greatly shorten the search time and avoid misidentification in other areas. If the horizontal period length of the image is known as L, then the search coordinates can be set as upper left (Row1 - 32, n*L - 32) and lower right (Row2 + 32, (n + 1)*L + 32), where n is a positive integer and (n*L) < width. As described above, the corresponding search can be performed according to the periodic distribution of the image. For images with periodic distribution, the positioning and query process is optimized, and the search and query efficiency is improved.

[0123] S303: Search on the target image according to the search coordinates and the search direction to obtain the positioning area.

[0124] In this embodiment, the search direction refers to the search direction of the positioning area in the target image, such as horizontal global search, horizontal left-end search, vertical global search, and vertical lower-end search, etc. By searching on the target image based on the initial positioning area, all positioning areas are searched out, that is, the positioning areas are arranged in a matrix on the target image according to the search coordinates and the search direction, and then all detection areas are obtained through calibration of the position relationship. It should be understood that during the process of searching for all positioning areas, since the search direction of the positioning area may change, the direction of the searched positioning area may be inclined, resulting in the inclination of the image of the positioning area. Therefore, after all positioning areas are searched, an affine transformation can be performed. The affine transformation algorithm refers to a technique that keeps the vertex coordinates and the center coordinates of the searched positioning area parallel to the vertex coordinates and the center coordinates of the initial positioning area to ensure that the direction of the positioning area is in the positive direction, thereby improving the accuracy of the subsequent obtained detection area and further enhancing the accuracy when determining the position of the final defect in the detection area.

[0125] S304: Obtain the detection area according to the positioning area and the calibration position relationship.

[0126] In this embodiment, according to the located areas obtained by searching and the obtained calibration position relationship, the detection area corresponding to each located area can be obtained through the calibration position relationship.

[0127] In one embodiment, before step S40: obtaining the detection area where the defective area is located according to the detection area and the defective area, the defective position determination method further includes:

[0128] Obtaining the defective area of the target image.

[0129] In the specific implementation process, the defect can obtain the image defect through an identifiable camera or a scanning device, and the identified defective area can be marked by drawing software. The defect can also be identified by a trained model. The model is obtained by training based on a plurality of existing images. Through the model, the defect of the target image can be quickly identified, improving the efficiency of subsequent comparison with the detection area. The defective area can be calibrated in the same calibration method as the detection area and the located area, making the defective area visible and having high recognition.

[0130] Refer to the appendix Figure 4 , which is the target image provided by the embodiment of the present application. The image has a certain regular distribution. Among them, the black area in the middle is the defect of the product.

[0131] Refer to the appendix Figure 5 , which is the image of the located area provided by the embodiment of the present application. Among them, the white frame is a drawn located area, and its size is determined according to the actual situation.

[0132] Refer to the appendix Figure 6 , which is the image of the shape template provided by the embodiment of the present application. Among them, the shape template shown in the appendix Figure 6 is used for positioning and querying, and is obtained according to the located area in the appendix Figure 5 . The located area is used as the center position of the cropped shape template, and cropping is performed on the target image shown in the appendix Figure 4 .

[0133] Refer to the appendix Figure 7 , which is the image of the detection area provided by the embodiment of the present application. Among them, the white area is a drawn detection area. Thus, the calibration position relationship can be obtained according to the white area and the white frame shown in the appendix Figure 5 .

[0134] Refer to the appendix Figure 8 , which is the image of obtaining multiple detection areas provided by the embodiment of the present application. Among them, the white area is multiple detection areas corresponding to the multiple located areas obtained according to the positioning query, that is, the detection areas are regularly obtained and arranged on the target image in a matrix manner.

[0135] Refer to the appendixFigure 9 This is an image of the defective area provided by an embodiment of the present application. Among them, the white area is the location where the defect is obtained.

[0136] Refer to the appendix Figure 10 This is an image of the detection area where the defective area is located provided by an embodiment of the present application. That is, all the detection areas obtained in the appendix Figure 8 are intersected with the detection areas obtained in the appendix Figure 9 The overlapping part is the detection area where the defective area is located, that is, the white area in the figure.

[0137] Refer to the appendix Figure 3 Based on the same inventive concept as in the foregoing embodiments, an embodiment of the present application further provides a defective position determination device, which includes:

[0138] An acquisition module, which is used to acquire a positioning area on a target image;

[0139] A conversion module, which is used to acquire a detection area on the target image according to the positioning area and the calibration position relationship, where the calibration position relationship is the position relationship between the positioning area and the detection area on the target image;

[0140] A determination module, which is used to acquire the detection area where the defective area is located according to the detection area and the defective area; among them, the defective area is the area where the defect is located obtained from the target image.

[0141] Those skilled in the art should understand that the division of each module in the embodiment is only a logical function division. In actual application, it can be fully or partially integrated into one or more actual carriers, and these modules can all be implemented in the form of software called by a processing unit, or all be implemented in the form of hardware, or be implemented in the form of a combination of software and hardware. It should be noted that each module in the defective position determination device in this embodiment corresponds one by one to each step in the defective position determination method in the foregoing embodiment. Therefore, the specific implementation manner of this embodiment can refer to the implementation manner of the foregoing defective position determination method, which will not be elaborated here.

[0142] Based on the same inventive concept as in the foregoing embodiments, an embodiment of the present application further provides a computer-readable storage medium, which stores a computer program. When the computer program is loaded and executed by a processor, it implements the defective position determination method provided by an embodiment of the present application.

[0143] Based on the same inventive concept as in the foregoing embodiments, an embodiment of the present application further provides an electronic device, including a processor and a memory, where

[0144] the memory is used to store a computer program;

[0145] The processor is used to load and execute a computer program so that the electronic device executes the defect location determination method provided in the embodiments of the present application.

[0146] In addition, based on the same inventive concept as in the foregoing embodiments, an embodiment of the present application further provides a computer program product, including a computer program, which is used to execute the defect location determination method provided in the embodiments of the present application when the computer program is executed.

[0147] In some embodiments, the computer-readable storage medium may be a memory such as FRAM, ROM, PROM, EPROM, EEPROM, flash memory, magnetic surface memory, optical disc, or CD-ROM; or it may be various devices including one or any combination of the foregoing memories. The computer may be various computing devices including smart terminals and servers.

[0148] In some embodiments, the executable instructions may be in the form of a program, software, software module, script, or code, and may be written in any form of programming language (including compiled or interpreted languages, or declarative or procedural languages), and may be deployed in any form, including being deployed as an independent program or being deployed as a module, component, subroutine, or other unit suitable for use in a computing environment.

[0149] As an example, the executable instructions may or may not correspond to a file in the file system, and may be stored as a part of a file that stores other programs or data. For example, they may be stored in one or more scripts in a HyperText Markup Language (HTML) document, stored in a single file dedicated to the program being discussed, or stored in multiple cooperating files (such as files that store one or more modules, subroutines, or code portions).

[0150] As an example, the executable instructions may be deployed to be executed on one computing device, or on multiple computing devices located at one location, or on multiple computing devices distributed at multiple locations and interconnected through a communication network.

[0151] It should be noted that in this article, the terms "include", "comprise", or any other variant thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or system including a series of elements not only includes those elements, but also includes other elements not explicitly listed, or further includes elements inherent to such process, method, article, or system. Without further limitation, an element defined by the statement "including one..." does not exclude the existence of additional identical elements in the process, method, article, or system including that element.

[0152] The serial numbers of the embodiments of the present application above are only for description and do not represent the superiority or inferiority of the embodiments.

[0153] Through the description of the above embodiments, those skilled in the art can clearly understand that the above embodiment methods can be implemented by means of software plus a necessary general hardware platform. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as a read-only memory / random access memory, magnetic disk, optical disk), and includes several instructions for causing a multimedia terminal device (which may be a mobile phone, a computer, a television receiver, or a network device, etc.) to execute the methods described in the various embodiments of the present application.

[0154] In summary, a method, device, storage medium, and electronic device for determining a defect position provided by the present application can quickly and accurately obtain the detection area where the defect is located by obtaining a positioning area on a target image; obtaining a detection area on the target image according to the positioning area and the calibration position relationship; and obtaining the detection area where the defect area is located according to the detection area and the defect area, that is, obtaining whether the defect exists in the specified area of the product.

[0155] The above are only the preferred embodiments of the present application and are not intended to limit the present application. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present application shall be included in the protection scope of the present application.

Claims

1. A method for determining the defect position, characterized in that, Including the following steps: Obtain a positioning area on the target image; Before the step of obtaining a positioning area on the target image, the method further includes: Obtain a calibration position relationship; before the step of obtaining a positioning area on the target image, the method further includes: Construct a two-dimensional coordinate system of the target image; The step of obtaining the calibration position relationship includes: Under the two-dimensional coordinate system, obtain the calibration position relationship; The step of obtaining the calibration position relationship includes: Draw the positioning area on the target image; Obtain a shape template according to the drawn positioning area, and obtain the central coordinates of the shape template; wherein, the shape template is obtained by cropping the image based on the positioning area and is used for positioning query; Draw a detection area on the target image and obtain the central coordinates of the detection area; According to the central coordinates of the shape template and the central coordinates of the detection area, obtain the calibration position relationship; or, The step of obtaining the calibration position relationship includes: Draw the positioning area on the target image and obtain the central coordinates of the positioning area; Draw the detection area on the target image; Obtain a shape template according to the drawn detection area, and obtain the central coordinates of the shape template; wherein, the shape template is obtained by cropping the image based on the detection area and is used for positioning query; According to the central coordinates of the positioning area and the central coordinates of the shape template, obtain the calibration position relationship; According to the positioning area and the calibration position relationship, obtain the detection area on the target image; wherein, the calibration position relationship is the position relationship between the positioning area and the detection area on the target image; According to the detection area and the defect area, obtain the detection area where the defect area is located; wherein, the defect area is the area where the defect is located obtained from the target image.

2. The method for determining the defect position according to claim 1, wherein The detection area is filled with a first pixel set, and the defect area is filled with a second pixel set; the step of obtaining the detection area where the defect area is located according to the detection area and the defect area includes: Obtain the intersection of the first pixel set and the second pixel set to determine the detection area where the defect area is located.

3. The method for determining the defect position according to claim 2, characterized in that, After the step of obtaining the detection area where the defect area is located according to the detection area and the defect area, the method further includes: According to the pixel information of the detection area and the defect area, obtain the feature information of the detection area where the defect area is located.

4. The method for determining the defect position according to claim 1, characterized in that, The step of obtaining the detection area on the target image according to the positioning area and the calibration position relationship includes: Obtain the vertex coordinates of the positioning area; According to the vertex coordinates of the positioning area and the image information of the target image, obtain search coordinates; Search on the target image according to the search coordinates and the search direction to obtain the positioning area; According to the positioning area and the calibration position relationship, obtain the detection area.

5. The method for determining the defect position according to claim 4, characterized in that The image information of the target image includes size information and periodic length information.

6. The method for determining the defect position according to claim 1, wherein Before the step of obtaining the detection area where the defect area is located according to the detection area and the defect area, the method further includes: Obtain the defect area of the target image.

7. A defect position determination device, characterized in that, Including: An acquisition module, which is used to obtain a positioning area on the target image; Before obtaining the positioning area on the target image, it further includes: Obtain the calibration position relationship; before obtaining the positioning area on the target image, it further includes: Construct a two-dimensional coordinate system of the target image; The obtaining of the calibration position relationship includes: Under the two-dimensional coordinate system, obtain the calibration position relationship; The obtaining of the calibration position relationship includes: Draw the positioning area on the target image; Obtain a shape template according to the drawn positioning area, and obtain the center coordinates of the shape template; wherein, the shape template is obtained by cropping the image based on the positioning area and is used for positioning query; Draw a detection area on the target image and obtain the center coordinates of the detection area; According to the center coordinates of the shape template and the center coordinates of the detection area, obtain the calibration position relationship; or, The obtaining of the calibration position relationship includes: Draw the positioning area on the target image and obtain the center coordinates of the positioning area; Draw the detection area on the target image; Obtain a shape template according to the drawn detection area, and obtain the center coordinates of the shape template; wherein, the shape template is obtained by cropping the image based on the detection area and is used for positioning query; According to the center coordinates of the positioning area and the center coordinates of the shape template, obtain the calibration position relationship; A conversion module, which is used to obtain the detection area on the target image according to the positioning area and the calibration position relationship, wherein the calibration position relationship is the position relationship between the positioning area and the detection area on the target image; A determination module, which is used to obtain the detection area where the defect area is located according to the detection area and the defect area; wherein, the defect area is the area where the defect is located obtained from the target image.

8. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is loaded and executed by a processor, it implements the defect position determination method according to any one of claims 1-6.

9. An electronic device, characterized in that, Including a processor and a memory, wherein, The memory is used to store a computer program; The processor is used to load and execute the computer program so that the electronic device executes the defect position determination method according to any one of claims 1-6.

10. A computer program product, characterized in that, Including a computer program, which is used to execute the defect position determination method according to any one of claims 1-6 when the computer program is executed.

Citation Information

Patent Citations

  • Roll package defect positioning method and roll package defect positioning device

    CN106276372A

  • Wind power inspection blade defect grade judgment method based on unmanned aerial vehicle

    CN111461210A