Appearance inspection method, device, equipment, storage medium and computer product
By constructing a template library and matching the images of the items to be detected, the problem of misjudgment of product appearance detection in the prior art is solved, the detection accuracy is improved, and it is suitable for product appearance defect detection in various forms and imaging situations.
Patent Information
- Application Number
- CN202410932178.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-12
- Publication Date
- 2024-11-19
- Estimated Expiration
- 2044-07-12
AI Technical Summary
In the prior art, due to misjudgment in the binary processing during product appearance detection, the accuracy of product appearance detection is reduced. Especially when the product has different shapes and different imaging light and darkness, the accuracy of defect detection is insufficient.
By constructing a template library, including product images in different shapes and imaging situations, a template library is established, and the images of the items to be detected are matched based on this library to improve detection accuracy.
It effectively solves the problem of misjudgment in product appearance detection, improves the detection accuracy, and ensures the accuracy of product appearance defect detection in various forms and imaging situations.
Smart Images

Figure CN118521571B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image recognition technology, and in particular to an appearance detection method, device, equipment, storage medium and computer product. Background Art
[0002] As the level of intelligent detection in manufacturing continues to improve, the use of image recognition technology to detect defects in product appearance has been widely used in the production process. In related technologies, the pixel value of the defect area of the product appearance is calculated and compared with the set threshold, and the product exceeding the threshold is judged as a defective product. However, in related technologies, when calculating the pixel value of the defect area, the product image needs to be binarized. When the product itself has various forms and the product image is bright and dark, the difference between the binarized images is large, and there are misjudgments when detecting surface defects, resulting in a decrease in the accuracy of product appearance detection. Summary of the invention
[0003] The main purpose of this application is to provide an appearance inspection method, device, equipment, storage medium and computer product, aiming to solve the technical problem of how to improve the accuracy of product appearance inspection.
[0004] To achieve the above objectives, the present application proposes an appearance detection method, which includes:
[0005] Acquire product sample images, wherein the product sample images include images of various forms and various imaging conditions;
[0006] The product sample image is made into a corresponding template image, and a template library is established based on the template image;
[0007] An image of an object to be detected is received, and based on the template library, the image of the object to be detected is detected to obtain an appearance detection result.
[0008] In one embodiment, the step of making the product sample image into a corresponding template image includes:
[0009] Select the product position of the product sample image to obtain an initial image;
[0010] Performing a good product judgment on the initial image to obtain a good product judgment result, and obtaining a good product image based on the good product judgment result;
[0011] Perform typical judgment on the good product image to obtain a typical judgment result, and obtain a template image based on the typical judgment result.
[0012] In one embodiment, the step of detecting the image of the object to be detected based on the template library to obtain the appearance detection result includes:
[0013] Based on the good product judgment result, obtaining a defective product image;
[0014] Based on the defective product image, the template library is screened to obtain a first template library, and based on the first template library and the good product image, the first template library is screened to obtain a second template library;
[0015] Based on the second template library, the image of the object to be detected is detected to obtain an appearance detection result.
[0016] In one embodiment, the step of screening the template library based on the defective product image to obtain a first template library, and screening the first template library based on the first template library and the good product image to obtain a second template library includes:
[0017] Matching each template image of the template library with the defective product image to obtain a defect similarity, and comparing the defect similarity with a preset defect threshold to obtain a comparison result, and then saving the first template image whose defect similarity is less than the defect threshold in the comparison result to obtain a first template library;
[0018] Each template image in the first template library is matched with the good product image to obtain a good product similarity, and the good product similarity is compared with a preset good product threshold to obtain a comparison result, and then a second template image in the comparison result whose good product similarity is greater than the bad threshold is saved to obtain a second template library.
[0019] In one embodiment, the step of detecting the image of the object to be detected based on the second template library to obtain an appearance detection result includes:
[0020] Compressing the target template library and the image of the object to be detected respectively to obtain a corresponding compressed template library and compressed image;
[0021] Matching the template of the compression template library with the compressed image to obtain compression similarity;
[0022] According to the compression similarity, the templates in the second template library are sorted in descending order to obtain a third template library;
[0023] The third template library and the image of the object to be detected are matched to obtain a matching similarity, and an appearance detection result is obtained based on the matching similarity.
[0024] In one embodiment, the step of matching the third template library with the image of the object to be detected to obtain a matching similarity, and obtaining an appearance detection result based on the matching similarity includes:
[0025] Matching the image of the object to be detected with the templates in the third template library in sequence to obtain matching similarity;
[0026] The matching similarity is judged. If the matching similarity is greater than a preset similarity threshold, the matching similarity is output, and the image of the object to be detected is determined to be a good product, thereby obtaining an appearance detection result.
[0027] In addition, to achieve the above-mentioned purpose, the present application also proposes an appearance detection device, which includes:
[0028] An acquisition module, used to acquire product sample images;
[0029] A template module, used to make the product sample image into a corresponding template image, and to establish a template library based on the template image;
[0030] The detection module is used to receive the image of the object to be detected, and detect the image of the object to be detected based on the template library to obtain an appearance detection result.
[0031] In addition, to achieve the above-mentioned purpose, the present application also proposes an appearance inspection device, which includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the appearance inspection method described above.
[0032] In addition, to achieve the above-mentioned purpose, the present application also proposes a storage medium, which is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the appearance detection method described above are implemented.
[0033] In addition, to achieve the above-mentioned purpose, the present application also provides a computer program product, which includes a computer program, and when the computer program is executed by a processor, the steps of the appearance detection method described above are implemented.
[0034] One or more technical solutions proposed in this application have at least the following technical effects:
[0035] This application constructs an image library that covers the different forms of products to be inspected, product images under different imaging conditions, and various defective product images. The products to be inspected are inspected through the image library, which solves the problems of various forms of products and different brightness of imaging, large differences in binarized images, and misjudgment when detecting appearance surface defects, thereby improving the accuracy of product appearance inspection. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0037] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0038] Figure 1 A schematic diagram of a flow chart provided for Embodiment 1 of the appearance inspection method of the present application;
[0039] Figure 2 This is a flow chart of the appearance inspection method of this application;
[0040] Figure 3 A schematic diagram of the template library production process for the appearance inspection method of this application;
[0041] Figure 4 This is a schematic diagram of the automatic screening template flow of the appearance inspection method of this application;
[0042] Figure 5 This is a schematic diagram of the appearance defect detection operation flow of the appearance inspection method of this application;
[0043] Figure 6 This is a schematic diagram of the module structure of the appearance inspection device according to an embodiment of the present application;
[0044] Figure 7 Schematic diagram of the device structure of the hardware operating environment involved in the appearance detection method in the embodiment of the present application.
[0045] The purpose, features and advantages of this application will be further described in conjunction with the embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0046] It should be understood that the specific embodiments described herein are only used to explain the technical solutions of the present application and are not used to limit the present application.
[0047] In order to better understand the technical solution of the present application, a detailed description will be given below in conjunction with the accompanying drawings and specific implementation methods.
[0048] The main solution of the embodiment of the present application is: obtaining product sample images, wherein the product sample images include images of various forms and various imaging conditions; making the product sample images into corresponding template images, and establishing a template library based on the template images; receiving images of objects to be detected, and based on the template library, detecting the images of objects to be detected to obtain appearance detection results.
[0049] In the related art, the pixel value of the defect area of the product appearance is calculated and compared with the set threshold, and the product exceeding the threshold is judged as a defective product. However, in the related art, when calculating the pixel value of the defect area, the product image needs to be binarized. When the product itself has various forms and the product image is bright and dark, the difference between the binarized images is large, and there are misjudgments when detecting surface defects, resulting in a decrease in the accuracy of product appearance detection.
[0050] This application constructs an image library that covers the different forms of products to be inspected, product images under different imaging conditions, and various defective product images. The products to be inspected are inspected through the image library, which solves the problems of various forms of products and different brightness of imaging, large differences in binarized images, and misjudgment when detecting appearance surface defects, thereby improving the accuracy of product appearance inspection.
[0051] It should be noted that the execution subject of this embodiment can be a computing service device with data processing, network communication and program running functions, such as a tablet computer, a personal computer, a mobile phone, etc., or an appearance inspection device capable of realizing the above functions, etc. The following takes the appearance inspection device as the execution subject as an example to illustrate this embodiment and the following embodiments.
[0052] Based on this, the present application embodiment provides an appearance detection method, referring to Figure 1 , Figure 1 This is a flow chart of the first embodiment of the appearance inspection method of the present application.
[0053] In this embodiment, the appearance detection method includes steps S100 to S300:
[0054] Step S100, obtaining product sample images, wherein the product sample images include images of various forms and various imaging conditions. The detection flow chart is as follows: Figure 2 As shown;
[0055] It should be noted that the product sample images refer to sample images used to construct the template library. The device obtains product images of different forms and different imaging, as well as various defective product images, and builds an image library based on the product sample images, wherein the image library includes a template library, a good product library, and a defective product library.
[0056] Step S200, the product sample image is made into a corresponding template image, and a template library is established based on the template image. The schematic diagram of the template library creation process is shown in FIG. Figure 3 As shown;
[0057] It is understandable that the template image refers to the template used for multi-template appearance surface defect detection. The template library refers to a template library composed of corresponding template images made from each product image with different morphology and imaging. The device obtains images from real-time acquisition or historical images stored locally as product sample images, and preferentially prepares a preliminary template library with historical images stored locally, and then supplements it with images acquired in real time.
[0058] In a first feasible implementation manner, step S200 may further include the following steps:
[0059] A product position of the product sample image is framed to obtain an initial image; a good product judgment is performed on the initial image to obtain a good product judgment result, and a good product image is obtained based on the good product judgment result; a typical judgment is performed on the good product image to obtain a typical judgment result, and a template image is obtained based on the typical judgment result.
[0060] It should be noted that the initial image refers to the image after the product in the image is framed. Good product images refer to the good product images of each form and different imaging that are made into corresponding good product images. The device uses ROI to frame the position of the product sample image that is large in size or has multiple products; the size requirements of the ROI frame are as follows:
[0061] a. The ROI of the template image must not be larger than the ROI of the detection image:
[0062] ≦
[0063] b. The ROI of the good product library image and the ROI of the defective product library image are 1 to 1.5 times the image ROI during normal detection:
[0064] or
[0065] Note: Requirement a is because the multi-template matching algorithm requires that the template image must not be larger than the detection image; requirement b is that during actual production, the position of the product in the field of view is uncertain, and a positioning tool is needed to determine the position of the product in the image, but the positioning tool will have a certain deviation.
[0066] The device adds the initial image to the correct image library based on the judgment result, and it cannot be confused, otherwise it will cause over-killing or under-killing misjudgment.
[0067] The device has the following selection requirements for template images: mainly standard good product images, supplemented by non-standard good product images; the device has the following selection requirements for good product images: standard good product images and non-standard good product images, the number of good product images must be greater than the number of template images; the device has the following selection requirements for defective product images: mainly typical defective product images, supplemented by defective product images that are prone to omission.
[0068] Note: The template image can be made from images in the good product library for positive multi-template matching; the template library can also be made from images in the bad product library for negative multi-template matching.
[0069] Step S300, receiving an image of an object to be detected, and detecting the image of the object to be detected based on the template library to obtain an appearance detection result.
[0070] It is understandable that the appearance inspection result refers to the result obtained by inspecting the appearance defects of the inspected object. The device matches the image of the inspected object with the template image in the template library to obtain the matching similarity, and the device judges the appearance defect detection of the inspected object based on the matching similarity to obtain the appearance inspection result.
[0071] The present embodiment provides an appearance inspection method. The present embodiment first obtains product sample images including various forms and various imaging conditions, produces corresponding template images, and constructs a template library. The template library is used to inspect the images of the objects to be inspected, thereby solving the problem of misjudgment when inspecting appearance surface defects and improving the accuracy of product appearance inspection.
[0072] In a feasible implementation manner, the appearance detection method further includes the following steps. The automatic template screening process diagram is as follows: Figure 4 As shown:
[0073] Based on the good product judgment result, a defective product image is obtained; based on the defective product image, the template library is screened to obtain a first template library; based on the first template library and the good product image, the first template library is screened to obtain a second template library; based on the second template library, the image of the object to be inspected is inspected to obtain an appearance inspection result.
[0074] It should be noted that defective product images refer to defective product images of each form and different imaging that are made into corresponding defective product images. The first template library refers to the first template library obtained by removing unusable templates from the template library. The second template library refers to the second template containing the first template library obtained by judging the first template library. The device matches the template images in the template library with the images in the defective product library one by one, and outputs all similarities of each defective image; as long as any image of the template image exists If the template has the risk of misjudging defective products as good products, the device determines that the template has the risk of misjudging defective products as good products, and marks the template as unusable; at the same time, the device sorts the similarities of the defective product images in descending order and outputs them to obtain the first template library.
[0075] Note: The purpose of sorting from large to small is to facilitate the identification of how close the defective product image is to the similarity threshold. The lower the matching similarity of the defective product image, the better.
[0076] The device matches the template images in the first template library with the images in the good product library one by one, and outputs the maximum similarity of each good product image; after the image in the good product library matches each image in the first template library, if there is If there is a situation where the templates in the first template library cannot cover the images in the good product library, there is a risk of misjudging good products as defective products, and new templates need to be added to the template library; at the same time, the similarities of the good product images are sorted and output in ascending order.
[0077] Note: The purpose of sorting from small to large is to facilitate the identification of how close the good product image is to the similarity threshold. The higher the matching similarity of the good product image, the better.
[0078] If new images are added to the template library, good product library, or defective product library, the device will need to automatically screen them again.
[0079] The present embodiment provides an appearance inspection method. In the present embodiment, the device first confirms whether there is a missed false positive by checking whether the matching similarity between all images in the defective product library and each template in the template library is less than a similarity threshold; then confirms whether there is an over-false positive by checking whether the matching similarity between all images in the good product library and each template in the template library is greater than a threshold. By automatically screening templates, the problem of misjudgment in the detection of appearance surface defects is solved, thereby improving the accuracy of product appearance inspection.
[0080] In a feasible implementation manner, the appearance inspection method further includes the following steps. The appearance defect inspection operation flow diagram is as follows: Figure 5 As shown:
[0081] The image of the object to be detected is matched with the templates of the third template library in sequence to obtain matching similarity; the matching similarity is judged, and if the matching similarity is greater than a preset similarity threshold, the matching similarity is output, and the image of the object to be detected is determined to be a good product, thereby obtaining an appearance detection result.
[0082] It is understandable that the matching similarity refers to the degree of similarity between the image of the object to be detected and the template in the third template library. The device compresses the template in the third template library and the image of the object to be detected to obtain a compressed template and a compressed image, wherein the compressed template and the compressed image are used for vinegar matching, and the image of the object to be detected and the template in the third template library are used for fine matching. The device sequentially uses the compressed template of the template image and the compressed image of the image of the object to be detected for matching to obtain n matching similarities. The device sorts the template images from large to small according to the similarities; and sequentially uses the template images and the target image for template matching in accordance with the rough matching order. When the matching similarity is greater than the similarity threshold, the matching similarity is output, and the image of the object to be detected is determined to be a good product, and the appearance detection result is obtained.
[0083] The present embodiment provides an appearance detection method. The present embodiment performs appearance detection on an object to be detected by a multi-template matching method. While ensuring the stability of the detection time, multiple templates are matched simultaneously, and the matching similarity is optimized. Multi-template matching is achieved by improving the traditional algorithm, reducing the hardware performance requirements and achieving cost reduction.
[0084] The present application also provides a device, the module structure diagram of the device is as follows Figure 6 As shown, the appearance detection device includes:
[0085] An acquisition module 10 is used to acquire a product sample image;
[0086] The template module 20 is used to make the product sample image into a corresponding template image, and to establish a template library based on the template image;
[0087] The detection module 30 is used to receive an image of an object to be detected, and detect the image of the object to be detected based on the template library to obtain an appearance detection result.
[0088] Optionally, the template module comprises:
[0089] The judgment module is used to frame the product position of the product sample image to obtain an initial image; perform good product judgment on the initial image to obtain a good product judgment result, and obtain a good product image based on the good product judgment result; perform typical judgment on the good product image to obtain a typical judgment result, and obtain a template image based on the typical judgment result.
[0090] The screening module is used to obtain a defective product image based on the good product judgment result; based on the defective product image, the template library is screened to obtain a first template library; based on the first template library and the good product image, the first template library is screened to obtain a second template library; based on the second template library, the image of the object to be inspected is inspected to obtain an appearance inspection result.
[0091] A comparison module is used to match each template image in the template library with the defective product image to obtain a defective similarity, and compare the defective similarity with a preset defective threshold to obtain a comparison result, and then save the first template image whose defective similarity is less than the defective threshold in the comparison result to obtain a first template library; match each template image in the first template library with the good product image to obtain a good product similarity, and compare the good product similarity with a preset good product threshold to obtain a comparison result, and then save the second template image whose good product similarity is greater than the bad threshold in the comparison result to obtain a second template library.
[0092] The compression module is used to compress the target template library and the image of the object to be detected respectively to obtain a corresponding compressed template library and a compressed image; match the templates of the compressed template library with the compressed image to obtain compression similarity; sort the templates of the second template library from large to small according to the compression similarity to obtain a third template library; match the third template library with the image of the object to be detected to obtain matching similarity, and obtain an appearance detection result based on the matching similarity.
[0093] The matching module is used to match the image of the object to be detected with the templates of the third template library in sequence to obtain matching similarity; judge the matching similarity, and if the matching similarity is greater than a preset similarity threshold, output the matching similarity, and determine that the image of the object to be detected is a good product, thereby obtaining an appearance detection result.
[0094] The present application also provides an appearance detection device, such as Figure 7 As shown, it shows a schematic diagram of the structure of the appearance inspection device suitable for implementing the embodiment of the present application. The appearance inspection device in the embodiment of the present application may include but is not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Descriptions), PMPs (Portable Media Players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 7 The appearance inspection device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0095] like Figure 7 As shown, the appearance inspection device may include a processing device 1001 (such as a central processing unit, a graphics processor, etc.), which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM: Read Only Memory) 1002 or the program loaded from the storage device 1003 to the random access memory (RAM: Random Access Memory) 1004. In RAM1004, various programs and data required for the operation of the appearance inspection device are also stored. The processing device 1001, ROM1002 and RAM1004 are connected to each other through a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Generally, the following systems can be connected to the I / O interface 1006: an input device 1007 including, for example, a touch screen, a touchpad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; an output device 1008 including, for example, a liquid crystal display (LCD: Liquid Crystal Display), a speaker, a vibrator, etc.; a storage device 1003 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 1009. The communication device 1009 can allow the appearance inspection device to communicate with other devices wirelessly or wired to exchange data. Although the figure shows an appearance inspection device with various systems, it should be understood that it is not required to implement or have all the systems shown. More or fewer systems can be implemented or provided instead.
[0096] In particular, according to the embodiments disclosed in the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present application include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device, or installed from a storage device 1003, or installed from a ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiment disclosed in the present application are executed.
[0097] The appearance inspection device provided by the present application adopts the appearance inspection method in the above embodiment to solve the technical problem of appearance inspection. Compared with the prior art, the beneficial effects of the appearance inspection device provided by the present application are the same as the beneficial effects of the appearance inspection method provided by the above embodiment, and the other technical features in the appearance inspection device are the same as the features disclosed in the method of the previous embodiment, which will not be repeated here.
[0098] It should be understood that the various parts disclosed in this application can be implemented by hardware, software, firmware or a combination thereof. In the description of the above embodiments, specific features, structures, materials or characteristics can be combined in any one or more embodiments or examples in a suitable manner.
[0099] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
[0100] An embodiment of the present application provides a storage medium, and the storage medium stores one or more programs, and the one or more programs can also be executed by one or more processors to implement the steps of any of the above-mentioned appearance detection methods.
[0101] The specific implementation of the storage medium of the present application is basically the same as the embodiments of the appearance detection method described above, and will not be repeated here.
[0102] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.
[0103] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.
[0104] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus hardware platform, or by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, or the part that contributes to the relevant technology, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM) and includes several instructions for enabling a terminal device (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in each embodiment of the present invention.
[0105] The above are only some embodiments of the present application, and the scope of implementation of the present application is not limited thereto. Any equivalent structure or equivalent process transformation made using the contents of the present application specification, or directly or indirectly applied in other related technical fields, are also included in the protection scope of the present application.
Claims
1. A method for appearance detection, characterized in that: The appearance detection method comprises: Acquire product sample images, wherein the product sample images include images of various forms and various imaging conditions; The product sample image is made into a corresponding template image, and a template library is established based on the template image; The step of making the product sample image into a corresponding template image comprises: Select the product position of the product sample image to obtain an initial image; Performing a good product judgment on the initial image to obtain a good product judgment result, and obtaining a good product image based on the good product judgment result; Performing typical judgment on the good product image to obtain a typical judgment result, and obtaining a template image based on the typical judgment result; Receiving an image of an object to be detected, and detecting the image of the object to be detected based on the template library to obtain an appearance detection result; Based on the template library, the step of detecting the image of the object to be detected to obtain the appearance detection result includes: Based on the good product judgment result, obtaining a defective product image; Based on the defective product image, the template library is screened to obtain a first template library, and based on the first template library and the good product image, the first template library is screened to obtain a second template library; Based on the second template library, the image of the object to be detected is detected to obtain an appearance detection result; The step of detecting the image of the object to be detected based on the second template library to obtain an appearance detection result comprises: Compressing the second template library and the image of the object to be detected respectively to obtain corresponding compressed template library and compressed image; Matching the template of the compression template library with the compressed image to obtain compression similarity; According to the compression similarity, the templates in the second template library are sorted in descending order to obtain a third template library; The third template library and the image of the object to be detected are matched to obtain a matching similarity, and an appearance detection result is obtained based on the matching similarity.
2. The appearance inspection method according to claim 1, characterized in that: The steps of screening the template library based on the defective product image to obtain a first template library, and screening the first template library based on the first template library and the good product image to obtain a second template library include: Matching each template image of the template library with the defective product image to obtain a defect similarity, and comparing the defect similarity with a preset defect threshold to obtain a comparison result, and then saving the first template image whose defect similarity is less than the defect threshold in the comparison result to obtain a first template library; Each template image in the first template library is matched with the good product image to obtain a good product similarity, and the good product similarity is compared with a preset good product threshold to obtain a comparison result, and then a second template image in the comparison result whose good product similarity is greater than the good product threshold is saved to obtain a second template library.
3. The appearance inspection method according to claim 1, characterized in that: The step of matching the third template library with the image of the object to be detected to obtain a matching similarity, and obtaining an appearance detection result based on the matching similarity includes: Sequentially matching the image of the object to be detected with the templates in the third template library to obtain matching similarity; The matching similarity is judged. If the matching similarity is greater than a preset similarity threshold, the matching similarity is output, and the image of the object to be detected is determined to be a good product, thereby obtaining an appearance detection result.
4. An appearance inspection device, characterized in that: The device comprises: An acquisition module, used to acquire product sample images; A template module, used to make the product sample image into a corresponding template image, and to establish a template library based on the template image; The template module comprises: A judgment module is used to frame the product position of the product sample image to obtain an initial image; perform a good product judgment on the initial image to obtain a good product judgment result, and obtain a good product image based on the good product judgment result; perform a typical judgment on the good product image to obtain a typical judgment result, and obtain a template image based on the typical judgment result; A detection module, used for receiving an image of an object to be detected, and detecting the image of the object to be detected based on the template library to obtain an appearance detection result; The detection module comprises: A screening module, configured to obtain a defective product image based on the good product judgment result; screen the template library based on the defective product image to obtain a first template library; screen the first template library based on the first template library and the good product image to obtain a second template library; and detect the image of the object to be detected based on the second template library to obtain an appearance detection result; The screening module comprises: The compression module is used to compress the second template library and the image of the object to be detected respectively to obtain a corresponding compressed template library and a compressed image; match the templates of the compressed template library with the compressed image to obtain compression similarity; sort the templates of the second template library from large to small according to the compression similarity to obtain a third template library; match the third template library with the image of the object to be detected to obtain matching similarity, and obtain an appearance detection result based on the matching similarity.
5. An appearance inspection device, characterized in that: The device comprises: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the appearance detection method according to any one of claims 1 to 3.
6. A storage medium, characterized in that: The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the appearance inspection method according to any one of claims 1 to 3 are implemented.
7. A computer program product, characterized in that The computer program product comprises a computer program, and when the computer program is executed by a processor, the steps of the appearance detection method according to any one of claims 1 to 3 are implemented.
