Method for detecting and identifying plastic target and related product
By using a pre-set detection model and contour removal technology, the accuracy problem of plastic target detection and recognition in complex backgrounds is solved, and efficient plastic target detection and recognition in complex backgrounds is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-30
- Publication Date
- 2026-04-07
AI Technical Summary
Existing near-infrared plastic identification systems struggle to accurately detect and identify plastic targets in complex imaging backgrounds, and traditional methods may include image data of non-plastic targets, resulting in low accuracy in detection, localization, and type identification.
A preset detection model is used to detect plastic targets. After obtaining the bounding box, the contour is extracted and non-complete contours are removed to ensure that the bounding box contains only complete contours. The image area is expanded in complex backgrounds to perform more comprehensive contour extraction. A mask is constructed to remove the detected targets to reduce interference.
It improves the accuracy and robustness of plastic target detection and localization, ensuring that each bounding box contains only one complete plastic target, eliminating interference from non-plastic targets, and thus improving the accuracy of detection and recognition.
Smart Images

Figure CN121810554A_ABST
Abstract
Description
Technical Field
[0001] This disclosure generally relates to the field of image processing technology. More specifically, this disclosure relates to a method, apparatus, and computer-readable storage medium for detecting plastic targets. Further, this disclosure also relates to a method, apparatus, and computer-readable storage medium for identifying plastic targets. Background Technology
[0002] With the development of technology, the diversity and complexity of plastic products are constantly increasing, making accurate detection and identification of plastic products a challenge. Existing near-infrared plastic identification systems utilize near-infrared optics technology, employing near-infrared spectral acquisition in key wavelength bands to image plastic products, obtaining near-infrared images containing plastic targets. Subsequently, through analysis and processing of these near-infrared images, the detection and identification of plastic targets can be achieved.
[0003] However, in actual imaging processes, complex backgrounds often result in incomplete outlines for some plastic targets. In such cases, traditional analysis and processing methods struggle to effectively detect, locate, and identify the type of plastic targets. Furthermore, while traditional methods can detect plastic targets and obtain bounding boxes surrounding them, these boxes may contain image data of non-plastic targets, leading to lower accuracy in detecting, locating, and identifying the type of plastic targets.
[0004] In view of this, there is an urgent need to provide a solution for detecting and identifying plastic targets, so as to effectively detect and identify plastic targets and improve the accuracy of detection, positioning and type identification of plastic products. Summary of the Invention
[0005] In order to at least address one or more of the technical problems mentioned above, this disclosure proposes solutions for detecting and identifying plastic targets in the following aspects.
[0006] In a first aspect, this disclosure provides a method for detecting plastic targets, comprising: acquiring an image to be inspected containing plastic targets; performing a detection operation on the plastic targets in the image to be inspected using a preset detection model to obtain a bounding box surrounding the plastic targets; performing a contour extraction operation on the image region surrounded by the bounding box to obtain multiple contours within the bounding box; based on the contour points on the multiple contours, removing incomplete contours from the multiple contours to obtain complete contours within the bounding box, wherein all contour points on the complete contours are located within the bounding box; and determining the image data surrounded by the complete contours within the bounding box as the image data of the plastic targets.
[0007] In some embodiments, performing a contour extraction operation on the image region enclosed by the bounding box to obtain multiple contours within the bounding box includes: performing an expansion operation on the image to be inspected and the bounding box to obtain an expanded image to be inspected and an expanded bounding box; and performing a contour extraction operation on the image region enclosed by the expanded bounding box to obtain multiple contours within the expanded bounding box.
[0008] In some embodiments, performing contour extraction on the image region enclosed by the bounding box to obtain multiple contours within the bounding box includes: obtaining the image region enclosed by the bounding box from the image to be inspected; performing binarization processing on the image region using a preset threshold to obtain a binarized image region; performing morphological processing on the binarized image region to obtain a morphologically processed image region; and performing contour extraction on the morphologically processed image region to obtain multiple contours within the bounding box.
[0009] In some embodiments, expanding the image to be inspected and the bounding box to obtain an expanded image to be inspected and an expanded bounding box includes: expanding the image to be inspected outward by N pixels around its perimeter and filling the N pixels with 0 values to obtain the expanded image to be inspected, wherein N is an integer greater than 0; increasing the horizontal and vertical coordinates of the lower right corner of the bounding box by 2N pixels respectively to obtain the expanded bounding box.
[0010] In some embodiments, the number of plastic targets is multiple, and the method further includes: constructing a mask of the complete contour, and using the mask to remove the corresponding plastic target from the image to be inspected to obtain a new image to be inspected; performing a contour extraction operation on the image region surrounded by the bounding box of the next plastic target in the new image to obtain multiple contours within the bounding box of the next plastic target; and continuing to perform the step of removing incomplete contours from the multiple contours based on contour points on the multiple contours to obtain complete contours within the bounding box, and determining the image data surrounded by the complete contours within the bounding box as the image data of the plastic target.
[0011] In some embodiments, the image to be inspected is a near-infrared image, and the preset detection model is a model obtained by training a machine learning model. Training the preset detection model by a machine learning model includes: acquiring a near-infrared sample image containing a plastic target; annotating the image region where the plastic target is located in the near-infrared sample image to form region annotation information; and inputting the near-infrared sample image and the region annotation information as training data into the preset detection model to train it.
[0012] In a second aspect, this disclosure provides an apparatus for detecting plastic targets, comprising: a processor; and a memory storing program instructions for detecting plastic targets, wherein when the program instructions are executed by the processor, the apparatus implements the method and several embodiments thereof described in the first aspect above.
[0013] In a third aspect, this disclosure provides a method for identifying plastic targets, comprising: acquiring a first near-infrared image and a second near-infrared image containing the plastic target, wherein the wavelength of the first near-infrared light wave used to acquire the first near-infrared image is different from the wavelength of the second near-infrared light wave used to acquire the second near-infrared image; using the method described in the first aspect and several embodiments thereof, determining first image data of the plastic target in the first near-infrared image and second image data of the plastic target in the second near-infrared image; determining a ratio of a first pixel value of the first image data to a second pixel value of the second image data; and determining the type of the plastic target based on the ratio and a preset threshold.
[0014] In a fourth aspect, this disclosure provides an apparatus for identifying plastic targets, comprising: a processor; and a memory storing program instructions for identifying plastic targets, wherein when the program instructions are executed by the processor, the apparatus implements the method and several embodiments thereof described in the third aspect above.
[0015] In a fifth aspect, this disclosure provides a computer-readable storage medium having stored program instructions thereon for detecting or identifying plastic targets, which, when executed by a processor, implement the methods and various embodiments thereof described in the first or third aspect above.
[0016] The above-described scheme for detecting plastic targets utilizes a pre-defined detection model to accurately detect and locate plastic targets in the image, even under complex imaging backgrounds. Applying this scheme to a plastic recognition system improves the overall system robustness. Furthermore, to further enhance detection and localization accuracy, after contour extraction of the image region enclosed by the bounding box obtained by the pre-defined detection module, incomplete contours within the bounding box are removed to obtain complete contours. This ensures that each bounding box contains only one complete plastic target, eliminating interference from non-plastic targets nearby and improving the accuracy of plastic target detection and localization. Subsequently, using complete plastic targets for type recognition further improves the accuracy of plastic target identification.
[0017] Furthermore, in some embodiments, when performing contour extraction on an image region enclosed by a bounding box, the disclosed scheme first expands the image to be inspected and the bounding box to obtain expanded images to be inspected and expanded bounding boxes. Then, contour extraction is performed on the image region enclosed by the expanded bounding box to obtain multiple contours within the expanded bounding box. This is done to ensure that the contours of the plastic target are all contained within the bounding box. At the edges of the image, contour extraction may fail to accurately identify contours due to boundary limitations. The expansion operation provides more contextual information for contour extraction, thereby improving the accuracy of contour recognition.
[0018] Furthermore, in some embodiments, when the image to be inspected contains multiple plastic targets, after detecting one plastic target, a mask of the complete outline of that plastic target can be constructed, and the plastic target can be removed from the image to obtain a new image to be inspected. Then, other plastic targets are detected based on the new image. Thus, by removing plastic targets that have already been detected, interference with subsequent plastic target detection processes can be reduced, which helps to improve the accuracy of plastic target detection. Attached Figure Description
[0019] The above and other objects, features, and advantages of exemplary embodiments of this disclosure will become readily apparent upon reading the following detailed description with reference to the accompanying drawings. In the drawings, several embodiments of this disclosure are illustrated by way of example and not limitation, and like or corresponding reference numerals denote like or corresponding parts, wherein:
[0020] Figure 1 This is an exemplary flowchart illustrating a method for detecting plastic targets according to some embodiments of this disclosure;
[0021] Figure 2 This is an exemplary flowchart illustrating a method for detecting plastic targets according to other embodiments of this disclosure;
[0022] Figure 3 It is shown Figure 2 Exemplary execution result diagrams for some steps in the method;
[0023] Figure 4 It is shown Figure 2 Exemplary execution results diagrams for other steps in the method;
[0024] Figure 5 This is an exemplary execution result diagram illustrating the removal of plastic targets according to embodiments of this disclosure;
[0025] Figure 6This is an exemplary flowchart illustrating a method for identifying plastic targets according to an embodiment of this disclosure;
[0026] Figure 7 This is an exemplary structural block diagram illustrating a device according to an embodiment of this disclosure. Detailed Implementation
[0027] The technical solutions in the embodiments of this disclosure will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this disclosure, and not all of them. Based on the embodiments in this disclosure, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this disclosure.
[0028] It should be understood that when the terms "first," "second," "third," and "fourth," etc., are used in the claims, specification, and drawings of this application, they are used only to distinguish different objects and not to describe a specific order. The terms "comprising" and "including" as used in the specification and claims of this disclosure indicate the presence of the described features, integrals, steps, operations, elements, and / or components, but do not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components, and / or collections thereof.
[0029] It should also be understood that the terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the scope of this disclosure. As used in this disclosure and claims, the singular forms “a,” “an,” and “the” are intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used in this disclosure and claims refers to any combination and all possible combinations of one or more of the associated listed items, and includes such combinations.
[0030] As used in this specification and claims, the term "if" may be interpreted, depending on the context, as "when," "once," "in response to determination," or "in response to detection." Similarly, the phrase "if determined" or "if [described condition or event] is detected" may be interpreted, depending on the context, as "once determined," "in response to determination," "once [described condition or event] is detected," or "in response to detection of [described condition or event]."
[0031] The specific embodiments disclosed herein will now be described in detail with reference to the accompanying drawings.
[0032] Figure 1An exemplary flowchart of a method 100 for detecting plastic targets according to some embodiments of this disclosure is shown. It will be understood that method 100 can be performed by any suitable device with data processing capabilities, such as, but not limited to, terminal devices and servers.
[0033] like Figure 1 As shown, in step S101, method 100 can acquire an image of the object to be inspected, containing the plastic target. The plastic target disclosed herein can be an image of a plastic article, which can have any suitable material, shape, and size. Here, the plastic article can be a plastic container, such as a plastic bottle, plastic bucket, or plastic basin. The material of the plastic article can be polypropylene (PP), polyethylene (PE), or polyethylene terephthalate (PET).
[0034] In this disclosed scheme, the image to be inspected can be a near-infrared image, and the image acquisition device in the near-infrared plastic identification system can be used to image the plastic product to obtain an image containing the plastic target. In actual operation, the image acquisition device can utilize the acquisition function of near-infrared light waves to obtain an image containing the plastic target. Here, the near-infrared light waves can include near-infrared light of 1200nm and 1660nm.
[0035] Next, in step S102, method 100 can use a preset detection model to perform a detection operation on the plastic target in the image to be inspected, so as to obtain the bounding box surrounding the plastic target.
[0036] The pre-defined detection model disclosed herein is used to locate plastic targets in an image to be inspected, and the location of the plastic target in the image is identified by the bounding box surrounding the plastic target. This pre-defined detection model can be a model trained using a machine learning model, such as a model trained using the YOLOv5 model.
[0037] In one implementation scenario, when training a machine learning model to obtain a preset detection model, near-infrared sample images containing plastic targets can be acquired first. Next, the image regions containing the plastic targets in the near-infrared sample images can be labeled to form region labeling information. Then, the near-infrared sample images and region labeling information can be used as training data to input into the preset detection model for training. Here, when labeling the image regions containing the plastic targets in the near-infrared sample images, bounding boxes can be used to label the image regions containing the plastic targets, and the four coordinate values of the bounding boxes are determined as the region labeling information for the image regions containing the plastic targets. In practice, the visual image labeling tool Labelimg can be used to label the bounding boxes of each plastic target on the near-infrared sample images.
[0038] In this implementation scenario, to improve the generalization ability of the preset detection model, the near-infrared sample images may include a first infrared sample image and a second infrared sample image with different wavelengths. In other words, in this implementation scenario, the wavelengths of the first infrared light wave used to acquire the first infrared sample image and the wavelengths of the second infrared light wave used to acquire the second infrared sample image are different. In one embodiment, the wavelengths of the first infrared light wave and the second infrared light wave may be one of 1200 nm and 1660 nm, respectively.
[0039] In the disclosed scheme, before training the preset detection model using near-infrared sample images, or before using the preset detection model to detect plastic targets in the image to be inspected, operations such as resizing and pseudo-color processing can be performed on the near-infrared sample images or the image to be inspected according to the requirements of the preset detection model. This preprocessing ensures that the image features (e.g., size and color) of the near-infrared sample images or the image to be inspected conform to the requirements of the preset detection model. In one implementation scenario, when the preset detection model is a model trained using the YOLOv5 model, the near-infrared sample images or the image to be inspected can be resized to 640×640 to meet the image size requirements of the preset detection model. Furthermore, pseudo-color processing can be performed on the near-infrared sample images or the image to be inspected to convert them into color images to meet the image color requirements of the preset detection model.
[0040] Furthermore, to ensure that the model does not overfit the training data and can generalize to unseen data, after the preset detection model is trained, the performance of the trained preset detection model can be evaluated using a validation set to obtain performance evaluation results. Additionally or optionally, the preset detection model can be iteratively adjusted based on the performance evaluation results. Here, the validation set may include near-infrared validation images containing plastic targets and their region annotation information. The method for obtaining near-infrared validation images and their distinguishing annotation information is similar to the method for obtaining near-infrared sample images and their region annotation information described above, and will not be repeated here.
[0041] Next, in step S103, method 100 can perform contour extraction on the image region enclosed by the bounding box to obtain multiple contours within the bounding box. Specifically, the image region enclosed by the bounding box (which can be called the region of interest, ROI for easy distinction) can first be obtained from the image to be inspected through a cropping operation. Then, the ROI can be binarized using a preset threshold to obtain a binarized image region. Following this, morphological processing can be performed on the binarized image region to obtain a morphologically processed image region. Then, the findContours function can be used to perform contour extraction on the morphologically processed image region to obtain multiple contours within the bounding box.
[0042] In practice, a bounding box can be represented by four coordinate values: the center point coordinates (X, Y), the width W, and the height H. These coordinates are not pixel coordinates, but normalized coordinates. Therefore, when it is necessary to obtain the image region enclosed by the bounding box from the image to be inspected, the normalized coordinates of the bounding box can first be converted into pixel coordinates in image space. Then, by performing a cropping operation on the image to be inspected according to the pixel coordinates in image space, the image region enclosed by the bounding box can be obtained. Here, the following formula can be used to convert the normalized coordinates of the bounding box into pixel coordinates in image space:
[0043] x = X × Image_W - (W × Image_W) / 2
[0044] y = Y × Image_H - (H × Image_H) / 2
[0045] w = W × Image_W
[0046] h = H × Image_H
[0047] Where (X, Y, W, H) are the normalized coordinates of the bounding box, (x, y, w, h) are the pixel coordinates of the bounding box, Image_W is the width of the image to be inspected, and Image_H is the height of the image to be inspected.
[0048] It is understood that those skilled in the art can select the specific value or range of the preset threshold for the aforementioned binarization processing according to actual needs, and can also select the specific operation or combination of operations for morphological processing according to actual needs. For example, the specific value of the preset threshold can be selected as 0. As another example, the morphological processing can be selected as an opening operation of erosion followed by dilation, so as to remove small objects or details in the binarized image area and smooth the boundaries of larger objects.
[0049] Next, in step S104, method 100 can eliminate incomplete contours from multiple contours based on contour points on multiple contours to obtain complete contours within bounding boxes. In practice, the completeness of a contour can be determined by checking whether all contour points on a contour are within the bounding box. If all contour points on a contour are within the bounding box, the contour is considered complete; otherwise, it is considered incomplete. Therefore, it can be concluded that all contour points on a complete contour are within the bounding box, while at least one contour point on an incomplete contour is not within the bounding box; or, in other words, at least one contour point on an incomplete contour is on or outside the bounding box.
[0050] Finally, in step S105, method 100 can determine the image data enclosed by the complete contour within the bounding box as the image data of the plastic target. Specifically, a mask of the complete contour can be constructed, and then the image data enclosed by the complete contour can be obtained using this mask and determined as the image data of the plastic target. Here, the mask can be a binary image with the same size as the bounding box. In the mask, the pixel value of the complete contour and its internal region is 255, and the pixel value of the region outside the complete contour is 0. Thus, by using an AND operation between the mask and the image region enclosed by the bounding box, the image data of the plastic target can be obtained.
[0051] After obtaining image data of the plastic target, the next step is to identify the plastic target based on this image data to determine its type. To facilitate understanding how plastic target identification is performed, a discussion will follow later. Figure 6 Provide a detailed description.
[0052] The above combination Figure 1 A method 100 for detecting plastic targets is described. This method 100 can detect plastic targets using a pre-set detection model, accurately detecting and locating plastic targets in the image even under complex imaging backgrounds. Applying this disclosed scheme to a plastic recognition system can improve the robustness of the entire system. Furthermore, after performing contour extraction on the image region enclosed by the bounding box obtained by the pre-set detection module, method 100 also removes incomplete contours from multiple contours within the bounding box to obtain complete contours within the bounding box. This ensures that each bounding box contains only one complete plastic target, eliminating interference from non-plastic targets near the plastic target and improving the accuracy of plastic target detection and localization.
[0053] In step S103, before performing contour extraction on the image region enclosed by the bounding box, method 100 needs to first obtain the image region enclosed by the bounding box from the image to be inspected through a cropping operation. However, for plastic targets near the edges of the image to be inspected, cropping along the bounding box may result in information loss, thus affecting the accuracy of plastic target detection and localization. Therefore, method 100 can perform an expansion operation on the image to be inspected and the bounding box before the cropping operation to obtain an expanded image to be inspected and an expanded bounding box. Then, contour extraction can be performed on the image region enclosed by the expanded bounding box to obtain multiple contours within the expanded bounding box. It is understood that in this case, in the following steps S104 and S105, the image to be inspected operated on by method 100 will be the expanded image to be inspected, and the bounding box will be the expanded bounding box.
[0054] Here, when expanding the image to be inspected and the bounding box, the image to be inspected can be expanded outwards by N pixels, and N pixels can be filled with 0 values to obtain the expanded image to be inspected. Then, the horizontal and vertical coordinates of the lower right corner of the bounding box can be increased by 2N pixels respectively to obtain the expanded bounding box. In this way, when the expanded bounding box is applied to the expanded image to be inspected, it can be ensured that the center of the expanded bounding box does not shift from the center of the plastic target in the expanded image to be inspected. Here, N is an integer greater than 0. It is understood that those skilled in the art can choose a specific value of N according to actual needs, and this disclosure does not impose specific limitations on this.
[0055] In one implementation scenario, the image to be inspected may contain multiple plastic targets, meaning there are at least two plastic targets. In this case, after method 100 performs the detection operation on the plastic targets in the image to be inspected in step S102, it can obtain multiple bounding boxes surrounding the multiple plastic targets. Next, when determining the image data of each plastic target, method 100 can perform steps S103 to S105 on each bounding box to determine the image data of each plastic target. It is understood that if an expansion operation is performed on the image to be inspected and the multiple bounding boxes in step S103, the image to be inspected operated on by method 100 in steps S104 and S105 will be the expanded image to be inspected, and the bounding boxes will be the expanded bounding boxes.
[0056] In this implementation scenario, the distance between multiple plastic targets in the image to be inspected may be very close. Therefore, for each plastic target, the bounding box surrounding it may contain partial image data of other plastic targets, resulting in low accuracy in plastic target detection and localization. To address this issue, method 100 performs the non-complete contour removal operation in step S104, which removes partial image data of other plastic targets within the bounding box, thereby eliminating interference from other nearby plastic targets and improving the accuracy of plastic target detection and localization.
[0057] Furthermore, method 100 can also reduce mutual interference between plastic target detection processes and improve the detection accuracy of plastic targets by removing plastic targets that have already been detected. Specifically, a mask of the complete contour of the plastic targets that have already been detected can be constructed, and the mask can be used to remove the plastic targets that have already been detected from the image to be inspected to obtain a new image to be inspected. Next, a contour extraction operation can be performed on the image region enclosed by the bounding box of the next plastic target in the new image to obtain multiple contours within the bounding box of the next plastic target. After that, the aforementioned steps S104 and S105 can be continued.
[0058] To make it easier to understand, let's combine the following... Figure 2 , Figure 3 and Figure 4 A method for detecting plastic targets, according to other embodiments of this disclosure, will be described in detail here. Figure 2 This is an exemplary flowchart illustrating a method 100 for detecting plastic targets according to other embodiments of this disclosure. Figure 3 and Figure 4 It is shown Figure 2 Exemplary execution result diagrams for each step in the method. Specifically,
[0059] In step S101, method 100 can acquire an image of the object to be inspected containing the plastic target (e.g., ...). Figure 3 (as shown in a).
[0060] In step S102, method 100 can use a preset detection model to perform a detection operation on the plastic target in the image to be inspected, so as to obtain the bounding box surrounding the plastic target (e.g., Figure 3 (as shown in the rectangle in c).
[0061] In step S103-1, method 100 may first perform an expansion operation on the image to be inspected and the bounding box to obtain an expanded image to be inspected (e.g., Figure 3 (as shown in b) and the expanded bounding box (as shown in...) Figure 3 (as shown in the rectangle in d).
[0062] In step S103-2, method 100 can perform contour extraction on the image region enclosed by the expanded bounding box to obtain multiple contours within the expanded bounding box (such as...). Figure 4 (As shown in the first column of images on the left).
[0063] In step S104, method 100 can, based on contour points on multiple contours, remove incomplete contours from multiple contours to obtain complete contours within the bounding box (e.g., ...). Figure 4 (As shown in the second column of images from the left).
[0064] In step S105, method 100 can determine the image data enclosed by the complete outline within the bounding box as the image data of the plastic target (e.g., Figure 4 (As shown in the third column of images from the left).
[0065] In one implementation scenario, for Figure 3The four plastic targets shown in diagram a can be determined by method 100 by repeatedly executing steps S103-2 to S105 four times. Alternatively or additionally, after completing steps S103-2 to S105 in the first three iterations, method 100 can first remove the detected plastic targets from the image to be inspected to obtain a new image before proceeding to the next iteration. See here for more details. Figure 5 The diagram illustrates exemplary execution results of removing plastic targets according to embodiments of this disclosure. Figure 5 a to Figure 5 b shows that after the first cycle process is completed, the first plastic target on the left in the image to be inspected is removed. Figure 5 b to Figure 5 c shows that after the second cycle process is completed, the second plastic target from the left in the image to be inspected is removed. Figure 5 c to Figure 5 Figure d shows that after the third cycle is completed, the third plastic target from the left in the image to be inspected is removed, leaving only the fourth plastic target from the left.
[0066] Understandable, Figures 3 to 5 The number of plastic targets shown is merely exemplary and illustrative, and the implementation methods and entities disclosed herein are not limited thereto, but may be changed without departing from the spirit of this application.
[0067] Next, combine Figure 6 An exemplary method 600 for identifying plastic targets according to an embodiment of this disclosure is described below. It is understood that method 600 can be performed by any suitable device with data processing capabilities, such as, but not limited to, terminal devices and servers.
[0068] like Figure 6 As shown, in step S601, method 600 can acquire a first near-infrared image and a second near-infrared image containing the same plastic target. Here, the wavelengths of the first near-infrared light wave used to acquire the first near-infrared image and the second near-infrared light wave used to acquire the second near-infrared image are different. In one embodiment, the wavelength of the first infrared light wave can be 1200 nm, and the wavelength of the second infrared light wave can be 1660 nm.
[0069] At step S602, method 600 may employ the aforementioned method for detecting plastic targets to determine first image data of the plastic target in the first near-infrared image and second image data of the plastic target in the second near-infrared image.
[0070] In step S603, method 600 can determine the ratio of a first pixel value of the first image data to a second pixel value of the second image data. Here, the first pixel value is the average of the pixel values in the first image data, and the second pixel value is the average of the pixel values in the second image data.
[0071] In step S604, the type of plastic target is determined based on the ratio and a preset threshold. Specifically, it can be determined whether the ratio is greater than the preset threshold. When the ratio is greater than the preset threshold, the plastic target can be determined to be PET plastic. Conversely, when the ratio is less than or equal to the preset threshold, the plastic target can be determined to be PE plastic or PP plastic. It should be understood that those skilled in the art can select the specific value or range of the preset threshold according to actual needs, and this disclosure does not specifically limit it in this regard.
[0072] In one implementation scenario, when there are multiple plastic targets, the type of each plastic target can be determined by executing step S604 multiple times. Furthermore, method 600 can also output the type of each plastic target. Additionally or optionally, method 600 can output the type of each plastic target visually or audibly.
[0073] Next, combine Figure 7 An exemplary description is provided of a device 700 for detecting or identifying plastic targets, as disclosed in this embodiment. For example... Figure 7 As shown, the device 700 in this embodiment may include a processor 701, a memory 702, and a communication bus 703.
[0074] In specific embodiments, the processor 701 described above can be at least one of the following: Application Specific Integrated Circuit (ASIC), Digital Signal Processor (DSP), Digital Signal Processing Device (DSPD), Programmable Logic Device (PLD), Field Programmable Gate Array (FPGA), CPU, controller, microcontroller, and microprocessor. It is understood that for different devices, the electronic device used to implement the above processor function can also be other types, and this embodiment does not specifically limit it.
[0075] In this disclosed embodiment, the communication bus 703 is used to realize the connection and communication between the processor 701 and the memory 702; the memory 702 stores program instructions for detecting or identifying plastic targets; when the processor 701 executes the program instructions stored in the memory 702, it implements the present disclosure in conjunction with the appendix. Figures 1 to 5 The method described herein for detecting plastic targets, or in conjunction with the appendix, is hereby disclosed. Figure 6 The method described is for identifying plastic targets.
[0076] The above combination Figure 7 This disclosure describes apparatus for detecting or identifying plastic targets, which can be used to perform the functions disclosed herein. It should be understood that the apparatus structures or architectures described herein are merely exemplary, and the implementations and entities of this application are not limited thereto, but can be modified without departing from the spirit of this application. It is understood that the descriptions of the various embodiments in this disclosure emphasize the differences between the embodiments, while their similarities or corresponding aspects can be referred to mutually. For the sake of brevity, this disclosure will not elaborate further on each aspect.
[0077] Based on the foregoing description in conjunction with the accompanying drawings, those skilled in the art will understand that the embodiments of this application can also be implemented by software programs. Therefore, this application also provides a computer-readable storage medium. This computer-readable storage medium stores program instructions for detecting a target or for identifying a plastic target, which can be used to implement the disclosure in conjunction with the accompanying drawings. Figures 1 to 5 The method described herein for detecting plastic targets, or in conjunction with the appendix, is hereby disclosed. Figure 6 The method described is for identifying plastic targets.
[0078] It should be noted that although the operations of the method of this application are described in a specific order in the accompanying drawings, this does not require or imply that these operations must be performed in that specific order, or that all the operations shown must be performed to achieve the desired result. On the contrary, the steps depicted in the flowchart can be performed in a different order. Additionally or alternatively, certain steps may be omitted, multiple steps may be combined into one step, and / or one step may be broken down into multiple steps.
[0079] While numerous embodiments of this disclosure have been shown and described herein, it will be apparent to those skilled in the art that such embodiments are provided by way of example only. Many modifications, alterations, and alternatives will occur to those skilled in the art without departing from the spirit and intent of this disclosure. It should be understood that various alternatives to the embodiments of this disclosure described herein may be employed in the practice of this disclosure. The appended claims are intended to define the scope of this disclosure and therefore cover equivalents or alternatives within the scope of these claims.
[0080] The collection and acquisition of various data in this application comply with relevant laws and regulations and are authorized by the data providers. Any organization or individual that needs to obtain external data shall obtain authorization in accordance with the law and ensure data security, and shall not illegally collect, use, process, or transmit unauthorized or unprotected data, nor shall it illegally buy, sell, provide, or disclose unauthorized or unprotected data.
Claims
1. A method for detecting plastic targets, comprising: Acquire an image of the object to be inspected, which contains a plastic target; A preset detection model is used to detect plastic targets in the image to be inspected in order to obtain a bounding box surrounding the plastic targets. Perform contour extraction on the image region enclosed by the bounding box to obtain multiple contours within the bounding box; Based on the contour points on the plurality of contours, incomplete contours are removed from the plurality of contours to obtain complete contours within the bounding box, wherein all contour points on the complete contours are located within the bounding box; and The image data enclosed by the complete outline within the bounding box is determined as the image data of the plastic target.
2. The method according to claim 1, wherein, Perform contour extraction on the image region enclosed by the bounding box to obtain multiple contours within the bounding box, including: The image to be inspected and the bounding box are expanded to obtain an expanded image to be inspected and an expanded bounding box; and A contour extraction operation is performed on the image region enclosed by the expanded bounding box to obtain multiple contours within the expanded bounding box.
3. The method according to claim 1 or 2, wherein, Perform contour extraction on the image region enclosed by the bounding box to obtain multiple contours within the bounding box, including: Obtain the image region enclosed by the bounding box from the image to be inspected; The image region is binarized using a preset threshold to obtain a binarized image region; Morphological processing is performed on the binarized image region to obtain a morphologically processed image region; and A contour extraction operation is performed on the morphologically processed image region to obtain multiple contours within the bounding box.
4. The method according to claim 2, wherein, The process of expanding the image to be inspected and the bounding box to obtain expanded images to be inspected and expanded bounding boxes includes: The image to be inspected is expanded outward by N pixels around its perimeter, and the N pixels are filled with 0 values to obtain the expanded image to be inspected, where N is an integer greater than 0; The horizontal and vertical coordinates of the lower right corner of the bounding box are increased by 2N pixels respectively to obtain the expanded bounding box.
5. The method according to claim 1 or 2, wherein, The number of plastic targets is multiple, and the method further includes: Construct a mask for the complete outline, and use the mask to remove the corresponding plastic target from the image to be inspected to obtain a new image to be inspected; A contour extraction operation is performed on the image region enclosed by the bounding box of the next plastic target in the new image to be inspected, to obtain multiple contours within the bounding box of the next plastic target; and Continue performing the process of removing incomplete contours from the multiple contours based on contour points to obtain complete contours within the bounding box, and determine the image data enclosed by the complete contours within the bounding box as the image data of the plastic target.
6. The method according to claim 1, wherein, The image to be inspected is a near-infrared image, and the preset detection model is a model obtained by training a machine learning model. The process of training the preset detection model using a machine learning model includes: Acquire near-infrared sample images containing plastic targets; The image region containing the plastic target in the near-infrared sample image is labeled to form region labeling information; and The near-infrared sample image and the region annotation information are input as training data into the preset detection model for training.
7. An apparatus for detecting plastic targets, comprising: processor; as well as A memory storing program instructions for detecting plastic targets, which, when executed by a processor, cause the device to perform the method according to any one of claims 1-6.
8. A method for identifying plastic targets, comprising: Acquire a first near-infrared image and a second near-infrared image containing a plastic target, wherein the wavelength of the first near-infrared light wave used to acquire the first near-infrared image is different from the wavelength of the second near-infrared light wave used to acquire the second near-infrared image; Using the method described in any one of claims 1-6, determine the first image data of the plastic target in the first near-infrared image and the second image data in the second near-infrared image; Determine the ratio of the first pixel value of the first image data to the second pixel value of the second image data; and The type of the plastic target is determined based on the ratio and a preset threshold.
9. A device for identifying plastic targets, comprising: processor; The device also includes a memory storing program instructions for identifying plastic targets, which, when executed by the processor, cause the device to perform the method according to claim 8.
10. A computer-readable storage medium having stored thereon program instructions for detecting and / or identifying plastic targets, wherein the program instructions, when executed by a processor, implement the method according to any one of claims 1-6 and / or the method according to claim 8.