A gas detection method and system based on the determination of the degree of motion disorder
By using a gas detection method based on the degree of motion disorder, and employing gray-scale centroid coordinates and Gini impurity to determine the threshold, the high computational resource requirements and long processing time of existing technologies are solved, thus achieving rapid and effective gas detection.
Patent Information
- Application Number
- CN202310106007.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-09
- Publication Date
- 2025-11-14
- Estimated Expiration
- 2043-02-09
AI Technical Summary
Existing gas detection methods rely on neural network processing, which requires high computational resources and has a long processing time. Furthermore, the shape and color of the gas are not fixed, making effective training difficult.
The mask image and grayscale image are obtained by moving target detection, and then binarized and background subtracted. The grayscale centroid coordinates are calculated, a coordinate system is built and the radian value sequence is calculated. The Gini impurity is used to identify gas and interfering objects.
It reduces computational complexity and resource requirements, enables rapid gas detection, is suitable for embedded systems, and can effectively distinguish between gases and interfering objects in complex environments.
Smart Images

Figure CN116934793B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of image processing and gas detection, and in particular to a gas detection method and system based on the determination of the degree of motion disorder. Background Technology
[0002] Today, the transportation industry plays a vital role in meeting supply and demand across regions, ensuring a rational economic layout, and promoting socio-economic development. Transportation connects many aspects of social production, exchange, distribution, and consumption, serving as a fundamental prerequisite for the normal operation of all aspects of my country's socio-economic life. However, transport vehicles traveling on public roads sometimes experience dangerous gas leaks, posing a significant threat to the lives and property of the people.
[0003] With the widespread deployment of surveillance systems on public roads, relevant agencies now have more "eyes in the sky" to detect potential hazards in a timely manner. However, with the dramatic increase in the number of surveillance cameras, relying solely on manual monitoring of video footage is no longer practical. To address the challenge of timely detection of gas leaks, many new theories and methods have emerged in recent years. Currently, a common gas detection method involves inputting the entire surveillance video into a neural network, which then determines the presence of gas. However, this method places high demands on the performance of the video processing computer and results in a long processing time. Furthermore, the fact that gases have no fixed shape or color presents a challenge for training the neural network. Summary of the Invention
[0004] In view of the above-mentioned shortcomings of the prior art, the present invention provides a gas detection method and system based on motion disorder determination. This method does not require neural network training and solves the problems of high performance requirements and long processing time of video processing computers in the existing related technologies.
[0005] In a first aspect, the present invention provides a gas detection method based on the determination of the degree of motion disorder, comprising the following steps:
[0006] Acquire video images, perform moving target detection on the video images, and obtain mask images and grayscale images of the moving objects;
[0007] The motion region is captured in the mask image and the grayscale image. The captured mask image is then binarized. The background is subtracted from the captured grayscale image to obtain the foreground moving object image.
[0008] The gray-level centroid coordinates of the moving object in each frame of the foreground moving object image are calculated sequentially, and the gray-level centroid coordinates of the moving object are saved in time sequence to obtain the gray-level centroid coordinate sequence.
[0009] A coordinate system is constructed using the coordinate points in the gray-scale centroid coordinate sequence and the radians are calculated. The entire coordinate sequence is traversed and calculated to convert all gray-scale centroid coordinates into a sequence of radian values ordered by time.
[0010] The degree of disorder in the radian value sequence is calculated to obtain the Gini impurity.
[0011] The Gini impurity is used as a threshold to distinguish gas from other moving objects in the image.
[0012] Preferably, moving target detection of the video image includes:
[0013] The Gaussian mixture model is used to detect moving objects in the video image to obtain a mask image of the moving object;
[0014] The mask image is subjected to morphological filtering to remove unnecessary noise.
[0015] Preferably, the process of capturing the moving region of the mask image and the grayscale image includes:
[0016] Capture the region of the moving object in the mask image and record the position coordinates of the minimum bounding rectangle of the moving object;
[0017] The position coordinates of the minimum binding rectangle are applied to the grayscale image to obtain a screenshot of the motion region of the grayscale image.
[0018] Preferably, the gray-level centroid coordinates of the moving object in the foreground moving object image are calculated in the following manner:
[0019]
[0020] Among them, C x C represents the horizontal axis coordinate of the grayscale centroid. y Let f(x,y) be the grayscale centroid coordinate on the vertical axis, and f(x,y) be the grayscale value of the moving object image at point (x,y).
[0021] Preferably, the step of constructing a coordinate system using the coordinate points in the gray-level centroid coordinate sequence and calculating the radians, and traversing the entire coordinate sequence to convert all gray-level centroid coordinates into a sequence of radian values ordered by time, includes:
[0022] A coordinate system is established by taking the first coordinate point of the gray-scale centroid coordinate sequence as the origin, and the radian from the second coordinate point to the origin is calculated to obtain the radian value θ1.
[0023] Traverse the entire sequence of grayscale centroid coordinates. On the nth traversal, use the nth coordinate as the origin to build a coordinate system, calculate the radian distance from the (n+1)th coordinate to the origin, and obtain the radian value θ. n , where n is a positive integer;
[0024] After n iterations, a sequence of radian values of length n can be obtained: [θ1, θ2, ..., θ n-1 ,θ n ], where θ1, θ2, ..., θ n-1 ,θ n ∈[-π, π].
[0025] Preferably, the Gini impurity is used to describe the degree of disorder and is calculated in the following manner:
[0026]
[0027] Where I G (f) represents the Gini impurity of the radian value sequence, f i This represents the probability of a certain radian value appearing in the sequence of radian values.
[0028] Secondly, the present invention provides a gas detection system based on the determination of the degree of motion disorder, the system comprising:
[0029] The moving target detection module is used to acquire video images, perform moving target detection on the video images, and obtain a mask image and a grayscale image of the moving object;
[0030] The image processing module is used to perform motion region screenshot processing on the mask image and the grayscale image, and to perform background subtraction operation on the screenshot of the mask image and the screenshot of the grayscale image to obtain the foreground moving object image.
[0031] The first calculation module is used to sequentially calculate the gray-level centroid coordinates of the moving object in each frame of the foreground moving object image, and save the gray-level centroid coordinates of the moving object in time sequence to obtain the gray-level centroid coordinate sequence.
[0032] The second calculation module is used to build a coordinate system using the coordinate points in the gray-scale centroid coordinate sequence and calculate the radians. It traverses and calculates the entire coordinate sequence to convert all gray-scale centroid coordinates into a sequence of radian values ordered by time.
[0033] The third calculation module is used to calculate the disorder of the radian value sequence to obtain the Gini impurity.
[0034] The judgment module is used to distinguish gas and other moving interference objects in the image by using the Gini impurity as a judgment threshold.
[0035] Preferably, the image processing module includes:
[0036] The screenshot processing unit is used to perform screenshot processing on the moving areas of the mask image and the grayscale image;
[0037] The binarization processing unit is used to perform binarization processing on the screenshot of the mask image to obtain a binarized image;
[0038] The background subtraction unit is used to perform background subtraction on the screenshots of the binarized image and the grayscale image to obtain an image of the moving object in the foreground.
[0039] Thirdly, the present invention provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the steps of the gas detection method based on the determination of the degree of motion disorder as described in the first aspect of the present invention.
[0040] Fourthly, the present invention provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the gas detection method based on the determination of the degree of motion disorder as described in the first aspect of the present invention.
[0041] This invention provides a gas detection method and system based on motion disorder determination. It uses Gini impurity as a threshold to distinguish gas from other moving interfering objects in video images. The method features a simple algorithm, low time complexity, fast computation, and low system requirements. This not only reduces detection costs but also allows for deployment in embedded systems, demonstrating strong practical value. Furthermore, this method can serve as a link in a multi-stage judgment process, providing a reference for more complex judgment systems. Attached Figure Description
[0042] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0043] Figure 1 This is a flowchart of a gas detection method based on motion disorder determination provided in an embodiment of the present invention;
[0044] Figure 2 This is a diagram showing the effect of the Gaussian mixture model algorithm for moving target detection in an embodiment of the present invention;
[0045] Figure 3 This is an illustration of the effect of using a mask image to capture the moving area of a grayscale image in an embodiment of the present invention;
[0046] Figure 4 This is a diagram showing the effect of background subtraction in an embodiment of the present invention;
[0047] Figure 5 This is a schematic diagram of the grayscale centroid of different objects in an embodiment of the present invention;
[0048] Figure 6 This is a grayscale centroid view of different objects in an embodiment of the present invention;
[0049] Figure 7 This is a schematic diagram illustrating the calculation of radians using the first two coordinates of the grayscale centroid coordinate sequence in an embodiment of the present invention;
[0050] Figure 8 This is a schematic diagram of the system structure according to an embodiment of the present invention;
[0051] Figure 9 This is a schematic diagram of the image processing module structure in the system of this embodiment of the invention;
[0052] Figure 10 This is a schematic diagram of the physical structure according to an embodiment of the present invention. Detailed Implementation
[0053] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be further described clearly and completely below with reference to the accompanying drawings of the embodiments of this invention. It should be noted that the described embodiments are merely some embodiments of this invention, and not all embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.
[0054] In the embodiments of this application, the term "and / or" is merely a description of the relationship between related objects, indicating that there can be three relationships. For example, A and / or B can represent three situations: A exists alone, A and B exist simultaneously, and B exists alone.
[0055] The terms "first" and "second" used in the embodiments of this application are for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of that feature. In the description of this application, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion. For example, a system, product, or device that includes a series of components or units is not limited to the listed components or units, but may optionally include unlisted components or units, or may optionally include other components or units inherent to such products or devices. In the description of this application, "a plurality of" means at least two, such as two, three, etc., unless otherwise explicitly specified.
[0056] Currently, a common method for gas detection involves inputting the entire surveillance video feed into a neural network, which then determines the presence of gas. However, this method places high demands on the performance of the video processing computer and results in a long processing time. Furthermore, since gases have no fixed shape or color, training the neural network presents a significant challenge.
[0057] Gini impurity is a measure used in predicting the degree of disorder and can be used to describe the level of disorder. This invention proposes a method to distinguish gas and other moving objects (such as pedestrians or cars) in an image based on the degree of disorder.
[0058] Figure 1 The flowchart of the gas detection method based on motion disorder determination provided in the embodiments of the present invention is as follows: Figure 1 As shown, the method includes:
[0059] Step S1: Acquire video images, perform moving target detection on the video images, and obtain the mask image and grayscale image of the moving objects;
[0060] First, traditional motion detection algorithms are used to detect moving objects in the entire video frame. There are many types of traditional motion detection algorithms, such as Gaussian mixture model, KNN background modeling algorithm, VIBE moving target detection algorithm, etc. Different algorithms can be selected according to different requirements of calculation speed and accuracy.
[0061] This invention employs a Gaussian mixture model (GMM) as the moving target detection algorithm. The GMM is a background representation method based on pixel sample statistics. It uses statistical information such as the probability density of a large number of pixel sample values over a long period (e.g., the number of patterns, the mean and standard deviation of each pattern) to represent the background, and then uses statistical differencing (e.g., the 3σ principle) to determine the target pixel. This method establishes multiple Gaussian models for each pixel, exhibiting high adaptability to backgrounds and effectively describing complex backgrounds.
[0062] Figure 2 The image shows the effect of the Gaussian mixture model algorithm for moving target detection in an embodiment of the present invention. Figure 2 As shown, (a) and (c) are the input video images, and (b) and (d) are the moving object mask images obtained by the Gaussian Mixture Model algorithm. White represents the foreground area, i.e., the moving object, and black represents the background area. Since the Gaussian Mixture Model algorithm is sensitive to noise, the camera needs to be stable and the ambient light needs to change minimally. Of course, motion detection algorithms with less noise impact can be used, but these will slow down the algorithm.
[0063] To filter out some noise, this embodiment of the invention performs morphological filtering on the mask image, using morphological opening operation and selecting a 5*5 filter kernel, which effectively filters out small noise. However, it also makes the edges of moving objects in the mask image obtained by the motion detection algorithm relatively rough.
[0064] Step S2: Perform motion region screenshot processing on the mask image and grayscale image, and binarize the mask image screenshot. Combine the grayscale image screenshot with background subtraction to obtain the foreground moving object image.
[0065] Figure 3 This is an example of capturing a moving region of a grayscale image using a mask image in an embodiment of the present invention. After obtaining the mask image, the position coordinates of the smallest bounding rectangle on the mask image are recorded using the findContours function of the OpenCV library, and then applied to the grayscale image to obtain a screenshot of the moving region.
[0066] Simultaneously, the moving region of the mask image is also captured, and then the moving region of the mask image is binarized. The calculation formula is as follows:
[0067]
[0068] Where g(x,y) is the processed binarized mask, and f(x,y) is the gray value of the mask image at point (x,y). Since the mask image is already a binarized image, the gray value of the foreground part is 255 and the gray value of the background part is 0, so we only need to consider the two gray values of 255 and 0.
[0069] Then, the binarized image and grayscale image screenshots are multiplied to remove background interference and retain only the information of the moving object, thus obtaining the foreground moving object image. Figure 4 This is a diagram illustrating the effect of background subtraction in an embodiment of the present invention, such as... Figure 4 As shown, the background information such as the asphalt road and grass behind the pedestrians has been greatly removed.
[0070] Step S3: Calculate the gray-scale centroid coordinates of the moving object in each frame of the foreground moving object image in sequence, and save the gray-scale centroid coordinates of the moving object in time sequence to obtain the gray-scale centroid coordinate sequence.
[0071] The grayscale centroid of the image after background subtraction is calculated using the following formula:
[0072]
[0073] Among them, C x C represents the horizontal axis coordinate of the grayscale centroid. y Let f(x,y) be the grayscale centroid coordinate on the vertical axis, and f(x,y) be the grayscale value of the moving object image at point (x,y).
[0074] Figure 5 This is a schematic diagram of the grayscale centroid of different objects in an embodiment of the present invention, such as... Figure 5 As shown, grayscale centroids of different objects are calculated and visualized, with black dots representing the grayscale centroids.
[0075] Using the above calculation formulas, the center of gravity of a moving object in each frame of the input video can be calculated sequentially, and the grayscale centroid coordinates of the moving object can be saved in time sequence to obtain a grayscale centroid coordinate sequence. The desired sequence length can be selected based on the FPS value of the input video. In this embodiment, the default is to save the grayscale centroid coordinates from 30 frames of images, corresponding to a grayscale centroid coordinate sequence of length 30.
[0076] The calculated gray-scale centroid coordinate sequence is equivalent to obtaining the motion trajectory of the gray-scale centroid. For interference objects such as pedestrians or vehicles, their gray-scale centroid changes relatively uniformly and smoothly during the motion. However, for gases, due to the diffusion effect in the air, the concentration at different locations will constantly change. Therefore, the change of the gray-scale centroid of gases in the video sequence will be very disordered and chaotic.
[0077] Figure 6 The figures show grayscale center of gravity views of different objects in this invention, where (a) is a grayscale center of gravity view of gas movement and (b) is a grayscale center of gravity view of pedestrian movement. As shown, the grayscale center of gravity of a pedestrian moves along the trajectory of the person's movement, and the movement trajectory is relatively stable with a consistent direction of change. However, for gases, due to the diffusion of gases in the air, the gas concentration changes irregularly in different areas. When reflected in the image, this results in the grayscale values of the gas movement area changing randomly and irregularly, thus the grayscale center of gravity exhibits a chaotic movement trajectory.
[0078] Step S4: Construct a coordinate system using the coordinate points in the gray-scale barycentric coordinate sequence and calculate the radians. Traverse and calculate the entire coordinate sequence to convert all gray-scale barycentric coordinates into a sequence of radian values ordered by time.
[0079] This invention employs a method of calculating the arc between points to describe the degree of disorder in the grayscale centroid motion trajectory. Since the area occupied by moving objects in the frame varies across different video sequences, the distance between points cannot be used to describe the motion. Therefore, this invention uses a method of calculating arc, as follows:
[0080] Figure 7 This is a schematic diagram of calculating the radian using the first two coordinates of the gray-scale centroid coordinate sequence in an embodiment of the present invention. The first coordinate point of the gray-scale centroid coordinate sequence is used as the origin to build a coordinate system, and the radian from the second coordinate point to the origin is calculated to obtain the radian value θ1.
[0081] Then, iterate through the entire grayscale centroid coordinate sequence. During the nth iteration, use the nth coordinate as the origin to build a coordinate system, calculate the radian distance from the (n+1)th coordinate point to the origin, and obtain the radian value θ. n , where n is a positive integer;
[0082] After n iterations, a sequence of radian values of length n can be obtained: [θ1, θ2, ..., θ n-1 ,θ n ], where θ1, θ2, ..., θ n-1 ,θ n ∈[-π, π].
[0083] This embodiment of the invention uses a coordinate sequence of length 30 to obtain 29 radian values [θ1, θ2, ..., θ] ordered by time. n-1 ,θ 29 ].
[0084] Step S5: Calculate the disorder of the radian value sequence to obtain the Gini impurity;
[0085] Gini impurity refers to the expected error rate of a data item when a result from one set is randomly applied to another set. It measures the probability that a randomly selected item from a dataset will be incorrectly assigned to another group. It is a measure of the degree of disorder in decision tree programming.
[0086] In this embodiment of the invention, Gini impurity is used as a standard to measure the degree of disorder in the motion of the grayscale center of gravity. The higher the Gini impurity, the more disordered and chaotic the motion. The formula for calculating Gini impurity is as follows:
[0087]
[0088] Where I G (f) represents the Gini impurity of the video sequence, f i This represents the probability of a certain radian value appearing in a sequence of radian values.
[0089] Step S6: Use Gini impurity as a judgment threshold to distinguish gas and other moving interference objects in the image.
[0090] To demonstrate the gas identification capability of the method in this embodiment of the invention, a comparative test was conducted using a video of a pedestrian walking and a video of a smoke generator producing smoke. This embodiment of the invention defaults to saving and calculating the coordinates of the grayscale centroid every 30 frames; that is, a Gini impurity calculation of the motion trajectory is performed every 29 shifts in the grayscale centroid. The Gini impurities of five sequences were recorded and the mean was calculated, and the results are shown in the table below.
[0091]
[0092] As can be seen from the table above, the disorder of the gas produced by the smoke generator is more than ten times that of pedestrians. Therefore, this embodiment of the invention relies on calculating the disorder of movement trajectories, using Gini impurity to describe the degree of disorder, and using Gini impurity as a judgment threshold to effectively distinguish pedestrians from gas. Using the method of this embodiment of the invention, gas can be effectively identified when multiple moving objects are present in the video frame.
[0093] Based on the same technical concept, embodiments of the present invention provide a gas detection system based on the determination of the degree of motion disorder. Figure 8 A schematic diagram of the system structure provided for an embodiment of the present invention includes:
[0094] The moving target detection module 801 is used to acquire video images, perform moving target detection on the video images, and obtain the mask image and grayscale image of the moving object.
[0095] The image processing module 802 is used to perform motion region screenshot processing on the mask image and grayscale image, and to perform binarization processing on the mask image screenshot, and to perform background subtraction operation in combination with the grayscale image screenshot to obtain the foreground moving object image.
[0096] The first calculation module 803 is used to calculate the gray-level centroid coordinates of the moving object in each frame of the foreground moving object image in turn, and save the gray-level centroid coordinates of the moving object in time sequence to obtain the gray-level centroid coordinate sequence.
[0097] The second calculation module 804 is used to build a coordinate system using the coordinate points in the gray-scale centroid coordinate sequence and calculate the radians. It traverses and calculates the entire coordinate sequence to convert all gray-scale centroid coordinates into a sequence of radian values ordered by time.
[0098] The third calculation module 805 is used to calculate the disorder of the radian value sequence to obtain the Gini impurity.
[0099] The judgment module 806 is used to distinguish gas and other moving interference objects in the image by using Gini impurity as a judgment threshold.
[0100] Figure 9 This is a schematic diagram of the image processing module structure in an embodiment of the present invention, as shown below. Figure 9 As shown, the image processing module includes:
[0101] The screenshot processing unit 8021 is used to perform screenshot processing of moving areas on the mask image and the grayscale image;
[0102] The binarization processing unit 8022 is used to perform binarization processing on the screenshot of the mask image to obtain a binarized image;
[0103] Background subtraction unit 8023 is used to perform background subtraction operation on the screenshots of the binarized image and the grayscale image to obtain the foreground moving object image.
[0104] Based on the same concept, this invention also provides a schematic diagram of a physical structure, such as... Figure 9 As shown, the server may include a processor 1010, a communications interface 1020, a memory 1030, and a communication bus 1040. The processor 1010, communications interface 1020, and memory 1030 communicate with each other via the communication bus 1040. The processor 1010 can call logical instructions in the memory 1030 to execute the steps of the gas detection method based on the degree of motion disorder determination as described in the above embodiments. For example, this includes:
[0105] Step S1: Acquire video images, perform moving target detection on the video images, and obtain the mask image and grayscale image of the moving objects;
[0106] Step S2: Perform motion region screenshot processing on the mask image and grayscale image, and binarize the mask image screenshot. Combine the grayscale image screenshot with background subtraction to obtain the foreground moving object image.
[0107] Step S3: Calculate the gray-level centroid coordinates of the moving object in each frame of the foreground moving object image, and save the gray-level centroid coordinates of the moving object according to the time series to obtain the gray-level centroid coordinate sequence.
[0108] Step S4: Construct a coordinate system using the coordinate points in the gray-scale barycentric coordinate sequence and calculate the radians. Traverse and calculate the entire coordinate sequence to convert all gray-scale barycentric coordinates into a sequence of radian values ordered by time.
[0109] Step S5: Calculate the disorder of the radian value sequence to obtain the Gini impurity;
[0110] Step S6: Use Gini impurity as a judgment threshold to distinguish gas and other moving interference objects in the image.
[0111] The processor 1010 can be a central processing unit (CPU). The processor can also be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or combinations thereof.
[0112] Furthermore, the logical instructions in the aforementioned memory 1030 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0113] The memory 1030 may include a program storage area and a data storage area. The program storage area may store the operating system and applications required for at least one function; the data storage area may store data created by the processor, etc. Furthermore, the memory may include high-speed random access memory and non-transitory memory, such as at least one disk storage device, flash memory device, or other non-transitory solid-state storage device. In some embodiments, the memory may optionally include memory remotely located relative to the processor, which can be connected to the processor via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.
[0114] Based on the same concept, embodiments of the present invention also provide a non-transitory computer-readable storage medium storing a computer program containing at least one piece of code executable by a master control device to control the master control device to implement the steps of the gas detection method based on the degree of motion disorder as described in the above embodiments. For example, it includes:
[0115] Step S1: Acquire video images, perform moving target detection on the video images, and obtain the mask image and grayscale image of the moving objects;
[0116] Step S2: Perform motion region screenshot processing on the mask image and grayscale image, and binarize the mask image screenshot. Combine the grayscale image screenshot with background subtraction to obtain the foreground moving object image.
[0117] Step S3: Calculate the gray-level centroid coordinates of the moving object in each frame of the foreground moving object image, and save the gray-level centroid coordinates of the moving object according to the time series to obtain the gray-level centroid coordinate sequence.
[0118] Step S4: Construct a coordinate system using the coordinate points in the gray-scale barycentric coordinate sequence and calculate the radians. Traverse and calculate the entire coordinate sequence to convert all gray-scale barycentric coordinates into a sequence of radian values ordered by time.
[0119] Step S5: Calculate the disorder of the radian value sequence to obtain the Gini impurity;
[0120] Step S6: Use Gini impurity as a judgment threshold to distinguish gas and other moving interference objects in the image.
[0121] Based on the same technical concept, this application also provides a computer program, which, when executed by a main control device, is used to implement the above-described method embodiments.
[0122] The program may be stored, in whole or in part, on a storage medium packaged with the processor, or in part or in whole on a memory not packaged with the processor.
[0123] Based on the same technical concept, this application also provides a processor for implementing the above-described method embodiments. The processor can be a chip.
[0124] In summary, the gas detection method and system based on motion disorder determination provided by this invention uses Gini impurity as a judgment threshold to distinguish gas from other moving interfering objects in video images. This method has a simple algorithm, low time complexity, fast computation, and low requirements for the computing system. It not only reduces detection costs but can also be deployed in embedded systems, demonstrating strong practical value. The method provided by this invention can distinguish gas even in the presence of interfering moving objects, making it useful in specific locations in public transportation. It can also serve as part of a multi-stage judgment process, providing a reference for more complex judgment systems.
[0125] In this document, the term "embodiment" means that a particular feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of this application. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment mutually exclusive with other embodiments. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.
[0126] The embodiments described above are merely illustrative of several implementations of the present invention, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of the present invention. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of the present invention, and these modifications and improvements all fall within the scope of protection of the present invention. Therefore, the scope of protection of this patent should be determined by the appended claims.
[0127] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A gas detection method based on the determination of the degree of motion disorder, characterized in that, Includes the following steps: Acquire video images, perform moving target detection on the video images, and obtain mask images and grayscale images of the moving objects; The motion region is captured in the mask image and the grayscale image. The captured mask image is then binarized. The background is subtracted from the captured grayscale image to obtain the foreground moving object image. The gray-level centroid coordinates of the moving object in each frame of the foreground moving object image are calculated sequentially, and the gray-level centroid coordinates of the moving object are saved in time sequence to obtain the gray-level centroid coordinate sequence. A coordinate system is constructed using the coordinate points in the gray-scale centroid coordinate sequence and the radians are calculated. The entire coordinate sequence is traversed and calculated to convert all gray-scale centroid coordinates into a sequence of radian values ordered by time. The degree of disorder in the radian value sequence is calculated to obtain the Gini impurity. The Gini impurity is used as a threshold to distinguish gas from other moving objects in the image.
2. The method according to claim 1, characterized in that, Moving target detection of the video image includes: The Gaussian mixture model is used to detect moving objects in the video image to obtain a mask image of the moving object; The mask image is subjected to morphological filtering to remove unnecessary noise.
3. The gas detection method according to claim 1, characterized in that, The process of capturing the moving region of the mask image and grayscale image includes: Capture the region of the moving object in the mask image and record the position coordinates of the minimum bounding rectangle of the moving object; The position coordinates of the minimum binding rectangle are applied to the grayscale image to obtain a screenshot of the motion region of the grayscale image.
4. The method according to claim 1, characterized in that, The gray-level centroid coordinates of the moving object in the foreground moving object image are calculated as follows: Among them, C x C represents the horizontal axis coordinate of the grayscale centroid. y Let f(x,y) be the grayscale centroid coordinate on the vertical axis, and f(x,y) be the grayscale value of the moving object image at point (x,y).
5. The method according to claim 1, characterized in that, The step of constructing a coordinate system using the coordinate points in the gray-level centroid coordinate sequence and calculating the radians, and traversing the entire coordinate sequence to convert all gray-level centroid coordinates into a sequence of radian values ordered by time, includes: A coordinate system is established by taking the first coordinate point of the gray-scale centroid coordinate sequence as the origin, and the radian from the second coordinate point to the origin is calculated to obtain the radian value θ1. Traverse the entire sequence of grayscale centroid coordinates. On the nth traversal, use the nth coordinate as the origin to build a coordinate system, calculate the radian distance from the (n+1)th coordinate to the origin, and obtain the radian value θ. n , where n is a positive integer; After n iterations, a sequence of radian values of length n can be obtained: [θ1, θ2, ..., θ n-1 ,θ n ], where θ1, θ2, ..., θ n-1 ,θ n ∈[-π, π].
6. The method according to claim 1, characterized in that, The Gini impurity is used to describe the degree of disorder and is calculated as follows: Where I G (f) represents the Gini impurity of the radian value sequence, f i This represents the probability of a certain radian value appearing in the sequence of radian values.
7. A gas detection system based on the determination of the degree of motion disorder, characterized in that, The system includes: The moving target detection module is used to acquire video images, perform moving target detection on the video images, and obtain a mask image and a grayscale image of the moving object; The image processing module is used to perform motion region screenshot processing on the mask image and the grayscale image, and to perform background subtraction operation on the screenshot of the mask image and the screenshot of the grayscale image to obtain the foreground moving object image. The first calculation module is used to sequentially calculate the gray-level centroid coordinates of the moving object in each frame of the foreground moving object image, and save the gray-level centroid coordinates of the moving object in time sequence to obtain the gray-level centroid coordinate sequence. The second calculation module is used to build a coordinate system using the coordinate points in the gray-scale centroid coordinate sequence and calculate the radians. It traverses and calculates the entire coordinate sequence to convert all gray-scale centroid coordinates into a sequence of radian values ordered by time. The third calculation module is used to calculate the disorder of the radian value sequence to obtain the Gini impurity. The judgment module is used to distinguish gas and other moving interference objects in the image by using the Gini impurity as a judgment threshold.
8. The system according to claim 7, characterized in that, The image processing module includes: The screenshot processing unit is used to perform screenshot processing on the moving areas of the mask image and the grayscale image; The binarization processing unit is used to perform binarization processing on the screenshot of the mask image to obtain a binarized image; The background subtraction unit is used to perform background subtraction on the screenshots of the binarized image and the grayscale image to obtain an image of the moving object in the foreground.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the steps of the gas detection method based on the determination of the degree of motion disorder as described in any one of claims 1 to 6.
10. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When executed by a processor, the computer program implements the steps of the gas detection method based on the determination of the degree of motion disorder as described in any one of claims 1 to 6.