A method, system, and medium for identifying and tracking microplastics and floc in a body of water
Patent Information
- Application Number
- CN202610295051.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2026-03-11
- Publication Date
- 2026-10-23
- Estimated Expiration
- 2046-03-11
AI Technical Summary
此类方法通常以单帧图像为处理对象,缺乏对同一微塑料或絮团在连续图像帧中保持身份一致性的约束,难以实现目标在时间维度上的连续识别与稳定跟踪
本发明通过将YOLOv8-seg模型的Backbone及Neck中关键位置的C2f模块替换为集成了CBAM注意力机制的C2f_improve模块,构建了一种专为微小、弱特征目标优化的识别模型。该改进能有效增强模型对微塑料及絮团浅层细节特征的提取能力,并在特征融合阶段强化有用信息、抑制背景噪声,从而显著提升了在复杂水体环境下对小目标的检测召回率与分割精度。同时,结合跨帧的运动预测与轨迹关联,能够在目标发生短时遮挡或中断时恢复其连续运动轨迹,为实现从单帧静态检测到多帧动态行为分析的跨越提供了基础,综合解决了现有通用检测模型在此场景下存在的漏检率高、无法精确分割及轨迹不稳定等技术问题。
Smart Images

Figure CN122200312B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of environmental monitoring and computer vision technology, and in particular to a method, system and medium for identifying and tracking microplastics and flocs in water. Background Technology
[0002] Microplastics (plastic particles with a diameter of less than 5 mm) are emerging pollutants. Their dynamic parameters, such as quantity, size, and sedimentation behavior in water bodies, are crucial for studying their environmental migration patterns and ecological risks. In particular, under controlled indoor water experiments, visual observation and quantitative analysis of microplastics and their flocs with sediment are important means to reveal their sedimentation characteristics and interaction mechanisms. However, existing experimental analysis methods still have shortcomings in data acquisition efficiency and parameter extraction accuracy.
[0003] With the development of image acquisition equipment and computer vision technology, automatic recognition methods based on video images have been gradually introduced into microplastic sedimentation experiments. For example, general target detection models such as YOLOv8 are directly used to analyze experimental video frames. These methods typically process single-frame images and lack constraints on maintaining consistency of identity for the same microplastic or floc in consecutive image frames, making it difficult to achieve continuous identification and stable tracking of targets over time. However, when the research object changes from macroscopic particles to micron-sized microplastics and sediment flocs, existing methods still have significant limitations: First, microplastics and flocs occupy a very small proportion of pixels in experimental images, and their target features are not significant. General detection models are prone to losing shallow detail information during feature extraction, leading to insufficient detection accuracy. Second, traditional target detection models use rectangular bounding boxes as output, which are difficult to accurately depict the true contours of irregular particles and flocs, resulting in inherent errors when calculating experimental parameters such as projected area and equivalent particle size based on the detection results.
[0004] Furthermore, during indoor water settling experiments, suspended particles, bubbles, and changes in lighting can easily interfere with the target. Microplastics and flocs may temporarily obscure or partially disappear during settling, causing interruptions in the target trajectory. The limitations of existing methods in feature fusion capabilities and cross-frame trajectory correlation stability make it difficult to obtain continuous and reliable target motion trajectories in complex experimental scenarios, thus restricting the accurate calculation of key dynamic parameters such as settling velocity. Summary of the Invention
[0005] The purpose of this invention is to provide a method for identifying and tracking microplastics and flocs in water, thereby improving the accuracy of detection and continuous trajectory tracking of microplastics and flocs in complex water environments.
[0006] To address the aforementioned technical problems, embodiments of the present invention provide a method for identifying and tracking microplastics and flocs in water, comprising the following steps: Acquire water body video data containing microplastics and flocs, and decompose the water body video data into a continuous sequence of image frames; The image frame sequence is sequentially input into the pre-trained microplastic and floc recognition model, which outputs the detection results of microplastics and floc targets in each image frame. The detection results include instance segmentation mask, bounding box position information, and category confidence. The microplastic and floc recognition model is an improved model based on YOLOv8-seg. The two C2f modules used for shallow and medium-level feature extraction in the backbone part of the original YOLOv8-seg model are replaced with C2f_improve modules. The C2f module in the starting stage of the Neck part of the original YOLOv8-seg model is replaced with a C2f_improve module. The C2f_improve module embeds a convolutional attention module (CBAM) at the output of the C2f module. The CBAM sequentially applies channel attention weighting and spatial attention weighting to the feature map. Based on the detection results, cross-frame motion prediction and trajectory association are performed on the spatial location information of microplastics and floc targets in continuous image frames to generate continuous target motion trajectories.
[0007] In some optional embodiments, the cross-frame motion prediction is associated with the trajectory, and the specific steps are as follows: When a new target appears based on the detection results of the current frame, extract the initial motion features of the new target; The initial motion characteristics of the new target are compared with the motion information at the end of the existing interrupted trajectory; If the direction of motion of the new target satisfies the first preset association condition with the direction of motion of the end of the existing interrupted trajectory, and the time of appearance of the new target satisfies the second preset association condition with the time of end of the existing interrupted trajectory, and the position of the next moment predicted based on the existing interrupted trajectory satisfies the third preset association condition with the actual starting position of the new target, then it is determined that the new target and the existing interrupted trajectory belong to the same physical target, and the trajectories of the two are merged and updated to form a continuous trajectory. The first preset association condition includes: the angle between the target's motion direction in adjacent frames is less than a preset angle threshold; the second preset association condition includes: the time interval between the new target and the end of the interrupted trajectory is less than a preset time threshold; and the third preset association condition includes: the Euclidean distance between the predicted position and the actual position is less than a preset spatial threshold.
[0008] In some optional embodiments, the method further includes filtering the target motion trajectory, with the following specific steps: Based on the continuous target motion trajectory, the physical parameters of the target are calculated, including the target area, settlement velocity, and lateral and longitudinal displacement components. Extract the number of pixels occupied by the target in the instance segmentation mask, calculate the physical area of a single pixel by combining the actual physical size of the video imaging area and the image resolution, and multiply the number of pixels by the physical area of a single pixel to obtain the effective area of the target. The pixel displacement is calculated based on the pixel coordinate changes of the target between adjacent image frames in the continuous target motion trajectory. The pixel displacement is converted into a real physical displacement based on the actual physical size of the video imaging area and the image resolution to obtain the displacement component. The motion time is obtained based on the timestamp difference between adjacent image frames. The average settlement velocity is calculated based on the real physical displacement and the motion time. The validity determination conditions are set based on the calculated physical parameters. The validity determination conditions include: the trajectory duration is greater than or equal to a first preset threshold, and the trajectory displacement amplitude is greater than or equal to a second preset threshold. The continuous target motion trajectories are screened according to the validity determination criteria, and trajectories that do not meet the criteria are eliminated to obtain valid target motion trajectories; The first preset threshold is used to limit the effective duration of the trajectory in the time dimension, and the second preset threshold is used to limit the effective range of motion of the trajectory in the spatial displacement dimension.
[0009] In some optional embodiments, the method further includes training a microplastics and floc recognition model, with the following specific steps: Obtain a labeled image dataset containing samples of microplastics and flocs; The microplastic and floc recognition model is trained using the labeled image dataset to obtain the pre-trained microplastic and floc recognition model.
[0010] Embodiments of the present invention also provide a computer device, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to perform the above-described method for identifying and tracking microplastics and flocs in water.
[0011] Embodiments of the present invention also provide a computer-readable storage medium storing a computer program that, when run by a processor, is capable of executing the above-described method for identifying and tracking microplastics and flocs in water.
[0012] The method for identifying and tracking microplastics and flocs in water provided by this invention has at least the following beneficial effects: This invention constructs a recognition model specifically optimized for small, weakly featured targets by replacing the C2f modules at key locations in the Backbone and Neck of the YOLOv8-seg model with C2f_improve modules that integrate the CBAM attention mechanism. This improvement effectively enhances the model's ability to extract shallow details of microplastics and flocs, and strengthens useful information and suppresses background noise during the feature fusion stage, thereby significantly improving the detection recall and segmentation accuracy of small targets in complex aquatic environments. Simultaneously, by combining cross-frame motion prediction and trajectory association, it can recover the continuous motion trajectory of a target when it experiences short-term occlusion or interruption, providing a foundation for transitioning from single-frame static detection to multi-frame dynamic behavior analysis. This comprehensively solves the technical problems of high false negative rates, inaccurate segmentation, and unstable trajectories in existing general detection models in this scenario.
[0013] This invention adds a dual-condition screening step based on physical parameters. By calculating the duration and displacement amplitude of the trajectory and setting physically reasonable thresholds, this scheme can effectively identify and eliminate spurious trajectories generated by instantaneous noise, detection jitter, or non-real motion. This screening mechanism ensures the reliability and accuracy of the target trajectory and its physical parameters (such as area and settlement velocity) used for analysis, improving the output quality and scientific value of the entire method from the data source. Attached Figure Description
[0014] The accompanying drawings, which are included to provide a further understanding of the invention and form part of this invention, illustrate exemplary embodiments of the invention and are used to explain the invention, but do not constitute an undue limitation of the invention. In the drawings:
[0015] Figure 1 This is a flowchart of a method for identifying and tracking microplastics and flocs in water according to an embodiment of the present invention; Figure 2 This is a structural diagram of the C2f_improve module provided according to an embodiment of the present invention; Figure 3 This is a structural diagram of a microplastic and floc identification model provided according to an embodiment of the present invention. Detailed Implementation
[0016] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below in conjunction with specific embodiments and corresponding drawings. Obviously, the described embodiments are only a part of the embodiments of this invention, and not all of them. Based on the embodiments of this invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this invention.
[0017] One embodiment of the present invention relates to a method for identifying and tracking microplastics and flocs in water. The implementation details of the method for identifying and tracking microplastics and flocs in water in this embodiment are described in detail below. The following implementation details are provided for ease of understanding and are not necessary for implementing this solution.
[0018] The specific process of the method for identifying and tracking microplastics and flocs in water in this embodiment can be described as follows: Figure 1 As shown, it includes: Step 101: Obtain water body video data containing microplastics and flocs, and decompose the water body video data into a continuous sequence of image frames; Images were extracted and labeled from 60 water body video samples in different scenarios to construct a training dataset. The microplastic dataset contains 877 images with 1059 labeled instances, and the floc dataset contains 1762 images with 8514 labeled instances. To address the challenges of small target size, low contrast with the background, and indistinct morphological features in microplastics and flocs, systematic preprocessing and enhancement were performed on the data before training. This included, but was not limited to: adjusting saturation (±70%) and brightness (±40%) in the HSV color space to simulate different lighting conditions; and performing spatial transformation enhancements, such as image scaling (±50%) and horizontal mirroring (50% probability), to improve the model's robustness to changes in target shape and position.
[0019] Step 102: The image frame sequence is sequentially input into the pre-trained microplastic and floc recognition model, and the detection result information of microplastic and floc targets in each image frame is output. The detection result information includes instance segmentation mask, bounding box position information, and category confidence. The microplastic and floc recognition model is an improved model based on YOLOv8-seg. The two C2f modules used for shallow and medium-level feature extraction in the Backbone part of the original YOLOv8-seg model are replaced with C2f_improve modules. The C2f module in the starting stage of the Neck part of the original YOLOv8-seg model is replaced with C2f_improve modules. The C2f_improve module embeds a convolutional attention module (CBAM) at the output of the C2f module. The CBAM sequentially performs channel attention weighting and spatial attention weighting on the feature map. The first C2f_improve module (backbone shallow layer): This layer is responsible for capturing low-level detailed features such as the edges and contours of the target. Embedding the CBAM attention mechanism enhances the model's response to local features of low-contrast, small-sized targets like microplastics and flocs in this early stage, preventing the loss of crucial details during subsequent downsampling.
[0020] The second C2f_improve module (backbone middle layer): The features at this location fuse detailed and preliminary semantic information. Introducing CBAM helps the model effectively distinguish real targets from complex background noise in the water (such as suspended particles and bubbles) at this stage, strengthens target discriminative features, and significantly reduces false positives and false negatives.
[0021] The third C2f_improve module (Neck initiation stage): This is a key node for multi-scale feature fusion. The introduction of CBAM can optimize the fusion process of feature maps with different resolutions, guide the network to focus on feature regions that are more critical for the detection of microplastics (small targets) and flocs (multi-scale targets), thereby improving the accuracy of instance segmentation masks.
[0022] The structure diagram of the C2f_improve module is as follows: Figure 2 As shown in the figure, the C2f_improve module embeds a convolutional attention module CBAM at the output of the C2f module; the CBAM module performs channel attention weighting and spatial attention weighting on the input features in sequence. The structure diagram of the microplastics and floc identification model is shown below. Figure 3 As shown in the figure, the two C2f modules used for shallow and medium layer feature extraction in the Backbone part of the original YOLOv8-seg model are replaced with the C2f_improve module; the C2f module in the starting stage of the Neck part of the original YOLOv8-seg model is replaced with the C2f_improve module.
[0023] Obtain a labeled image dataset containing samples of microplastics and flocs; The microplastic and floc recognition model is trained using the labeled image dataset. Through iterative optimization, the model learns to accurately identify and segment microplastics and flocs from complex water images, ultimately resulting in the pre-trained microplastic and floc recognition model.
[0024] Step 103: Based on the detection results, perform cross-frame motion prediction and trajectory association on the spatial position information of microplastics and floc targets in continuous image frames to generate continuous target motion trajectories.
[0025] Since the YOLO model is essentially a single-frame image detector, this embodiment introduces a multi-target tracking algorithm for cross-frame association to obtain the continuous motion trajectory of the target in the video. To address the issues of trajectory interruption and ID switching caused by target occlusion and changes in lighting in aquatic environments, this method constructs a trajectory association mechanism based on motion prediction during the tracking process.
[0026] Specifically, when a new target is detected, the system extracts its initial motion characteristics (such as position, time, direction of motion, and velocity) and compares them with the motion information at the end of the interrupted trajectory. Association determination requires three conditions to be met simultaneously: the angle between the new target's and the historical trajectory's motion direction is within an acceptable range; the time interval between their appearances does not exceed a threshold; and the distance between the new target's actual starting position and its predicted position based on the historical trajectory's motion state is less than a set value. When the above direction, time, and position prediction conditions are met simultaneously, the system determines that they are the same physical target and automatically merges the trajectories and assigns a unified ID number. This effectively recovers the target's complete motion trajectory even in complex situations such as occlusion, significantly reducing duplicate counting and laying the foundation for accurate subsequent dynamic parameter calculations.
[0027] When a new target appears based on the detection results of the current frame, extract the initial motion features of the new target; The initial motion characteristics of the new target are compared with the motion information at the end of the existing interrupted trajectory; If the direction of motion of the new target satisfies the first preset association condition with the direction of motion of the end of the existing interrupted trajectory, and the time of appearance of the new target satisfies the second preset association condition with the time of end of the existing interrupted trajectory, and the position of the next moment predicted based on the existing interrupted trajectory satisfies the third preset association condition with the actual starting position of the new target, then it is determined that the new target and the existing interrupted trajectory belong to the same physical target, and the trajectories of the two are merged and updated to form a continuous trajectory. The first preset association condition includes: the angle between the target's motion direction in adjacent frames is less than a preset angle threshold; the second preset association condition includes: the time interval between the new target and the end of the interrupted trajectory is less than a preset time threshold; and the third preset association condition includes: the Euclidean distance between the predicted position and the actual position is less than a preset spatial threshold.
[0028] Based on the continuous target motion trajectory, the physical parameters of the target are calculated, including the target area, settlement velocity, and lateral and longitudinal displacement components. Calculating the target area includes: extracting the number of pixels occupied by the target in the instance segmentation mask, calculating the physical area of a single pixel by combining the actual physical size of the video imaging area and the image resolution, and multiplying the number of pixels by the physical area of a single pixel to obtain the effective area of the target; The calculation of settlement velocity and displacement components includes: calculating pixel displacement based on the pixel coordinate changes of the target between adjacent image frames in the continuous target motion trajectory; converting the pixel displacement into real physical displacement based on the actual physical size of the video imaging area and the image resolution to obtain displacement components; obtaining motion time based on the timestamp difference between adjacent image frames; and calculating average settlement velocity based on the real physical displacement and the motion time. The validity determination conditions are set based on the calculated physical parameters. The validity determination conditions include: the trajectory duration is greater than or equal to a first preset threshold, and the trajectory displacement amplitude is greater than or equal to a second preset threshold. The continuous target motion trajectories are screened according to the validity determination criteria, and trajectories that do not meet the criteria are eliminated to obtain valid target motion trajectories.
[0029] The first preset threshold is used to limit the effective duration of the trajectory in the time dimension, and the second preset threshold is used to limit the effective range of motion of the trajectory in the spatial displacement dimension.
[0030] The steps of the various methods described above are only for clarity. In practice, they can be combined into one step or some steps can be split into multiple steps. As long as they include the same logical relationship, they are all within the protection scope of this invention. Adding insignificant modifications or introducing insignificant designs to the algorithm or process, without changing the core design of the algorithm and process, are also within the protection scope of this invention.
[0031] Another embodiment of the present invention relates to a computer-readable storage medium storing a computer program. When executed by a processor, the computer program implements the method embodiments described above.
[0032] That is, those skilled in the art will understand that all or part of the steps in the methods of the above embodiments can be implemented by a program instructing related hardware. This program is stored in a storage medium and includes several instructions to cause a device (which may be a microcontroller, chip, etc.) or processor to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0033] Those skilled in the art will understand that the above embodiments are specific embodiments for implementing the present invention, and in practical applications, various changes can be made to them in form and detail without departing from the spirit and scope of the present invention.
Claims
1. A method for identifying and tracking microplastics and flocs in water, characterized in that, The method includes: Acquire water body video data containing microplastics and flocs, and decompose the water body video data into a continuous sequence of image frames; The image frame sequence is sequentially input into the pre-trained microplastic and floc recognition model, which outputs the detection results of microplastics and floc targets in each image frame. The detection results include instance segmentation mask, bounding box position information, and category confidence. The microplastic and floc recognition model is an improved model based on YOLOv8-seg. The two C2f modules used for shallow and medium-level feature extraction in the backbone part of the original YOLOv8-seg model are replaced with C2f_improve modules. The C2f module in the starting stage of the Neck part of the original YOLOv8-seg model is replaced with a C2f_improve module. The C2f_improve module embeds a convolutional attention module (CBAM) at the output of the C2f module. The CBAM sequentially applies channel attention weighting and spatial attention weighting to the feature map. Based on the detection results, cross-frame motion prediction and trajectory association are performed on the spatial location information of microplastics and floc targets in continuous image frames to generate continuous target motion trajectories. The cross-frame motion prediction and trajectory association process involves the following steps: When a new target appears based on the detection results of the current frame, extract the initial motion features of the new target; The initial motion characteristics of the new target are compared with the motion information at the end of the existing interrupted trajectory; If the direction of motion of the new target satisfies the first preset association condition with the direction of motion of the end of the existing interrupted trajectory, and the time of appearance of the new target satisfies the second preset association condition with the time of end of the existing interrupted trajectory, and the position of the next moment predicted based on the existing interrupted trajectory satisfies the third preset association condition with the actual starting position of the new target, then it is determined that the new target and the existing interrupted trajectory belong to the same physical target, and the trajectories of the two are merged and updated to form a continuous trajectory. The first preset association condition includes: the angle between the motion directions of the target in adjacent frames is less than a preset angle threshold; the second preset association condition includes: the time interval between the new target and the end of the interrupted trajectory is less than a preset time threshold; the third preset association condition includes: the Euclidean distance between the predicted position and the actual position is less than a preset spatial threshold. It also includes filtering the target's motion trajectory, with the specific steps as follows: Based on the continuous target motion trajectory, the physical parameters of the target are calculated, including the target area, settlement velocity, and lateral and longitudinal displacement components. Extract the number of pixels occupied by the target in the instance segmentation mask, calculate the physical area of a single pixel by combining the actual physical size of the video imaging area and the image resolution, and multiply the number of pixels by the physical area of a single pixel to obtain the effective area of the target. The pixel displacement is calculated based on the pixel coordinate changes of the target between adjacent image frames in the continuous target motion trajectory. The pixel displacement is converted into a real physical displacement based on the actual physical size of the video imaging area and the image resolution to obtain the displacement component. The motion time is obtained based on the timestamp difference between adjacent image frames. The average settlement velocity is calculated based on the real physical displacement and the motion time. The validity determination conditions are set based on the calculated physical parameters. The validity determination conditions include: the trajectory duration is greater than or equal to a first preset threshold, and the trajectory displacement amplitude is greater than or equal to a second preset threshold. The continuous target motion trajectories are screened according to the validity determination criteria, and trajectories that do not meet the criteria are eliminated to obtain valid target motion trajectories; The first preset threshold is used to limit the effective duration of the trajectory in the time dimension, and the second preset threshold is used to limit the effective range of motion of the trajectory in the spatial displacement dimension.
2. The method for identifying and tracking microplastics and flocs in water as described in claim 1, characterized in that, This also includes training a model for identifying microplastics and flocs, with the following specific steps: Obtain a labeled image dataset containing samples of microplastics and flocs; The microplastic and floc recognition model is trained using the labeled image dataset to obtain the pre-trained microplastic and floc recognition model.
3. A computer system, characterized in that, include: At least one processor; And a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to perform the method for identifying and tracking microplastics and flocs in water as described in any one of claims 1 to 2.
4. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, is capable of performing the method for identifying and tracking microplastics and flocs in water as defined in any one of claims 1 to 2.
Citation Information
Patent Citations
Non-motor vehicle microscopic trajectory data mining method
CN117765416A