Target object detection method, device, storage medium and electronic device
By performing two threshold segmentation of the image to be tested of the device to be detected, the problems of large amount of calculation and time-consuming in the prior art are solved, and efficient and fast device defect detection is achieved, which is suitable for high-throughput scenarios.
Patent Information
- Application Number
- CN202111567204.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-20
- Publication Date
- 2025-02-14
- Estimated Expiration
- 2041-12-20
AI Technical Summary
The algorithm used in the prior art for device defect detection has a large amount of calculation, a large resource occupancy, and a long time consuming, making it difficult to achieve real-time detection and fast output results.
By acquiring the image to be tested of the device to be detected, a detection area is generated and two threshold segments are performed. The first segment is used to distinguish the target object from the background, and the second segment is used to determine the abnormal pixels, thereby determining whether the target object has defects.
It realizes simpler and faster device defect detection, greatly improves detection efficiency, is suitable for high-throughput detection scenarios, and can accurately detect defects and noise areas of target objects.
Smart Images

Figure CN114494122B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of device detection, and in particular to a method, device, storage medium and electronic device for detecting a target object. Background Art
[0002] Usually, after a device is manufactured, it may have various defects, such as scratches on the surface of the device pins and cracks on the surface of the device shell. Therefore, it is necessary to detect defects in the produced devices before leaving the factory to eliminate devices with quality defects. Device defect detection generally requires the use of special testing equipment. With the continuous development of science and technology, the structural complexity of various devices and the production capacity of devices are also constantly improving. Correspondingly, higher requirements are placed on device testing equipment.
[0003] However, existing algorithms in the prior art often require the identification of specific objects such as damage and cracks. These object recognition algorithms generally have the problems of large computational complexity, high resource usage, and long time consumption. They are not suitable for scenarios that require real-time detection and complete calculations and output results in a short time. Summary of the invention
[0004] The purpose of the embodiments of the present application is to provide a method, device, storage medium and electronic device for detecting a target object.
[0005] In order to achieve the above-mentioned object, the present application provides a first aspect of a method for detecting a target object, comprising:
[0006] Acquire an image to be tested that includes a device to be tested;
[0007] Generate a detection area in the image to be tested, and make the detection area cover the target object of the device to be tested in the image to be tested;
[0008] Performing a first threshold segmentation on the detection area by using a first preset threshold to determine an actual area of the target object in the detection area, wherein the first preset threshold is used to distinguish the target object from the background area in the image to be detected;
[0009] Performing a second threshold segmentation on the actual area by a second preset threshold to determine abnormal pixels in the actual area, wherein the second preset threshold is set according to a color component of the abnormal pixels;
[0010] Determine whether the target object has an abnormality based on the abnormal area composed of abnormal pixels.
[0011] Optionally, generating a detection area in the image to be tested and making the detection area cover the target object of the device to be tested in the image to be tested includes: obtaining a template image corresponding to the image to be tested, wherein the template image includes a reference device and an initial detection area covering the target object in the reference device; comparing the image to be tested with the template image to determine a position offset between the device to be tested in the image to be tested and the reference device in the template image; and generating a detection area in the image to be tested according to the position offset.
[0012] Optionally, performing a second threshold segmentation on the actual area through a second preset threshold to determine abnormal pixels in the actual area includes: performing a second threshold segmentation on the area covered by the detection area of the image to be tested through a second preset threshold, and determining abnormal pixels in the detection area as initial abnormal pixels; and determining pixels in the initial abnormal pixels that are located in the actual area as abnormal pixels.
[0013] Optionally, determining pixels in the actual area among the initial abnormal pixels as abnormal pixels includes: setting the initial abnormal pixels to 1 and setting all pixels in the actual area to 1; performing an AND operation on the area composed of the initial abnormal pixels and the actual area, and determining pixels whose AND operation result is 1 as abnormal pixels.
[0014] Optionally, after performing a second threshold segmentation on the actual area using a second preset threshold, the method further includes: performing connectivity processing on the binarized actual area; performing denoising processing on the result after the connectivity processing; and determining the actual area of the target object in the detection area based on the detection area after the calculation.
[0015] Optionally, the first preset threshold is a numerical range set according to a difference in component values between a target object of the sample device and a background area in at least one color channel in the sample image.
[0016] Optionally, the second preset threshold is a numerical range set according to a component value of at least one color channel in a region where a target object of the sample device in the sample image has defects.
[0017] According to a second aspect of the present application, there is provided a device for detecting a target object, comprising: an image acquisition module for acquiring an image to be detected containing a device to be detected; a detection area determination module for generating a detection area in the image to be detected, and making the detection area cover the target object of the device to be detected in the image to be detected; a first processing module for performing a first threshold segmentation on the detection area through a first preset threshold to determine an actual area of the target object in the detection area, wherein the first preset threshold is used to distinguish the target object from the background area in the image to be detected; a second processing module for performing a second threshold segmentation on the actual area through a second preset threshold to determine abnormal pixels in the actual area, wherein the second preset threshold is set according to the color component of the abnormal pixels; and an abnormality detection module for determining whether the target object has an abnormality according to an abnormal area composed of abnormal pixels.
[0018] A third aspect of the present application provides a machine-readable storage medium, on which instructions are stored. When the instructions are executed by a processor, the processor is configured to execute the above-mentioned target object detection method.
[0019] A fourth aspect of the present application provides an electronic device, in which a processor and a memory are connected via a bus, a computer program is stored in the memory, and the above-mentioned method for detecting a target object is executed when the computer program is called by the processor.
[0020] Through the above technical solution, the defects of the target object can be detected more easily and quickly, the detection efficiency of the target object can be greatly improved, and it can adapt to the detection scene of high-throughput target objects. The solution of the present invention can accurately find the real area of the target object in the detection area through two threshold segmentations, and can detect the defects in the target object, effectively avoiding the noise area outside the target object, and is very suitable for scenes with irregular shapes of target objects.
[0021] Other features and advantages of the embodiments of the present application will be described in detail in the subsequent specific implementation section. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] The accompanying drawings are used to provide a further understanding of the embodiments of the present application and constitute a part of the specification. Together with the following specific implementations, they are used to explain the embodiments of the present application, but do not constitute a limitation on the embodiments of the present application. In the accompanying drawings:
[0023] Figure 1 A schematic diagram of a process flow of a method for detecting a target object according to an embodiment of the present application is schematically shown;
[0024] Figure 2 A schematic diagram of a target object detection device according to an embodiment of the present application is shown;
[0025] Figure 3 The internal structure diagram of a computer device according to an embodiment of the present application is schematically shown. DETAILED DESCRIPTION
[0026] In order to make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the technical scheme in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. It should be understood that the specific implementation methods described herein are only used to illustrate and explain the embodiments of the present application, and are not used to limit the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.
[0027] Figure 1 The flowchart of the method for detecting a target object according to an embodiment of the present application is schematically shown. Figure 1 As shown, in one embodiment of the present application, a method for detecting a target object is provided, comprising the following steps:
[0028] Step 101: Acquire an image to be tested that includes a device to be tested.
[0029] Step 102: Generate a detection area in the image to be detected, and make the detection area cover the target object of the device to be detected in the image to be detected.
[0030] Step 103 , performing a first threshold segmentation on the detection area by using a first preset threshold to determine an actual area of the target object in the detection area, wherein the first preset threshold is used to distinguish the target object from the background area in the image to be detected.
[0031] Step 104 , performing a second threshold segmentation on the actual area by using a second preset threshold to determine abnormal pixels in the actual area, wherein the second preset threshold is set according to the color component of the abnormal pixels.
[0032] Step 105: Determine whether the target object is abnormal based on the abnormal area composed of abnormal pixels.
[0033] As a common defect in device production, the surface damage of device pins often reduces the production quality of devices. Therefore, it is necessary to detect the surface damage of device pins to improve the production quality of devices. To detect the surface of device pins, first, the processor can obtain an image to be tested containing the device to be tested. The image to be tested can be captured by an image acquisition device. The image acquisition device can be a device with image acquisition function such as a camera, a video camera, a camera, a recorder, etc. After the image acquisition device captures the image to be tested containing the device to be tested, the processor can obtain the image to be tested containing the device to be tested. Then, the processor can generate a detection area in the image to be tested, and make the detection area cover the target object of the device to be tested in the image to be tested.
[0034] In one embodiment, generating a detection area in an image to be tested and making the detection area cover a target object of a device to be tested in the image to be tested includes: acquiring a template image corresponding to the image to be tested, wherein the template image includes a reference device and an initial detection area covering the target object in the reference device; comparing the image to be tested with the template image to determine a position offset between the device to be tested in the image to be tested and the reference device in the template image; and generating a detection area in the image to be tested according to the position offset.
[0035] Generate a detection area in the image to be tested, and make the detection area cover the target object of the device to be tested in the image to be tested. The processor can first obtain a template image corresponding to the image to be tested. Among them, the target object of the device to be tested can refer to the pin of the device to be tested. The template image can include a reference device and an initial detection area covering the target object in the reference device. The reference device can refer to a device without defects or with negligible defects. In the template image, the detection area of the template image can be marked according to the position of the reference device. The detection area of the template image can refer to the initial detection area covering the target object in the reference device.
[0036] In the actual detection process, the position of the device to be detected may be offset, that is, the detection area of the template image cannot cover the target object of the device to be detected in the image to be detected. For example, when the positions of the image acquisition device that shoots the template image and the image acquisition device that shoots the image to be detected remain unchanged, but because the device to be detected has not been put in place or the device to be detected is produced and moved during the transmission and detection process, the device in the image to be detected may be offset. In this case, if the detection area of the template image is marked according to the reference device position in the template image, and the detection area is generated in the image to be detected according to the detection area of the template image. At this time, the detection area of the template image may not cover the target object of the device to be detected in the image to be detected, and the result of the device detection will have a large error.
[0037] In order to correct the position offset of the detection area in the image to be detected, the processor can compare the image to be detected with the template image to determine the position offset between the device to be detected in the image to be detected and the reference device in the template image. After determining the position offset, the processor can generate a detection area in the image to be detected according to the position offset. At this time, the relative position relationship between the detection area and the device in the template image is the same as the relative position relationship between the detection area and the device in the image to be detected. Among them, there can be multiple ways to generate the detection area in the image to be detected according to the position offset. For example, it can be to first generate the detection area in the image to be detected, and then adjust the position of the detection area according to the determined position offset to complete the offset correction of the detection area. It can also be to adjust the position offset of the detection area while generating the detection area in the image to be detected according to the position offset to complete the offset correction of the detection area.
[0038] Taking the pins of the device to be detected as an example, if the detection area of the template image covers the pins of the device to be detected, but due to the irregular shape of the device pins, the pins of each device may be deviated. Therefore, after generating the detection area, we can first distinguish the pins of the device to be detected in the image to be detected from the background area to reduce the calculation amount of subsequent detection and improve detection efficiency and accuracy.
[0039] After the detection area is generated, the processor may perform a first threshold segmentation on the detection area by a first preset threshold to determine the actual area of the target object in the detection area. The first preset threshold may distinguish the target object from the background area in the image to be detected. In one embodiment, the first preset threshold is a numerical range set according to the difference in component values between the target object and the background area of the sample device in the sample image in at least one color channel. The first preset threshold may be a numerical range set according to the difference in component values of the edge of the sample device in the sample image in at least one color channel. The sample image contains a sample device. The color component of each pixel in the sample image may involve three color channels, and the color channels may include three channels of R, G and B, and the component value of each color channel may be 0 to 255. The target object of the sample device may be a pin of the sample device. By detecting the sample device, the pixels of the target object and the pixels of the background area may be obtained, so that the first preset threshold is set according to the difference in component values of at least one color channel between the pixels of the target object in the sample device and the pixels of the background area to distinguish the pixels corresponding to the target object and the background area of the sample device. For example, assuming that the target object is a pin, the sample device may be a device with a defective pin.
[0040] After determining the actual area of the target object in the detection area, the processor can perform a second threshold segmentation on the actual area through a second preset threshold to determine the abnormal pixels in the actual area. The second preset threshold can be set according to the color component of the abnormal pixel. In one embodiment, the second preset threshold is a numerical range set according to the component value of at least one color channel in the area where the target object of the sample device in the sample image has defects. The sample image contains a sample device. Each pixel in the sample image can include three color channels, and the color channels can include three channels of R, G and B, corresponding to the red, green and blue channels respectively, and the component value of each color channel can be 0 to 255. Taking the target object as the pin of the device as an example, then the corresponding sample device in this embodiment is a device with a defective pin. After distinguishing the pin of the sample device from the background area where the sample image of the sample device is located, in order to further determine the defective area of the pin of the sample device, a second preset threshold can be set to determine the pixel corresponding to the defective pin of the sample device. When the device to be detected is subsequently detected, it can be quickly distinguished whether the pin of the device to be detected is defective and the pixel corresponding to the defective pin according to the second preset threshold set above. Taking the pin of the device to be tested as an example, in the actual detection process, the pin of the device can be directly illuminated by some light sources in the red, green and blue channels. If the second preset threshold is set according to the component value of the R channel in the area where the pin of the device to be tested is defective in the image to be tested, at this time, because the pin of the device is scratched and the copper surface is exposed, when it is directly illuminated by the light source in the R channel, that is, the red channel, the component value of the R channel in the area where the copper surface is exposed is higher. Therefore, when the second threshold segmentation is performed on the actual area by the second preset threshold, the abnormal pixels in the actual area can be determined, that is, the pixels with higher component values of the R channel.
[0041] In one embodiment, performing a second threshold segmentation on the actual area by using a second preset threshold to determine abnormal pixels in the actual area includes: performing a second threshold segmentation on the area of the image to be tested that is covered by the detection area by using the second preset threshold, and determining abnormal pixels in the detection area as initial abnormal pixels; and determining pixels in the initial abnormal pixels that are located in the actual area as abnormal pixels.
[0042] After determining the actual area of the target object in the detection area, the detection area can be segmented by a second threshold. The processor can first perform a second threshold segmentation on the area of the image to be tested that is covered by the detection area through a second preset threshold, and determine the abnormal pixels in the detection area as initial abnormal pixels. Since the area of the detection area can be larger than the actual area of the target object in the detection area, the abnormal pixel points in the detection area can be points outside the target object. Therefore, after being determined as the initial abnormal pixel, the abnormal pixel points in the detection area need to be further distinguished.
[0043] In one embodiment, determining pixels in the actual area among the initial abnormal pixels as abnormal pixels includes: setting the pixel points of the actual area of the target object in the detection area obtained in step 103 to 1, and setting other pixel points in the detection area to 0, to obtain a binary image; and, since the actual area is irregular, it is preferred to perform a second threshold segmentation on the entire detection area by a second preset threshold in step 104 (this step is not based on the binary image obtained by performing the first threshold segmentation on the image to be tested in step 103, but is directly performed based on the image to be tested), to obtain the initial abnormal pixels in the entire detection area, setting all the initial abnormal pixel points to 1 (a part of these pixels may be located outside the actual area), and setting other pixel points in the detection area to 0, to obtain another binary image; next, the above two binary images are overlaid on each other, and an AND operation is performed, so that the AND operation result of the pixels that are both located in the actual area and abnormal is still 1, so that the abnormal pixels in the actual area of the target object can be found.
[0044] In one embodiment, after performing a second threshold segmentation on the actual area using a second preset threshold, the method further includes: performing connectivity processing on the binarized actual area; performing denoising processing on the result after the connectivity processing; and determining the actual area of the target object in the detection area based on the detection area after the calculation.
[0045] After performing the second threshold segmentation on the actual area by the second preset threshold, the processor may further perform connectivity processing on the binarized actual area. The connectivity processing may refer to performing a closing operation on the actual area. That is, several defects that are visually discontinuous but may actually be the same defect may be merged together. After performing the connectivity processing, the processor may perform denoising processing on the result after the connectivity processing. The denoising processing may refer to an opening operation. That is, isolated small dots, burrs, and small connections may be removed, so that the shape outline of the actual area remains basically unchanged.
[0046] After determining the abnormal pixels, the processor can determine whether the target object is abnormal based on the abnormal area composed of the abnormal pixels. In one embodiment, to determine whether the target object is abnormal, an AND operation can be performed on the actual area of the target object in the detection area and the abnormal area composed of the abnormal pixels. Then, the pixel points whose operation result of the AND operation is 0 are extracted, and the area of the pixel points is calculated to determine whether the target object is abnormal. Taking the pins of the detection device as an example, the abnormality of the device pins can be copper leakage.
[0047] Through the above technical solution, defects of the target object can be detected more easily and quickly, the detection efficiency of the target object can be greatly improved, and it can adapt to high-throughput target object detection scenarios.
[0048] Figure 1 FIG. 1 is a flow chart of a method for detecting a target object in one embodiment. It should be understood that although Figure 1 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figure 1 At least part of the steps may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.
[0049] In one embodiment, Figure 2 As shown, a detection device for a target object is provided, comprising an image acquisition module, a detection area determination module, a first processing module, a second processing module and an abnormality detection module, wherein:
[0050] The image acquisition module 201 is used to acquire an image to be tested that includes a device to be tested.
[0051] The detection area determination module 202 is used to generate a detection area in the image to be detected, and make the detection area cover the target object of the device to be detected in the image to be detected.
[0052] The first processing module 203 is used to perform a first threshold segmentation on the detection area through a first preset threshold to determine the actual area of the target object in the detection area, wherein the first preset threshold is used to distinguish the target object from the background area in the image to be detected.
[0053] The second processing module 204 is configured to perform a second threshold segmentation on the actual area by using a second preset threshold to determine abnormal pixels in the actual area, wherein the second preset threshold is set according to the color component of the abnormal pixels.
[0054] The abnormality detection module 205 is used to determine whether there is an abnormality in the target object according to the abnormal area composed of abnormal pixels.
[0055] When the surface of the device pin is inspected, the image acquisition module 201 can acquire the image to be tested of the device to be detected. The image to be tested may refer to an image to be tested containing the device to be detected. The image to be tested may be captured by an image acquisition device. The image acquisition device may be a device with image acquisition function such as a camera, a video camera, a camera, a recorder, etc. After the image acquisition device captures the image to be tested containing the device to be detected, the image acquisition module 201 can acquire the image to be tested of the device to be detected.
[0056] After acquiring the image to be tested of the device to be tested, the detection area delineation module 202 can generate a detection area in the image to be tested, and make the detection area cover the target object of the device to be tested in the image to be tested. Specifically, the detection area delineation module 202 can obtain a template image corresponding to the image to be tested, wherein the template image includes a reference device and an initial detection area covering the target object in the reference device. After acquiring the template image, the detection area delineation module 202 compares the image to be tested with the template image to determine the position offset between the device to be tested in the image to be tested and the reference device in the template image. When the position offset is determined, the detection area delineation module 202 can generate a detection area in the image to be tested according to the position offset.
[0057] After determining the detection area of the image to be tested, the first processing module 203 can perform a first threshold segmentation on the detection area through a first preset threshold to determine the actual area of the target object in the detection area, wherein the first preset threshold is used to distinguish the target object from the background area in the image to be tested. Wherein, the sample image contains a sample device. By detecting the sample device, the pixels of the target object and the pixels of the background area can be obtained, so that the first preset threshold is set according to the difference in component values of at least one color channel in the pixels of the target object and the pixels of the background area in the sample device to distinguish the pixels corresponding to the target object and the background area of the sample device. For example, assuming that the target object is a pin, the sample device can be a device with a defective pin. The color channel may include three channels of R, G and B, and the component value of each color channel may be 0 to 255.
[0058] When the actual area of the target object in the detection area is determined, the second processing module 204 can perform a second threshold segmentation on the actual area by a second preset threshold to determine abnormal pixels in the actual area, wherein the second preset threshold is set according to the color component of the abnormal pixels. After determining the abnormal pixels, the abnormality detection module 205 can determine whether the target object is abnormal according to the abnormal area composed of the abnormal pixels.
[0059] The target object detection device includes a processor and a memory. The above-mentioned image acquisition module, detection area determination module, first processing module, second processing module and abnormality detection module are all stored in the memory as program units, and the processor executes the above-mentioned program modules stored in the memory to implement corresponding functions.
[0060] The processor includes a kernel, which calls the corresponding program unit from the memory. One or more kernels can be set, and the detection method of the target object can be implemented by adjusting the kernel parameters.
[0061] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM, and the memory includes at least one memory chip.
[0062] An embodiment of the present application provides a storage medium on which a program is stored. When the program is executed by a processor, the above-mentioned target object detection method is implemented.
[0063] An embodiment of the present application provides a processor, which is used to run a program, wherein the above-mentioned target object detection method is executed when the program is running.
[0064] An embodiment of the present application provides an electronic device, including a processor and a memory, wherein the processor and the memory are connected via a bus, and a computer program is stored in the memory. When the computer program is called by the processor, the above-mentioned target object detection method is executed.
[0065] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 3As shown. The computer device includes a processor A01, a network interface A02, a memory (not shown in the figure) and a database (not shown in the figure) connected through a system bus. Among them, the processor A01 of the computer device is used to provide computing and control capabilities. The memory of the computer device includes an internal memory A03 and a non-volatile storage medium A04. The non-volatile storage medium A04 stores an operating system B01, a computer program B02 and a database (not shown in the figure). The internal memory A03 provides an environment for the operation of the operating system B01 and the computer program B02 in the non-volatile storage medium A04. The database of the computer device is used to store data such as images to be tested. The network interface A02 of the computer device is used to communicate with an external terminal through a network connection. When the computer program B02 is executed by the processor A01, a method for detecting a target object is implemented.
[0066] Those skilled in the art will understand that Figure 3 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0067] An embodiment of the present application provides a device, which includes a processor, a memory, and a program stored in the memory and executable on the processor. When the processor executes the program, the following steps are implemented: obtaining an image to be tested that includes a device to be tested; generating a detection area in the image to be tested, and making the detection area cover a target object of the device to be tested in the image to be tested; performing a first threshold segmentation on the detection area through a first preset threshold to determine an actual area of the target object in the detection area, wherein the first preset threshold is used to distinguish the target object from the background area in the image to be tested; performing a second threshold segmentation on the actual area through a second preset threshold to determine abnormal pixels in the actual area, wherein the second preset threshold is set according to the color component of the abnormal pixels; and determining whether the target object has an abnormality based on the abnormal area composed of the abnormal pixels.
[0068] In one embodiment, generating a detection area in an image to be tested and making the detection area cover a target object of a device to be tested in the image to be tested includes: acquiring a template image corresponding to the image to be tested, wherein the template image includes a reference device and an initial detection area covering the target object in the reference device; comparing the image to be tested with the template image to determine a position offset between the device to be tested in the image to be tested and the reference device in the template image; and generating a detection area in the image to be tested according to the position offset.
[0069] In one embodiment, performing a second threshold segmentation on the actual area by using a second preset threshold to determine abnormal pixels in the actual area includes: performing a second threshold segmentation on the area of the image to be tested that is covered by the detection area by using the second preset threshold, and determining abnormal pixels in the detection area as initial abnormal pixels; and determining pixels in the initial abnormal pixels that are located in the actual area as abnormal pixels.
[0070] In one embodiment, determining pixels in the actual area among the initial abnormal pixels as abnormal pixels includes: setting the initial abnormal pixels to 1 and setting all pixels in the actual area to 1; performing an AND operation on the area composed of the initial abnormal pixels and the actual area, and determining pixels whose AND operation result is 1 as abnormal pixels.
[0071] In one embodiment, after performing a second threshold segmentation on the actual area using a second preset threshold, the method further includes: performing connectivity processing on the binarized actual area; performing denoising processing on the result after the connectivity processing; and determining the actual area of the target object in the detection area based on the detection area after the calculation.
[0072] In one embodiment, the first preset threshold is a numerical range set according to a difference in component values between a target object of the sample device and a background area in at least one color channel in the sample image.
[0073] In one embodiment, the second preset threshold is a value range set according to a component value of at least one color channel in a region where a target object of the sample device in the sample image has defects.
[0074] The present application also provides a computer program product, which, when executed on a data processing device, is suitable for executing a program that is initialized with the following method steps: acquiring an image to be tested that includes a device to be tested; generating a detection area in the image to be tested, and making the detection area cover a target object of the device to be tested in the image to be tested; performing a first threshold segmentation on the detection area through a first preset threshold to determine an actual area of the target object in the detection area, wherein the first preset threshold is used to distinguish the target object from the background area in the image to be tested; performing a second threshold segmentation on the actual area through a second preset threshold to determine abnormal pixels in the actual area, wherein the second preset threshold is set according to the color component of the abnormal pixels; and determining whether the target object has an abnormality based on the abnormal area composed of the abnormal pixels.
[0075] In one embodiment, generating a detection area in an image to be tested and making the detection area cover a target object of a device to be tested in the image to be tested includes: acquiring a template image corresponding to the image to be tested, wherein the template image includes a reference device and an initial detection area covering the target object in the reference device; comparing the image to be tested with the template image to determine a position offset between the device to be tested in the image to be tested and the reference device in the template image; and generating a detection area in the image to be tested according to the position offset.
[0076] In one embodiment, performing a second threshold segmentation on the actual area by using a second preset threshold to determine abnormal pixels in the actual area includes: performing a second threshold segmentation on the area of the image to be tested that is covered by the detection area by using the second preset threshold, and determining abnormal pixels in the detection area as initial abnormal pixels; and determining pixels in the initial abnormal pixels that are located in the actual area as abnormal pixels.
[0077] In one embodiment, determining pixels in the actual area among the initial abnormal pixels as abnormal pixels includes: setting the initial abnormal pixels to 1 and setting all pixels in the actual area to 1; performing an AND operation on the area composed of the initial abnormal pixels and the actual area, and determining pixels whose AND operation result is 1 as abnormal pixels.
[0078] In one embodiment, after performing a second threshold segmentation on the actual area using a second preset threshold, the method further includes: performing connectivity processing on the binarized actual area; performing denoising processing on the result after the connectivity processing; and determining the actual area of the target object in the detection area based on the detection area after the calculation.
[0079] In one embodiment, the first preset threshold is a numerical range set according to a difference in component values between a target object of the sample device and a background area in at least one color channel in the sample image.
[0080] In one embodiment, the second preset threshold is a value range set according to a component value of at least one color channel in a region where a target object of the sample device in the sample image has defects.
[0081] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0082] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0083] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0084] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0085] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0086] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0087] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0088] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity 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, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0089] The above are only embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included within the scope of the claims of the present application.
Claims
1. A method for detecting a target object, characterized in that: The detection method comprises: Acquire an image to be tested that includes a device to be tested; Generate a detection area in the image to be detected, and make the detection area cover the target object of the device to be detected in the image to be detected; Performing a first threshold segmentation on the detection area by using a first preset threshold to determine an actual area of the target object in the detection area, wherein the first preset threshold is used to distinguish the target object from the background area in the image to be detected; Performing a second threshold segmentation on the actual area by a second preset threshold to determine abnormal pixels in the actual area, wherein the second preset threshold is set according to a color component of the abnormal pixel, and the second preset threshold is a numerical range set according to a component value of at least one color channel in an area where a target object of a sample device in a sample image has a defect; Determining whether the target object has an abnormality according to the abnormal area composed of the abnormal pixels; Wherein, performing a second threshold segmentation on the actual area by using a second preset threshold to determine abnormal pixels in the actual area includes: Performing a second threshold segmentation on the area of the image to be tested that is covered by the detection area by using the second preset threshold, and determining abnormal pixels in the detection area as initial abnormal pixels; A pixel located in the actual area among the initial abnormal pixels is determined as the abnormal pixel.
2. The method for detecting a target object according to claim 1, characterized in that: Generating a detection area in the image to be detected and making the detection area cover a target object of the device to be detected in the image to be detected includes: Acquire a template image corresponding to the image to be tested, wherein the template image includes a reference device and an initial detection area covering a target object in the reference device; Comparing the image to be tested with the template image to determine the position offset between the device to be tested in the image to be tested and the reference device in the template image; A detection area is generated in the image to be detected according to the position offset.
3. The method for detecting a target object according to claim 1, characterized in that: Determining the pixels in the initial abnormal pixels and located in the actual area as the abnormal pixels comprises: The initial abnormal pixel is set to 1, and all pixels in the actual area are set to 1; An AND operation is performed on the region composed of the initial abnormal pixels and the actual region, and pixels whose AND operation result is 1 are determined as the abnormal pixels.
4. The method for detecting a target object according to claim 1, characterized in that: The first preset threshold is a numerical range set according to the difference in component values between the target object of the sample device and the background area in at least one color channel in the sample image.
5. A detection device for a target object, characterized in that: include: An image acquisition module, used for acquiring an image to be tested including a device to be tested; A detection area determination module, used for generating a detection area in the image to be detected, and making the detection area cover the target object of the device to be detected in the image to be detected; A first processing module, configured to perform a first threshold segmentation on the detection area by using a first preset threshold to determine an actual area of the target object in the detection area, wherein the first preset threshold is used to distinguish the target object from the background area in the image to be detected; A second processing module is used to perform a second threshold segmentation on the actual area through a second preset threshold to determine abnormal pixels in the actual area, wherein the second preset threshold is set according to the color component of the abnormal pixel, and the second preset threshold is a numerical range set according to the component value of the area where the target object of the sample device in the sample image has defects in at least one color channel, and performing a second threshold segmentation on the actual area through the second preset threshold to determine the abnormal pixels in the actual area includes: performing a second threshold segmentation on the area of the image to be tested covered by the detection area through the second preset threshold, and determining the abnormal pixels in the detection area as initial abnormal pixels; and determining the pixels of the initial abnormal pixels located in the actual area as the abnormal pixels; The abnormality detection module is used to determine whether the target object has an abnormality according to the abnormal area composed of the abnormal pixels.
6. A machine-readable storage medium having instructions stored thereon, characterized in that: When the instruction is executed by a processor, the processor is configured to perform the target object detection method according to any one of claims 1 to 4.
7. An electronic device, comprising a processor and a memory, wherein the processor and the memory are connected via a bus, wherein: A computer program is stored in the memory, and when the computer program is called by the processor, the method for detecting a target object according to any one of claims 1 to 4 is executed.
Citation Information
Patent Citations
System and method for visual inspection on burrs and stain defects of radio frequency identification (RFID) antennae
CN103091331A
Circuit board defect detection method and device, terminal equipment and storage medium
CN111982911A
LCD foreign matter defect color imaging detection method, electronic equipment and storage medium
CN112798613A