Flocculation form online monitoring and dosing control method based on optical flow method and machine learning
By combining optical flow and machine learning, the problems of interference and dynamic feature extraction in the flocculant dosing process were solved, achieving high-precision monitoring of flocculation status and pre-dosing control, improving flocculation effect and the stability of effluent water quality, and reducing reagent consumption.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- ZHEJIANG UNIV OF TECH
- Filing Date
- 2026-03-24
- Publication Date
- 2026-07-03
AI Technical Summary
Existing technologies have problems such as poor resistance to dynamic interference, lack of process kinetic information, weak generalization ability of data-driven models, and lagging control strategies during the flocculant addition process, which lead to misjudgment of flocculation state, waste of reagents, and unstable effluent quality.
A method combining optical flow and machine learning is adopted. Dynamic rheological features are extracted through dense optical flow calculation and bubble interference suppression. Combined with static morphological features, a cross-attention fusion network is used for feature fusion. A feedforward prediction module and a feedback correction module are constructed to achieve high-precision monitoring of flocculation state and advance dosing control.
It achieves high-precision and anti-interference monitoring of flocculation status, reduces reagent consumption and operating costs, improves flocculation effect and effluent quality stability, and reduces reagent consumption by 10%-20%.
Smart Images

Figure CN121894901B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of wastewater treatment automation technology, and in particular to a method for online monitoring and dosing control of floc morphology based on optical flow and machine learning. Background Technology
[0002] In municipal and industrial sludge dewatering processes, the optimized dosage of flocculants is crucial for ensuring dewatering efficiency and reducing operating costs. Insufficient dosage leads to incomplete sludge-water separation and turbid filtrate; excessive dosage not only increases reagent costs but may also cause filter cloth clogging, equipment corrosion, and secondary pollution.
[0003] Currently, mainstream methods still rely on operators' experience for manual observation and adjustment, which suffers from strong subjectivity, slow response, and the inability to achieve precise 24-hour control. Although machine vision-based solutions have been proposed, such as capturing floc images with cameras and using convolutional neural networks (CNNs) for size or density analysis, these solutions generally suffer from the following three fundamental defects: 1) Poor resistance to dynamic interference: Actual flocculation reactors often contain bubbles, scum, and uneven lighting reflections. Traditional static image analysis methods are prone to misidentifying bubbles with similar gray levels or contours as flocs, leading to misjudgments of the flocculation state. 2) Lack of process kinetic information: The flocculation effect depends not only on the final size of the flocs but also on the floc formation process, the fluid shear environment, and the floc strength (shear resistance) of the flocs themselves. Analyzing only a single frame of static image cannot obtain key dynamic rheological characteristics such as floc growth, breakage, and sedimentation. 3) Bottleneck of data-driven models: Advanced machine learning models require a large amount of high-quality labeled data for training. However, acquiring thousands of labeled images corresponding to different precise flocculation degrees (usually measured by indicators such as capillary absorption time (CST), cake moisture content, or settling ratio) at industrial sites is extremely costly, and operating conditions are highly variable. This results in weak generalization ability of directly trained models, and their performance drops sharply when encountering new influent water quality or reagent types, failing to meet the requirements for stable operation. 4) 4. Control strategy lag: Existing automatic dosing systems mostly adopt proportional-integral-derivative (PID) control based on the deviation between the current monitored value and the set value. This pure feedback control has inherent lag and cannot make advance adjustments to rapid changes in influent flow rate and concentration, resulting in large fluctuations in the control process, reagent waste, or unstable effluent quality.
[0004] Therefore, there is an urgent need to design an intelligent integrated solution for flocculation monitoring and dosing that can resist on-site interference, integrate dynamic process information, have strong robustness under small sample conditions, and achieve predictive feedforward control. Summary of the Invention
[0005] In view of the shortcomings of the prior art, the technical problem to be solved by the present invention is to provide an online monitoring and dosing control method for flocculation morphology based on optical flow and machine learning. This method can not only accurately and robustly assess the flocculation state in real time, but also achieve proactive and stable dosing control based on predictive information, ultimately achieving the goals of improving dewatering effect, stabilizing effluent quality, saving reagent consumption, and reducing operating costs.
[0006] This invention is achieved by the following technical solution: an online monitoring and dosing control method for flocculant morphology based on optical flow and machine learning, comprising the following steps:
[0007] S1. Acquire the raw video stream of the liquid surface area in the flocculation reactor and preprocess it;
[0008] S2. Based on the preprocessed video stream in S1, static morphological feature vectors and dynamic rheological feature vectors are extracted in parallel. Then, adaptive weighted fusion is performed through the feature fusion module to obtain the fused feature vector. The dynamic rheological feature vector is obtained by dense optical flow calculation, bubble interference suppression and dynamic feature encoding in sequence.
[0009] S3. Construct and train the prediction model, input the fusion feature vector obtained in S2 into the trained prediction model, and output the current predicted flocculation value;
[0010] S4. Construct and train the feedforward prediction module. Input the real-time or historical data of the influent parameters and the fused feature vector into the feedforward prediction module to calculate the feedforward acceleration rate of the flocculant. At the same time, based on the deviation between the predicted flocculation degree and the target set value, the feedback correction module calculates the feedback correction rate. Combine the feedforward acceleration rate and the feedback correction rate to generate the final control signal to adjust the flocculant dosage.
[0011] Furthermore, the steps for extracting the dynamic rheological feature vector in S2 are as follows:
[0012] 1) Dense optical flow calculation,
[0013] Based on the preprocessed video stream in S1, the motion vector of each pixel between two consecutive frames in the video stream is calculated to obtain the dense optical flow field between consecutive frames.
[0014] 2) Suppression of bubble interference.
[0015] Calculate the direction angle and amplitude of the motion vector for each pixel, identify and remove pixel regions belonging to the floating bubbles, and obtain the denoised optical flow field. O clean ;
[0016] 3) Dynamic feature encoding,
[0017] The optical flow field of the two channels Oclean The image is converted into a three-channel color-coded image, and then input into a convolutional neural network to extract the dynamic rheological feature vector.
[0018] Furthermore, the specific steps for suppressing bubble interference are as follows:
[0019] 1) Calculate the direction angle of the motion vector for each pixel. , ; Calculate the amplitude of the motion vector for each pixel. m , ,in For vertical displacement, This is a horizontal displacement;
[0020] 2) Identify abnormal motion areas. When the direction angle θ falls within a range near the vertical upward direction and the amplitude m is greater than a set set settling velocity threshold, the pixel is determined to belong to the floating bubble.
[0021] 3) Generate a binary mask M Set all pixels identified as floating bubbles to 0 and all others to 1;
[0022] 4) Place the mask M With optical flow field O Element-wise multiplication is performed to obtain the denoised optical flow field. O clean .
[0023] Furthermore, the static morphological feature vector is extracted using a spatial flow network, with the following steps:
[0024] 1) Extract keyframes from the video stream processed in S1 at fixed intervals;
[0025] 2) Input the keyframes into a lightweight convolutional neural network, remove its last classification layer, and extract a high-dimensional feature vector. .
[0026] Furthermore, the feature fusion module in S2 is a cross-attention fusion network, and the steps to obtain the fused feature vector are as follows:
[0027] 1) Dynamic feature vectors F t and static feature vectors F s Static features are obtained by projecting different fully connected layers onto the same feature space. and dynamic features ;
[0028] 2) Based on dynamic characteristics As a query, static features As keys and values, attention weights are calculated and weighted onto the static features, outputting the weighted static features. ;
[0029] 3) Weighted static features With original dynamic characteristics By concatenating the data along the channel dimension, a fused feature vector is obtained.
[0030] Furthermore, the step in S4 where the feedforward prediction module calculates the feedforward acceleration rate of the flocculant includes, after training the feedforward model... Input the inflow rate over the past T minutes Q in 、 Inlet water turbidity Turb in The fused feature vector of the sliding window sequence and the current time step The output is the predicted change in flocculant demand. At the feedforward dosing rate baseline Adding the predicted changes in flocculant demand Obtain feedforward control output .
[0031] Furthermore, the feedback correction module in S4 calculates the feedback correction rate through feedback control logic, as follows:
[0032] 1) Calculate the deviation between the predicted flocculation degree and the target setpoint. The calculation formula is as follows:
[0033] ,
[0034] in The optimal target value for flocculation degree set for the process.
[0035] 2) A three-segment hierarchical control logic is adopted. When the deviation e is less than or equal to zero, the output feedback correction amount is zero or a small maintenance flow rate; when the deviation e is greater than zero and less than or equal to the first threshold, the output feedback correction amount is the flow rate proportional to the deviation; when the deviation is greater than the first threshold, the output feedback correction amount is the preset maximum compensation flow rate.
[0036] Furthermore, the prediction model described in S3 is a regression model trained using a training set augmented with a conditional variational autoencoder. The training steps are as follows:
[0037] 1) Collect raw data from the original video stream, gather N sets of data, and form the original dataset;
[0038] 2) Obtaining synthetic datasets through CVAE data augmentation D synFirst, construct a conditional variational autoencoder. Will Mapped to Gaussian distribution parameters in the latent space decoder by Given the condition, we obtain the latent variable z and reconstruct the eigenvector. Training is completed based on loss function optimization. In the generation phase, for any target flocculation value... From The sample z is then used to generate the corresponding synthetic feature vector F through the decoder. syn Repeat the above process to generate M synthetic data samples and construct a synthetic dataset. D syn ;
[0039] 3) To train the prediction model, first merge the synthetic dataset and the original dataset to form a merged dataset. D train Automatically search and train the optimal regression model .
[0040] Furthermore, the preprocessing steps for acquiring the raw video stream in S1 include:
[0041] 1) Fixed area trimming: Select a rectangular area that includes the main reaction area and avoids interference from the vessel wall;
[0042] 2) Color space conversion: Convert the RGB image to a grayscale image;
[0043] 3) Image normalization, performing histogram equalization or contrast-limited adaptive histogram equalization to enhance the contrast between the flocs and the background, and obtain the pre-processed video stream.
[0044] Furthermore, the original video stream is acquired during the operation of the dosing control system, which includes a flocculation reactor, an imaging unit, a light-shielding unit, an edge computing and control unit, a dosing pump, and an auxiliary sensing unit. A light-shielding unit is installed outside the observation window of the flocculation reactor, the imaging unit faces the observation window of the flocculation reactor, the dosing pump is connected to the inlet end of the flocculation reactor, and the imaging unit, the dosing pump, and the auxiliary sensing unit are all electrically connected to the edge computing and control unit.
[0045] Beneficial effects of this invention:
[0046] 1. High precision and strong anti-interference: By using optical flow to distinguish flocs from bubbles at the physical motion level, the problem of misjudgment caused by static visual methods is fundamentally solved. Combined with dual-flow characteristics, the monitoring information is more comprehensive and the accuracy is significantly higher than that of single image analysis methods.
[0047] 2. Excellent model robustness: By using CVAE to generate synthetic data that conforms to the physical laws of the process, the training set is effectively expanded, enabling the core prediction model to maintain strong generalization ability under the condition of scarce data and adapt to changes in different water quality and chemicals.
[0048] 3. Intelligent feature fusion: An attention mechanism is introduced for feature fusion, enabling the model to autonomously focus on the morphological features most relevant to the current fluid dynamic state, thereby improving the efficiency of feature utilization and the interpretability of the model.
[0049] 4. Advanced and stable control performance: The "feedforward + feedback" composite control mode uses influent information and image features for disturbance prediction and feedforward compensation, and then uses high-precision flocculation degree prediction for feedback fine-tuning, which greatly reduces the lag of pure feedback control, making the dosing process more stable, the effluent water quality more stable, and the overall chemical consumption reduced by 10%-20%.
[0050] 5. Low cost and easy deployment: The core algorithm can be deployed on a single edge computing device, and can form a complete system with conventional industrial cameras and dosing pumps. The hardware modification cost is low, making it easy to upgrade and promote the application in existing sewage treatment plants. Attached Figure Description
[0051] Figure 1 This is a schematic diagram of the online monitoring and dosing control system for floc morphology based on optical flow and machine learning.
[0052] Figure 2 This is a flowchart illustrating an online monitoring and dosing control method for flocculant morphology based on optical flow and machine learning.
[0053] Figure 3 This is a schematic diagram of the dual-stream feature extraction and adaptive fusion module.
[0054] Figure 4 A schematic diagram of the data augmentation process based on CVAE;
[0055] Figure 5 This is a schematic diagram of an intelligent feedforward-feedback composite controller;
[0056] Figure 6 This is a schematic diagram illustrating the principle of bubble removal.
[0057] Figure 7 This is a schematic diagram of the response characteristics of a three-segment hierarchical feedback control. Detailed Implementation
[0058] To further illustrate the technical means and effects of the present invention in achieving its intended purpose, the following detailed description of the specific implementation methods, structures, features, and effects of the present invention, in conjunction with the accompanying drawings and preferred embodiments, is provided below.
[0059] Reference Figures 1-7 As shown, this invention provides a method for online monitoring of floc morphology and dosing control based on optical flow and machine learning, the steps of which are as follows:
[0060] S1. Video stream acquisition and preprocessing.
[0061] Under constant illumination, raw video streams of the liquid surface area in the flocculation reactor of the dosing control system are continuously acquired at a fixed frame rate (preferably 12 fps). Each frame undergoes the following preprocessing, with the specific steps for raw video stream preprocessing as follows:
[0062] 1) Fixed area trimming: Cut out a rectangular area that includes the main reaction area and avoids interference from the vessel wall.
[0063] 2) Color space conversion: Convert RGB images to grayscale images.
[0064] 3) Image normalization: Perform histogram equalization or contrast-limited adaptive histogram equalization to enhance the contrast between the flocs and the background and obtain the pre-processed video stream.
[0065] S2. Dual-stream feature extraction and intelligent fusion.
[0066] This step employs a dual-stream network architecture that parallelizes both spatial and temporal streams. Based on the preprocessed video stream in S1, it extracts static morphological feature vectors and dynamic rheological feature vectors in parallel using the dual-stream network. Then, an attention-guided feature fusion module adaptively weights and fuses the static morphological feature vectors and dynamic rheological feature vectors to obtain a fused feature vector. The specific steps are as follows:
[0067] S21. Spatial flow network extracts static morphological features. The specific steps are as follows:
[0068] 1) Extract keyframes from the video stream processed in S1 at fixed intervals;
[0069] 2) Input the keyframes into a lightweight convolutional neural network, remove its last classification layer, and extract a high-dimensional feature vector from the output (1280 dimensions) of the global_average_pooling2d layer. The feature vector encoding includes static visual information such as floc size distribution, edge sharpness, and texture roughness. The convolutional neural network is preferably MobileNetV2, EfficientNet-Lite, or ConvNeXt-Tiny, using MobileNetV2 pre-trained on ImageNet.
[0070] S22. Dynamic rheological features are extracted based on a time-flow network. The dynamic rheological feature vector is obtained sequentially through dense optical flow calculation, bubble interference suppression, and dynamic feature encoding. The time-flow network preferably uses OpenCV's cv2.calcOpticalFlowFarneback function to calculate optical flow. Optical flow distinguishes flocs from bubbles at the physical motion level, fundamentally solving the misjudgment problem of static visual methods. Combining dual-flow features provides more comprehensive monitoring information and significantly higher accuracy than single-image analysis methods. The specific steps are as follows:
[0071] 1) Dense optical flow calculation.
[0072] Based on the preprocessed video stream in S1, the Farneback algorithm or the deep learning-based RAFT-lite algorithm is used to calculate the motion vector of each pixel between two consecutive frames in the video stream, obtaining the dense optical flow field between consecutive frames. The motion vector includes horizontal displacement u and vertical displacement v, and the optical flow field... .
[0073] 2) Suppression of bubble interference.
[0074] Calculate the direction angle and amplitude of the motion vector for each pixel, identify and remove pixel regions belonging to the floating bubbles, and obtain the denoised optical flow field. O clean The specific steps include:
[0075] a. Calculate the orientation angle of the motion vector for each pixel. , ; Calculate the amplitude of the motion vector for each pixel. m , ,in For vertical displacement, This represents horizontal displacement.
[0076] b. Identify the abnormal motion region. In the rotating flow field created by mechanical stirring, the normal floc's motion direction is mainly consistent with the tangential direction of the mainstream flow field. When the direction angle... If a pixel falls within a range (e.g., [80°, 100°]) in the vertically upward direction and its amplitude m is greater than a set set settling velocity threshold, the pixel is determined to be a floating bubble.
[0077] c. Generate a binary maskM Set all pixels identified as floating bubbles to 0 and all others to 1;
[0078] d. Place the mask M With optical flow field O Element-wise multiplication is performed to obtain the denoised optical flow field. O clean .
[0079] 3) Dynamic feature encoding.
[0080] The optical flow field of the two channels O clean Convert the image into a three-channel color-coded image (e.g., map the u and v components to the H and S channels of the HSV color space, and the amplitude m to the V channel). Input the image into another lightweight convolutional neural network to extract dynamic rheological feature vectors. Preferably, the dynamic feature encoding network uses a simple 3-layer CNN, outputting a 256-dimensional feature map. F t The dynamic rheological feature vector F t It encodes dynamic information such as flow field velocity distribution, shear rate, and consistency of floc motion.
[0081] S23. Adaptive Feature Fusion Module.
[0082] The adaptive feature fusion module is a cross-attention fusion network that obtains fused feature vectors. The steps are as follows:
[0083] 1) Dynamic feature vectors F t and static feature vectors F s Static features are obtained by projecting different fully connected layers onto the same feature space. and dynamic features ;
[0084] 2) Based on dynamic characteristics As a query, static features As keys and values, attention weights are calculated and applied to the static features, outputting the weighted static features. The formula for calculating attention weights is as follows:
[0085]
[0086] in .
[0087] 3) Weighted static features With original dynamic characteristics The features are concatenated along the channel dimension to obtain the fused feature vector. .
[0088] S3. Robust prediction model for flocculation degree based on data augmentation.
[0089] A prediction model is constructed and trained. The fused feature vector obtained in S2 is input into the trained prediction model, and the current predicted flocculation value is output. The prediction model is a regression model trained using a training set augmented with a conditional variational autoencoder. This step is divided into an offline training stage and an online prediction stage, as detailed below:
[0090] S31. Offline training phase. The training steps are as follows:
[0091] 1) Constructing the original dataset. During the initial system deployment, the system is run under various typical operating conditions to collect raw data from the original video stream, gathering N sets of data to form the original dataset. Each set of data includes a fused feature vector. And the actual flocculation index measured at the same moment through experiments (e.g., standardized CST values), forming the raw data. ;
[0092] 2) Obtaining synthetic datasets through CVAE data augmentation D syn By utilizing CVAE to generate synthetic data that conforms to the physical laws of the process, the training set is effectively expanded, enabling the core prediction model to maintain strong generalization ability even under data-scarce conditions and adapt to changes in different water qualities and chemicals. The specific steps are as follows:
[0093] a. First, construct a conditional variational autoencoder. Will Mapped to Gaussian distribution parameters in the latent space decoder by y true Given the condition, latent variables z are sampled from this distribution, and the feature vector is reconstructed. ;
[0094] b. Training is completed based on loss function optimization, where the loss function is the sum of reconstruction loss and KL divergence: ;
[0095] c. Generation stage, for any target flocculation value y cond From The sample z is then used to generate the corresponding synthetic feature vector through the decoder. F synRepeat this process to generate M synthetic data samples and construct a synthetic dataset. D syn .
[0096] 3) Train the prediction model. First, merge the synthetic dataset and the original dataset to form a merged dataset. ,exist D train Automatically search and train the optimal regression model .
[0097] S32. Online prediction stage. The fused feature vector extracted in real time... Directly input the deployed, trained prediction model In the middle, the current predicted flocculation degree value is output in real time. .
[0098] S4. Intelligent feedforward-feedback composite control strategy, including feedforward prediction module and feedback correction module.
[0099] First, a feedforward prediction module is constructed and trained. Real-time or historical data of influent parameters and fused feature vectors are input into the feedforward prediction module to calculate the feedforward dosing acceleration rate of flocculant. At the same time, based on the deviation between the predicted flocculation degree and the target set value, the feedback correction rate is calculated through the feedback correction module. The feedforward dosing acceleration rate and the feedback correction rate are combined to generate the final control signal to adjust the flocculant dosage.
[0100] S41. Feedforward prediction module.
[0101] 1) Training the feedforward model (such as Temporal Convolutional Network (TCN) or Simple Regression Model).
[0102] 2) In the post-trained feedforward model Input the inflow rate over the past T minutes Q in 1. Turbidity of influent Turb in The fused feature vector of the sliding window sequence and the current time step The output is the predicted change in flocculant demand. .
[0103] 3) Based on the feedforward dosing rate baseline Adding the predicted changes in flocculant demand Obtain feedforward control output .
[0104] S42. Feedback Correction Module.
[0105] The feedback correction module uses feedback control logic to calculate the feedback correction rate, and the steps are as follows:
[0106] 1) Calculate the deviation between the predicted flocculation degree and the target setpoint. The calculation formula is as follows:
[0107] ,
[0108] in The optimal target value for flocculation degree set for the process.
[0109] 2) A three-segment hierarchical control logic is adopted, which includes a maintenance zone, a fine-tuning zone, and a response zone.
[0110] a. Maintenance zone: when deviation... e When less than or equal to zero, the feedback correction amount of the output (Zero or very low sustaining flow);
[0111] b. Fine-tuning zone: When the deviation e is greater than zero and less than or equal to the first threshold ( , (Number of standardized units), the output feedback correction is a flow rate proportional to the deviation (Number of standardized units). );
[0112] c. Response zone: When the deviation is greater than the first threshold ( This indicates that flocculation is severely insufficient, and the output feedback correction amount... It is the preset maximum compensation flow, i.e. ;
[0113] S43. Composite Decision-Making and Output.
[0114] By combining the feedforward acceleration rate and the feedback correction rate, a final control signal is generated to adjust the flocculant dosage. This is the final dosing pump set flow rate. Then, through edge computing units... Q set The signal is converted into a corresponding control signal (PWM duty cycle or analog voltage) to drive the dosing pump. The "feedforward + feedback" composite control mode utilizes influent information and image features for disturbance prediction and feedforward compensation, followed by feedback fine-tuning through high-precision flocculation degree prediction. This significantly reduces the lag of pure feedback control, resulting in a smoother dosing process, more stable effluent quality, and a 10%-20% reduction in overall chemical consumption. Ultimately, this achieves the goals of improving dewatering efficiency, stabilizing effluent quality, saving chemical consumption, and reducing operating costs.
[0115] S5. The model updates online.
[0116] The system can periodically (e.g., every 24 hours) update the new data generated that day. The data is cached, and operators periodically input small amounts of corresponding laboratory validation values. This creates a small batch of new datasets. Transfer learning techniques are then employed on the already trained model. and Based on this, fine-tuning is performed to enable the system to adapt to the long-term slow changes in the process.
[0117] Reference Figure 1 As shown, the above-mentioned S1 dosing control system includes a flocculation reactor, an imaging unit, a light-shielding unit, an edge computing and control unit 7, a dosing pump, and an auxiliary sensing unit. A light-shielding unit is installed outside the observation window of the flocculation reactor, the imaging unit faces the observation window of the flocculation reactor, the dosing pump is connected to the inlet end of the flocculation reactor, and the imaging unit, dosing pump, and auxiliary sensing unit are all electrically connected to the edge computing and control unit. Specifically, it includes:
[0118] 1) Flocculation reactor: includes a glass container 1, a magnetic stir bar and a magnetic stirrer. The magnetic stir bar is placed at the bottom of the glass container, and the drive end of the magnetic stir bar passes through the bottom of the glass container and is connected to the magnetic stirrer.
[0119] 2) Imaging Unit: Includes an industrial camera 6 and a dedicated light source 5. The camera faces the observation window of the flocculation reactor, with a frame rate of no less than 10 fps and a resolution of no less than 1280×720. The light source is a strip-shaped LED diffused light source with a color temperature of 4000-5000K, which uniformly illuminates the liquid surface from the top to ensure that the "constant brightness assumption" required for optical flow calculation is met and to minimize specular reflection.
[0120] 3) Shielding unit: A black rubber shield 2 is installed on the outside of the reactor observation window (outside the glass container) to shield the interference of ambient stray light.
[0121] 4) Edge Computing and Control Unit 7: An embedded edge computing device with a built-in GPU (such as the Nvidia Jetson Nano series) is equipped with a Raspberry Pi Camera v2.1 (6). The camera is connected to the camera through a high-speed interface (such as MIPI CSI-2, USB3.0), and GPUDirect RDMA technology is used to reduce image transmission latency. This unit runs all the core algorithms of this invention and integrates digital / analog output modules.
[0122] 5) Execution Unit: Includes a peristaltic pump or screw pump 9 controlled by the edge computing unit, which adds chemicals to the mixture 3 through the dosing pipeline 10 for precise dosing of liquid flocculant. The pump's drive signal receives a PWM or 4-20mA analog signal from the edge computing unit.
[0123] 6) Auxiliary sensing unit: An online turbidity meter and an electromagnetic flow meter are installed on the inlet pipe of the flocculation reactor, and their signals are connected to the edge computing unit as input for feedforward control.
[0124] Example: Based on the intelligent dosing control system experiment, the process of the online monitoring and dosing control method of the present invention is described in detail below:
[0125] I. System Hardware Architecture (Refer to) Figure 1 (As shown).
[0126] 1. Reaction environment: Transparent glass container (1), with black rubber light-shielding layer (2) wrapped around the side walls to shield side light, leaving only top illumination. The light source (5) uses an LED lamp with a color temperature of 4000K to provide stable illumination that satisfies the "constant brightness assumption" for optical flow calculation.
[0127] 2. Computation and Acquisition: An Nvidia Jetson Nano edge computing device (7) was used, equipped with a Raspberry Pi Camera v2.1 (6). The camera was connected via a MIPI CSI-2 interface (8), and GPUDirect RDMA technology was used to reduce image transmission latency.
[0128] 3. Actuator: The flocculant dosing pump (9) adds the agent to the mixture (3) through the dosing pipeline (10). The pump speed is controlled by the analog output signal of Jetson Nano.
[0129] II. Software Implementation and Parameter Configuration.
[0130] 1. Image preprocessing: The camera was running at 12fps with a resolution of 1296x972. The ROI was set to the 800x600 area in the center of the image. Contrast enhancement was performed using CLAHE.
[0131] 2. Two-stream network.
[0132] a. Spatial Flow: Using MobileNetV2 pre-trained on ImageNet, the output (1280 dimensions) of the global_average_pooling2d layer is taken as... F s .
[0133] b. Time Flow: Optical flow is calculated using OpenCV's `cv2.calcOpticalFlowFarneback` function. The bubble removal threshold is set to the direction angle range [85°, 95°], and the amplitude threshold is 0.5 pixels / frame. The dynamic feature encoding network uses a simple 3-layer CNN, outputting a 256-dimensional... F t .
[0134] c. Fusion Module: The dimension of the attention head is set to 64. Finally... It has 1536 dimensions.
[0135] 3. CVAE and prediction model training (offline).
[0136] a. Approximately 300 sets of raw data were collected. Both the encoder and decoder of CVAE are 3-layer fully connected networks, with the latent variable dimension set to 32.
[0137] b. Using H2O AutoML, with a maximum training time of 300 seconds, we trained on a dataset that combined 2700 data sets. The automatically selected optimal model was the Stacked Ensemble model, which achieved an R² of 0.96 on the independent test set.
[0138] 4. Control strategy implementation (online).
[0139] a. Feedforward model Linear regression was used, with the input being the average influent flow rate over the past 5 minutes and the current turbidity.
[0140] b. Feedback control parameters: ,K p =0.5 mL / (min·unit deviation), Q max =50mL / min. The control cycle is 5 seconds.
[0141] III. System Operation.
[0142] After the system is powered on, it enters the online monitoring and control mode. The Jetson device continuously acquires images, executes steps S2 to S4, and calculates and outputs a new value every 5 seconds. Q set The dosing pump is controlled by a signal. The host computer in the central control room displays the predicted flocculation degree curve, dosing curve, and alarm information in real time via a web interface. After a week of trial operation, the system was able to maintain the sludge moisture content within the set range even with influent concentration fluctuations of ±20%. Compared to the manual control stage, PAM consumption was reduced by approximately 15%.
[0143] The above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention in any way. Although the present invention has been disclosed above with reference to preferred embodiments, it is not intended to limit the present invention. Any person skilled in the art can make some modifications or alterations to the above-disclosed technical content to create equivalent embodiments without departing from the scope of the present invention. Any simple modifications, equivalent changes and alterations made to the above embodiments based on the technical essence of the present invention without departing from the scope of the present invention shall still fall within the scope of the present invention.
Claims
1. A dosing control method based on online monitoring of flocculant morphology using optical flow and machine learning, characterized by the following steps: as follows: S1. Acquire the raw video stream of the liquid surface area in the flocculation reactor and preprocess it; S2. Based on the preprocessed video stream in S1, static morphological feature vectors and dynamic rheological feature vectors are extracted in parallel. Then, adaptive weighted fusion is performed through the feature fusion module to obtain the fused feature vector. The dynamic rheological feature vector is obtained by dense optical flow calculation, bubble interference suppression and dynamic feature encoding in sequence. The steps for extracting dynamic rheological feature vectors are as follows: 1) Dense optical flow calculation: Based on the preprocessed video stream in S1, calculate the motion vector of each pixel between two consecutive frames in the video stream to obtain the dense optical flow field between consecutive frames. 2) Bubble interference suppression: Calculate the direction angle and amplitude of the motion vector for each pixel, identify and remove pixel regions belonging to floating bubbles, and obtain the denoised optical flow field. O clean ; 3) Dynamic feature encoding, which encodes the optical flow field of the two channels. O clean The image is converted into a three-channel color-coded image, and then input into a convolutional neural network to extract the dynamic rheological feature vector. The static morphological feature vector is extracted using a spatial flow network, and the steps are as follows: 1) Extract keyframes from the video stream processed in S1 at fixed intervals; 2) Input the keyframes into a lightweight convolutional neural network, remove its last classification layer, and extract a high-dimensional feature vector. ; S3. Construct and train the prediction model, input the fusion feature vector obtained in S2 into the trained prediction model, and output the current predicted flocculation value; S4. Construct and train the feedforward prediction module. Input the influent parameters and fused feature vector into the feedforward prediction module to calculate the feedforward dosing acceleration rate of flocculant. At the same time, based on the deviation between the predicted flocculation degree and the target set value, the feedback correction rate is calculated through the feedback correction module. Combine the feedforward dosing acceleration rate and the feedback correction rate to generate the final control signal to adjust the flocculant dosage.
2. The dosing control method based on online monitoring of flocculation morphology using optical flow and machine learning as described in claim 1, characterized in that: The specific steps for suppressing bubble interference are as follows: 1) Calculate the direction angle of the motion vector for each pixel. , ; Calculate the amplitude of the motion vector for each pixel. m , ,in Vertical displacement This is a horizontal displacement; 2) Identify the abnormal motion area, when the direction angle θ If a pixel falls within a range near the vertically upward direction and its amplitude m is greater than a set set settling velocity threshold, the pixel is determined to be a floating bubble. 3) Generate a binary mask M Set all pixels identified as floating bubbles to 0 and all others to 1; 4) Place the mask M With optical flow field O Element-wise multiplication is performed to obtain the denoised optical flow field. O clean .
3. The dosing control method based on optical flow and machine learning for online monitoring of flocculant morphology according to claim 1 or 2, characterized in that: S2 The feature fusion module is a cross-attention fusion network. The steps to obtain the fused feature vector are as follows: 1) Dynamic feature vectors F t and static feature vectors F s Static features are obtained by projecting different fully connected layers onto the same feature space. and dynamic features ; 2) Based on dynamic characteristics As a query, static features As keys and values, attention weights are calculated and weighted onto the static features, outputting the weighted static features. ; 3) Weighted static features With original dynamic characteristics By concatenating the data along the channel dimension, a fused feature vector is obtained.
4. The dosing control method based on online monitoring of flocculation morphology using optical flow and machine learning as described in claim 1, characterized in that: The steps in S4 for calculating the feedforward acceleration rate of flocculants in the feedforward prediction module include: [The following steps are taken in the trained feedforward model...] Input the inflow rate over the past T minutes Q in 1. Turbidity of influent Turb in The fused feature vector of the sliding window sequence and the current time step The output is the predicted change in flocculant demand. At the feedforward dosing rate baseline Adding the predicted changes in flocculant demand Obtain feedforward control output .
5. The dosing control method based on optical flow and machine learning for online monitoring of flocculent morphology according to claim 1, 2, or 4, characterized in that: In S4, the feedback correction module calculates the feedback correction rate through feedback control logic, as follows: 1) Calculate the deviation between the predicted flocculation degree and the target setpoint. The calculation formula is as follows: , in y target The optimal target value for flocculation degree set for the process. 2) A three-section hierarchical control logic is adopted, when the deviation... e When the value is less than or equal to zero, the output feedback correction is zero or a small maintenance flow. when deviation e When the value is greater than zero and less than or equal to the first threshold, the output feedback correction amount is the flow rate proportional to the deviation; When the deviation is greater than the first threshold, the output feedback correction amount is the preset maximum compensation flow.
6. The dosing control method based on online monitoring of flocculation morphology using optical flow and machine learning according to claim 1, characterized in that: S3 The prediction model described herein is a regression model trained using a training set augmented with a conditional variational autoencoder. The training steps are as follows: 1) Collect raw data from the original video stream, gather N sets of data, and form the original dataset; 2) Obtaining synthetic datasets through CVAE data augmentation D syn First, construct a conditional variational autoencoder. E Φ Will Mapped to Gaussian distribution parameters in the latent space decoder D θ by y true Given the condition, we obtain the latent variable z and reconstruct the eigenvector. Training is completed based on loss function optimization. In the generation phase, for any target flocculation value... y cond From The sample z is then used to generate the corresponding synthetic feature vector F through the decoder. syn Repeat the above process to generate M synthetic data samples and construct a synthetic dataset. D syn ; 3) To train the prediction model, first merge the synthetic dataset and the original dataset to form a merged dataset. D train Automatically search and train the optimal regression model .
7. The dosing control method based on optical flow and machine learning for online monitoring of flocculant morphology according to claim 1, 2, 4, or 6, is characterized in that: The steps for preprocessing the raw video stream acquired in S1 include: 1) Fixed area trimming: Select a rectangular area that includes the main reaction area and avoids interference from the vessel wall; 2) Color space conversion: Convert the RGB image to a grayscale image; 3) Image normalization, performing histogram equalization or contrast-limited adaptive histogram equalization to enhance the contrast between the flocs and the background, and obtain the pre-processed video stream.
8. The dosing control method based on online monitoring of flocculent morphology using optical flow and machine learning according to claim 7, characterized in that: The original video stream is acquired during the operation of the dosing control system, which includes a flocculation reactor, an imaging unit, a light-shielding unit, an edge computing and control unit, a dosing pump, and an auxiliary sensing unit. A light-shielding unit is installed outside the observation window of the flocculation reactor, the imaging unit faces the observation window of the flocculation reactor, the dosing pump is connected to the inlet end of the flocculation reactor, and the imaging unit, the dosing pump, and the auxiliary sensing unit are all electrically connected to the edge computing and control unit.