Methods for detecting appearance defects, electronic devices and storage media
By automatically identifying appearance defects in industrial products through image processing and machine learning algorithms, the problem of slow speed and unstable quality standards in manual visual inspection has been solved, achieving efficient and accurate defect detection.
Patent Information
- Application Number
- CN202211043508.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-29
- Publication Date
- 2025-10-28
- Estimated Expiration
- 2042-08-29
AI Technical Summary
In current industrial production, defect detection relies on manual visual inspection, which results in poor objectivity of quality standards and slow detection speed, making it impossible to effectively deal with product appearance defects.
By employing image processing and machine learning algorithms, the system acquires images of the target object under different brightness conditions, uses a pre-trained detection model to identify and classify defect types, and combines grayscale processing and image matrix standard deviation analysis to automatically determine whether the target object has defects.
It enables rapid and accurate detection of appearance defects, improves detection efficiency and quality, and reduces human error and visual fatigue.
Smart Images

Figure CN115456969B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of defect detection, specifically to methods for detecting appearance defects, electronic devices, and storage media. Background Technology
[0002] In the manufacturing process of precision products, instability of processes, insufficient mechanical positioning accuracy, and environmental factors in the factory often lead to various defects in the produced products. These defects not only affect the appearance of the products but also pose safety hazards. Therefore, defect detection has always been an indispensable part of industrial production.
[0003] In the current industrial context, the traditional method of manual visual inspection is still used. After defects are found, unqualified products are manually rejected. This existing quality inspection situation is affected by factors such as visual fatigue and emotional fluctuations of quality inspectors, which inevitably leads to poor objectivity of quality standards and slow inspection speed. Summary of the Invention
[0004] This disclosure provides a method for detecting appearance defects, an electronic device, and a storage medium, which can be flexibly applied to a variety of application scenarios.
[0005] In a first aspect, embodiments of this application provide a method for detecting appearance defects, comprising: acquiring an appearance image of each of at least one point of a target object; performing a first detection on the appearance image of the point to determine whether the appearance of the point has a preset defect; and, if the appearance of the point has a preset defect, determining whether the appearance of the target object has a defect according to the type of the preset defect.
[0006] Optionally, the appearance image of the point includes multiple appearance images of the point under different brightness illumination conditions.
[0007] Optionally, the first detection of the appearance image of the point to determine whether there is a preset defect in the appearance of the point includes: inputting the appearance image of the point into a pre-trained first detection model, and determining whether there is a preset defect in the appearance of the point through the first detection model.
[0008] Optionally, before determining whether the appearance of the target object has a defect based on the type of the preset defect, the method further includes: performing grayscale processing on the appearance image of the point; calculating the standard deviation of the image matrix of the appearance image of the point; retaining the appearance images of the points whose standard deviation is greater than or equal to the standard deviation threshold and / or retaining the appearance image of the point with the largest standard deviation.
[0009] Optionally, when the appearance of the point has a preset defect, determining whether the appearance of the target object has a defect according to the type of the preset defect includes: when the point has a linear defect, detecting the diagonal length of the defective portion in the appearance image; when the diagonal length is greater than a preset length threshold, determining that the appearance of the target object has a defect.
[0010] Optionally, when a preset defect exists in the appearance of the point, determining whether the appearance of the target object has a defect based on the type of the preset defect includes: when a sheet-like defect exists in the point, detecting the area of the defective portion in the appearance image; and when the area is greater than a preset area threshold, determining that the appearance of the target object has a defect.
[0011] Optionally, when the appearance of the point has a preset defect, determining whether the appearance of the target object has a defect based on the type of the preset defect includes: when the point has a dirt defect, detecting dirty pixels in the defective part of the appearance image; and when the number of dirty pixels in the appearance image is greater than a preset number threshold, determining that the appearance of the target object has a defect.
[0012] Optionally, detecting dirty pixels in the defective portion of the appearance image includes: performing grayscale processing on the defective portion of the appearance image; calculating the standard deviation of the image matrix of the defective portion of the appearance image; determining a first parameter of the defective portion of the appearance image based on the standard deviation and a preset function, wherein the preset function is a linear function of the standard deviation and the first parameter; and performing binarization processing on the defective portion of the appearance image based on the first parameter to determine the dirty pixels in the defective portion of the appearance image.
[0013] Optionally, before detecting dirty pixels in the defective portion of the appearance image of the point, the method further includes: pre-acquiring multiple sets of correspondences between the standard deviation and the first parameter as a training set; initializing the fitting function and inputting the training set into the gradient descent algorithm model to iterate the fitting function to obtain a preset function.
[0014] Optionally, determining whether the appearance of the target object has a defect based on the type of the preset defect when the appearance of the point has a preset defect includes: directly determining that the appearance of the target object has a defect when the point has a dent defect.
[0015] Optionally, before performing a first detection on the appearance image of the location to determine whether the appearance of the location has a preset defect, the method further includes: inputting the appearance image into a second detection model to determine the logo portion in the appearance image; cropping the logo portion in the appearance image as a logo image; inputting the logo image into a third detection model to determine whether the logo image has an appearance defect portion of the target object; and if the logo image has the appearance defect portion, determining that the target object has an appearance defect.
[0016] Optionally, the method further includes: acquiring an appearance image of the logo point of the target object; performing a first detection on the appearance image of the logo point to determine whether there is a preset defect in the appearance of the logo point; and determining that the appearance of the target object has a defect if there is a preset defect in the appearance of the logo point.
[0017] Secondly, embodiments of this application provide an electronic device having a processor and a memory, wherein the memory stores computer instructions, and when the computer instructions are executed by the processor, they implement the steps of the method described in any of the first aspects above.
[0018] Thirdly, embodiments of this application provide a storage medium storing computer instructions thereon, which, when executed by a processor, implement the steps of the method described in any of the first aspects above.
[0019] One beneficial effect of this disclosure is that by acquiring an appearance image of at least one point of a target object and detecting the appearance image, it can be determined whether a preset defect exists at that point. If a preset defect exists at that point, the appearance of the target object is determined to be defective based on the type of defect. In this example, this method can automatically, specifically, and quickly determine whether the appearance of the target object is defective based on the type of defect, thus improving detection efficiency and detection quality.
[0020] Other features and advantages of the embodiments of this disclosure will become clear from the following detailed description of exemplary embodiments with reference to the accompanying drawings. Attached Figure Description
[0021] The accompanying drawings, which are incorporated in and form a part of this specification, illustrate embodiments of the present disclosure and, together with their description, serve to explain the principles of the embodiments of the present disclosure.
[0022] Figure 1 A flowchart of a method for detecting appearance defects according to an embodiment of the present disclosure is shown.
[0023] Figure 2A block diagram of an electronic device according to an embodiment of the present disclosure is shown. Detailed Implementation
[0024] Various exemplary embodiments of the present disclosure will now be described in detail with reference to the accompanying drawings. It should be noted that, unless otherwise specifically stated, the relative arrangement, numerical expressions, and values of the components and steps set forth in these embodiments do not limit the scope of the invention.
[0025] The following description of at least one exemplary embodiment is merely illustrative and is in no way intended to limit the invention or its application or use.
[0026] Techniques, methods, and equipment known to those skilled in the art may not be discussed in detail, but where appropriate, such techniques, methods, and equipment should be considered part of the specification.
[0027] In all the examples shown and discussed herein, any specific values should be interpreted as merely exemplary and not as limitations. Therefore, other examples of exemplary embodiments may have different values.
[0028] It should be noted that similar labels and letters in the following figures indicate similar items; therefore, once an item is defined in one figure, it does not need to be discussed further in subsequent figures.
[0029] This application discloses a method for detecting appearance defects, such as... Figure 1 As shown, the method includes steps S11-S13.
[0030] Step S11: For each of at least one point of the target object, acquire the appearance image of the point.
[0031] In one example of this embodiment, the target object can be any item whose appearance needs to be inspected for defects, such as VR glasses, mobile phones, etc. The locations of the target object can be determined based on its shape. Specifically, to ensure detection effectiveness, the locations of the target object's curved surfaces should be included at as many angles as possible. After determining the locations, an image of each location on the target object can be captured, serving as the target image for that location.
[0032] In one example of this embodiment, the appearance image of the point includes multiple appearance images of the point under different brightness illumination conditions.
[0033] In one example of this embodiment, different appearance defects result in different imaging effects under different brightness conditions. For instance, dirt defects produce better imaging effects in brighter environments, while bright spot defects produce better imaging effects in darker environments. Furthermore, due to the curved surface, some defects, such as bright spot defects, have poorer imaging effects. Therefore, for each location, multiple appearance images under different lighting conditions can be acquired. For example, two appearance images of that location can be acquired, including one brighter image and one darker image.
[0034] In this example, by acquiring appearance images of the target object at multiple points with different brightness, the problem of imaging appearance defects on the curved surface of the target object can be solved, and a clear appearance image that can be detected can be obtained, so that subsequent detection can accurately determine whether there are appearance defects in the target object.
[0035] Step S12: Perform a first inspection on the appearance image of the location to determine whether there is a preset defect in the appearance of the location.
[0036] In one example of this embodiment, the preset defect can include various types of defects, such as linear defects, sheet-like defects, dents, and dirt defects. Specifically, linear defects can include lint and linear bright marks. Sheet-like defects can include sheet-like bright marks, etc.
[0037] In one example of this embodiment, a first detection is performed on the appearance image of the point to determine whether there is a preset defect in the appearance of the point. This includes: inputting the appearance image of the point into a pre-trained first detection model, and using the first detection model to determine whether there is a preset defect in the appearance of the point.
[0038] In one example of this embodiment, the first detection model is a detection model, specifically a YOLOv5 algorithm model. This model can be pre-trained to determine whether the appearance of a point contains a predetermined type of defect. In one example, after the YOLOv5 model determines that a predetermined type of defect exists in the appearance image, it can use a rectangular detection box to select the image of the defective part as the defective part. It is understood that the defective part mentioned in this example includes not only the image of the defective part, but also the image of the normal part within the selected area.
[0039] In one example of this embodiment, when a preset defect exists in the appearance of the point, the image of the defective part can be extracted from the appearance image of the point. Specifically, the defective part of the appearance image in the detection box can be cropped out by the YOLOv5 model so as to determine whether the appearance of the target object exists.
[0040] In one example of this embodiment, before determining whether the appearance of the target object has a defect according to the type of preset defect, the method further includes: performing grayscale processing on the appearance image of the point, calculating the standard deviation of the image matrix of the appearance image of the point, retaining the appearance image of the point with a standard deviation greater than or equal to the standard deviation threshold and / or retaining the appearance image of the point with the largest standard deviation.
[0041] In one example of this embodiment, due to the curved surface of the target object and the differences in imaging effects of different types of defects under different lighting conditions, some images of the target object may have poor imaging quality. Therefore, the appearance images can be first converted to grayscale, and the standard deviation of the image matrix of the grayscale image can be calculated. When the standard deviation is greater than or equal to a preset standard deviation threshold, it indicates that the image quality of the appearance image is better and the image edges are clearer. Therefore, appearance images with a standard deviation greater than or equal to the standard deviation threshold can be retained, while appearance images with a standard deviation less than the standard deviation threshold can be discarded. In another example, it is possible that the standard deviation of all appearance images at a certain point is less than the standard deviation threshold. To avoid missed detections, the appearance image with the largest standard deviation among multiple appearance images of that point can be retained.
[0042] In this example, by converting the appearance image to grayscale and calculating the standard deviation of the grayscale image matrix, appearance images with poor imaging effects can be effectively eliminated, avoiding the influence of curved surfaces and lighting conditions on the appearance image, reducing the error of subsequent appearance defect detection, and since at least one appearance image of the point will be retained, there will be no missed detection.
[0043] Step S13: If there is a preset defect in the appearance of the point, determine whether there is a defect in the appearance of the target object according to the type of preset defect.
[0044] In one example of this embodiment, determining whether the appearance of a target object has a defect can be done by determining whether the appearance of the target object meets the requirements. Different defect types may have different defect identification standards. Taking a linear defect as an example, if the length of the linear bright mark is less than 5mm and the width is less than 0.15mm, then for this linear bright mark, the defect will be considered to be relatively small, and it will not be determined that the target object has an appearance defect.
[0045] In one example of this embodiment, when a preset defect exists in the appearance of the point, determining whether the appearance of the target object has a defect based on the type of the preset defect includes: when a linear defect exists in the point, detecting the diagonal length of the defective portion in the appearance image, and determining that the appearance of the target object has a defect when the diagonal length is greater than a preset length threshold.
[0046] In one example of this embodiment, if the defect in the appearance image is a linear defect, such as a fibrous hair or a linear bright mark, its length cannot be accurately measured due to its irregular shape. Therefore, the length of the linear defect can be determined by calculating the diagonal pixel length of the defective portion of the linear defect in the appearance image, such as the portion selected by the detection box. The preset length threshold can be set according to actual needs. When the length exceeds the threshold, the target object is considered to have an appearance defect.
[0047] In one example of this embodiment, if a preset defect exists in the appearance of a point, determining whether the appearance of the target object has a defect based on the type of the preset defect includes: if a sheet-like defect exists in the point, detecting the area of the defective part in the appearance image, and determining that the appearance of the target object has a defect when the area is greater than a preset area threshold.
[0048] In one example of this embodiment, if the defect in the appearance image is a sheet-like defect, such as a sheet-like bright mark, its size cannot be accurately measured because its shape is irregular. Therefore, the pixel area of the defective portion of the sheet-like defect in the appearance image, such as the portion selected by the detection box, can be calculated, and the size of the sheet-like defect can be determined by the pixel area. A preset area threshold can be set according to actual needs. When the area is greater than the threshold, the target object is considered to have an appearance defect.
[0049] In one example of this embodiment, when the appearance of the point has a preset defect, determining whether the appearance of the target object has a defect based on the type of the preset defect includes: when the point has a dirt defect, detecting the dirty pixels of the defective part in the appearance image, and determining that the appearance of the target object has a defect when the number of dirty pixels is greater than a preset number threshold.
[0050] In one example of this embodiment, detecting dirty pixels in a defective portion of an appearance image includes: performing grayscale processing on the appearance image of the point, calculating the standard deviation of the image matrix of the appearance image of the point, determining a first parameter of the defective portion of the appearance image of the point based on the standard deviation and a preset function, wherein the preset function is a linear function of the standard deviation and the first parameter, and performing binarization processing on the defective portion of the appearance image based on the first parameter to determine the dirty pixels in the defective portion of the appearance image.
[0051] In this embodiment, if the appearance image contains dirt or defects, the image can first be converted to grayscale, and the standard deviation of the processed image matrix can be calculated. The first parameter of the appearance image is determined using this standard deviation and a preset function. This first parameter is used to distinguish whether a pixel is a dirty pixel.
[0052] In one example of this embodiment, before detecting dirty pixels in the defective part of the appearance image, the method further includes: pre-acquiring the correspondence between multiple sets of standard deviations and the first parameter as a training set, initializing the fitting function, inputting the training set into the gradient descent algorithm model, iterating the fitting function, and obtaining the preset function.
[0053] In this embodiment, the standard deviation (std) and the first parameter (C) of m appearance images can be obtained in advance. The standard deviation and the first parameter of each appearance image are used as a set of training data (std, C) to obtain a training set of m sets of training data.
[0054] Initialize the fitting function h θ (std)=θ i0 +θ i1 ×std, initialization parameter θ i0 =θ i1 =0, initialize the learning rate α = 0.001, and initialize the number of iterations k = 0; iterate the initial fitting function by applying the gradient descent algorithm.
[0055] Update the loss function: And calculate the partial derivatives Update based on the partial derivative Where θ i Including θ i0 and θ i1 Two parameters. The final function is output when the number of iterations k meets the requirement or the function meets the requirement:
[0056] h θ (std)=θ k0 +θ k1 std is a linear function of the standard deviation and the first parameter, i.e., a preset function.
[0057] After calculating the standard deviation of the grayscale image, the standard deviation can be substituted into a preset function to obtain the first parameter of the defective part of the image.
[0058] After obtaining the first parameter, the defective part can be binarized using the `adaptiveThreshold` function in OpenCV. Specifically, for each pixel in the defective part of the appearance image, the average grayscale value of all pixels within a preset region centered on that pixel can be obtained; this is the first average value. The preset region can be an N*N pixel area centered on that pixel. The specific value of N can be flexibly set according to the actual situation.
[0059] After obtaining the first average value for a pixel, the threshold for that pixel can be obtained by subtracting the first average value from the first parameter. The grayscale value of the pixel is then compared to the threshold to determine whether the pixel's grayscale value is set to 0 or 255. In one example, a pixel with a grayscale value of 255 can be identified as a dirty pixel.
[0060] After binarizing the defective portion, the number of dirty pixels in the defective portion can be obtained. When the number of dirty pixels exceeds a preset threshold, ...
[0061] In one example of this embodiment, if the defect in the appearance image is a dirt defect, its shape and size are irregular, and it cannot be accurately detected by common methods. Therefore, the defective part in the appearance image can be binarized to determine the number of dirty pixels, and the size of the dirt defect can be determined by the number of dirty pixels. The preset number threshold can be set according to actual needs. When the number of dirty pixels is greater than the threshold, the target object is considered to have an appearance defect.
[0062] In one example of this embodiment, when there is a preset defect in the appearance of the point, it is determined whether the appearance of the target object is defective according to the type of the preset defect, including: when there is a dent defect in the point, it is directly determined that the appearance of the target object is defective.
[0063] In one example of this embodiment, if the defect in the appearance image is a dent defect, that is, if the target object has a dent, it can be directly determined that the appearance of the target object has a defect.
[0064] In one example of this embodiment, before performing a first detection on the appearance image of the point to determine whether there is a preset defect in the appearance of the point, the method further includes: inputting the appearance image into a second detection model, determining the logo portion in the appearance image, cropping the logo portion in the appearance image as a logo image, inputting the logo image into a third detection model, determining whether there is an appearance defect portion of the target object in the logo image, and determining that the target object has an appearance defect if there is an appearance defect portion in the logo image.
[0065] In one example of this embodiment, the second detection model and the first detection model can be the same algorithm model or different models. Using this pre-trained model, it is determined whether a logo portion exists in the appearance image. The logo portion of the appearance image is the part of the target object that bears its identifier. When a logo portion exists in the appearance image, a rectangular detection box can be used to select the image frame of the logo portion, and the image within the detection box is cropped as the logo image.
[0066] In one example of this embodiment, after obtaining the logo image, the logo image can be input into a third detection model. Specifically, the third detection model can be a YOLOv5 algorithm model. This model can be pre-trained based on a defective logo image and the corresponding data annotation of the image to identify whether the logo image input into the model has any appearance defects.
[0067] In one example of this embodiment, if there is an appearance defect in the logo image, it can be directly determined that the appearance of the target object does not meet the requirements and has an appearance defect.
[0068] In one example of this embodiment, the method further includes: acquiring an appearance image of the logo point of the target object, performing a first detection on the appearance image of the logo point, determining whether there is a preset defect in the appearance of the logo point, and determining that the appearance of the target object is defective if there is a preset defect in the appearance of the logo point.
[0069] In this embodiment, the target object's locations may include logo locations. These logo locations are set based on the target object's logo before acquiring its appearance image. When acquiring the appearance image of at least one location of the target object, the appearance image of the logo location is directly acquired, and a first detection is performed on the logo portion. Specifically, the detection may involve inputting the logo portion into a pre-trained model. This model can be pre-trained based on a defective logo image and its corresponding data annotations to identify whether the logo image input into the model has any appearance defects. If an appearance defect exists in the logo location's appearance image, it can be directly determined that the target object's appearance does not meet the requirements and has appearance defects.
[0070] In this example, this approach avoids misjudging the logo portion in the appearance image, such as the model identifying the logo portion as a defective part, or ignoring the defective part in the logo portion, thereby improving the accuracy and detection effect of appearance defects.
[0071] This embodiment provides an electronic device 100, such as... Figure 2 As shown, the electronic device has a processor 101 and a memory 102. The memory 102 stores computer instructions. When the computer instructions are executed by the processor, they implement the various processes of the above-described method embodiment for detecting appearance defects and achieve the same technical effect. To avoid repetition, they will not be described again here.
[0072] This embodiment provides a computer-readable storage medium storing executable commands. When executed by a processor, the executable commands implement the various processes of the above-described method embodiment for detecting appearance defects and achieve the same technical effect. To avoid repetition, they will not be described again here.
[0073] It should be noted that all actions involving the acquisition of signals, information, or data in this application are carried out in compliance with the relevant data protection laws and policies of the country where the application is located, and with the authorization granted by the owner of the relevant device / account.
[0074] The various embodiments in this disclosure are described in a progressive manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the device and apparatus embodiments are basically similar to the method embodiments, so the descriptions are relatively simple; relevant parts can be referred to the descriptions of the method embodiments.
[0075] The foregoing has described specific embodiments of this disclosure. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims may be performed in a different order than that shown in the embodiments and may still achieve the desired results. Furthermore, the processes depicted in the drawings do not necessarily require the specific or sequential order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0076] Embodiments of this disclosure may be systems, methods, and / or computer program products. A computer program product may include a computer-readable storage medium having computer-readable program instructions loaded thereon for causing a processor to implement various aspects of the embodiments of this disclosure.
[0077] Computer-readable storage media can be tangible devices capable of holding and storing instructions for use by an instruction execution device. Computer-readable storage media can be, for example—but not limited to—electrical storage devices, magnetic storage devices, optical storage devices, electromagnetic storage devices, semiconductor storage devices, or any suitable combination thereof. More specific examples (a non-exhaustive list) of computer-readable storage media include: portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), static random access memory (SRAM), portable compact disc read-only memory (CD-ROM), digital multifunction disc (DVD), memory sticks, floppy disks, mechanical encoding devices, such as punch cards or recessed protrusions storing instructions thereon, and any suitable combination thereof. The computer-readable storage media used herein are not to be construed as transient signals themselves, such as radio waves or other freely propagating electromagnetic waves, electromagnetic waves propagating through waveguides or other transmission media (e.g., light pulses through fiber optic cables), or electrical signals transmitted through wires.
[0078] The computer-readable program instructions described herein can be downloaded from computer-readable storage media to various computing / processing devices, or downloaded via a network, such as the Internet, local area network, wide area network, and / or wireless network, to an external computer or external storage device. The network may include copper transmission cables, fiber optic transmission, wireless transmission, routers, firewalls, switches, gateway computers, and / or edge servers. A network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards them to the computer-readable storage media in the respective computing / processing device.
[0079] Computer program instructions used to perform the operations of embodiments of this disclosure may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-dependent instructions, microcode, firmware instructions, state setting data, or source code or object code written in any combination of one or more programming languages, including object-oriented programming languages such as Smalltalk, C++, etc., and conventional procedural programming languages such as the "C" language or similar programming languages. The computer-readable program instructions may execute entirely on a user's computer, partially on a user's computer, as a standalone software package, partially on a user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or may be connected to an external computer (e.g., via the Internet using an Internet service provider). In some embodiments, electronic circuitry, such as programmable logic circuitry, field-programmable gate arrays (FPGAs), or programmable logic arrays (PLAs), is personalized by utilizing state information from the computer-readable program instructions. This electronic circuitry can execute the computer-readable program instructions to implement various aspects of embodiments of this disclosure.
[0080] Various aspects of embodiments of this disclosure are described herein with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this disclosure. It should be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer-readable program instructions.
[0081] These computer-readable program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, thereby producing a machine, so that when these instructions are executed by the processor of the computer or other programmable data processing device, a device is generated that implements the functions / actions specified in one or more blocks in the flowchart and / or block diagram. These computer-readable program instructions can also be stored in a computer-readable storage medium, where these instructions cause the computer, programmable data processing device, and / or other device to operate in a specific manner. Thus, the computer-readable medium storing the instructions comprises an article of manufacture that includes instructions for implementing various aspects of the functions / actions specified in one or more blocks in the flowchart and / or block diagram.
[0082] Computer-readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device to cause a series of operational steps to be performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process, thereby causing the instructions executed on the computer, other programmable data processing apparatus, or other device to perform the functions / actions specified in one or more boxes of a flowchart and / or block diagram.
[0083] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of the present disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of an instruction, which contains one or more executable instructions for implementing a specified logical function. In some alternative implementations, the functions marked in the blocks may occur in a different order than those marked in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions. It will be known to those skilled in the art that implementation in hardware, implementation in software, and implementation in a combination of software and hardware are equivalent.
[0084] The various embodiments of this disclosure have been described above. These descriptions are exemplary and not exhaustive, and are not limited to the disclosed embodiments. Many modifications and variations will be apparent to those skilled in the art without departing from the scope of the described embodiments. The terminology used herein is chosen to best explain the principles, practical application, or improvement of the technology in the market, or to enable others skilled in the art to understand the embodiments disclosed herein.
Claims
1. A method for detecting appearance defects, characterized in that, include: For each of at least one point of the target object, acquire an appearance image of the point; A first inspection is performed on the appearance image of the point to determine whether there is a preset defect in the appearance of the point. If a predetermined defect exists in the appearance of the specified location, it is determined whether the appearance of the target object is defective based on the type of the predetermined defect. In the case where a preset defect exists in the appearance of the target object, determining whether the appearance of the target object has a defect based on the type of the preset defect includes: In the event of a dirt defect at the specified location, detect the dirty pixels in the defective portion of the appearance image. If the number of dirty pixels in the appearance image is greater than a preset threshold, it is determined that the appearance of the target object has a defect; The detection of dirty pixels in the defective portion of the appearance image includes: The defective parts of the appearance image are converted to grayscale. Calculate the standard deviation of the image matrix of the defective portion of the appearance image; Based on the standard deviation and a preset function, a first parameter of the defective portion of the appearance image is determined, wherein the preset function is a linear function of the standard deviation and the first parameter; Based on the first parameter, the defective portion of the appearance image is binarized to determine the dirty pixels in the defective portion of the appearance image. Before detecting dirty pixels in the defective portion of the appearance image, the method further includes: Obtain the standard deviation std and the first parameter C of m appearance images, and use the standard deviation and the first parameter of each appearance image as a set of training data to obtain a training set including m sets of training data. Initialize the fitting function h θ (std)=θ i0 +θ i1 ×std, initialization parameter θ i0 =θ i1 =0, initialize learning rate α = 0.001, initial number of iterations k = 0; The training set is input and the gradient descent algorithm is applied to iterate the initial fitting function; Update loss function And calculate the partial derivatives According to the partial derivative renew Where θ i Including θ i0 and θ i1 ; When the iteration count k meets the requirement or the function meets the requirement, the preset function h is output. θ (std)=θ k0 +θ k1 std.
2. The method according to claim 1, characterized in that, The appearance images of the location include multiple appearance images of the location under different brightness lighting conditions.
3. The method according to claim 1, characterized in that, The first detection of the appearance image of the point to determine whether the appearance of the point has a preset defect includes: The appearance image of the location is input into a pre-trained first detection model. The first detection model is used to determine whether the appearance of the location has a preset defect.
4. The method according to claim 2, characterized in that, Before determining whether the appearance of the target object has a defect based on the type of the preset defect, the method further includes: The appearance image of the location is converted to grayscale. Calculate the standard deviation of the image matrix of the appearance images of the points; Retain the appearance images of the points whose standard deviation is greater than or equal to the standard deviation threshold and / or retain the appearance images of the points with the largest standard deviation.
5. The method according to claim 1, characterized in that, In the case where a preset defect exists in the appearance of the target object, determining whether the appearance of the target object has a defect based on the type of the preset defect includes: In the case of a linear defect at the specified location, the diagonal length of the defective portion in the appearance image is detected. When the diagonal length is greater than a preset length threshold, it is determined that the appearance of the target object has a defect.
6. The method according to claim 1, characterized in that, In the case where a preset defect exists in the appearance of the target object, determining whether the appearance of the target object has a defect based on the type of the preset defect includes: In the case of a sheet-like defect at the specified location, the area of the defective portion in the appearance image is detected; When the area is greater than a preset area threshold, it is determined that the appearance of the target object has defects.
7. The method according to claim 1, characterized in that, In the case where a preset defect exists in the appearance of the target object, determining whether the appearance of the target object has a defect based on the type of the preset defect includes: If there is a dent or scratch at the specified location, it can be directly determined that the appearance of the target object is defective.
8. The method according to claim 1, characterized in that, Before performing a first inspection on the appearance image of the location to determine whether the appearance of the location has a preset defect, the method further includes: The appearance image is input into the second detection model to determine the logo portion in the appearance image; Extract the logo portion from the aforementioned appearance image to obtain the logo image; The logo image is input into a third detection model to determine whether there are any appearance defects in the target object in the logo image; If the appearance defect is present in the logo image, it is determined that the target object has an appearance defect.
9. The method according to claim 1, characterized in that, The method further includes: acquiring an appearance image of the logo location of the target object; A first inspection is performed on the appearance image of the logo location to determine whether there are any preset defects in the appearance of the logo location; If a predetermined defect exists in the appearance of the logo location, it is determined that the appearance of the target object is defective.
10. An electronic device, characterized in that, The device has a processor and a memory, the memory storing computer instructions that, when executed by the processor, implement the steps of the method according to any one of claims 1-9.
11. A storage medium, characterized in that, It stores computer instructions that, when executed by a processor, implement the steps of the method described in any one of claims 1-9.
Citation Information
Patent Citations
Defect detection method, system, and apparatus
CN110726724A
Cigarette appearance online detection method and device
CN111189837A
Lens detection method and device and readable storage medium
CN111678673A
Product detection method and device, electronic equipment and storage medium
CN111833303A