Solvent recognition algorithm in chemical experiment stirring state
Through real-time video stream and image feature analysis, combined with Manhattan feature distance and target detection, the problem of automatic identification of solution and clear state in chemical experiments is solved, efficient and accurate solution and clear state monitoring and control are achieved, and solution and clear state identification is adapted to complex fluid states.
Patent Information
- Application Number
- CN202510699350.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-28
- Publication Date
- 2025-09-12
AI Technical Summary
In the existing technology, the identification of the clear state in chemical experiments relies on manual judgment and is easily affected by interference factors. In addition, the recognition accuracy of automated equipment and algorithm models in multi-component or colored solutions is low, making it difficult to accurately distinguish between false clarification and true clear state, resulting in false triggering or missed detection.
By acquiring a real-time video stream of the stirring state, extracting key frame images and performing HSV image feature extraction, the similarity of the brightness and saturation channel features is calculated, and the dissolution state is judged by combining the Manhattan feature distance. When the dissolution state is pending, delayed frame acquisition is performed for confirmation. Finally, the target detection algorithm is used to detect the particles at the bottom of the container to ensure accuracy.
It realizes fully automated, timely and accurate dissolution monitoring and control, reduces manual intervention, adapts to different reaction tests, improves experimental efficiency and accuracy, and reduces redundant operation time of experimenters.
Smart Images

