Snowflake recognition method based on machine vision and computer equipment thereof
Through the machine vision-based snowflake recognition method, edge detection and Kalman filter are used to predict snowflake position, the problem of inaccurate snowflake recognition in traditional methods is solved, and efficient snowflake recognition and trajectory prediction in complex environments is achieved, which is suitable for meteorological monitoring and industrial refrigeration fields.
Patent Information
- Application Number
- CN202510787018.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-13
- Publication Date
- 2025-08-22
- Estimated Expiration
- 2045-06-13
AI Technical Summary
Traditional snowflake recognition methods are insufficient in resolution and sampling frequency, making it difficult to capture tiny snowflake particles, and the image recognition effect is inaccurate under complex weather conditions, and the physical model depends on environmental parameters and is difficult to obtain in real time, which affects the accuracy of the analysis.
Using a machine vision-based method, we select a single frame image from the video for edge detection, extract the snowflake particle outline, use a Kalman filter to predict the snowflake position and match it, and build a similarity matrix for trajectory verification, combining image preprocessing and feature extraction to improve recognition accuracy and trajectory prediction accuracy.
It realizes accurate identification of snowflake edges and trajectories in complex environments, reduces the amount of calculation, improves the accuracy and real-timeness of snowflake recognition, and is suitable for analysis in the fields of meteorological monitoring, environmental science and industrial refrigeration.
Smart Images

