Micro-plastic detection method, system, equipment and medium
Through the improved YOLOv5 object detection algorithm, combined with the actual size of the detection frame and pixel size, the problems of slow detection speed, high cost and poor accuracy in the existing microplastic detection methods are solved, and efficient and accurate microplastic detection is achieved.
Patent Information
- Application Number
- CN202411575004.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-06
- Publication Date
- 2025-02-18
AI Technical Summary
The existing microplastic detection methods have problems such as slow detection speed, high cost, complex sample preparation, poor detection accuracy, and limited generalization ability to new environments and new samples.
Using the improved YOLOv5 object detection algorithm, the detection frame can be used to initially estimate the particle size based on the actual size of the image and the pixel size of the detection frame to output the microplastic particle size distribution.
It improves the accuracy and efficiency of microplastic detection, reduces manual intervention, is suitable for various microplastic detection tasks, and can accurately identify microplastics when the target size and shape change greatly.
Smart Images

Figure CN119478015A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing technology, and more specifically to a microplastic detection method, system, equipment and medium. Background Art
[0002] In order to deal with the problem of microplastic pollution, the detection methods of microplastics have received widespread attention around the world. The current microplastic detection methods include optical microscopy, fluorescence microscopy, computed tomography (CT), Raman spectroscopy imaging, machine learning and deep learning methods, among which:
[0003] The traditional optical microscopy method uses an optical microscope to take images of microplastics and uses image processing and pattern recognition algorithms to detect and classify microplastics. Due to the limited resolution of optical microscopes, it is difficult to detect very small microplastics. The image processing process requires processing a large number of images, which is time-consuming and leads to slow processing speed. Detection and classification require manual assistance, making it difficult to achieve full automation.
[0004] The traditional fluorescence microscopy method uses a fluorescence microscope to capture images. Microplastics will fluoresce under ultraviolet light, and the microplastics are detected through image analysis software. However, sample preparation is complicated and requires specific treatment of the sample to enable it to fluoresce under ultraviolet light. The cost of the detection instrument is high, and the fluorescence microscope and related equipment are expensive. At the same time, other substances may also fluoresce during detection, which increases the difficulty of detection and is easily interfered by the detection background.
[0005] The traditional computer tomography (CT) method uses CT scanning technology to obtain a three-dimensional image of the sample, and detects and identifies microplastics through image segmentation and pattern recognition algorithms. Due to the expensive CT equipment, high maintenance costs, high detection costs, complex data processing of the recognition algorithm, requiring a lot of computing resources, and long single scanning time, it is difficult to process large batches of samples.
[0006] Traditional Raman spectroscopy imaging combines Raman spectroscopy technology and microscopic imaging to identify microplastics through the characteristic peaks of the Raman spectrum. Since the spectra of other substances in the environment of the identification process may interfere with the detection of microplastics, the samples need to be specifically processed to reduce interference, the sample preparation requirements are high, and the equipment is expensive and complicated to operate.
[0007] Traditional machine learning and deep learning methods use machine learning and deep learning algorithms to train models with a large number of labeled samples to achieve automatic detection and classification of microplastics. Since the model training process requires a large number of labeled samples for training, the data collection and labeling costs are high, the model's generalization ability to new environments and new samples is limited, and frequent updates may be required. The training and inference process requires a lot of computing resources.
[0008] In summary, the existing microplastic detection methods require a large number of labeled samples for training in the model training process, and the data collection and labeling costs are high. They cannot meet the needs of situations where the target size and shape vary greatly. The model has limited generalization ability for new environments and new samples and needs to be updated frequently, resulting in a too complicated sample detection process and poor detection accuracy. Summary of the invention
[0009] In response to the problems existing in the above-mentioned fields, the present invention proposes a microplastic detection method, system, device and medium. The improved YOLOv5 target detection algorithm constructed by this method is suitable for various microplastic detection tasks. The detection frame can make a preliminary estimate of the particle size based on the actual scale of the image and the pixel size of the detection frame, and the detection results can output the microplastic particle size distribution.
[0010] In order to solve the above technical problems, the present invention discloses a microplastic detection method, comprising the following steps:
[0011] Obtaining the original image of the microplastics to be detected;
[0012] Construct an improved YOLOv5 target detection algorithm, traverse each detection box before saving the detection result in the YOLO layer of the original YOLOv5 target detection algorithm; extract the center point coordinates, length and width of each detection box according to the detection box of each object detected;
[0013] The original image of the microplastics to be detected is input into the improved YOLOv5 target detection algorithm to detect microplastics, and the center point coordinates, length and width of each detection frame are extracted;
[0014] The area of each detection frame is determined according to the coordinates, length and width of the center point of the detection frame. The area of each detection frame is used as the projection area of the microplastic particles to determine the diameter of the microplastic particles. The actual particle size of the microplastic is output according to the diameter of the microplastic particles, the magnification of the original image and the actual scale of the image.
[0015] Preferably, the diameter of the microplastic particles is determined as:
[0016]
[0017] Among them, A represents the area of the detection frame, and D represents the pixel diameter of the microplastic particles.
[0018] Preferably, the actual scale of the image is the ratio between the actual length of the image and the pixel size.
[0019] Preferably, the actual particle size of the output microplastics is:
[0020]
[0021] Among them, D represents the pixel diameter of the microplastic particles, S represents the actual scale of the image, and M represents the magnification of the image.
[0022] Preferably, the step of obtaining the original image of the microplastics to be detected comprises the following steps:
[0023] Obtain original images of the microplastics to be detected at different magnifications through a microscope;
[0024] The acquired original images were divided into training set, validation set and test set in a ratio of 8:1:1 according to the magnification;
[0025] The two datasets, training set and validation set, were annotated to construct a microplastic detection dataset for microplastic detection.
[0026] Preferably, the labeling of the two data sets, the training set and the validation set, specifically includes:
[0027] LabelImg was used to annotate the category, center point coordinates, width, and height of the microplastic detection boxes in the training set and validation set, and multiple annotated microplastic images were obtained through the annotation software.
[0028] Preferably, a microplastic detection system is also included, comprising:
[0029] A dataset construction module for obtaining raw images of microplastics to be detected;
[0030] An algorithm construction module is used to construct an improved YOLOv5 target detection algorithm, traverse each detection frame before saving the detection result in the YOLO layer of the original YOLOv5 target detection algorithm; extract the center point coordinates, length and width of each detection frame according to the detection frame of each object detected; input the acquired original image of the microplastic to be detected into the improved YOLOv5 target detection algorithm, perform microplastic detection, and extract the center point coordinates, length and width of each detection frame;
[0031] The microplastic detection module is used to determine the area of each detection frame based on the center point coordinates, length and width of the detection frame; use the area of each detection frame as the projection area of the microplastic particles to determine the diameter of the microplastic particles; and output the actual particle size of the microplastics based on the diameter of the microplastic particles, the magnification of the original image and the actual scale of the image.
[0032] Preferably, a computer device is also included, the computer device comprising a memory and a processor, the memory storing a computer program, and when the computer program is executed by the processor, the processor executes the following steps:
[0033] Obtaining the original image of the microplastics to be detected;
[0034] Construct an improved YOLOv5 target detection algorithm, traverse each detection box before saving the detection result in the YOLO layer of the original YOLOv5 target detection algorithm; extract the center point coordinates, length and width of each detection box according to the detection box of each object detected;
[0035] The original image of the microplastics to be detected is input into the improved YOLOv5 target detection algorithm to detect microplastics, and the center point coordinates, length and width of each detection frame are extracted;
[0036] The area of each detection frame is determined according to the coordinates, length and width of the center point of the detection frame. The area of each detection frame is used as the projection area of the microplastic particles to determine the diameter of the microplastic particles. The actual particle size of the microplastic is output according to the diameter of the microplastic particles, the magnification of the original image and the actual scale of the image.
[0037] Preferably, it further comprises a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the processor executes the following steps:
[0038] Obtaining the original image of the microplastics to be detected;
[0039] Construct an improved YOLOv5 target detection algorithm, traverse each detection box before saving the detection result in the YOLO layer of the original YOLOv5 target detection algorithm; extract the center point coordinates, length and width of each detection box according to the detection box of each object detected;
[0040] The original image of the microplastics to be detected is input into the improved YOLOv5 target detection algorithm to detect microplastics, and the center point coordinates, length and width of each detection frame are extracted;
[0041] The area of each detection frame is determined according to the coordinates, length and width of the center point of the detection frame. The area of each detection frame is used as the projection area of the microplastic particles to determine the diameter of the microplastic particles. The actual particle size of the microplastic is output according to the diameter of the microplastic particles, the magnification of the original image and the actual scale of the image.
[0042] Compared with the prior art, the present invention has the following beneficial effects:
[0043] The microplastic detection method proposed by the present invention uses an improved YOLOv5 target detection algorithm to traverse each detection frame before saving the detection result in the YOLO layer. According to the detection frame of each object detected, the center point coordinates, length and width of each detection frame are extracted. The method can be trained to adapt to different environments and samples and is suitable for various microplastic detection tasks. The algorithm can be trained on a large number of labeled samples when the target size and shape vary greatly. The detection result is converted into the actual physical size of the image by the size of the actual particles of the image. The target detection algorithm can learn the size characteristics of microplastics. It combines YOLOv5 and the detection frame estimation method to reduce manual intervention, thereby improving the accuracy of detection. The improved YOLOv5 target detection algorithm can make a preliminary estimate of the particle size based on the actual scale of the image and the pixel size of the detection frame through the detection frame, and the detection result can output the distribution of the particle size of microplastics. Obtaining a preliminary estimate of the size of microplastics while detecting them will help to more fully understand the nature of microplastic pollution. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] Figure 1 This is a flow chart of the microplastic detection method proposed in the present invention;
[0045] Figure 2 A schematic diagram of an original image of microplastics obtained according to an embodiment of the present invention;
[0046] Figure 3 A schematic diagram of the process of constructing a microplastic detection dataset provided by an embodiment of the present invention;
[0047] Figure 4 The original image of microplastics obtained by microscopic photography provided in an embodiment of the present invention;
[0048] Figure 5 The detection result obtained by the improved YOLOv5 target detection algorithm provided by the embodiment of the present invention. DETAILED DESCRIPTION
[0049] The following will be combined with the attached embodiment of the present invention Figure 1-Figure 5 , the technical solutions in the embodiments of the present invention are clearly and completely described. It should be understood that the terms described in the present invention are only used to describe specific implementation methods and are not used to limit the present invention.
[0050] like Figure 1 As shown, the present invention proposes a microplastic detection method, comprising the following steps:
[0051] S1: Acquire the original image of the microplastics to be detected;
[0052] S2: construct an improved YOLOv5 target detection algorithm, traverse each detection box before saving the detection result in the YOLO layer of the original YOLOv5 target detection algorithm; according to the detection box of each object detected, extract the center point coordinates, length and width of each detection box;
[0053] The original image of the microplastics to be detected is input into the improved YOLOv5 target detection algorithm to detect microplastics, and the center point coordinates, length and width of each detection frame are extracted;
[0054] S4: Determine the area of each detection frame according to the center point coordinates, length and width of the detection frame; use the area of each detection frame as the projection area of the microplastic particles to determine the diameter of the microplastic particles; output the actual particle size of the microplastic according to the diameter of the microplastic particles, the magnification of the original image and the actual scale of the image.
[0055] Specifically, in step S1, obtaining the original image of the microplastic to be detected includes the following steps:
[0056] Obtain original images of the microplastics to be detected at different magnifications through a microscope;
[0057] The acquired original images were divided into training set, validation set and test set in a ratio of 8:1:1 according to the magnification;
[0058] The two datasets, training set and validation set, were annotated to construct a microplastic detection dataset for microplastic detection.
[0059] Among them, the two data sets of training set and verification set are labeled, including:
[0060] Use LabelImg to annotate the category, center point coordinates, width, and height of the microplastic detection boxes in the training set and validation set. Obtain multiple annotated microplastic images through the annotation software and generate corresponding annotation information files in txt format.
[0061] In step S2, the improved YOLOv5 target detection algorithm proposed in the present invention traverses each detection frame before saving the detection result in the original YOLOv5 target detection algorithm; according to the detection frame of each object detected, the center point coordinates, length and width of each detection frame are extracted, and the area of each detection frame is calculated.
[0062] Add a calculation and statistics module to the detect.py file of the YOLOv5 target detection algorithm. Specifically, before saving the detection results, traverse each detection frame, and extract the center point coordinates, length and width information of each detection frame based on the detection frame of each object detected; use the detection frame length and width information to calculate and determine the area of each detection frame; calculate the pixel particle size based on the area of each detection frame, and then obtain an estimate of the actual length of the microplastic based on the length of the pixel particle size, the image size, and the magnification factor.
[0063] The specific algorithm steps of the improved YOLOv5 target detection algorithm are shown in Table 1 below.
[0064] Table 1 Improved YOLOv5 target detection algorithm steps
[0065]
[0066] By analyzing the area of each detection frame, the area of the detection frame is regarded as the projected area of the microplastic particles, and the diameter of the microplastic particles is calculated using the following formula:
[0067]
[0068] Among them, A represents the area of the detection frame, and D represents the pixel diameter of the microplastic particles.
[0069] The statistical output of the algorithm is combined with the image magnification and the ratio between the pixel size of the image and the actual length to calculate the size of the actual microplastic particles.
[0070] The calculation formula to determine the actual particle size of the image is:
[0071]
[0072] Among them, D represents the pixel diameter of the microplastic particles calculated by the detection frame area, S represents the actual scale of the image, that is, the ratio between the pixel size and the actual length, and M represents the magnification of the image.
[0073] The detection results are converted into the actual physical size of the image through the actual particle size of the image.
[0074] The present invention also proposes a microplastic detection system, comprising:
[0075] A dataset construction module for obtaining raw images of microplastics to be detected;
[0076] An algorithm construction module is used to construct an improved YOLOv5 target detection algorithm, traverse each detection frame before saving the detection result in the YOLO layer of the original YOLOv5 target detection algorithm; extract the center point coordinates, length and width of each detection frame according to the detection frame of each object detected; input the acquired original image of the microplastic to be detected into the improved YOLOv5 target detection algorithm, perform microplastic detection, and extract the center point coordinates, length and width of each detection frame;
[0077] The microplastic detection module is used to determine the area of each detection frame based on the center point coordinates, length and width of the detection frame; use the area of each detection frame as the projection area of the microplastic particles to determine the diameter of the microplastic particles; and output the actual particle size of the microplastics based on the diameter of the microplastic particles, the magnification of the original image and the actual scale of the image.
[0078] As a modern target detection algorithm, YOLOv5 can quickly detect and locate microplastics in microscope images and achieve efficient real-time processing. The algorithm has high detection accuracy, especially when the target size and shape vary greatly. By training a large number of labeled samples, YOLOv5 can learn the characteristics of microplastics, thereby improving the accuracy of detection. The present invention uses the bounding box obtained by detection to make a preliminary estimate of the particle size based on the actual size of the image and the pixel size of the detection box.
[0079] The advantages of the method proposed in the present invention include real-time performance and fast inference speed, making it suitable for scenarios that require rapid detection; high precision, which can accurately identify and locate microplastics, improving the reliability of detection; high degree of automation, combined with YOLOv5 and detection box estimation method, which can reduce human intervention; and flexibility, the model can adapt to different environments and samples through training, and is suitable for various microplastic detection tasks.
[0080] Example
[0081] In order to verify the feasibility of the microplastic detection method proposed in the present invention, the present invention conducted the following experimental verification, and the specific experimental process is as follows:
[0082] like Figure 2 As shown in the figure, it is the original image of microplastics obtained by an embodiment of the present invention, wherein Figure (a) is the original image of microplastics obtained to introduce the source of the microplastic image and the equipment used; Figure (b) is the data set construction, including the annotation of the microplastic image; Figure (c) is the training of the YOLOv5 model, which shows the training results and detection performance of the YOLOv5 model; Figure (d) is the detection results and discussion, which mainly analyzes the training results and actual detection results.
[0083] After obtaining the original image set, the embodiment provided by the present invention needs to annotate these images to generate corresponding annotation information files in txt format, such as Figure 3 LabelImg is used to annotate the microplastics in the acquired image. The annotation content includes the category of the detection box, the center point coordinates (0.819271, 0.109722), the width of 0.075000 and the height of 0.108330. These parameters reflect the location and size of the selected microplastics.
[0084] Finally, a total of 300 microplastic images were obtained through the experimental equipment, and the 300 microplastic images were divided equally, with 100 images of each magnification (5×, 10×, 20×).
[0085] The images at each magnification are divided into training set, validation set and test set in a ratio of 8:1:1, obtaining 240 training images, 30 validation images and 30 test images respectively.
[0086] The model is trained using the training set, its performance is evaluated using the validation set, and finally the overall performance of the model is evaluated on the test set.
[0087] The original images of microplastics taken through a microscope, such as Figure 4 The constructed microplastic detection dataset is input into the improved YOLOv5 target detection algorithm, and the detection results obtained are as follows: Figure 5 shown.
[0088] The specific information of the test result output of the present invention is as follows: 192.81759643554688 130.2973175048828211.5704345703125 143.22866821289062 183.0376434326172 167.15640258789062 194.46142578125 140.9345703125 145.5478515625379.5785827636719
[0092] A total of 10 pieces of actual microplastic particle size information.
[0093] According to the calculation formula of the actual particle size of the image, the actual particle size of the image is calculated. The specific value of S in the formula is determined by the shooting equipment. The value of this experiment is 2.7 microns / pixel, and the image magnification is 10 times. The size information of the actual microplastic particle size calculated is: 52.06 35.18 57.12 38.67 49.4245.13 52.5 38.05 39.3 102.49
[0095] The size of the microplastic sample used in this experiment is 50 microns, and the results obtained can be used as a basis for preliminary estimation of the distribution of the particle size of the detected microplastics. Among them, the only oversized result 102.49 can also be reasonably explained, because microplastics have adsorption and there is adhesion between microplastics, which is also reflected in the upper left corner of the test results.
[0096] By analyzing the experimental analysis results provided by the present invention, it can be verified that the microplastic detection method proposed in the present invention can accurately identify and locate microplastics.
[0097] The above description is only a preferred specific implementation manner of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can make equivalent replacements or changes according to the technical scheme and inventive concept of the present invention within the technical scope disclosed by the present invention, which should be covered by the protection scope of the present invention.
[0098] In addition, unless otherwise specified, all technical and scientific terms used in the present invention have the same meanings as commonly understood by those skilled in the art to which the present invention belongs. All documents mentioned in this specification are incorporated by reference to disclose and describe the methods related to the documents. In the event of any conflict with any incorporated document, the content of this specification shall prevail.
Claims
1. A method for detecting microplastics, characterized in that: The following steps are involved: Obtaining the original image of the microplastics to be detected; Construct an improved YOLOv5 target detection algorithm, traverse each detection box before saving the detection result in the YOLO layer of the original YOLOv5 target detection algorithm; extract the center point coordinates, length and width of each detection box according to the detection box of each object detected; The original image of the microplastics to be detected is input into the improved YOLOv5 target detection algorithm to detect microplastics, and the center point coordinates, length and width of each detection frame are extracted; The area of each detection frame is determined according to the coordinates, length and width of the center point of the detection frame. The area of each detection frame is used as the projection area of the microplastic particles to determine the diameter of the microplastic particles. The actual particle size of the microplastic is output according to the diameter of the microplastic particles, the magnification of the original image and the actual scale of the image.
2. The microplastic detection method according to claim 1, characterized in that: The diameter of the microplastic particles is determined as: Among them, A represents the area of the detection frame, and D represents the pixel diameter of the microplastic particles.
3. The microplastic detection method according to claim 2, characterized in that: The actual scale of the image is the ratio between the actual length of the image and the pixel size.
4. The microplastic detection method according to claim 3, characterized in that: The actual particle size of the output microplastics is: Among them, D represents the pixel diameter of the microplastic particles, S represents the actual scale of the image, and M represents the magnification of the image.
5. The microplastic detection method according to claim 4, characterized in that: The obtaining of the original image of the microplastics to be detected comprises the following steps: Obtain original images of the microplastics to be detected at different magnifications through a microscope; The acquired original images were divided into training set, validation set and test set in a ratio of 8:1:1 according to the magnification; The two datasets, training set and validation set, were annotated to construct a microplastic detection dataset for microplastic detection.
6. The microplastic detection method according to claim 5, characterized in that: The labeling of the two data sets of training set and validation set specifically includes: LabelImg was used to annotate the category, center point coordinates, width, and height of the microplastic detection boxes in the training set and validation set, and multiple annotated microplastic images were obtained through the annotation software.
7. A microplastic detection system, characterized in that: include: A dataset construction module for obtaining raw images of microplastics to be detected; An algorithm construction module is used to construct an improved YOLOv5 target detection algorithm, traverse each detection frame before saving the detection result in the YOLO layer of the original YOLOv5 target detection algorithm; extract the center point coordinates, length and width of each detection frame according to the detection frame of each object detected; input the acquired original image of the microplastic to be detected into the improved YOLOv5 target detection algorithm, perform microplastic detection, and extract the center point coordinates, length and width of each detection frame; The microplastic detection module is used to determine the area of each detection frame based on the center point coordinates, length and width of the detection frame; use the area of each detection frame as the projection area of the microplastic particles to determine the diameter of the microplastic particles; and output the actual particle size of the microplastics based on the diameter of the microplastic particles, the magnification of the original image and the actual scale of the image.
8. A computer device, characterized in that: The computer device includes a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor performs the following steps: Obtaining the original image of the microplastics to be detected; Construct an improved YOLOv5 target detection algorithm, traverse each detection box before saving the detection result in the YOLO layer of the original YOLOv5 target detection algorithm; extract the center point coordinates, length and width of each detection box according to the detection box of each object detected; The original image of the microplastics to be detected is input into the improved YOLOv5 target detection algorithm to detect microplastics, and the center point coordinates, length and width of each detection frame are extracted; The area of each detection frame is determined according to the coordinates, length and width of the center point of the detection frame. The area of each detection frame is used as the projection area of the microplastic particles to determine the diameter of the microplastic particles. The actual particle size of the microplastic is output according to the diameter of the microplastic particles, the magnification of the original image and the actual scale of the image.
9. A computer-readable storage medium, characterized in that: The computer readable storage medium stores a computer program, and when the computer program is executed by a processor, the processor performs the following steps: Obtaining the original image of the microplastics to be detected; Construct an improved YOLOv5 target detection algorithm, traverse each detection box before saving the detection result in the YOLO layer of the original YOLOv5 target detection algorithm; extract the center point coordinates, length and width of each detection box according to the detection box of each object detected; The original image of the microplastics to be detected is input into the improved YOLOv5 target detection algorithm to detect microplastics, and the center point coordinates, length and width of each detection frame are extracted; The area of each detection frame is determined according to the coordinates, length and width of the center point of the detection frame. The area of each detection frame is used as the projection area of the microplastic particles to determine the diameter of the microplastic particles. The actual particle size of the microplastic is output according to the diameter of the microplastic particles, the magnification of the original image and the actual scale of the image.
Citation Information
Patent Citations
Microalgae identification method based on improved YOLOv3
CN112784748A
Semi-artificial initial tracking frame determining and tracking method and system combined with target detection
CN113947619A
Plastic package film defect detection method and device, electronic equipment and storage medium
CN116833111A
Microplastic length calculation method based on artificial intelligence
CN117554252A
Microplastic intelligent identification positioning and size calculation system based on artificial intelligence
CN118351113A