Figure CN120635766A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image recognition, and in particular to a solution-clearance recognition algorithm in a stirring state of a chemical experiment. Background Art
[0002] In chemical experimental systems, stirring is one of the core means to accelerate the dissolution of compounds. Its principle is based on fluid mechanics and mass transfer theory: the mechanical force generated by the stirring device pushes the liquid mixture into a turbulent state, increases the contact area between the solute and the solvent, and reduces the diffusion resistance at the solid-liquid interface, thereby accelerating the diffusion process of the solute molecules into the solvent. When the solute molecules are evenly dispersed in the solvent and form a uniform, stable single-phase system, the "dissolution" state is reached. The completion of this process depends on the synergistic effect of multiple physical and chemical parameters such as stirring rate, temperature, solute particle size, and solvent polarity. Its essence is to break the thermodynamic non-equilibrium state of the system through external energy input, and promote the solute dissolution to reach dynamic equilibrium.
[0003] Accurately identifying the clarity of a liquid mixture has a key impact on the entire experimental process. From the perspective of reaction process control, clarity directly indicates the completion of the dissolution stage and the starting conditions for subsequent reactions (such as titration, crystallization, extraction, etc.). Delayed judgment may lead to deviations in the concentration of reaction substrates, affecting product yield and selectivity. From the perspective of the operating logic of the automated experimental platform, the clarity of the solution is a key trigger signal, and its recognition accuracy determines the continuity and degree of automation of the experimental process, and is a basic link in realizing unattended experiments. In addition, in scenarios that are sensitive to dissolution efficiency, such as high-throughput screening and drug synthesis, rapid and reliable clarity identification helps optimize the combination of experimental parameters, improve experimental efficiency, and reduce reagent consumption costs.
[0004] Current solution-clearance identification technology in automated laboratories still has significant limitations. The first is the inefficiency and subjectivity of manual judgment. Traditional methods rely on laboratory personnel to observe the clarity of the solution. This is affected by interfering factors such as lighting conditions, container material, and solute color, and is prone to misjudgment or delays. It also cannot meet the real-time monitoring needs of large-scale automated experiments. Secondly, there are limitations to single-dimensional detection. Existing automated equipment mostly uses physical parameters such as conductivity and turbidity for solution-clearance judgment, but these parameters are easily affected by factors such as temperature drift and impurity interference, and the recognition accuracy is particularly low for multi-component systems or colored solutions. Thirdly, the algorithm model is not adaptable enough. Traditional machine vision algorithms are only designed for simple solution systems and lack the ability to extract features for complex fluid states (such as microemulsions and colloidal transition states). It is difficult to accurately distinguish between "false clarity" and true clarity, resulting in false triggering or missed detection in the automated process. Summary of the Invention
[0005] The embodiment of the present invention provides a solution clarity identification algorithm under stirring state in chemical experiments, which is used to solve the problem in the prior art that the traditional method relies on the experimenter to make judgments by observing the clarity of the solution, which is easily affected by interference factors such as lighting conditions, container material, solute color, etc., and is prone to misjudgment or delay, and cannot meet the real-time monitoring needs of large-scale automated experiments. Existing automated equipment mostly makes solution clarity judgments based on physical parameters such as conductivity and turbidity, but these parameters are easily affected by factors such as temperature drift and impurity interference, especially for multi-component systems or colored solutions. The recognition accuracy is low; furthermore, the algorithm model is not adaptable enough. Traditional machine vision algorithms are only designed for simple solution systems and lack the ability to extract features of complex fluid states (such as microemulsions and colloidal transition states). It is difficult to accurately distinguish between the "false clarity" state and the real solution clarity state, resulting in false triggering or missed detection in the automation process.
[0006] On the one hand, an embodiment of the present invention provides a solution-clearance identification algorithm in a stirred state of a chemical experiment, including:
[0007] Acquire a real-time video stream of the stirring state of the solution;
[0008] Extracting the current experimental picture through the real-time video stream;
[0009] Extracting the first T seconds of experimental pictures through the real-time video stream;
[0010] Obtaining a key frame image of the current experimental picture by image clipping;
[0011] Obtain the first T seconds of the key frame image of the first T seconds of the experimental image by image clipping;
[0012] Extracting features from the key frame image and the key frame image T seconds before the image and performing similarity calculation;
[0013] Stirring and dissolving identification is performed based on the result of the similarity calculation.
[0014] In a possible implementation, obtaining the real-time video stream of the stirring state of the solution is to obtain real-time stream data of a camera through an RTSP protocol.
[0015] In a possible implementation, the key frame image of the current experimental picture is obtained by clipping the image, and the key frame image is obtained by clipping the video frame of the current experimental picture according to the selected area of the experimental phenomenon.
[0016] In a possible implementation, performing feature extraction on the key frame image and the key frame image T seconds before and then performing similarity calculation includes:
[0017] Extract HSV image features from the key frame image and the key frame image before T seconds respectively;
[0018] Counting the brightness channel features and saturation channel features of the key frame image and the key frame image T seconds before;
[0019] Determine the similarity of the brightness channel feature and the saturation channel feature of the key frame image and the key frame image T seconds before by calculating the Manhattan feature distance;
[0020] A judgment result is obtained according to the similarity and similarity threshold of the brightness channel feature and the saturation channel feature.
[0021] In a possible implementation, obtaining a judgment result according to the similarity and similarity threshold of the brightness channel feature and the saturation channel feature includes:
[0022] Determining the clarity of the solution based on a magnitude relationship between the similarity threshold and the similarity between the brightness channel feature and the saturation channel feature;
[0023] The result of the clear state being pending is retained;
[0024] After retaining the result of the dissolution state as pending, the acquisition of the current experimental image and the experimental image T seconds before is continued for T1 seconds.
[0025] In a possible implementation, the stirring device is turned off after the result that the dissolved clear state is pending is obtained N times in succession.
[0026] In a possible implementation, after shutting down the stirring device, the method further includes:
[0027] detecting particles at the bottom of a container of the solution using a target detection algorithm;
[0028] Stirring is restarted according to the detection result of the particles at the bottom of the container.
[0029] The present invention provides a solution-clearance identification algorithm in a chemical experiment under stirring conditions, which has the following advantages:
[0030] (1) Fully automated monitoring and control of the dissolution and purging operations of the reaction bottles reduces the number of laboratory personnel checking and controlling, while enabling timely and accurate monitoring and control for different reaction tests.
[0031] (2) Reduce the waiting time of experimenters and the redundant time set based on experience, and speed up the progress of the experiment. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0033] Figure 1 This is a flowchart of a solution-clearance identification algorithm in a chemical experiment under stirring state provided in an embodiment of the present application. DETAILED DESCRIPTION
[0034] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.
[0035] Figure 1 A schematic flow chart of a solution-clearance identification algorithm for a chemical experiment under stirring provided by an embodiment of the present invention; an algorithm for solution-clearance identification for a chemical experiment under stirring provided by an embodiment of the present invention, comprising:
[0036] Acquire a real-time video stream of the stirring state of the solution;
[0037] Extracting the current experimental picture through the real-time video stream;
[0038] Extracting the first T seconds of experimental pictures through the real-time video stream;
[0039] Obtaining a key frame image of the current experimental picture by image clipping;
[0040] Obtain the first T seconds of the key frame image of the first T seconds of the experimental image by image clipping;
[0041] Extracting features from the key frame image and the key frame image T seconds before the image and performing similarity calculation;
[0042] Perform stirring and dissolving identification according to the result of the similarity calculation;
[0043] The real-time video stream of the stirring state of the solution is obtained by acquiring real-time stream data of the camera through the RTSP protocol;
[0044] The key frame image of the current experimental picture is obtained by clipping the image, and the key frame image is obtained by clipping the video frame of the current experimental picture according to the selected area of the experimental phenomenon;
[0045] The similarity calculation after feature extraction of the key frame image and the key frame image T seconds before includes:
[0046] Extract HSV image features from the key frame image and the key frame image before T seconds respectively;
[0047] Counting the brightness channel features and saturation channel features of the key frame image and the key frame image T seconds before;
[0048] Determine the similarity of the brightness channel feature and the saturation channel feature of the key frame image and the key frame image T seconds before by calculating the Manhattan feature distance;
[0049] Obtaining a judgment result according to the similarity and similarity threshold of the brightness channel feature and the saturation channel feature;
[0050] Obtaining a judgment result based on the similarity and similarity threshold of the brightness channel feature and the saturation channel feature includes:
[0051] Determining the clarity of the solution based on a magnitude relationship between the similarity threshold and the similarity between the brightness channel feature and the saturation channel feature;
[0052] The result of the clear state being pending is retained;
[0053] After retaining the result of the dissolution state as pending, a delay of T1 seconds is made to continue acquiring the current experimental image and the experimental image T seconds before;
[0054] After the result that the dissolved clear state is pending is obtained for N consecutive times, the stirring device is turned off;
[0055] After shutting down the stirring device, the method further comprises:
[0056] The particles at the bottom of the container of the solution are detected by an object detection algorithm.
[0057] For example, the clear state of the solution is confirmed based on the similarity relationship between the similarity threshold and the brightness channel feature and the saturation channel feature, by extracting HSV image features from the key frame image and the key frame image T seconds before. The V (brightness) channel feature L of the focus area is counted separately. A and L B and S (saturation) channel characteristics S A and S B ;
[0058] Determine the similarity of two images in brightness and saturation by calculating the Manhattan distance of different features of the two sets of images;
[0059] Manhattan feature distance calculation formula:
[0060] Distance(A,B)=|L A -L B |+|S A -S B |
[0061] Feature similarity calculation formula:
[0062]
[0063] Determine whether the similarity is greater than the threshold. If the similarity is less than the threshold, the result is not clear. If the similarity is greater than the threshold, the result is clear pending and the result is saved in the queue. After a delay of T1 seconds, continue to take frames for feature extraction and similarity calculation.
[0064] Determine whether the latest N results in the queue are continuously in the clear pending state. If so, turn off stirring and proceed to the next step; if not, continue to calculate the frame similarity;
[0065] When the result of N consecutive calculations is that the solution is clear, the stirring is turned off. The image features are extracted using the target detection algorithm (YoloV8) to detect whether there are solid particles at the bottom of the reaction bottle.
[0066] If solid particles are present, restart stirring for T2 minutes, then stop stirring and perform a solid particle detection on the bottom. If no solid particles are present, the liquid mixture is judged to be completely dissolved.
[0067] In a possible embodiment, the implementation code of the liquidation recognition feature extraction algorithm is as follows:
[0068] importmatplotlib.pyplotasplt
[0069] defvisualize_channel_features(v_features,s_features,title="Channel Feature Analysis"):
[0070] """Visualize V channel and S channel features"""
[0071] fig,axes=plt.subplots(2,2,figsize=(12,8))
[0072] #V channel histogram
[0073] axes[0,0].bar(range(len(v_features['histogram'])),v_features['histogram'])
[0074] axes[0,0].set_title('V channel histogram')
[0075] axes[0,0].set_xlabel('brightness range')
[0076] axes[0,0].set_ylabel('frequency')
[0077] #S channel histogram
[0078] axes[0,1].bar(range(len(s_features['histogram'])),s_features['histogram'])
[0079] axes[0,1].set_title('S channel histogram')
[0080] axes[0,1].set_xlabel('saturation interval')
[0081] axes[0,1].set_ylabel('frequency')
[0082] #Statistical features
[0083] stats=[
[0084] (v_features['mean'],v_features['std'],v_features['skewness']),
[0085] (s_features['mean'],s_features['std'],s_features['skewness']) ]
[0087] channel_names = ['V channel', 'S channel']
[0088] feature_names = ['mean', 'standard deviation', 'skewness']
[0089] fori,(mean,std,skew)inenumerate(stats):
[0090] axes[1,i].axis('off')
[0091] axes[1,i].table(
[0092] cellText=[[f'{mean:2f}'],[f'{std:2f}'],[f'{skew:2f}']],
[0093] rowLabels=feature_names,
[0094] colLabels=[channel_names[i]],
[0095] loc='center' )
[0097] plt.suptitle(title,fontsize=16)
[0098] plt.tight_layout()
[0099] plt.subplots_adjust(top=0.9)
[0100] returnfig
[0101] #Usage Example
[0102] defdemo_feature_analysis():
[0103] #Assume that the current frame and the previous T second frame have been obtained
[0104] current_frame=cv2.imread('current_frame.jpg')
[0105] previous_frame=cv2.imread('previous_frame.jpg')
[0106] # Initialize the analyzer
[0107] analyzer = ChemicalDissolutionAnalyzer(roi_coords = [100, 100, 500, 400]) # Extract features
[0108] _,s_current,v_current=analyzer.extract_hsv_features(current_frame)
[0109] _,s_previous,v_previous=analyzer.extract_hsv_features(previous_frame)
[0110] #Calculate channel features
[0111] v_features_current=analyzer.calculate_channel_features(v_current)
[0112] s_features_current=analyzer.calculate_channel_features(s_current)
[0113] #Visualize the current frame features
[0114] fig=visualize_channel_features(v_features_current,s_features_current,"Current frame channel features")
[0115] plt.show()
[0116] #Calculate similarity
[0117] v_similarity=analyzer.calculate_manhattan_similarity(
[0118] v_features_current,
[0119] analyzer.calculate_channel_features(v_previous) )
[0121] s_similarity=analyzer.calculate_manhattan_similarity(
[0122] s_features_current,
[0123] analyzer.calculate_channel_features(s_previous) )
[0125] print(f"V channel similarity:{v_similarity:4f}")
[0126] print(f"S channel similarity:{s_similarity:4f}")
[0127] importcv2
[0128] import numpy asnp
[0129] fromcollectionsimportdeque classChemicalDissolutionAnalyzer:
[0130] def__init__(self,roi_coords,similarity_threshold=0.85,
[0131] pending_threshold=0.95,delay_time=1.0,
[0132] consecutive_pending_count=5, stirring_time=30):
[0133] # Initialization parameters
[0134] self.roi_coords = roi_coords #ROI region coordinates [x1, y1, x2, y2]
[0135] self.similarity_threshold = similarity_threshold # similarity threshold for dissolution self.pending_threshold = pending_threshold # similarity threshold for pending status self.delay_time = delay_time # delay time (seconds)
[0136] self.consecutive_pending_count = consecutive_pending_count #Number of consecutive pending times self.stirring_time = stirring_time #Stirring time (seconds)
[0137] #Result Queue
[0138] self.result_queue=deque(maxlen=consecutive_pending_count)
[0139] defextract_hsv_features(self,image):
[0140] """Extract HSV color space features"""
[0141] #Convert to HSV color space
[0142] hsv_image=cv2.cvtColor(image,cv2.COLOR_BGR2HSV)
[0143] #Extract ROI area
[0144] x1,y1,x2,y2=self.roi_coordsroi=hsv_image[y1:y2,x1:x2]
[0145] #Separate HSV channels
[0146] h,s,v=cv2.split(roi)
[0147] returnh,s,v
[0148] defcalculate_channel_features(self,channel,bins=32):"""Calculate channel feature histograms and statistics"""
[0149] #Calculate histogram
[0150] hist=cv2.calcHist([channel],[0],None,[bins],[0,256])#Normalized histogram
[0151] hist=cv2.normalize(hist,hist).flatten()
[0152] #Calculate statistical features
[0153] mean_val = np.mean(channel)
[0154] std_val = np.std(channel)
[0155] skew_val=self._calculate_skewness(channel)
[0156] return {
[0157] 'histogram':hist,
[0158] 'mean':mean_val,
[0159] 'std':std_val,
[0160] 'skewness':skew_val
[0161] }
[0162] def_calculate_skewness(self,data):
[0163] """Calculate data skewness"""
[0164] n=data.sizemean=np.mean(data)
[0165] std = np.std(data)
[0166] ifstd == 0:
[0167] return0
[0168] skewness=np.sum(((data-mean) / std)**3) / n
[0169] returnskewness defcalculate_manhattan_similarity(self,feature1,feature2):
[0170] """Calculate Manhattan feature distance and convert it into similarity"""
[0171] #Calculate histogram distance
[0172] hist_distance=cv2.compareHist(feature1['histogram'],
[0173] feature2['histogram'],
[0174] cv2.HISTCMP_BHATTACHARYYA)
[0175] #Calculate statistical feature differences
[0176] mean_diff=abs(feature1['mean']-feature2['mean']) / 255.0 std_diff=abs(feature1['std']-feature2['std']) / 255.0
[0177] skew_diff = abs(feature1['skewness'] - feature2['skewness']) / 3.0 # skewness range is approximately [-3, 3] # Comprehensive distance (weighted average)
[0178] combined_distance=(
[0179] 0.6*hist_distance+
[0180] 0.2*mean_diff+
[0181] 0.1*std_diff+
[0182] 0.1*skew_diff )
[0184] #Convert to similarity (the smaller the distance, the higher the similarity)
[0185] similarity=1.0-combined_distance
[0186] Returns Similarity
[0187] defanalyze_dissolution_state(self,current_frame,previous_frame):
[0188] """Analyze the dissolution state of the solution"""
[0189] #Extract HSV features
[0190] _,s_current,v_current=self.extract_hsv_features(current_frame)
[0191] _,s_previous,v_previous=self.extract_hsv_features(previous_frame)
[0192] #Calculate channel features
[0193] v_features_current=self.calculate_channel_features(v_current)
[0194] v_features_previous=self.calculate_channel_features(v_previous)
[0195] s_features_current=self.calculate_channel_features(s_current)
[0196] s_features_previous = self.calculate_channel_features(s_previous)
[0197] # Calculate similarity
[0198] v_similarity = self.calculate_manhattan_similarity(v_features_current, v_features_previous)
[0199] s_similarity = self.calculate_manhattan_similarity(s_features_current, s_features_previous)
[0200] # Comprehensive similarity (take the minimum value because both brightness and saturation need to be similar)
[0201] combined_similarity = min(v_similarity, s_similarity)
[0202] # Determine the dissolution state
[0203] if combined_similarity < self.similarity_threshold:
[0204] return "Not dissolved clearly"
[0205] elif combined_similarity < self.to_be_determined_threshold:
[0206] return "Dissolution pending"
[0207] else:
[0208] return "Dissolved clearly"
[0209] def process_frame_pair(self, current_frame, previous_frame):
[0210] """Process the current frame and the frame pair of the previous T seconds"""
[0211] # Analyze the dissolution state
[0212] state = self.analyze_dissolution_state(current_frame, previous_frame)
[0213] # Update the result queue
[0214] self.result_queue.append(state)
[0215] # Check if it is pending for N consecutive times
[0216] if all(s == "Pending for clarification of dissolution" for s in self.result_queue) and len(self.result_queue) >= self.consecutive_pending_count:
[0217] return "Pending consecutively, stop stirring"
[0218] else:
[0219] return state
[0220] Although the preferred embodiments of the present invention have been described, those skilled in the art can make additional changes and modifications once they know the basic creative concept. Therefore, the appended claims are intended to be construed to include the preferred examples as well as all changes and modifications that fall within the scope of the present invention.
[0221] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalent technologies, the present invention is also intended to include these modifications and variations.
Claims
1. A solution-clearance identification algorithm in a chemical experiment under stirring, characterized by: include: Acquire a real-time video stream of the stirring state of the solution; Extracting the current experimental picture through the real-time video stream; Extracting the first T seconds of experimental pictures through the real-time video stream; Obtaining a key frame image of the current experimental picture by image clipping; Obtain the first T seconds of the key frame image of the first T seconds of the experimental image by image clipping; Extracting features from the key frame image and the key frame image T seconds before the image and performing similarity calculation; Stirring and dissolving identification is performed based on the result of the similarity calculation.
2. The solution-clearance identification algorithm in a chemical experiment under stirring state according to claim 1 is characterized in that: The real-time video stream of the stirring state of the solution is obtained by acquiring real-time stream data of the camera through the RTSP protocol.
3. The solution-clearance identification algorithm in a chemical experiment under stirring state according to claim 1 is characterized in that: The key frame image of the current experimental picture is obtained by image clipping, which is to obtain the key frame image by clipping the video frame of the current experimental picture according to the selected area of the experimental phenomenon.
4. The algorithm for identifying liquid and clear substances in a chemical experiment under stirring according to claim 1, characterized in that: The similarity calculation after feature extraction of the key frame image and the key frame image T seconds before includes: Extract HSV image features from the key frame image and the key frame image before T seconds respectively; Counting the brightness channel features and saturation channel features of the key frame image and the key frame image T seconds before; Determine the similarity of the brightness channel feature and the saturation channel feature of the key frame image and the key frame image T seconds before by calculating the Manhattan feature distance; A judgment result is obtained according to the similarity and similarity threshold of the brightness channel feature and the saturation channel feature.
5. The algorithm for identifying liquid and clear substances in a chemical experiment under stirring according to claim 4 is characterized in that: Obtaining a judgment result based on the similarity and similarity threshold of the brightness channel feature and the saturation channel feature includes: Determining the clarity of the solution based on a magnitude relationship between the similarity threshold and the similarity between the brightness channel feature and the saturation channel feature; The result of the clear state being pending is retained; After retaining the result of the dissolution state as pending, the acquisition of the current experimental image and the experimental image T seconds before is continued for T1 seconds.
6. The solution-clearance identification algorithm in a chemical experiment under stirring state according to claim 5 is characterized in that: After the result that the dissolved clear state is pending is obtained N times in succession, the stirring device is turned off.
7. The algorithm for identifying liquid and clear substances in a chemical experiment under stirring according to claim 6, characterized in that: After shutting down the stirring device, the method further comprises: detecting particles at the bottom of a container of the solution using a target detection algorithm; Stirring is restarted according to the detection result of the particles at the bottom of the container.
Citation Information
Patent Citations
Blending state identification method and system
CN110006735A
Chemical reaction solution color mutation identification method
CN113393539A
Permanganate index titration method and system
CN116952930A
Titanium alloy uniform mixing identification method and device
CN119941665A