A solution stirring abnormality detection method adaptive to image contrast
By using an adaptive image comparison method, the stirring state of chemical solutions is detected using the YOLO11 model and a Siamese network. This addresses the shortcomings of automated detection in existing technologies and achieves high-precision and reliable monitoring of the stirring state.
Patent Information
- Application Number
- CN202610353836.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-03-23
- Publication Date
- 2026-06-26
AI Technical Summary
Existing technologies struggle to achieve reliable, real-time, and automated detection of the stirring state of chemical solutions, especially in complex scenarios where false alarm and false negative rates are high, and manual monitoring is inefficient.
An adaptive image comparison method is adopted. By acquiring the stirring video stream in real time, the YOLO11 model is used to identify the solution area, dynamically creating the baseline and the area to be detected. The image similarity is calculated using a Siamese network, and the stirring anomaly is determined by combining a state queue, which can adapt to changes in liquid level and different colored solutions.
It achieves 24/7 uninterrupted automated monitoring, reduces false alarm and false alarm rates, improves detection accuracy, and adapts to complex scenarios such as different liquid ratios and container reflectivity.
Smart Images

Figure CN122290041A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of computer vision and automated chemical experiment detection technology, specifically relating to an adaptive image comparison method for detecting abnormal solution stirring. Background Technology
[0002] In the field of chemical automation laboratories, solution stirring is a fundamental and crucial experimental operation. Whether the stirring is uniform and thorough directly affects the reaction rate, product purity, and even the success or failure of the experiment. Currently, monitoring the stirring status mainly relies on the naked observation of the experimenters. This method has disadvantages such as high labor costs, susceptibility to subjective factors and fatigue, and difficulty in achieving 24 / 7 uninterrupted monitoring, which may lead to missed detections and delays in the experimental process.
[0003] With the development of computer vision technology, some general visual detection methods (such as histogram analysis, SSIM comparison, and PISR comparison) have been attempted to be applied to similar scenarios. However, chemical solution stirring scenarios have their own unique characteristics: the solution color, density, and mixing ratio vary greatly; the curvature of the stirring container wall may cause image distortion and reflection; and the dynamic changes in liquid morphology during stirring are complex. These factors make general algorithms poorly adaptable, difficult to set detection thresholds, and result in high false positive and false negative rates. For example, for solutions of different colors, the SSIM values may vary greatly even under uniform conditions, making it difficult to accurately determine using a fixed threshold.
[0004] There are also some related patent solutions in the existing technology, such as a visual recognition-based shell breaking stirring system and working method (CN120536231B) which does not involve dynamic detection of solution area and cannot adapt to liquid level changes, and an image comparison test method (CN119206258A) which does not use a brightness transformation enhancement model and cannot adapt to multi-color solutions.
[0005] Therefore, there is an urgent need for a technical solution that can adapt to complex real-world scenarios and reliably, in real-time, and automatically detect abnormalities in solution stirring. Summary of the Invention
[0006] The purpose of this invention is to overcome the shortcomings of the prior art and provide an adaptive image comparison method for detecting abnormal stirring in solutions, thereby achieving automated and high-precision detection of the stirring state of chemical solutions and solving the problems of low efficiency of manual detection and poor adaptability of general vision methods.
[0007] The objective of this invention is achieved through the following technical solution: An adaptive image-contrast method for detecting solution stirring anomalies includes the following steps: S1. Real-time acquisition of video stream of the solution stirring process; S2. Input a single frame image from the video stream into the target detection model to identify the solution region; S3. Based on the identified solution area, dynamically create one reference area and at least one area to be detected in the vertical direction; S4. After converting the images of the reference region and each of the regions to be detected to grayscale, the images are input into a pre-trained Siamese network for similarity calculation to obtain the corresponding similarity value D. S5. Compare the similarity value D obtained in step S4 with the preset similarity threshold Margin, output the corresponding state determination result, and store the state determination result in a state queue. S6. Repeat S1-S5 until the length of the state queue reaches the preset maximum length. S7. Based on all the status determination results in the status queue, comprehensively determine whether the solution stirring is abnormal.
[0008] Furthermore, in step S2, the target detection model is the YOLO11 model.
[0009] Furthermore, in step S3, the specific steps of the dynamic creation include: S3.1 Select the effective height range in the vertical direction of the solution region. H removes the top and bottom areas with a preset ratio of 5% to avoid boundary interference, and h is the total height range; S3.2, Preset number of areas A num and preset area width A w Set minimum aspect ratio ; S3.3 Calculate the height A of the preset area h And the suggested number of areas C: (1) (2); S3.4 If the aspect ratio of the preset area is greater than the minimum aspect ratio Then the preset number of regions A is used. num Otherwise, use the suggested area number C.
[0010] Furthermore, the twin network described in step S4 consists of two sub-networks with identical structures and shared weights, and the sub-networks are formed by stacking multiple layers of convolutions.
[0011] Furthermore, in step S4, the similarity value D is obtained by calculating the L2 distance between the feature vectors output by the two sub-networks.
[0012] Furthermore, the training method for the Siamese network in step S4 includes: S4.1. Construct a training dataset, which contains images of solution regions with different colors, different mixing ratios, and different stirring states. S4.2. Perform grayscale processing and unified brightness transformation on each image in the training dataset. S4.3. Input the images after brightness transformation into a siamese network for training. Optimize the network weights through backpropagation of the contrast loss function, and iteratively train until the loss function converges.
[0013] Furthermore, in S4.2, the method for unified brightness transformation of images is specifically as follows: For the two input grayscale images I a (x, y) and I b (x, y), with a size of M×N and pixel value range [0, 255], calculate their global minimum pixel value Pix Min and global maximum pixel value Pix Max , and the calculation formula is: (9) (10); Set a random offset , The value range of (11); Perform brightness adjustment to obtain the transformed image: (12) (13).
[0014] Furthermore, the specific determination process of step S5 is as follows: If the similarity value D≥Margin, add an abnormal state to the status queue and terminate the traversal of the regions to be detected in the current round; if the similarity values D of all regions to be detected and the reference region are <Margin, add a normal state to the status queue.
[0015] Furthermore, the value of the preset maximum length of the status queue in step S6 is associated with the frame rate of the video stream to ensure that the status queue covers the determination results for a continuous period of time.
[0016] Compared with the prior art, the technical solution provided by the present invention has the following beneficial effects: (1)High degree of automation: It can monitor continuously for 7×24 hours, automatically complete status recognition and recording, and significantly reduce manual intervention; (2) Strong adaptability: The solution area is dynamically detected by the target detection model to adapt to changes in liquid level; the solution area is covered in multiple areas in the vertical direction to adapt to different liquid ratios; the image uniform brightness transformation method is adopted to adapt to different colored solutions and effectively cope with complex scenarios such as container reflection and solution color variation. (3) High detection accuracy: The twin network is used to accurately calculate the region similarity, and the state queue is used to filter out misjudgments caused by occasional fluctuations, thereby reducing the false alarm rate and the false detection rate. Attached Figure Description
[0017] Figure 1 This is a schematic diagram of a solution stirring scenario according to the present invention; Figure 2 This is the overall flowchart of the solution stirring abnormality detection method of the present invention; Figure 3 A flowchart for dynamically creating a logical determination process for the reference region and the region to be detected in this invention; Figure 4 This is a schematic diagram showing the distribution of the reference region and the region to be detected within the solution region in this invention; Figure 5 This is a flowchart of the twin network training method of the present invention; 1 is a camera; 2 is a transparent stirring container; 3 is a stirring paddle; 4 is solution A; 5 is solution B. Detailed Implementation
[0018] To enable those skilled in the art to better understand the technical solutions of the present invention, the present invention will be further described in detail below with reference to the accompanying drawings and embodiments.
[0019] This invention provides an adaptive image comparison method for detecting abnormal solution stirring. In this embodiment, the solution stirring scenario is as follows: Figure 1 As shown, the system includes a transparent stirring container 2 and a camera 1 deployed on one side of the container 2. The camera 1 is positioned at eye level. A stirring paddle 3 is used to stir solutions A4 and B5 evenly (the specific stirring method is not shown in the figure, but could be mechanical or magnetic stirring, etc.). The image data is processed by an external computer module. In this embodiment, data transmission is wireless, but this is not specifically limited; the transmission function is sufficient. The abnormal stirring detection process is as follows: Figure 2 As shown, the specific steps are as follows: Step 1: System Initialization Create a state queue (Queue) with a maximum length of Nq and set it to empty. In this embodiment, Nq=24, which corresponds to the 1 second 24fps video used in this invention, to ensure that the state queue covers the judgment results for a continuous period of time.
[0020] Step 2: Acquire video frames A single frame of video stream is captured in real time from a camera deployed above the mixing equipment.
[0021] Step 3: Detect the solution area The image frame is input into the object detection model. This model is specifically designed for detecting solution regions in a stirred container. A conventional object detection model can be used. The choice depends on the hardware's computing power and the specific requirements of the project scenario. This embodiment selects the YOLO11 object detection model. YOLO11's advantages include a small number of parameters, fast inference speed, and high portability when deployed on different platforms.
[0022] The YOLO11 model outputs the bounding box information of the solution region. yolo ={x1,y1,x2,y2,w,h}, where (x1,y1) and (x2,y2) are the coordinates of the top-left and bottom-right corners of the bounding box, respectively, and w and h are the width and height of the box, respectively. The YOLO11 model can accurately identify dynamically changing liquid levels, offering greater flexibility compared to fixed-area settings. This allows subsequent detection tasks to focus solely on the solution area, eliminating interference from background and other invalid regions, thus improving detection efficiency.
[0023] Step 4: Dynamically create the detection area Based on Box yolo Dynamically create a reference region A base And N regions to be detected {A1, A2, ..., AN}. Figure 3 As shown, the specific judgment rules are as follows: 4.1 Select the effective height range in the vertical direction of the solution region The height range of 5% above and below is excluded to avoid the influence of the liquid level line and the curvature of the container bottom, ensuring the effectiveness of the area. h is the total height range. 4.2 Number of preset areas and the preset area width A w Set the minimum aspect ratio to be [value]. ; 4.3 Calculate the height A of the preset area h And the suggested number of areas C: (1) (2); 4.4 If the aspect ratio of the preset area is greater than... If the desired area is found, the preset area number will be used; otherwise, the suggested area number will be used. When calculating the aspect ratio, the maximum value of the height and width will be used as the denominator.
[0024] When using the suggested area number, the preset frame size is: width A. w The height is C h : (3).
[0025] like Figure 4 As shown, within the effective height H, these areas are set at equal intervals or distributed as needed along the vertical direction. The first area a is designated as the reference area A. base The remaining regions b, c, d, e, and f are designated as region A to be detected. i The area selected vertically needs to cover different heights; this embodiment is just one method and is not limited to the reference area A. base With the area to be detected A i The arrangement can be any way that meets this requirement.
[0026] The width of the region in this embodiment is A. w =64 pixel value, height A h The patterned area of the beaker (position w) was avoided. ), set A from top to bottom num = There are 6 regions, the first region is A base Other areas are areas to be detected, A base and A i The coordinates are described as follows: (4) (5) (6) (7) (8) In the formula, It is to exclude 5% of the height range above and below. There are no requirements for setting this value, as long as it avoids the influence of the liquid level line and the curvature of the bottom of the container.
[0027] Step 5: Enter the region comparison loop For each region A to be detected i (i=1 to N) Perform comparison processing: 5.1, Place A base and A i The images are converted to grayscale respectively. In this embodiment, A... base and A i The image is an RGB color image, and grayscale processing is performed using existing grayscale formulas. The grayscale processing in this invention can also be performed using color images in other color space formats, through appropriate conversion processing.
[0028] 5.2. Input the grayscale image pair into a pre-trained Siamese network (SiameseNet) to output the corresponding feature distance. The feature distance represents the similarity value D between the two. The closer the result of D is to 0, the more evenly the solution is stirred. On the contrary, the solution stirring is abnormal.
[0029] 5.3. Compare the similarity value D with a preset similarity threshold Margin: If D < Margin, it is considered that A base and A i are similar in image features at this moment, and the result of this comparison is "normal". Continue to loop and compare the next area to be detected.
[0030] If D ≥ Margin, it is considered that the two are not similar, and the result of this comparison is "abnormal", and immediately jump out of the loop.
[0031] Step 6. Add a status value to the status queue According to the loop result of Step 5, add a status value to the status queue Queue.
[0032] If the loop ends prematurely due to D ≥ Margin, add the status "False" (representing abnormality) to the tail of Queue.
[0033] If the loop is completed normally (that is, the comparison results of all N areas are D < Margin), add the status "True" (representing normal) to the tail of Queue.
[0034] Step 7. Determine whether to perform the final status output If the length of Queue has not reached Nq, return to Step 2 to process the next frame of image.
[0035] If the length of Queue has reached Nq, perform Step 8.
[0036] Step 8. Comprehensive judgment If all the status values in Queue are "False", it is determined that the solution stirring is "abnormal" during the current time period. The system triggers an audible and visual alarm and simultaneously records a log.
[0037] If there is at least one "True" status in Queue, it is determined that the stirring is "normal" or there is an acceptable instantaneous "fluctuation".
[0038] After the judgment is completed, the queue can be cleared or partially processed, and return to Step 1 for continuous monitoring. Siamese network structure and training
[0039] SiameseNet is a special neural network architecture used to learn the similarity between samples. It consists of two sub-networks with identical structures and shared weights. When a pair of samples is input, these two sub-networks extract their features and generate corresponding feature vectors. The network then calculates the distance between these two vectors to determine the similarity between the original input samples. Its core advantage lies in ensuring the consistency of feature extraction standards through shared parameters, making it effective for image feature comparison tasks in solution stirring scenarios.
[0040] In this embodiment, the subnetwork consists of three stacked convolutional layers. Using a structure with a small number of parameters can achieve faster inference speed while meeting computational requirements. The distance between two feature vectors is calculated using L2 distance (Euclidean distance).
[0041] like Figure 5 As shown in the flowchart, SiameseNet requires enhanced training. During the model training phase, the similarity margin in this example is set to 1. A contrastive loss function is used. The closer the distance D is to 0, the more similar the input pair of samples are, indicating that the solution is stirred more evenly. D≥1 indicates dissimilarity and abnormal solution stirring. First, a training dataset is constructed, which contains images of solution regions with different colors, different mixing ratios, and different stirring states. Then, as shown in Figure 6, the images in the training dataset are grayscaled and subjected to uniform brightness transformation. The brightness-transformed images are then input into the SiameseNet for training. The network weights are optimized through backpropagation using the contrastive loss function. The training is iterated until the loss function converges, and finally, the optimal weight parameters of SiameseNet are obtained.
[0042] These shared weight parameters constitute a universal feature extractor that can transform solution region images of different colors and brightness into the same feature space, generating comparable feature vectors. By calculating the distance between feature vectors, the weight parameters essentially encode the visual discrimination criterion of "solution homogeneity," enabling the network to ignore irrelevant color differences and focus on the consistency judgment of texture and structure, thereby providing the core intelligent decision-making basis for achieving adaptive and highly robust anomaly detection.
[0043] The image uniform brightness transformation method is as follows: Given two grayscale images Ia(x,y) and Ib(x,y) of size M×N with pixel values ranging from [0,255], calculate their global minimum pixel value PixMin and global maximum pixel value PixMax using the following formula: (9) (10); Set random offset , The value range must ensure that the transformed pixel value is within the range of [0, 255]. (11); Perform brightness adjustment to obtain the transformed image: (12) (13) Crop the transformed pixel values to the range of [0,255]. Experimental data:
[0044] To verify the effectiveness of the method of this invention, comparative experiments and stability tests were conducted in a standard laboratory environment. The standard laboratory environment included: an ambient temperature of 20–25℃, a relative humidity of 40–60%RH, uniform diffused white light illumination of 500–1000 lux, and no significant mechanical vibration; the reagents used in the experiments were of analytical grade, the glassware conformed to GB / T specifications, and the instruments and equipment were used after calibration.
[0045] The experimental data of this invention are shown in Table 1 below:
[0046] As shown in Table 1, the judgment results of this method in three typical scenarios are completely consistent with the actual solution state.
[0047] Stability data from continuous operation for 72 hours
[0048] Note: Occasional fluctuations refer to instantaneous fluctuations caused by data anomalies or judgment anomalies in individual image frames.
[0049] As shown in Table 2, during a continuous 72-hour test, this method can effectively filter out interference caused by video frame fluctuations and maintain stable detection performance.
[0050] The accuracy rates of histogram analysis, SSIM comparison, and PISR comparison methods under various solution color conditions are shown in Table 3 below:
[0051] As shown in Table 3, comparative experiments on solutions of different colors demonstrate that the accuracy of this method in red, yellow, and dark black solutions all exceed 98%, with a false negative rate of less than 1.6%, significantly outperforming traditional methods such as PISR, SSIM, and histogram analysis. Traditional methods perform reasonably well under ideal laboratory lighting and with a single solution color, but in actual production, variations in ambient light intensity and different colored solutions can lead to drastic fluctuations in the final results.
[0052] In this invention, even if the container surface is reflective or the solution color is dark or light, the data-enhanced twin network can still accurately identify similarity; the dynamically created comparison area effectively covers different solution heights and adapts to various liquid ratios; the state queue effectively filters out accidental fluctuations, ensuring reliable detection results.
Claims
1. A method for adaptive image contrast solution agitation anomaly detection, the method comprising: Includes the following steps: S1 acquires video stream images of the solution stirring process in real time; S2 inputs a single frame image from the video stream into the target detection model to identify the solution region; S3 Based on the identified solution area, dynamically create one reference area and at least one area to be detected in the vertical direction; S4 After converting the images of the reference region and each of the regions to be detected to grayscale, the images are input into a pre-trained Siamese network for similarity calculation to obtain the corresponding similarity value D; S5 compares the similarity value D obtained in step S4 with the preset similarity threshold Margin, outputs the corresponding state determination result, and stores the state determination result in a state queue. S6 Repeat S1-S5 until the length of the state queue reaches the preset maximum length; S7 Based on all the status determination results in the status queue, comprehensively determine whether the solution stirring is abnormal.
2. The method for detecting abnormal solution stirring according to claim 1, characterized in that, In step S2, the target detection model is the YOLO11 model.
3. The solution stirring abnormality detection method according to claim 1, characterized by, In step S3, the specific steps of dynamic creation include: S3.1 Select the effective height range in the vertical direction of the solution region. H removes the top and bottom areas with a preset ratio of 5% to avoid boundary interference, and h is the total height range; S3.2, Preset number of areas A num and preset area width A w Set minimum aspect ratio ; S3.3 Calculate the height A of the preset area h And the suggested number of areas C: (1) (2); S3.4 If the aspect ratio of the preset area is greater than the minimum aspect ratio Then the preset number of regions A is used. num Otherwise, use the suggested area number C.
4. The method for detecting abnormal solution stirring according to claim 1, characterized in that, The twin network described in step S4 consists of two sub-networks with identical structures and shared weights, and the sub-networks are formed by stacking multiple layers of convolutions.
5. The method for detecting abnormal solution stirring according to claim 1, characterized in that, In step S4, the similarity value D is obtained by calculating the L2 distance between the feature vectors output by the two sub-networks.
6. The solution stirring abnormality detection method according to claim 4, characterized by The training method for the Siamese network described in step S4 includes: S4.1 Construct a training dataset, which contains images of solution regions with different colors, different mixing ratios, and different stirring states; S4.2 Perform grayscale conversion and uniform brightness transformation on each image in the training dataset; S4.3 Input the brightness-transformed image into the Siamese network for training. Optimize the network weights through backpropagation using the comparative loss function, and iterate until the loss function converges.
7. The method for detecting abnormal solution stirring according to claim 5, characterized in that, In S4.2, the image uniform brightness transformation method is specifically as follows: The two input grayscale images I a (x,y) and I b Given a set of pixels (x, y) of size M×N with pixel values ranging from [0, 255], calculate their global minimum pixel value Pix. Min and global maximum pixel value Pix Max The calculation formula is: (9) (10); Set random offset , The value range must ensure that the transformed pixel value is within the range of [0, 255]. (11); performing brightness adjustment to obtain a transformed image: (12) (13)。 8. The solution stirring abnormality detection method according to claim 1, characterized by, The specific determination process of step S5 is as follows: if the similarity value D ≥ similarity threshold Margin, then add an abnormal state to the state queue and terminate the traversal of the detection area in the current round; if the similarity value D between all detection areas and the baseline area is less than the similarity threshold Margin, then add a normal state to the state queue.
9. The method for detecting abnormal solution stirring according to claim 1, characterized in that, The maximum length of the state queue in step S6 is preset to be related to the frame rate of the video stream, so as to ensure that the state queue covers the judgment results for a continuous period of time.
10. The method for detecting abnormal solution stirring according to claim 1, characterized in that, If the overall judgment result in step S7 is abnormal, an audible and visual alarm will be triggered and a log will be recorded simultaneously. If it is normal, the process will return to step S1 for continuous monitoring.
Citation Information
Patent Citations
Image comparison test method
CN119206258A
A shell breaking and stirring system and working method based on visual recognition
CN120536231B