Figure CN120318598B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a weather recognition method, in particular to a snowflake recognition method based on machine vision and computer equipment thereof. Background Art
[0002] The detection and analysis of snowflake particles plays a crucial role in meteorological monitoring, environmental science, industrial refrigeration, and scientific research. In meteorological monitoring, each snowflake is a microscopic recorder of the atmospheric environment. Its unique morphology, precise size, and spatial distribution contain information about key meteorological factors such as atmospheric temperature, humidity, and airflow. In environmental science, snowflake particles serve as a "natural detector" for tracking atmospheric pollutants. As snowflakes fall, they absorb dust, pollen, heavy metal particles, and various chemical pollutants from the air. The types and concentrations of these pollutants can be clearly revealed through snowflake detection and analysis. Studying the characteristics of snowflake particles is also crucial in industrial refrigeration. Understanding the morphology and size distribution of snowflakes helps optimize the design and operating parameters of refrigeration equipment in industries such as food freezing and cold chain logistics. In scientific research, snowflake particles provide a unique perspective for exploring the microscopic world. Physicists use the study of snowflake crystallization to explore the laws of crystal growth and the principles of phase transitions. However, traditional methods for identifying snowflakes still have several limitations.
[0003] On the one hand, traditional snowflake recognition methods are limited by the resolution and sampling frequency of the equipment. They are unable to capture tiny snowflake particles and are prone to missing small-sized snowflakes. Moreover, under complex weather conditions such as strong winds and heavy snow, snowflakes block and overlap each other, which seriously interferes with image recognition effects, resulting in large data deviations and affecting the accuracy of subsequent analysis.
[0004] On the other hand, traditional snowflake recognition methods are based on physical models when predicting the trajectory of snowflakes. Although this method can construct the snowflake motion equation, it relies on a large amount of precise environmental parameters and snowflake attribute data, which are difficult to obtain and update in real time in practice. Summary of the Invention
[0005] An object of the present invention is to overcome at least one defect in the prior art and provide a snowflake recognition method based on machine vision.
[0006] A further object of the present invention is to recognize snowflakes by performing edge detection on snowflake images and extracting effective snowflake particles.
[0007] Another further object of the present invention is to predict the snowflake position and match the valid snowflake particles with the snowflake trajectory to verify whether the predicted snowflake trajectory is correct.
[0008] In particular, the present invention provides a snowflake recognition method based on machine vision, including: selecting a single-frame image from a video as a processing object as a snowflake image to be identified; performing edge detection on the snowflake image to be identified and extracting the outline of snowflake particles; taking the outline of snowflake particles that meet preset screening conditions as valid snowflake particles, and extracting characteristic information of the valid snowflake particles.
[0009] Optionally, the step of extracting characteristic information of valid snowflake particles also includes: obtaining the predicted snowflake position in the single-frame image, the predicted snowflake position is obtained based on the snowflake trajectory prediction of the image before the single-frame image; matching within the set range of the snowflake prediction position to determine whether the valid snowflake particles belong to the snowflake trajectory; if so, updating the snowflake trajectory.
[0010] Optionally, the step of obtaining the predicted snowflake position includes: determining the motion state of the snowflake particles in the previous frame of the single-frame image based on the snowflake trajectory, the motion state including position, velocity and acceleration; using a Kalman filter to predict the motion state in the previous frame to obtain the predicted motion state of the snowflake particles in the single-frame image; extracting the predicted snowflake position from the predicted state.
[0011] Optionally, the step of matching within the set range of the snowflake prediction position includes: obtaining the snowflake particle search radius; adjusting the search radius according to the speed and acceleration in the predicted motion state; searching for valid snowflake particles with the snowflake prediction position as the center according to the adjusted search radius; if valid snowflake particles are found, it is determined that the valid snowflake particles belong to the snowflake trajectory.
[0012] Optionally, when the valid snowflake particles do not belong to the snowflake track, it also includes: counting the consecutive lost frames of the snowflake track to obtain the number of lost frames; judging whether the number of lost frames exceeds a preset threshold; if so, creating a new snowflake track; if not, outputting statistical information of the track status of the snowflake track.
[0013] Optionally, the step of matching within the set range of the snowflake prediction position includes: constructing a similarity matrix between the snowflake trajectory and the effective snowflake particles; storing the similarity matrix in the form of a two-dimensional array; judging whether the effective snowflake particles are successfully matched with the snowflake trajectory based on the two-dimensional array; wherein, the step of judging whether the effective snowflake particles are successfully matched with the snowflake trajectory based on the two-dimensional array includes: judging whether the similarity matrix is less than a dynamic threshold; the dynamic threshold is adjusted according to the length of the snowflake trajectory and the number of consecutive frame drops; if so, the output similarity is 0; if not, the value of the similarity matrix is output as the similarity.
[0014] Optionally, the step of performing edge detection on the snowflake image to be identified includes: identifying a grayscale image corresponding to the snowflake image to be identified; performing image preprocessing on the grayscale image by using noise reduction and contrast enhancement methods; binarizing and segmenting the preprocessed grayscale image to generate a binary image; and performing edge detection on the binary image.
[0015] Optionally, after the step of generating a binary image, the step further includes: determining whether the binary image has a disconnected area; if so, performing a closing operation on the binary image, and determining whether the binary image has obvious noise points; if so, performing a dilation operation on the binary image.
[0016] Optionally, after the step of performing edge detection on the snowflake image to be identified, the step also includes: determining whether the snowflake image meets the preset minimum blur requirement; if so, determining whether there are still valid snowflake particles in the snowflake image; if so, extracting feature information in the snowflake image, the feature information including the geometric features, brightness features and blur features of the valid snowflake particles; if not, adaptively adjusting the snowflake image, and re-determining whether the snowflake image meets the preset minimum blur requirement.
[0017] Optionally, the present invention further provides a computer device comprising: a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement any of the steps of the above-mentioned machine vision-based snowflake recognition method.
[0018] The machine vision-based snowflake recognition method provided by the present invention selects a single-frame image from a video as the snowflake image to be identified, performs edge detection and extracts snowflake particle outlines on the snowflake image to be identified, and selects snowflake particle outlines that meet preset screening criteria as valid snowflake particles. This method can accurately locate snowflake edges and separate irregular snowflake contour features (such as branches, corners, and symmetry) even in complex environmental backgrounds, avoiding the false detection caused by grayscale similarity in traditional threshold segmentation. Moreover, after extracting the snowflake particle outline, further feature information (such as area, perimeter, roundness, fractal dimension, etc.) can be extracted to provide a quantitative basis for snowflake classification (such as columnar, star-shaped, and flake-shaped).
[0019] Furthermore, after extracting feature information, the method of the present invention can also predict snowflake trajectories. Snowflake trajectories can be predicted by obtaining the predicted snowflake positions in a single-frame image and matching them within a set range of predicted snowflake positions to determine whether a valid snowflake particle belongs to the snowflake trajectory. If a valid snowflake particle belongs to the snowflake trajectory, the snowflake trajectory should be updated. This method can accurately predict snowflake trajectories and, when predictions deviate, promptly detect and correct errors in the predicted trajectory by determining whether the valid snowflake particle matches the snowflake trajectory.
[0020] Based on the following detailed description of specific embodiments of the present invention in conjunction with the accompanying drawings, those skilled in the art will become more aware of the above and other objects, advantages and features of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] Hereinafter, some specific embodiments of the present invention will be described in detail in an exemplary and non-limiting manner with reference to the accompanying drawings. The same reference numerals in the accompanying drawings indicate the same or similar components or parts. It should be understood by those skilled in the art that these drawings are not necessarily drawn to scale. In the accompanying drawings:
[0022] Figure 1 is a flowchart of a snowflake recognition method according to an embodiment of the present invention;
[0023] Figure 2 is a flowchart of steps for predicting snowflake trajectories according to one embodiment of the present invention;
[0024] Figure 3 is a flowchart of steps for obtaining snowflake prediction positions according to one embodiment of the present invention;
[0025] Figure 4 is a flow chart of steps for matching within a set range of snowflake prediction positions according to one embodiment of the present invention;
[0026] Figure 5 is a flowchart of steps in a case where a valid snowflake particle does not belong to a snowflake track according to one embodiment of the present invention;
[0027] Figure 6 is a flowchart of steps for matching within a set range of snowflake prediction positions according to one embodiment of the present invention;
[0028] Figure 7 1 is a flow chart of the steps of performing edge detection on a snowflake image to be identified according to one embodiment of the present invention;
[0029] Figure 8 is a flowchart of steps after generating a binary image according to one embodiment of the present invention;
[0030] Figure 9 1 is a flow chart of steps after edge detection of a snowflake image to be identified according to one embodiment of the present invention;
[0031] Figure 10 is a flowchart of a snowflake recognition and trajectory prediction method according to an embodiment of the present invention;
[0032] Figure 11 is a schematic diagram of a computer program product according to one embodiment of the present invention;
[0033] Figure 12 is a schematic diagram of a computer-readable storage medium according to one embodiment of the present invention; and
[0034] Figure 13 is a schematic diagram of a computer device according to one embodiment of the present invention. DETAILED DESCRIPTION
[0035] It should be understood by those skilled in the art that the embodiments described below are only some embodiments of the present invention, rather than all embodiments of the present invention, and that these embodiments are intended to explain the technical principles of the present invention and are not intended to limit the scope of protection of the present invention. Based on the embodiments provided by the present invention, all other embodiments obtained by those skilled in the art without creative effort should still fall within the scope of protection of the present invention.
[0036] It should be noted that the logic and / or steps represented in the flowchart or described in other ways herein can be considered as a sequenced list of executable instructions for implementing logical functions, which can be specifically implemented in any computer-readable medium for use by an instruction execution system, device or equipment (such as a computer-based system, a system including a processor or other system that can fetch instructions from an instruction execution system, device or equipment and execute instructions), or used in combination with these instruction execution systems, devices or equipment.
[0037] The present invention provides a snowflake recognition method based on machine vision, such as Figure 1 As shown, the identification method at least includes the following steps S101 to S103.
[0038] Step S101 selects a single frame from the video being processed as the snowflake image to be identified. Selecting a single frame from a continuous video frame for processing reduces computational complexity compared to directly processing the continuous video frame. This allows for easier focus on the snowflake shape at a specific moment and avoids interference from dynamic snowflake changes.
[0039] Step S102, edge detection is performed on the snowflake image to be identified to extract the outline of the snowflake particles. Edge detection can significantly distinguish the snowflake particles from the background, highlight the outline boundary of the snowflake, and facilitate subsequent outline analysis. When performing edge detection on the snowflake, methods such as the Sobel operator or the Laplacian operator can be used. When performing edge detection, the Sobel operator is used to calculate the gradient amplitude and detect the edge direction. The calculation formula of the Sobel operator is: in, and Represent the gradient values in the horizontal and vertical directions respectively. G represents the gradient amplitude, which is used to characterize the strength of the edge.
[0040] When performing edge detection, the Laplacian operator is used to enhance high-frequency features and highlight edges. The calculation formula of the Laplacian operator is: in, It is the second-order derivative of the pixel point, which is used to detect high-frequency edge information.
[0041] In step S103, the snowflake particle outlines that meet the preset screening conditions are regarded as valid snowflake particles, and the characteristic information of the valid snowflake particles is extracted. Among them, the preset screening conditions can be contour closure screening, contour symmetry assessment or grayscale uniformity, etc. This step can filter out incomplete, overlapping or blurred snowflake outlines (such as obscured particles) to ensure that the analysis object is an independent, identifiable and valid individual. In the process of extracting valid snowflake particles, the area, perimeter, equivalent diameter and brightness of the snowflake particles should also be calculated. The formula for calculating the particle area is: Among them, A represents the pixel area of the snowflake particle, and contour refers to the set of pixel points within the particle outline.
[0042] The formula for calculating the perimeter is: Where P is the perimeter of the snowflake particle, ( , ) are the coordinates of the contour points.
[0043] The calculation formula for the equivalent diameter is: in, is the equivalent diameter of a snowflake particle, calculated from the area of the snowflake particle. The formula for calculating the maximum Feret diameter is:
[0044] The maximum Feret diameter is the longest distance between two points, given the coordinates of all the vertices of a Feret figure. A Feret figure is a special type of convex polygon in which any two opposite sides are parallel and equal in length.
[0045] The brightness feature comes from direct processing of the image and includes multiple parameters such as mean, standard deviation, skewness, kurtosis, fuzziness formula, etc. The calculation formula is as follows:
[0046] where μ is the mean, is the standard deviation, Skewness is the skewness, Kurtosis is the kurtosis, Blurriness is the fuzziness, is the Laplacian variance of the image, which is used to evaluate the sharpness of the particle edges.
[0047] like Figure 7 As shown, the step of performing edge detection on the snowflake image to be identified may include at least steps S701 to S704.
[0048] Step S701 identifies a grayscale image corresponding to the snowflake image to be identified. Snowflake morphology recognition relies primarily on brightness differences (e.g., the contrast between the snowflake and the background). Using a grayscale image eliminates color interference. This provides a unified input format for subsequent preprocessing and edge detection, preventing algorithm instability caused by color channel differences.
[0049] Step S702, pre-process the grayscale image by using noise reduction and contrast enhancement methods. Removing noise from the image (such as sensor noise, environmental interference) can prevent noise from being misjudged as snowflake edges, thereby improving detection accuracy. The noise reduction method can adopt methods such as Gaussian filtering or median filtering, which can retain the true edges while suppressing interference when recognizing grayscale images. Enhancing contrast can magnify the brightness difference between snowflakes and the background, making the edge area more obvious and easier for subsequent detection algorithms to capture. Enhancing contrast can improve the overall contrast of the image through histogram equalization, or enhance local details through adaptive thresholding.
[0050] The formula for Gaussian filtering noise reduction is: in, is the standard deviation of the Gaussian kernel and determines the smoothness of the filter.
[0051] The formula for contrast enhancement is:
[0052] Where I(x,y) represents the pixel value, μ is the average global brightness of the image, and k is the enhancement factor, typically between 1.5 and 2.0. For low-contrast images, k can be 1.8 or higher to significantly improve image contrast. For images with normal contrast, k can be 1.5 for moderate contrast enhancement.
[0053] Step S703: Binarize and segment the preprocessed grayscale image to generate a binary image. Binarizing the image thoroughly separates the target from the background, eliminating ambiguity caused by grayscale gradients. This facilitates direct positioning by the edge detection algorithm. Furthermore, the algorithm for calculating the binary image has low complexity, making it more suitable for real-time processing scenarios. Using the binary image for edge detection also allows for the early removal of large background areas, reducing the scope of ineffective calculations.
[0054] In the binary segmentation stage, the goal is to generate a binary image and achieve clear separation of particles and background. The binary segmentation process includes static threshold segmentation and adaptive threshold segmentation. The formula for static threshold segmentation is:
[0055] Where I(x,y) represents the pixel value after binarization, and T represents the global fixed threshold.
[0056] The formula for adaptive threshold segmentation is: Where local_mean(x,y) is the mean value in the local window and δ is the offset value.
[0057] Step S704: edge detection is performed on the binary image. By detecting pixels in the binary image, the edges of the snowflakes are accurately extracted, which can provide a basis for subsequent edge detection.
[0058] After generating a binary image, you can also check whether there are disconnected areas or obvious noise points in the binary image. Figure 8 As shown, the steps after generating the binary image may further include steps S801 to S804.
[0059] Step S801: Determine whether there is a disconnected area in the binary image.
[0060] Step S802: If yes, perform a closing operation on the binary image.
[0061] Step S803: Determine whether there are obvious noise points in the binary image.
[0062] Step S804: If yes, perform dilation operation on the binary image.
[0063] Closing and dilation operations address the issues of broken outlines and noise interference that may remain during the binarization process, making the snowflake objects in the image more realistic. This process significantly improves the accuracy of edge detection and the reliability of subsequent analysis. It is an important means of refined processing in image preprocessing and is particularly suitable for snowflake outline recognition scenarios that are sensitive to morphological features.
[0064] After edge detection of the snowflake image, it is also necessary to monitor whether the snowflake image meets the preset blurriness and whether there are still valid snowflake particles in the snowflake image. Figure 9 As shown, the steps after edge detection of the snowflake image to be identified include at least steps S901 to S904.
[0065] Step S901 determines whether the snowflake image meets a preset minimum blur requirement. This image blur detection can screen out images with blurred edges due to focus failure, motion blur, and other factors, thus preventing invalid processing. The preset minimum blur requirement can be determined based on historical data or dynamically adjusted during the snowflake trajectory recognition process based on specific circumstances.
[0066] Step S902: If yes, determine whether there are still valid snowflake particles in the snowflake image.
[0067] Step S903: If yes, extract feature information from the snowflake image, wherein the feature information includes geometric features, brightness features, and fuzziness features of effective snowflake particles.
[0068] If not, in step S904, adaptive adjustments are performed on the snowflake image. A reassessment is then made as to whether the snowflake image meets the preset minimum blur requirement. Adaptive adjustments (such as contrast enhancement or edge sharpening) can improve blurring caused by uneven lighting, scattered light, and other factors. After the adaptive processing, the snowflake image is reassessed as to whether it meets the preset minimum blur requirement. This eliminates the impact of blurred images on snowflake outline detection.
[0069] After extracting the characteristic information of effective snowflake particles, the trajectory of snowflake particles can also be predicted, such as Figure 2 As shown, the step of predicting the trajectory of snowflake particles includes at least steps S201 to S203.
[0070] Step 201: Obtain the predicted snowflake positions in a single-frame image. The predicted snowflake positions are based on the snowflake trajectories in the image preceding the single-frame image. Predicting the snowflake positions based on the snowflake trajectories in the image preceding the single-frame image limits subsequent matching to the area adjacent to the predicted positions, avoiding an indiscriminate search across the entire image and significantly reducing computational effort. This approach is particularly applicable to high-resolution images or real-time processing scenarios.
[0071] Step S202 : Matching is performed within the set range of the predicted snowflake position to determine whether a valid snowflake particle belongs to the snowflake track. Matching within the set range of the predicted position avoids interference from similar features in the background (such as light spots or textures similar to the shape of snowflakes) and verifies the existence of the target only within a reasonable area.
[0072] In step S203, if the valid snowflake particle belongs to the snowflake track, the snowflake track is updated. If the valid snowflake particle belongs to an existing track, the track parameters are updated immediately to maintain the continuity of the target across multiple frames and avoid tracking interruptions caused by local occlusion and noise interference.
[0073] The predicted position of the snowflake track before a single-frame image is used to limit the subsequent matching range, avoiding indiscriminate search of the entire image to reduce the amount of calculation. At the same time, matching within the set range can avoid interference from similar background features, accurately determine whether the valid snowflake particles belong to the track, and if so, update the track parameters in time. This improves computing efficiency while enhancing anti-interference capabilities, ensuring the continuity and reliability of the snowflake track in multiple frames of images, and is suitable for high-resolution or real-time processing scenarios.
[0074] like Figure 3 As shown, the step of obtaining the predicted snowflake position may include steps S301 to S303.
[0075] In step S301, the motion state of the snowflake particles in the previous frame of the single-frame image is determined based on the snowflake trajectory. The motion state includes position, velocity, and acceleration. The snowflake motion state is abstracted into position, velocity, and acceleration, forming a computable state vector, which provides the basis for the subsequent Kalman filter model. This avoids crude tracking based solely on pixel position and uses multi-dimensional parameters (such as velocity trend) to more accurately describe the physical motion characteristics of the snowflakes.
[0076] In step S302, a Kalman filter is used to predict the motion state of the previous frame, generating a predicted motion state for the snowflake particles in the single-frame image. This Kalman filter smoothes trajectory fluctuations caused by noise (e.g., blurring or partial occlusion) in the single-frame image. This predicted state, filtered using the Kalman filter, smooths trajectory fluctuations and outputs an estimated value that is closer to the true motion trajectory.
[0077] Step S303: extract the snowflake prediction position from the prediction state.
[0078] The Kalman filter is a recursive algorithm primarily used for state estimation in dynamic systems. By combining the predicted and observed values of the current state, the Kalman filter can optimize the estimate of the system state in the presence of noise. Using the Kalman filter to estimate and predict the motion state (position, velocity, acceleration) of snowflake particles enables continuous tracking of their trajectory.
[0079] The motion state of the snowflake particles in the above steps consists of position, velocity, and acceleration. The state vector can be defined as: in, , Indicates the current location. , represents the velocity component. , represents the acceleration component.
[0080] The Kalman filter assumes that the particles move with uniform acceleration, and their positions are determined by their velocity and acceleration. Its state transition equation is:
[0081] Where F is the state transition matrix, is the process noise. The state transition matrix F is:
[0082] in, is the time interval between the current frame and the previous frame. This model assumes that: position changes are determined by velocity and acceleration. Velocity changes are determined by acceleration. Acceleration remains constant.
[0083] Process noise Reflecting the random disturbance in the dynamic system, the process noise covariance matrix Q is defined as:
[0084] Where q is a scalar (adjustable parameter) representing the strength of the process noise. The magnitude of Q controls the model’s sensitivity to changes in acceleration and velocity.
[0085] There is a certain relationship between the motion state of snowflake particles and the observed value, which can be expressed as Indicates the two-dimensional position of the snowflake particles in the current frame, that is:
[0086] The observation equation can describe the relationship between the observed value and the motion state of the snowflake, namely:
[0087] Where H is the measurement matrix, defined as:
[0088] in, is the measurement noise, which represents the observation error. The measurement noise covariance matrix R is defined as:
[0089] in, , is the variance of the location observations.
[0090] The specific working steps of the Kalman filter are divided into two steps, namely prediction and update. The formula for determining the predicted state is:
[0091] in, is the measured state vector.
[0092] The definition formula of the forecast error covariance is:
[0093] in, is the predicted error covariance matrix. is the error covariance matrix of the previous frame.
[0094] The main task in the update phase is to calculate the Kalman gain:
[0095] in, is the Kalman gain, which is used to balance the predicted and observed values.
[0096] The formula for status update is:
[0097] in, is the updated state vector. is the residual between the observed and predicted values.
[0098] The updated error covariance formula is:
[0099] Where I represents the identity matrix.
[0100] The Kalman filter analyzes historical trajectory data to predict the snowflake particle's location in the next frame, thereby narrowing the search for matches. To smooth noise, the Kalman filter combines observed and predicted values to reduce the impact of noise during the detection process. Furthermore, the Kalman filter is tolerant to missed detections. This means that if a particle fails to be detected in a given frame, the predicted value is used to update the trajectory, ensuring trajectory continuity.
[0101] like Figure 4 As shown, the step of matching within the set range of the snowflake prediction position may include steps S401 to S405.
[0102] Step S401, obtaining the snowflake particle search radius.
[0103] Step S402: adjusting the search radius according to the speed and acceleration in the predicted motion state.
[0104] Step S403: searching for valid snowflake particles with the snowflake prediction position as the center according to the adjusted search radius.
[0105] Step S404: determine whether valid snowflake particles are found.
[0106] Step S405: If a valid snowflake particle is found, it is determined that the valid snowflake particle belongs to a snowflake track.
[0107] This series of steps combines the historical motion states (position, velocity, and acceleration) of snowflake trajectories with a Kalman filter to predict the position and motion state of snowflake particles within a single frame. Based on the predicted velocity and acceleration, the search radius is dynamically adjusted, and valid snowflake particles are matched within the range surrounding the predicted position. The search results are then used to update the snowflake trajectory, forming a coherent snowflake tracking and state update mechanism. Matching within the set range of the predicted snowflake position narrows the search range for snowflake particles within a single frame, improving matching efficiency and accuracy and avoiding a blind search of the entire image. Simultaneously, real-time trajectory updates ensure continuous tracking of snowflake motion, effectively solving the problem of correlated matching between consecutive frames in a video sequence and enhancing the robustness and real-time performance of snowflake tracking. This method is suitable for scenarios requiring precise capture of snowflake motion, such as weather monitoring and image synthesis, and provides reliable position and state data for subsequent analysis or applications based on snowflake motion.
[0108] like Figure 5 As shown, the steps in the case where the valid snowflake particles do not belong to the snowflake track may include steps S501 to S504.
[0109] In step S501, the number of consecutive lost frames in the snowflake trajectory is counted to obtain the number of lost frames. The number of times a trajectory fails to match a valid snowflake particle in consecutive frames is recorded to quantify the trajectory's continuity. This provides a measurable basis for subsequent determination of trajectory failure, avoiding misjudging the trajectory's termination based on a single frame loss, and enhancing the accuracy and robustness of trajectory status assessment.
[0110] Step S502 determines whether the number of lost frames exceeds a preset threshold. This threshold serves as a criterion for determining trajectory continuity, distinguishing between brief fluctuations and long-term failures. For example, a snowflake particle may cause a single or a few frames to be lost due to temporary occlusion (e.g., interference from other objects). However, if the number of lost frames does not exceed the preset threshold, the system will not terminate the trajectory easily, thus reducing false positives.
[0111] Step S503: If yes, then a new snowflake track is created. When the number of lost frames exceeds the preset threshold, the original track is determined to be invalid, and the process returns to step S302 to re-predict the single-frame motion state of the snowflake particles and create a new snowflake track.
[0112] If not, then output statistical information about the trajectory status of the snowflake track. If the number of lost frames does not exceed a preset threshold, the statistical information about the trajectory status should be recorded so that the reasons why valid snowflake particles do not belong to the snowflake track can be analyzed based on the statistical information. The statistical information can include parameters such as the average equivalent diameter or total area of the snowflake particles that can reflect the location or size of the snowflake particles. The statistical information can also include parameters such as the velocity or acceleration of the snowflake particles.
[0113] When determining a match within a set range of predicted snowflake locations, a similarity matrix can be constructed for matching. The similarity matrix can be stored in the form of a two-dimensional array, and the two-dimensional array is used to determine whether the valid snowflake particles are successfully matched with the snowflake trajectory. As a storage medium for the similarity matrix, the two-dimensional array is an ideal choice for the snowflake trajectory matching problem due to its efficient storage and computing characteristics, flexible matching strategy compatibility, and engineering scalability. The two-dimensional array can transform abstract similarity calculations into structured data operations, providing underlying data support for trajectory recognition tasks that require high real-time performance, accuracy, and robustness.
[0114] like Figure 6 As shown, the step of matching within the set range of the snowflake prediction position may at least include steps S601 to S605.
[0115] Step S601: Construct a similarity matrix between snowflake tracks and valid snowflake particles. The relationship between snowflake tracks and valid snowflake particles is converted into a two-dimensional array in the form of a mathematical matrix, providing a quantifiable basis for subsequent matching.
[0116] In step S602, the similarity matrix is stored in a two-dimensional array. Two-dimensional arrays have a simple structure and fast access speed, making them suitable for rapid computer reading and processing, especially reducing latency in real-time prediction scenarios. Using two-dimensional arrays when matching a large number of snowflake tracks with valid snowflake particles can effectively improve the matching rate.
[0117] Step S603 determines whether the similarity matrix is less than a dynamic threshold. Using a dynamic threshold rather than a fixed value automatically adjusts the matching criteria based on real-time data characteristics (such as snowflake density and ambient noise), improving the algorithm's robustness in different scenarios. Furthermore, threshold screening can eliminate invalid matches with extremely low similarity (such as background noise or non-snowflake particles), reducing subsequent computational effort and improving efficiency. The dynamic threshold can be determined by the snowflake's position, velocity, and acceleration, and can also be adaptively adjusted based on weather factors.
[0118] If so, step S604 outputs a similarity of 0. Values below the threshold are directly marked as 0 to avoid misidentifying noise as valid snowflakes and reduce the frequency of false alarms. Furthermore, omitting further analysis of values below the threshold can effectively improve the matching rate between snowflake tracks and valid snowflake particles.
[0119] Step S605: If not, output the value of the similarity matrix as the similarity. For matches above the threshold, retain the original similarity value to provide accurate data for subsequent matching calculations.
[0120] When calculating similarity, the total similarity between two particles It is composed of the weighted sum of multiple feature similarities. The calculation formula for the total similarity is:
[0121] in, is the position similarity. , is the feature similarity. , is the weight of position and feature similarity, which satisfies + =1, which can be adjusted according to the experiment. The position similarity is calculated based on the Euclidean distance between two points, and the calculation formula is:
[0122] in, = and = are the position coordinates of trajectory i and particle j. is the Euclidean distance. It is the scale parameter of position similarity, which is used to control the effect of distance on similarity.
[0123] Feature similarity It combines the similarity of multiple features, including shape features (Hu moment), brightness features, and geometric features. Each feature similarity has a separate formula and weight. The Hu moment is a commonly used shape descriptor that can describe the rotation, scale, and mirror invariance of an object. Assume that the Hu moment of the i-th trajectory is Hi and the Hu moment of the j-th particle is Hj. The calculation formula for the Hu moment is:
[0124] Where |Hi-Hj| is the Euclidean distance of the Hu moment. α is a scaling parameter used to control the influence of the Hu moment on the similarity. Furthermore, the brightness feature describes the average brightness and brightness distribution of the snowflake particles. The brightness similarity between two particles is calculated based on the difference in average brightness, and the calculation formula is:
[0125] in, is the Euclidean distance. is the scale parameter of position similarity.
[0126] Geometric features include the area and perimeter of snowflake particles, which are used to describe the size of the particles. The geometric feature similarity is based on the relative ratio of the area, and its calculation formula is:
[0127] Where Ai and Aj are the areas of trajectory i and particle j respectively.
[0128] The comprehensive feature similarity is the weighted sum of the shape, brightness and geometric feature similarities, and its calculation formula is:
[0129] The similarity matrix S is a two-dimensional matrix that represents the similarity between all trajectories and particles in the current frame. The similarity matrix S can be expressed as:
[0130] Where n is the number of trajectories in the previous frame. m is the number of particles detected in the current frame. S represents the total similarity between trajectory i and particle j.
[0131] To find the optimal match between a trajectory and a particle, the Hungarian algorithm can also be used to solve the minimum-cost bipartite graph matching problem. Because the Hungarian algorithm solves a minimum value problem, its input can be the negative value of the similarity matrix S. The core process of this method first involves an initialization phase: a negative similarity matrix C is input. Next, the optimal match search step begins: by applying the Hungarian algorithm, a matching combination between the trajectory and the particle is determined to minimize the total cost. Finally, the matching result is output. The matching pair (i, j) is then returned, while matches below a preset similarity threshold are excluded. To enhance matching robustness, the similarity threshold is dynamically adjusted based on the trajectory status. The default similarity threshold can be set to 0.6. For newly generated and short trajectories, a higher similarity threshold is required to achieve a strict match. For stable and long trajectories, a lower similarity threshold can be used to improve fault tolerance. In situations where there is continuous frame loss or unstable trajectory status, the similarity threshold should be lowered to avoid track loss.
[0132] In some optional embodiments, such as Figure 10 As shown, the steps of the snowflake recognition and trajectory prediction method include at least steps S1001 to S1006.
[0133] Step S1001: Image preprocessing: The image preprocessing process includes identifying a grayscale image corresponding to the snowflake image to be identified, performing binary segmentation on the grayscale image, and other steps.
[0134] Step S1002: Snowflake particle detection. The process of performing snowflake particle detection also includes the steps of determining the minimum blurriness of the snowflakes and performing adaptive adjustment on the snowflakes.
[0135] Step S1003: Feature extraction. By extracting the geometric features, brightness features, and fuzziness features of valid snowflake particles, a data foundation can be provided for subsequent prediction of snowflake trajectories and feature similarity matching.
[0136] Step S1004: Kalman filter motion prediction: Using the Kalman filter to filter can predict a trajectory with smooth trajectory fluctuations and output an estimated value that is closer to the actual motion trajectory.
[0137] Step S1005: Feature similarity matching. The feature similarity matching step includes the steps of constructing a similarity matrix and determining whether a valid snowflake particle is successfully matched with a snowflake track based on the value of the similarity matrix.
[0138] Step S1006: Dynamic trajectory management. Trajectory management can provide optimized trajectory processing functions specifically for the motion patterns of small particles by adjusting features such as the area threshold of small particles, the maximum matching distance of small particles, and the minimum similarity required for matching, such as checking for trajectory intersections.
[0139] This embodiment also provides a computer program product 10 , a computer-readable storage medium 20 , and a computer device 30 . Figure 11 is a schematic diagram of a computer program product 10 according to one embodiment of the present invention, Figure 12 is a schematic diagram of a computer-readable storage medium 20 according to one embodiment of the present invention, Figure 13 is a schematic diagram of a computer device 30 according to one embodiment of the present invention. A computer program product 10 includes a computer program 11. When executed by a processor 32, this computer program 11 implements the steps of any of the aforementioned machine vision-based snowflake recognition methods. A computer-readable storage medium 20 stores the computer program 11. When executed by the processor 32, this computer program 11 implements the steps of any of the aforementioned machine vision-based snowflake recognition methods. The computer device 30 may include a memory 31, a processor 32, and the computer program 11 stored in the memory 31 and executed by the processor 32.
[0140] The computer program 11 for performing the operations of the present invention may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-dependent instructions, microcode, firmware instructions, state setting data, integrated circuit configuration data, or source or object code written in any combination of one or more programming languages and procedural programming languages. Computer program 11 may be executed entirely on the user's computer, partially on the user's computer, as a stand-alone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the latter case, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider). In some embodiments, to perform various aspects of the present invention, electronic circuits, such as programmable logic circuits, field-programmable gate arrays (FPGAs), or programmable logic arrays (PLAs), may execute computer-readable program instructions by utilizing state information from the computer-readable program instructions to personalize the electronic circuits.
[0141] For the purposes of this embodiment, computer program product 10 is a product containing computer program 11. For the purposes of this embodiment, computer-readable storage medium 20 is a tangible device capable of retaining and storing computer program 11. It can be any device that can contain, store, communicate, propagate, or transmit program 11 for use by, or in conjunction with, an instruction execution system, apparatus, or device. More specific examples (not an exhaustive list) of computer-readable storage medium 20 include the following: a portable computer diskette, hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), static random access memory (SRAM), portable compact disc read-only memory (CD-ROM), digital versatile disk (DVD), memory stick, floppy disk, mechanical encoding device, and any suitable combination of the foregoing.
[0142] Computer device 30 may be, for example, a server, desktop computer, laptop computer, tablet computer, or smartphone. In some examples, computer device 30 may be a cloud computing node. Computer device 30 may be described in the general context of computer system-executable instructions (such as program modules) executed by a computer system. Generally, program modules may include routines, programs, objects, components, logic, data structures, and the like that perform specific tasks or implement specific abstract data types. Computer device 30 may be implemented in a distributed cloud computing environment where tasks are performed by remote processing devices linked via a communications network. In a distributed cloud computing environment, program modules may be located on local or remote computing system storage media, including storage devices.
[0143] Computer device 30 may include a processor 32 adapted to execute stored instructions, and a memory 31 that provides temporary storage for instructions during operation. Processor 32 may be a single-core processor, a multi-core processor, a computing cluster, or any number of other configurations. Memory 31 may include random access memory (RAM), read-only memory, flash memory, or any other suitable storage system.
[0144] The computer device 30 may also include a network adapter / interface and an input / output (I / O) interface. The I / O interface allows data to be input and output with external devices that can be connected to the computer device. The network adapter / interface can provide communication between the computer device and a network, which is generally shown as a communication network.
[0145] At this point, those skilled in the art will recognize that, although a number of exemplary embodiments of the present invention have been shown and described in detail herein, many other variations or modifications consistent with the principles of the present invention may be directly determined or derived from the disclosure of the present invention without departing from the spirit and scope of the present invention. Therefore, the scope of the present invention should be understood and deemed to cover all such other variations or modifications.
Claims
1. A snowflake recognition method based on machine vision, characterized in that include: Select a single frame image from the video being processed as a snowflake image to be identified; Performing edge detection on the snowflake image to be identified to extract the outline of snowflake particles; Taking the snowflake particle outlines that meet the preset screening conditions as valid snowflake particles, and extracting feature information of the valid snowflake particles; After the step of extracting the characteristic information of the effective snowflake particles, the following step is further included: Obtaining a predicted snowflake position in the single-frame image, wherein the predicted snowflake position is obtained based on a snowflake trajectory prediction of the image before the single-frame image; Perform matching within a set range of the snowflake prediction position to determine whether the valid snowflake particle belongs to the snowflake trajectory; If so, the snowflake trajectory is updated; The step of matching within the set range of the snowflake prediction position includes: Constructing a similarity matrix between the snowflake trajectory and the valid snowflake particles; Storing the similarity matrix in the form of a two-dimensional array; According to the two-dimensional array, it is determined whether the valid snowflake particles are successfully matched with the snowflake trajectory; wherein, The step of determining whether the valid snowflake particles are successfully matched with the snowflake trajectory according to the two-dimensional array includes: Determining whether the similarity matrix is less than a dynamic threshold; the dynamic threshold is adjusted according to the length of the snowflake track and the number of consecutive frame drops; If so, the output similarity is 0; If not, the value of the similarity matrix is output as the similarity.
2. The snowflake recognition method based on machine vision according to claim 1, characterized in that: The step of obtaining the predicted snowflake position includes: Determining the motion state of snowflake particles in a frame before the single-frame image according to the snowflake trajectory, wherein the motion state includes position, velocity, and acceleration; Using a Kalman filter to predict the motion state in the previous frame to obtain the predicted motion state of the snowflake particles in the single frame image; The snowflake prediction position is extracted from the prediction state.
3. The snowflake recognition method based on machine vision according to claim 2, characterized in that: The step of matching within the set range of the snowflake prediction position includes: Get the snowflake particle search radius; adjusting the search radius according to the speed and acceleration in the predicted motion state; Searching for the valid snowflake particles with the snowflake prediction position as the center according to the adjusted search radius; If the valid snowflake particle is found, it is determined that the valid snowflake particle belongs to the snowflake track.
4. The snowflake recognition method based on machine vision according to claim 1, characterized in that: In the case where the valid snowflake particle does not belong to the snowflake track, the method further includes: Counting consecutive lost frames of the snowflake trajectory to obtain the number of lost frames; Determining whether the number of lost frames exceeds a preset threshold; If so, a new snowflake track is created; If not, the statistical information of the trajectory status of the snowflake trajectory is output.
5. The snowflake recognition method based on machine vision according to claim 1, characterized in that: The step of performing edge detection on the snowflake image to be identified comprises: Identifying a grayscale image corresponding to the snowflake image to be identified; Performing image preprocessing on the grayscale image by using a noise reduction and contrast enhancement method; Performing binarization segmentation on the pre-processed grayscale image to generate a binary image; Edge detection is performed on the binary image.
6. The snowflake recognition method based on machine vision according to claim 5, characterized in that: The step of generating a binary image further includes: Determining whether there is a disconnected area in the binary image; If so, a closing operation is performed on the binary image, and, Determine whether there are obvious noise points in the binary image; If so, a dilation operation is performed on the binary image.
7. The snowflake recognition method based on machine vision according to claim 1, characterized in that: After the step of performing edge detection on the snowflake image to be identified, the method further includes: Determining whether the snowflake image meets a preset minimum blur requirement; If so, determining whether the valid snowflake particles still exist in the snowflake image; If so, extracting the feature information in the snowflake image, the feature information including the geometric features, brightness features, and fuzziness features of the effective snowflake particles; If not, the snowflake image is adaptively adjusted, and it is re-determined whether the snowflake image meets the preset minimum blur requirement.
8. A computer device comprising a memory, a processor, and a computer program stored in the memory, wherein: The processor executes the computer program to implement the steps of the snowflake recognition method based on machine vision according to any one of claims 1 to 7.
Citation Information
Patent Citations
Real-time snowfall intensity estimation method based on video analysis
CN105957057A
Snowfall intensity detecting method
KR101430932B1