Gas leakage detection method and apparatus, electronic device, and readable storage medium
By converting spectral images into grayscale images and using background subtraction and morphological operations to identify and fuse dynamic and static object profiles, the problem of not being able to detect gas clusters in the prior art is solved, and a more comprehensive gas leakage detection is achieved.
Patent Information
- Application Number
- PCT/CN2024/133422
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2024-02-02
- Filing Date
- 2024-11-21
- Publication Date
- 2025-08-07
AI Technical Summary
Existing gas leak detection technologies cannot effectively detect the shape and size of gas clusters, and it is difficult to install and maintain gas detection sensors in some scenarios.
By converting the spectral image into a grayscale image, dynamic foreground is extracted using background subtraction and generating binary maps, combining Gaussian filtering and morphological operations, dynamic and static object profiles are identified, and air mass profiles are fused to detect leaked gases.
It realizes complete detection of leaked gas, improves the comprehensiveness and accuracy of gas leakage detection, and is suitable for a variety of scenarios.
Smart Images

Figure CN2024133422_07082025_PF_FP_ABST
Abstract
Description
Gas leak detection method, device, electronic device and readable storage medium
[0001] This application claims priority to the Chinese patent application with application number 202410160078.3 filed with the Patent Office of China on February 2, 2024, and with the invention name “A gas leakage detection method, device, electronic device and readable storage medium”, and the entire contents of the above patent application are introduced into this application by reference. Technical Field
[0002] The present application relates to the field of leakage detection technology, and in particular to a gas leakage detection method, device, electronic device and readable storage medium. Background Art
[0003] In the chemical industry, the transportation and storage of chemical raw materials are crucial. Chemical raw materials are often toxic, flammable, explosive, or volatile substances, such as propane, propylene, and benzene. Leakage can cause them to evaporate into a gaseous state and spread, potentially causing explosions or other safety incidents. Therefore, effective gas leak detection technology is crucial.
[0004] Currently, gas leak detection technology typically relies on gas detection sensors. In this detection method, the gas detection sensor must come into contact with the gas to detect a leak. This single-point detection method cannot detect the shape or size of the gas cloud. Furthermore, in some scenarios (such as the top of a chemical gas tank), gas detection sensors are difficult to install and maintain. Summary of the Invention
[0005] In view of this, the purpose of the present application is to provide a gas leakage detection method, device, electronic device and readable storage medium, which can detect the gas mass contour of the leaking gas, thereby improving the comprehensiveness of gas leakage detection.
[0006] In a first aspect, an embodiment of the present application provides a gas leakage detection method, comprising:
[0007] For each spectral image containing the target object to be detected, convert the spectral image into a grayscale image;
[0008] Extracting the dynamic foreground in the grayscale image using background subtraction to generate a corresponding first binary image; in the first binary image, the white area is the area where the dynamic object is located, and the black area is the area where the background is located;
[0009] extracting a dynamic object contour from the first binary image, and determining whether the dynamic object contour is an air mass contour;
[0010] When the dynamic object contour is an air mass contour, the minimum pixel value and the maximum pixel value of the pixels within the area formed by the dynamic object contour in the grayscale image are used as the upper and lower limits of the pixel interval, the colors of the pixels in the grayscale image whose pixel values are within the pixel interval are converted to white, and the colors of the pixels whose pixel values are outside the pixel interval are converted to black, so as to generate a corresponding second binary image;
[0011] extracting a static object contour from the second binary image, and determining whether the static object contour is an air mass contour;
[0012] When the static object contour is an air mass contour, the static object contour and the dynamic object contour are merged to obtain the air mass contour of the detected leaked gas.
[0013] In combination with the first aspect, an embodiment of the present application provides a first possible implementation of the first aspect, wherein extracting the dynamic foreground in the grayscale image using background subtraction to generate the corresponding first binary image includes:
[0014] Performing noise reduction processing on the grayscale image by Gaussian filtering to obtain a noise-reduced smoothed image;
[0015] The dynamic foreground in the smoothed image is extracted using Gaussian background subtraction to generate a corresponding first binary image.
[0016] In combination with the first aspect, an embodiment of the present application provides a second possible implementation of the first aspect, wherein, before extracting the dynamic object contour from the first binary image, the method further includes:
[0017] Dividing the first binary image into grid-like images on an even basis;
[0018] For each square in the grid-like square image, when the square contains a white area, the square is determined as a target square and the square is recorded as a first value; when the square does not contain a white area, the square is recorded as a second value;
[0019] Calculating a ratio of the number of target squares to the number of all squares in the grid square image to obtain a first ratio;
[0020] If the first ratio is less than a first threshold, determining the first binary image as a non-rain and snow scene image;
[0021] If the first ratio is greater than or equal to the first threshold, then, for each row of squares in the gridded square image, the sum of the values of the row of squares is calculated based on the values of each square in the row of squares to obtain a first sum value of the row of squares; and for each column of squares in the gridded square image, the sum of the values of the column of squares is calculated based on the values of each square in the column of squares to obtain a second sum value of the column of squares; the values include the first value and the second value;
[0022] For each row of squares, determining whether all first sum values correspond to a uniform distribution; and for each column of squares, determining whether all second sum values correspond to a uniform distribution;
[0023] When all the first sum values conform to a uniform distribution, and all the second sum values conform to a uniform distribution, determining the first binary image as a rain and snow scene image;
[0024] When all the first sum values do not conform to a uniform distribution, and / or all the second sum values do not conform to a uniform distribution, determining the first binary image as a non-rain and snow scene image;
[0025] The step of extracting the contour of the dynamic object from the first binary image includes:
[0026] When the first binary image is a non-rain and snow scene image, the contour of the dynamic object is extracted from the first binary image.
[0027] In combination with the first aspect, the embodiment of the present application provides a third possible implementation of the first aspect, wherein determining whether the dynamic object contour is an air mass contour includes:
[0028] Calculating the number of contour points on the dynamic object contour and the area of the region formed by the dynamic object contour;
[0029] When the number of the contour points is less than a second threshold, and the area of the region is less than a third threshold, determining the dynamic object contour as a point-shaped air mass contour;
[0030] When the number of the contour points is not less than a second threshold value, and / or the area of the region is not less than a third threshold value, fitting a fitted contour of the dynamic object contour based on each contour point on the dynamic object contour; wherein the smoothness of the fitted contour is greater than the smoothness of the dynamic object contour;
[0031] calculating a ratio of the number of fitting contour points on the fitting contour to the number of contour points on the dynamic object contour to obtain a second ratio;
[0032] When the second ratio is greater than a fourth threshold, determining the dynamic object contour as an air mass contour;
[0033] When the second ratio is not greater than the fourth threshold, the dynamic object contour is determined as a non-air mass contour.
[0034] In combination with the first aspect, the embodiment of the present application provides a fourth possible implementation of the first aspect, wherein extracting the static object contour from the second binary image and determining whether the static object contour is an air mass contour includes:
[0035] extracting a static object contour from the second binary image to determine whether the static object contour intersects with the dynamic object contour;
[0036] If the static object contour intersects with the dynamic object contour, it is determined whether the static object contour is an air mass contour.
[0037] In combination with the first aspect, the embodiment of the present application provides a fifth possible implementation of the first aspect, wherein, before converting each spectral image containing the target object to be detected into a grayscale image, the method further includes:
[0038] Acquire a visible light image and multiple continuous spectral images containing the target object to be detected;
[0039] When the static object contour is an air mass contour, after fusing the static object contour with the dynamic object contour to obtain the detected air mass contour of the leaked gas, the method further includes:
[0040] For each pixel in the grayscale image, determining a preset pixel value interval to which the pixel value of the pixel in the grayscale image belongs;
[0041] Coloring the position of the pixel in the grayscale image using a preset color value pre-set for the preset pixel value interval, and obtaining a colored image corresponding to the grayscale image after each pixel in the grayscale image is colored;
[0042] According to the detected air mass contour of the leaked gas, cutting out a colored air mass area at the position where the air mass contour is located from the colored image;
[0043] The colored air mass area is superimposed on the corresponding position of the visible light image to obtain a marked image.
[0044] In combination with the fifth possible implementation of the first aspect, an embodiment of the present application provides a sixth possible implementation of the first aspect, wherein each of the spectral images corresponds to a respective marker image; after obtaining the marker image corresponding to each of the spectral images, the method further includes:
[0045] According to the order of each of the spectral images and the respective marked images corresponding to each of the spectral images, the marked images are sorted, so as to generate a leakage video of the leaked gas according to the sorted marked images.
[0046] In a second aspect, an embodiment of the present application further provides a gas leakage detection device, comprising:
[0047] A first conversion module is used to convert each spectral image containing a target object to be detected into a grayscale image;
[0048] A first extraction module is configured to extract a dynamic foreground in the grayscale image using a background subtraction method to generate a corresponding first binary image; in the first binary image, a white area is an area where a dynamic object is located, and a black area is an area where a background is located;
[0049] a second extraction module, configured to extract a dynamic object contour from the first binary image, and determine whether the dynamic object contour is an air mass contour;
[0050] a second conversion module configured to, when the dynamic object contour is an air mass contour, use the minimum pixel value and the maximum pixel value of the pixels within the area formed by the dynamic object contour in the grayscale image as the upper and lower limits of the pixel interval, convert the colors of the pixels in the grayscale image whose pixel values are within the pixel interval to white, and convert the colors of the pixels whose pixel values are outside the pixel interval to black, so as to generate a corresponding second binary image;
[0051] a third extraction module, configured to extract a static object contour from the second binary image, and determine whether the static object contour is an air mass contour;
[0052] A fusion module is used to fuse the static object contour and the dynamic object contour when the static object contour is an air mass contour, so as to obtain the air mass contour of the detected leaked gas.
[0053] In conjunction with the second aspect, an embodiment of the present application provides a first possible implementation of the second aspect, wherein the first extraction module, when used to extract the dynamic foreground in the grayscale image using background subtraction and generate the corresponding first binary image, is specifically configured to:
[0054] Performing noise reduction processing on the grayscale image by Gaussian filtering to obtain a noise-reduced smoothed image;
[0055] The dynamic foreground in the smoothed image is extracted using Gaussian background subtraction to generate a corresponding first binary image.
[0056] In combination with the second aspect, the embodiment of the present application provides a second possible implementation of the second aspect, wherein the apparatus further includes:
[0057] a dividing module, configured to divide the first binary image into mesh-like square images before the second extraction module extracts the contour of the dynamic object from the first binary image;
[0058] a first determining module configured to, for each square in the grid-like square image, determine the square as a target square and record the square as a first value when the square contains a white area; and record the square as a second value when the square does not contain a white area;
[0059] a first calculation module, configured to calculate a ratio of the number of target squares to the number of all squares in the grid square image to obtain a first ratio;
[0060] a second determining module, configured to determine the first binary image as a non-rain and snow scene image if the first ratio is less than a first threshold;
[0061] a second calculation module configured to, if the first ratio is greater than or equal to the first threshold, calculate, for each row of squares in the grid square image, a sum of the values of the row of squares based on the values of each square in the row of squares to obtain a first sum value; and calculate, for each column of squares in the grid square image, a sum of the values of the column of squares based on the values of each square in the column of squares to obtain a second sum value; the values comprising the first and second values;
[0062] a judgment module, configured to judge, for each row of squares, whether all first sum values corresponding to the first sum values conform to a uniform distribution, and to judge, for each column of squares, whether all second sum values conform to a uniform distribution;
[0063] a third determining module, configured to determine the first binary image as a rain and snow scene image when all the first sum values conform to a uniform distribution and all the second sum values conform to a uniform distribution;
[0064] a fourth determining module, configured to determine the first binary image as a non-rain and snow scene image when all of the first sum values do not conform to a uniform distribution and / or when all of the second sum values do not conform to a uniform distribution;
[0065] When the second extraction module is used to extract the contour of the dynamic object from the first binary image, it is specifically used to:
[0066] When the first binary image is a non-rain and snow scene image, the contour of the dynamic object is extracted from the first binary image.
[0067] In combination with the second aspect, the embodiment of the present application provides a third possible implementation of the second aspect, wherein the second extraction module, when used to determine whether the dynamic object contour is an air mass contour, is specifically configured to:
[0068] Calculating the number of contour points on the dynamic object contour and the area of the region formed by the dynamic object contour;
[0069] When the number of the contour points is less than a second threshold, and the area of the region is less than a third threshold, determining the dynamic object contour as a point-shaped air mass contour;
[0070] When the number of the contour points is not less than a second threshold value, and / or the area of the region is not less than a third threshold value, fitting a fitted contour of the dynamic object contour based on each contour point on the dynamic object contour; wherein the smoothness of the fitted contour is greater than the smoothness of the dynamic object contour;
[0071] calculating a ratio of the number of fitting contour points on the fitting contour to the number of contour points on the dynamic object contour to obtain a second ratio;
[0072] When the second ratio is greater than a fourth threshold, determining the dynamic object contour as an air mass contour;
[0073] When the second ratio is not greater than the fourth threshold, the dynamic object contour is determined as a non-air mass contour.
[0074] In conjunction with the second aspect, an embodiment of the present application provides a fourth possible implementation of the second aspect, wherein the third extraction module, when used to extract a static object contour from the second binary image and determine whether the static object contour is an air mass contour, is specifically configured to:
[0075] extracting a static object contour from the second binary image to determine whether the static object contour intersects with the dynamic object contour;
[0076] If the static object contour intersects with the dynamic object contour, it is determined whether the static object contour is an air mass contour.
[0077] In combination with the second aspect, the embodiments of the present application provide a fifth possible implementation of the second aspect, which further includes:
[0078] an acquisition module, configured to acquire a visible light image and a plurality of continuous spectral images containing the target object to be detected before the first conversion module converts each spectral image containing the target object to be detected into a grayscale image;
[0079] a fifth determining module configured to, when the static object contour is an air mass contour, fuse the static object contour with the dynamic object contour to obtain the detected air mass contour of the leaked gas, and then determine, for each pixel in the grayscale image, a preset pixel value interval to which the pixel value of the pixel in the grayscale image belongs;
[0080] a coloring module, configured to color the position of the pixel in the grayscale image using a preset color value pre-set for the preset pixel value interval, and obtain a colored image corresponding to the grayscale image after each pixel position in the grayscale image is colored;
[0081] A cropping module, configured to crop a colored air mass area at a position where the air mass outline of the detected leaked gas is located from the colored image;
[0082] The superposition module is used to superimpose the colored air mass area onto the corresponding position of the visible light image to obtain a marked image.
[0083] In combination with the fifth possible implementation of the second aspect, the embodiment of the present application provides a sixth possible implementation of the second aspect, wherein each of the spectral images corresponds to a respective marker image; and the apparatus further includes:
[0084] A generation module is used to sort the labeled images according to the order of each spectral image and the labeled images corresponding to each spectral image after the fusion module obtains the labeled images corresponding to each spectral image, so as to generate a leakage video of the leaked gas according to the sorted labeled images.
[0085] In a third aspect, an embodiment of the present application further provides an electronic device comprising: a processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor. When the electronic device is running, the processor and the memory communicate through the bus, and when the machine-readable instructions are executed by the processor, the steps of any possible implementation method of the first aspect above are performed.
[0086] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of any possible implementation method of the first aspect are executed.
[0087] The present invention provides a gas leak detection method, device, electronic device, and readable storage medium. When a static object's outline is an air mass outline, the static object outline (i.e., the static air mass outline) is merged with the dynamic object outline (i.e., the dynamic air mass outline) to form a complete air mass outline of the leaking gas. Compared to the single-point detection method used in the prior art, the method of this embodiment can detect a more complete air mass outline of the leaking gas, which helps improve the comprehensiveness of gas leak detection.
[0088] In order to make the above-mentioned objects, features and advantages of the present application more obvious and easy to understand, preferred embodiments are given below and described in detail with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0089] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other relevant drawings can be obtained based on these drawings without creative work.
[0090] FIG1 shows a flow chart of a gas leakage detection method provided in an embodiment of the present application;
[0091] FIG2 shows a schematic diagram of a grayscale image and a smoothed image provided in an embodiment of the present application;
[0092] FIG3 shows a schematic structural diagram of a gas leakage detection device provided in an embodiment of the present application;
[0093] FIG4 shows a schematic structural diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0094] In order to make the purpose, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. The components of the embodiments of the present application generally described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the application for protection, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work are within the scope of protection of this application.
[0095] At present, there are two main types of gas leak detection technologies:
[0096] The first type is gas leak detection using gas detection sensors. In this detection method, the gas detection sensor must be in contact with the gas to detect a leak. This is a single-point detection method and cannot detect the shape or size of the gas cloud. Furthermore, in some scenarios (such as the top of a chemical gas tank), gas detection sensors are difficult to install and maintain.
[0097] The second type of gas detection is based on infrared optical gas imaging. Optical gas imagers are specifically designed to "see" various gases, including hydrocarbons. They can detect gases within the imaging area, have a wide detection range, and can reveal the distribution of gases. With the development of optical gas imaging technology, this gas detection technology is becoming increasingly widely used.
[0098] There are two general approaches to using optical gas imagers to detect gas leaks: One involves a person holding a handheld optical gas imager to film the inspection area, allowing the human eye to identify gases from the video. The other involves placing the optical gas imager in a fixed location to film the inspection area. The video is then automatically transmitted to a recognition system, which uses visual recognition technology to automatically identify gases from the video and mark gas masses. This approach is clearly more timely and effective.
[0099] Gas visual recognition technology based on optical gas imager video is generally divided into two steps:
[0100] Step 1: Leveraging the characteristics of gas motion, use multiple consecutive frames of images to identify moving targets. Preliminarily identify the moving target as an air mass. Common algorithms used in this step include frame difference, background subtraction, and optical flow.
[0101] Step 2: Further analyze the detected moving target to see if it is an air mass. This step can be divided into two categories:
[0102] 1) Traditional machine learning: This approach extracts features from air masses, such as texture features (LBP, DWT) and morphological features (HOG). Classification algorithms are then used to classify air masses into gas and non-air masses based on these features. Commonly used classification algorithms include SVM, KNN, AdaBoost, and Random Forest.
[0103] 2) Deep CNN machine learning. You can design your own network model or use existing models such as Yolo.
[0104] Gas identification technology based on optical imager video relies on step one: detecting moving air masses. However, this approach has a drawback: in multiple consecutive frames, some air masses may be stationary, thus being misidentified as background and not detected. Consequently, static air masses may be missed, significantly impacting the amount of gas leaks detected.
[0105] The difficulty of gas identification technology based on optical imager video lies in step two, that is, how to determine whether a moving target is a gas. For this step, the current method has the following shortcomings:
[0106] Deep learning requires a large amount of data, but in reality the probability of gas leakage is small, the scenes are diverse, and image data is not easy to collect, making it difficult to effectively train a reliable model.
[0107] Traditional machine learning, which extracts gas signatures from static images and then classifies them, is also not ideal for the following reasons: optical imagers capture infrared images, which can only use grayscale images (losing color features); the image resolution is low, making it difficult to distinguish texture features from the background. Air masses have variable morphology, so using morphological features is also not ideal.
[0108] In view of the above problems, based on this, the embodiments of the present application provide a gas leakage detection method, device, electronic device and readable storage medium, which are described below through embodiments.
[0109] Example 1:
[0110] To facilitate understanding of this embodiment, a gas leakage detection method disclosed in the embodiment of the present application is first introduced in detail. FIG1 shows a flow chart of a gas leakage detection method provided in the embodiment of the present application, as shown in FIG1 , including the following steps S101-S106:
[0111] S101: For each spectral image containing a target object to be detected, convert the spectral image into a grayscale image.
[0112] In this embodiment, the target objects to be inspected are objects that are at risk of gas leakage and require gas leak detection, such as gas tanks, pipelines, valves, etc. that store or transmit gas. Since gas is usually colorless and invisible to the naked eye, it is necessary to regularly inspect the target objects for gas leaks.
[0113] In this embodiment, a visible light camera and a spectral camera are positioned around the target object. The distance between the lenses of the visible light camera and the spectral camera is less than a preset distance, that is, the lenses of the two cameras are very close. When photographing the target object, the visible light camera and the spectral camera have the same shooting angle, and both cameras are stationary during the shooting.
[0114] The spectral camera collects a spectral image at a preset time interval, for example, a spectral image is collected every 10 seconds, and a total of 50 spectral images are collected. During the process of collecting spectral images, the visible light camera collects a visible light image containing the target object to be detected.
[0115] In a possible implementation, before executing step S101 , it is further possible to: obtain a visible light image containing the target object to be detected from a visible light camera, and obtain multiple continuous spectral images containing the target object to be detected from a spectral camera.
[0116] Among them, multiple continuous spectral images, for example, spectral images collected at the 1st second, the 6th second, the 11th second...
[0117] In this embodiment, after acquiring multiple continuous spectral images, each spectral image is converted into a grayscale image. Figure 2 shows a schematic diagram of a grayscale image and a smoothed image provided in an embodiment of the present application. As shown in Figure 2, the image on the left is a schematic diagram of a grayscale image. Each spectral image corresponds to a grayscale image.
[0118] S102: Using background subtraction to extract the dynamic foreground in the grayscale image, and generating a corresponding first binary image; in the first binary image, the white area is the area where the dynamic object is located, and the black area is the area where the background is located.
[0119] In a possible implementation, when executing step S102, the following steps S1021-S1022 may be specifically performed:
[0120] S1021: performing noise reduction processing on the grayscale image by Gaussian filtering to obtain a smoothed image after noise reduction;
[0121] S1022: Use Gaussian background subtraction to extract the dynamic foreground in the smooth image and generate a corresponding first binary image.
[0122] In step S1021, the grayscale image is smoothed using a Gaussian filter to remove noise from the grayscale image. As shown in Figure 2, the right side is a schematic diagram of the smoothed image. Each grayscale image corresponds to a smoothed image after noise reduction, and therefore each spectral image corresponds to a smoothed image.
[0123] In step S1022, each smoothed image corresponds to a first binary image, that is, each grayscale image corresponds to a first binary image. The first binary image is a black and white image.
[0124] In one possible implementation, since the target object to be detected is usually located outdoors, and rainy or snowy days interfere with gas leak detection, resulting in inaccurate detection, after generating the first binary image and before executing step S103, it is further possible to determine whether it is currently raining or snowing according to the following steps S1023-S10210:
[0125] S1023: Divide the first binary image into grid-like images on an even basis.
[0126] In this embodiment, for each first binary image, the first binary image is evenly divided into a grid-like image of N1 (number of rows)×N2 (number of columns), wherein N1 and N2 may be the same or different.
[0127] S1024: For each square in the grid image, when the square contains a white area, the square is determined as a target square and the square is recorded as a first value; when the square does not contain a white area, the square is recorded as a second value.
[0128] In this embodiment, since the first binary image is a black and white image, the gridded square image is also a black and white image. For each square in the gridded square image, when the square contains a white area (for example, the square is entirely white, or the square is partially white and partially black), the square is recorded as a first value, and the square is determined as the target square. When the square is entirely black, the square is recorded as a second value. The first value can be 1, and the second value can be 0.
[0129] S1025: Calculate the ratio of the number of target squares to the number of all squares in the grid square image to obtain a first ratio.
[0130] In this embodiment, the ratio of the number of target squares to the number of all squares in the grid square image is used as the first ratio.
[0131] S1026: If the first ratio is less than the first threshold, the first binary image is determined to be a non-rain and snow scene image.
[0132] S1027: If the first ratio is greater than or equal to the first threshold, then for each row of squares in the grid square image, the numerical value of the row of squares is calculated according to the numerical value of each square in the row of squares to obtain a first sum of the squares in the row; and for each column of squares in the grid square image, the numerical value of the column of squares is calculated according to the numerical value of each square in the column of squares to obtain a second sum of the squares in the column; the numerical value includes the first numerical value and the second numerical value.
[0133] In this embodiment, if the first ratio is greater than or equal to the first threshold, the sum of the values of each row in the gridded square image is calculated horizontally to obtain N1 first sum values, and the sum of the values of each column in the gridded square image is calculated vertically to obtain N2 second sum values.
[0134] S1028: For each first sum value corresponding to each row of squares, determine whether all first sum values conform to a uniform distribution; and for each second sum value corresponding to each column of squares, determine whether all second sum values conform to a uniform distribution.
[0135] In this embodiment, whether all first sum values conform to the uniform distribution is determined by using a uniform distribution algorithm (eg, Kolmogorov-Smirnov Test), and whether all second sum values conform to the uniform distribution is determined.
[0136] S1029: When all the first sum values conform to the uniform distribution and all the second sum values conform to the uniform distribution, the first binary image is determined to be a rain and snow scene image.
[0137] In this embodiment, when the first binary image is an image of a rainy or snowy scene, gas leakage detection is no longer performed, that is, step S103 and subsequent steps are stopped.
[0138] S10210: When all the first sum values do not conform to the uniform distribution, and / or when all the second sum values do not conform to the uniform distribution, the first binary image is determined to be a non-rain and snow scene image.
[0139] In this embodiment, when the first binary image is an image of a non-rain and snow scene, the gas leakage detection is continued, that is, step S103 and subsequent steps are continued.
[0140] S103: extracting a dynamic object contour from the first binary image, and determining whether the dynamic object contour is an air mass contour.
[0141] In a possible implementation, when executing step S103 to extract the contour of the dynamic object from the first binary image, the following steps may be specifically performed: when the first binary image is a non-rain and snow scene image, extract the contour of the dynamic object from the first binary image.
[0142] In this embodiment, since the first binary image is a black and white image, in which the white area is the area where the dynamic object is located and the black area is the area where the background is located, the black and white boundary in the first binary image is used as the contour of the dynamic object.
[0143] Each first binary image corresponds to a dynamic object contour. Therefore, each grayscale image corresponds to a dynamic object contour. Similarly, each spectral image corresponds to a dynamic object contour.
[0144] In this embodiment, when the first binary image is a non-rain and snow scene image, the following steps may also be performed when extracting the dynamic object contour from the first binary image:
[0145] When the first binary image is an image of a non-rainy or snowy scene, a detection area in the first binary image is set, the detection area includes the target object to be detected, and the detection area occupies 60% of the first binary image. This method is conducive to reducing background interference.
[0146] Next, the image within the detection area is further denoised to remove motion noise. Specifically, a rectangular filter, part of the morphological opening and closing operation, is used to open the image within the detection area, followed by a closing operation. The opening operation removes small white dots, while the closing operation closes small black holes. The contours of dynamic objects are extracted from the denoised detection area.
[0147] In a possible implementation, when executing step S103 to determine whether the dynamic object contour is an air mass contour, the following steps S1031-S1036 may be specifically performed:
[0148] S1031: Calculate the number of contour points on the dynamic object contour and the area of the region formed by the dynamic object contour.
[0149] In this embodiment, the contour of the dynamic object is composed of multiple contour points.
[0150] S1032: When the number of contour points is less than the second threshold, and the area of the region is less than the third threshold, the dynamic object contour is determined as a point-shaped air mass contour.
[0151] Among them, the point-shaped gas contour is a type of gas contour. Therefore, when the number of contour points of the dynamic object contour is less than the second threshold and the area is less than the third threshold, the dynamic object contour can be determined as an air mass contour.
[0152] S1033: When the number of contour points is not less than a second threshold, and / or the area of the region is not less than a third threshold, fitting a fitting contour of the dynamic object contour based on each contour point on the dynamic object contour; wherein the smoothness of the fitting contour is greater than the smoothness of the dynamic object contour.
[0153] S1034: Calculate the ratio of the number of fitting contour points on the fitting contour to the number of contour points on the dynamic object contour to obtain a second ratio.
[0154] In this embodiment, since the fitting contour is smoother than the dynamic object contour, the shape of the fitting contour is different from the shape of the dynamic object contour, that is, the number of fitting contour points on the fitting contour may be different from the number of contour points on the dynamic object contour.
[0155] S1035: When the second ratio is greater than a fourth threshold, the dynamic object contour is determined to be an air mass contour.
[0156] In this embodiment, a larger second ratio indicates that the contour of the dynamic object is less smooth. Since the contour of a gas mass is usually not smooth, a larger second ratio indicates that the contour of the dynamic object is a gas mass contour.
[0157] S1036: When the second ratio is not greater than a fourth threshold, determine the dynamic object contour as a non-air mass contour.
[0158] In this embodiment, the smaller the second ratio is, the smoother the dynamic object contour is, while the gas mass contour is usually not smooth. Therefore, the smaller the second ratio is, the smaller the dynamic object contour is, which indicates that the dynamic object contour is not a gas mass contour.
[0159] S104: When the contour of the dynamic object is an air mass contour, the minimum pixel value and the maximum pixel value of the pixel points in the area formed by the contour of the dynamic object in the grayscale image are used as the upper and lower limits of the pixel interval, the color of the pixel points in the grayscale image whose pixel values are within the pixel interval is converted to white, and the color of the pixel points whose pixel values are outside the pixel interval is converted to black, so as to generate a corresponding second binary image.
[0160] In this embodiment, for each first binary image, when the dynamic object contour in the first binary image is an air mass contour, the grayscale image corresponding to the first binary image is determined, and the minimum pixel value and maximum pixel value of the pixel points in the area formed by the dynamic object contour are extracted from the grayscale image, and the minimum pixel value and the maximum pixel value are used as the upper and lower limits of the pixel interval.
[0161] S105: extracting a static object contour from the second binary image, and determining whether the static object contour is an air mass contour.
[0162] In a possible implementation, when executing step S105, the following steps S1051-S1052 may be specifically performed:
[0163] S1051: Extracting a static object contour from the second binary image to determine whether the static object contour intersects with the dynamic object contour.
[0164] In this embodiment, the second binary image is a black and white image, wherein white areas are static air mass candidate areas and black areas are non-static air mass areas. The black and white boundaries in the second binary image are used as static object contours.
[0165] S1052: If the static object contour intersects with the dynamic object contour, determine whether the static object contour is an air mass contour.
[0166] In this embodiment, whether the static object contour is an air mass contour can be determined by the following method:
[0167] Calculate the number of contour points on the static object contour and the area of the region formed by the static object contour.
[0168] When the number of contour points on the static object contour is less than the second threshold, and the area of the region formed by the static object contour is less than the third threshold, the static object contour is determined to be a point-shaped air mass contour.
[0169] When the number of contour points on the static object contour is not less than a second threshold, and / or the area of the region formed by the static object contour is not less than a third threshold, a fitted contour of the static object contour is fitted based on the contour points on the static object contour; wherein the smoothness of the fitted contour of the static object contour is greater than the smoothness of the static object contour.
[0170] The ratio of the number of fitting contour points on the fitting contour of the static object contour to the number of contour points on the static object contour is calculated to obtain a third ratio.
[0171] When the third ratio is greater than a fourth threshold, the static object contour is determined to be an air mass contour.
[0172] When the third ratio is not greater than a fourth threshold, the static object contour is determined as a non-air mass contour.
[0173] S106: When the static object contour is an air mass contour, the static object contour and the dynamic object contour are merged to obtain the air mass contour of the detected leaked gas.
[0174] In this embodiment, when the static object contour is an air mass contour, the static object contour is fused into the dynamic object contour to obtain the air mass contour of the detected leaked gas, wherein each spectral image corresponds to one air mass contour.
[0175] In a possible implementation, after executing step S106, the following steps S1071-S1074 may be further performed:
[0176] S1071: For each pixel in the grayscale image, determine a preset pixel value interval to which the pixel value of the pixel in the grayscale image belongs.
[0177] In this embodiment, the size of the visible light image is set to the size of the spectral image. All spectral images have the same size. The size of the grayscale image is the same as the size of the spectral image.
[0178] A preset number of color values are defined, wherein the smaller the color value, the lighter the color. For example, 10 color values are defined.
[0179] The pixel value interval 0-255 is divided into a preset number of parts to obtain the preset number of preset pixel value intervals. For example, after the pixel value interval 0-255 is divided into 10 parts, the preset pixel value intervals of each part are 0-25, 26-50, etc.
[0180] In this embodiment, for each pixel in the grayscale image, the preset pixel value interval to which the pixel value of the pixel in the grayscale image belongs is determined. For example, when the pixel value of the pixel is 14, the preset pixel value interval to which the pixel belongs is 0-25.
[0181] S1072: Using a preset color value pre-set for the preset pixel value interval, coloring the position of the pixel in the grayscale image. When each pixel in the grayscale image is colored, a colored image corresponding to the grayscale image is obtained.
[0182] In this embodiment, each preset pixel value interval corresponds to a defined color value, and different preset pixel value intervals correspond to different color values.
[0183] After determining the preset pixel value interval to which the pixel belongs, the position of the pixel in the grayscale image is colored using the color value corresponding to the preset pixel value interval, thereby obtaining a colored image corresponding to the grayscale image.
[0184] In this embodiment, each grayscale image corresponds to a respective colored image.
[0185] S1073: Based on the detected air mass contour of the leaked gas, a colored air mass region at the location of the air mass contour is cut out from the colored image.
[0186] In this embodiment, based on the air mass outline corresponding to the grayscale image, a colored air mass region at the position where the air mass outline is located is clipped from the colored image corresponding to the grayscale image.
[0187] S1074: Superimpose the colored air mass area onto the corresponding position of the visible light image to obtain a marked image.
[0188] In this embodiment, the colored air mass area is superimposed on the corresponding position of the visible light image. When there is only one colored air mass area corresponding to the same grayscale image, a frame is used to select and mark the colored air mass area in the visible light image to obtain a marked image corresponding to the grayscale image.
[0189] When there are multiple colored air mass areas corresponding to the same grayscale image, determine the distance between any two adjacent colored air mass areas. When the distance is less than the preset distance, the two adjacent colored air mass areas are determined as a group of colored air mass areas. In the visible light image, use a frame to frame and mark the group of colored air mass areas; when the distance is not less than the preset distance, use different frames to frame and mark the two adjacent colored air mass areas respectively in the visible light image to obtain a marked image corresponding to the grayscale image.
[0190] In one possible implementation, since each grayscale image corresponds to a respective marker image, the marker image corresponding to each spectral image can be determined based on the correspondence between the grayscale image and the spectral image. After obtaining the marker image corresponding to each spectral image, the following steps can be performed:
[0191] According to the order of each spectral image and the labeled image corresponding to each spectral image, the labeled images are sorted, so as to generate a leakage video of the leaking gas according to the sorted labeled images.
[0192] In this embodiment, the trajectory of the gas leakage can be seen through the leakage video.
[0193] In this embodiment, in order to determine whether the air mass of a dynamic object and the gas of a static object are the contours of an air mass, this embodiment does not use deep learning, nor does it use the traditional method of extracting static and dynamic features of an air mass using a classification algorithm. Instead, it finds the contours of the object based on the foreground image after background subtraction, and then uses the air mass contour features to simply and effectively identify the air mass of a dynamic object and the gas of a static object. The method is direct, simple, stable and effective. In addition, by integrating the contours of static objects into the contours of dynamic objects, a relatively complete air mass contour is formed. By adding a rain and snow detection part, the false alarm rate is reduced. By superimposing the detection results (air mass contours) on the visible light image, the presentation effect is improved.
[0194] Example 2:
[0195] Based on the same technical concept, the present application also provides a gas leakage detection device. FIG3 shows a schematic structural diagram of a gas leakage detection device provided in an embodiment of the present application. As shown in FIG3 , the device includes:
[0196] The first conversion module 301 is configured to convert each spectral image containing a target object to be detected into a grayscale image;
[0197] A first extraction module 302 is configured to extract the dynamic foreground in the grayscale image using a background subtraction method to generate a corresponding first binary image; in the first binary image, the white area is the area where the dynamic object is located, and the black area is the area where the background is located;
[0198] A second extraction module 303 is configured to extract a dynamic object contour from the first binary image and determine whether the dynamic object contour is an air mass contour;
[0199] The second conversion module 304 is configured to, when the dynamic object contour is an air mass contour, use the minimum and maximum pixel values of the pixels within the area formed by the dynamic object contour in the grayscale image as the upper and lower limits of the pixel interval, convert the colors of the pixels in the grayscale image whose pixel values are within the pixel interval to white, and convert the colors of the pixels whose pixel values are outside the pixel interval to black, so as to generate a corresponding second binary image;
[0200] a third extraction module 305 , configured to extract a static object contour from the second binary image, and determine whether the static object contour is an air mass contour;
[0201] The fusion module 306 is configured to fuse the static object contour with the dynamic object contour when the static object contour is an air mass contour, so as to obtain the air mass contour of the detected leaked gas.
[0202] Optionally, when the first extraction module 302 is used to extract the dynamic foreground in the grayscale image using background subtraction to generate the corresponding first binary image, it is specifically used to:
[0203] Performing noise reduction processing on the grayscale image by Gaussian filtering to obtain a noise-reduced smoothed image;
[0204] The dynamic foreground in the smoothed image is extracted using Gaussian background subtraction to generate a corresponding first binary image.
[0205] Optionally, the device further includes:
[0206] a division module, configured to divide the first binary image into grid-like images before the second extraction module 303 extracts the contour of the dynamic object from the first binary image;
[0207] a first determining module configured to, for each square in the grid-like square image, determine the square as a target square and record the square as a first value when the square contains a white area; and record the square as a second value when the square does not contain a white area;
[0208] a first calculation module, configured to calculate a ratio of the number of target squares to the number of all squares in the grid square image to obtain a first ratio;
[0209] a second determining module, configured to determine the first binary image as a non-rain and snow scene image if the first ratio is less than a first threshold;
[0210] a second calculation module configured to, if the first ratio is greater than or equal to the first threshold, calculate, for each row of squares in the grid square image, a sum of the values of the row of squares based on the values of each square in the row of squares to obtain a first sum value; and calculate, for each column of squares in the grid square image, a sum of the values of the column of squares based on the values of each square in the column of squares to obtain a second sum value; the values comprising the first and second values;
[0211] a judgment module, configured to judge, for each row of squares, whether all first sum values corresponding to the first sum values conform to a uniform distribution, and to judge, for each column of squares, whether all second sum values conform to a uniform distribution;
[0212] a third determining module, configured to determine the first binary image as a rain and snow scene image when all the first sum values conform to a uniform distribution and all the second sum values conform to a uniform distribution;
[0213] a fourth determining module, configured to determine the first binary image as a non-rain and snow scene image when all of the first sum values do not conform to a uniform distribution and / or when all of the second sum values do not conform to a uniform distribution;
[0214] When used to extract the contour of the dynamic object from the first binary image, the second extraction module 303 is specifically used to:
[0215] When the first binary image is a non-rain and snow scene image, the contour of the dynamic object is extracted from the first binary image.
[0216] Optionally, when used to determine whether the dynamic object contour is an air mass contour, the second extraction module 303 is specifically configured to:
[0217] Calculating the number of contour points on the dynamic object contour and the area of the region formed by the dynamic object contour;
[0218] When the number of the contour points is less than a second threshold, and the area of the region is less than a third threshold, determining the dynamic object contour as a point-shaped air mass contour;
[0219] When the number of the contour points is not less than a second threshold value, and / or the area of the region is not less than a third threshold value, fitting a fitted contour of the dynamic object contour based on each contour point on the dynamic object contour; wherein the smoothness of the fitted contour is greater than the smoothness of the dynamic object contour;
[0220] calculating a ratio of the number of fitting contour points on the fitting contour to the number of contour points on the dynamic object contour to obtain a second ratio;
[0221] When the second ratio is greater than a fourth threshold, determining the dynamic object contour as an air mass contour;
[0222] When the second ratio is not greater than the fourth threshold, the dynamic object contour is determined as a non-air mass contour.
[0223] Optionally, when the third extraction module 305 is used to extract the static object contour from the second binary image and determine whether the static object contour is an air mass contour, it is specifically used to:
[0224] extracting a static object contour from the second binary image to determine whether the static object contour intersects with the dynamic object contour;
[0225] If the static object contour intersects with the dynamic object contour, it is determined whether the static object contour is an air mass contour.
[0226] Optionally, also include:
[0227] an acquisition module, configured to acquire a visible light image and a plurality of continuous spectral images containing the target object to be detected before the first conversion module 301 converts each spectral image containing the target object to be detected into a grayscale image;
[0228] a fifth determining module configured to, when the static object contour is an air mass contour, fuse the static object contour with the dynamic object contour to obtain the detected air mass contour of the leaked gas, and then determine, for each pixel in the grayscale image, a preset pixel value interval to which the pixel value of the pixel in the grayscale image belongs;
[0229] a coloring module, configured to color the position of the pixel in the grayscale image using a preset color value pre-set for the preset pixel value interval, and obtain a colored image corresponding to the grayscale image after each pixel position in the grayscale image is colored;
[0230] A cropping module, configured to crop a colored air mass area at a position where the air mass outline of the detected leaked gas is located from the colored image;
[0231] The superposition module is used to superimpose the colored air mass area onto the corresponding position of the visible light image to obtain a marked image.
[0232] Optionally, each of the spectral images corresponds to a respective marker image; the device further comprises:
[0233] A generation module is used to sort the labeled images according to the order of each spectral image and the labeled images corresponding to each spectral image after the fusion module obtains the labeled images corresponding to each spectral image, so as to generate a leakage video of the leaked gas according to the sorted labeled images.
[0234] Example 3:
[0235] Figure 4 is a structural diagram of an electronic device provided in an embodiment of the present application, including: a processor 401, a memory 402 and a bus 403. The memory 402 stores machine-readable instructions executable by the processor 401. When the electronic device runs the above-mentioned information processing method, the processor 401 communicates with the memory 402 through the bus 403, and the processor 401 executes the machine-readable instructions to perform the method steps described in Example 1.
[0236] Example 4:
[0237] The fourth embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the method steps described in the first embodiment are executed.
[0238] Those skilled in the art will clearly understand that, for the convenience and brevity of description, the specific working processes of the above-described devices, electronic devices, and computer-readable storage media can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0239] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the modules is only a logical function division. There may be other division methods in actual implementation. For example, multiple modules or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection of some communication interface, device or unit, which can be electrical, mechanical or other forms.
[0240] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.
[0241] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0242] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium that is executable by a processor. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.
[0243] Finally, it should be noted that the above-described embodiments are only specific implementation methods of the present application, which are used to illustrate the technical solutions of the present application, rather than to limit them. The scope of protection of the present application is not limited thereto. Although the present application has been described in detail with reference to the above-described embodiments, those skilled in the art should understand that any person skilled in the art can modify or easily conceive of changes to the technical solutions described in the above-described embodiments within the technical scope disclosed in the present application, or perform equivalent replacements for some of the technical features thereof. Such modifications, changes, or replacements do not deviate from the spirit and scope of the technical solutions of the embodiments of the present application, and should be included in the scope of protection of the present application. Therefore, the scope of protection of the present application shall be based on the scope of protection of the claims.
Claims
1. A gas leak detection method, characterized in that: include: For each spectral image containing the target object to be detected, convert the spectral image into a grayscale image; Extracting the dynamic foreground in the grayscale image using background subtraction to generate a corresponding first binary image; in the first binary image, the white area is the area where the dynamic object is located, and the black area is the area where the background is located; extracting a dynamic object contour from the first binary image, and determining whether the dynamic object contour is an air mass contour; When the dynamic object contour is an air mass contour, the minimum pixel value and the maximum pixel value of the pixels within the area formed by the dynamic object contour in the grayscale image are used as the upper and lower limits of the pixel interval, the colors of the pixels in the grayscale image whose pixel values are within the pixel interval are converted to white, and the colors of the pixels whose pixel values are outside the pixel interval are converted to black, so as to generate a corresponding second binary image; extracting a static object contour from the second binary image, and determining whether the static object contour is an air mass contour; When the static object contour is an air mass contour, the static object contour and the dynamic object contour are merged to obtain the air mass contour of the detected leaked gas.
2. The method according to claim 1, characterized in that The method of extracting the dynamic foreground in the grayscale image using background subtraction to generate a corresponding first binary image includes: Performing noise reduction processing on the grayscale image by Gaussian filtering to obtain a noise-reduced smoothed image; The dynamic foreground in the smoothed image is extracted using Gaussian background subtraction to generate a corresponding first binary image.
3. The method according to claim 1, characterized in that Before extracting the dynamic object contour from the first binary image, the method further includes: Dividing the first binary image into grid-like images on an even basis; For each square in the grid-like square image, when the square contains a white area, the square is determined as a target square and the square is recorded as a first value; when the square does not contain a white area, the square is recorded as a second value; Calculating a ratio of the number of target squares to the number of all squares in the grid square image to obtain a first ratio; If the first ratio is less than a first threshold, determining the first binary image as a non-rain and snow scene image; If the first ratio is greater than or equal to the first threshold, then, for each row of squares in the gridded square image, the sum of the values of the row of squares is calculated based on the values of each square in the row of squares to obtain a first sum value of the row of squares; and for each column of squares in the gridded square image, the sum of the values of the column of squares is calculated based on the values of each square in the column of squares to obtain a second sum value of the column of squares; the values include the first value and the second value; For each row of squares, determining whether all first sum values correspond to a uniform distribution; and for each column of squares, determining whether all second sum values correspond to a uniform distribution; When all the first sum values conform to a uniform distribution, and all the second sum values conform to a uniform distribution, determining the first binary image as a rain and snow scene image; When all the first sum values do not conform to a uniform distribution, and / or all the second sum values do not conform to a uniform distribution, determining the first binary image as a non-rain and snow scene image; The step of extracting the contour of the dynamic object from the first binary image includes: When the first binary image is a non-rain and snow scene image, the contour of the dynamic object is extracted from the first binary image.
4. The method according to claim 1, characterized in that The determining whether the dynamic object contour is an air mass contour includes: Calculating the number of contour points on the dynamic object contour and the area of the region formed by the dynamic object contour; When the number of the contour points is less than a second threshold, and the area of the region is less than a third threshold, determining the dynamic object contour as a point-shaped air mass contour; When the number of the contour points is not less than a second threshold value, and / or the area of the region is not less than a third threshold value, fitting a fitted contour of the dynamic object contour based on each contour point on the dynamic object contour; wherein the smoothness of the fitted contour is greater than the smoothness of the dynamic object contour; calculating a ratio of the number of fitting contour points on the fitting contour to the number of contour points on the dynamic object contour to obtain a second ratio; When the second ratio is greater than a fourth threshold, determining the dynamic object contour as an air mass contour; When the second ratio is not greater than the fourth threshold, the dynamic object contour is determined as a non-air mass contour.
5. The method according to claim 1, characterized in that: The step of extracting a static object contour from the second binary image and determining whether the static object contour is an air mass contour includes: extracting a static object contour from the second binary image to determine whether the static object contour intersects with the dynamic object contour; If the static object contour intersects with the dynamic object contour, it is determined whether the static object contour is an air mass contour.
6. The method according to claim 1, characterized in that Before converting each spectral image containing the target object to be detected into a grayscale image, the method further includes: Acquire a visible light image and multiple continuous spectral images containing the target object to be detected; When the static object contour is an air mass contour, after fusing the static object contour with the dynamic object contour to obtain the detected air mass contour of the leaked gas, the method further includes: For each pixel in the grayscale image, determining a preset pixel value interval to which the pixel value of the pixel in the grayscale image belongs; Coloring the position of the pixel in the grayscale image using a preset color value pre-set for the preset pixel value interval, and obtaining a colored image corresponding to the grayscale image after each pixel in the grayscale image is colored; According to the detected air mass contour of the leaked gas, cutting out a colored air mass area at the position where the air mass contour is located from the colored image; The colored air mass area is superimposed on the corresponding position of the visible light image to obtain a marked image.
7. The method according to claim 6, characterized in that Each of the spectral images corresponds to a respective marker image; after obtaining the marker image corresponding to each of the spectral images, the method further includes: According to the order of each of the spectral images and the respective marked images corresponding to each of the spectral images, the marked images are sorted, so as to generate a leakage video of the leaked gas according to the sorted marked images.
8. A gas leak detection device, characterized in that: include: A first conversion module is used to convert each spectral image containing a target object to be detected into a grayscale image; A first extraction module is configured to extract a dynamic foreground in the grayscale image using a background subtraction method to generate a corresponding first binary image; in the first binary image, a white area is an area where a dynamic object is located, and a black area is an area where a background is located; a second extraction module, configured to extract a dynamic object contour from the first binary image, and determine whether the dynamic object contour is an air mass contour; a second conversion module configured to, when the dynamic object contour is an air mass contour, use the minimum pixel value and the maximum pixel value of the pixels within the area formed by the dynamic object contour in the grayscale image as the upper and lower limits of the pixel interval, convert the colors of the pixels in the grayscale image whose pixel values are within the pixel interval to white, and convert the colors of the pixels whose pixel values are outside the pixel interval to black, so as to generate a corresponding second binary image; a third extraction module, configured to extract a static object contour from the second binary image, and determine whether the static object contour is an air mass contour; A fusion module is used to fuse the static object contour and the dynamic object contour when the static object contour is an air mass contour, so as to obtain the air mass contour of the detected leaked gas.
9. An electronic device, characterized in that: include: A processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor and the memory communicate via the bus, and when the machine-readable instructions are executed by the processor, the steps of the method according to any one of claims 1 to 7 are performed.
10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, which, when executed by a processor, executes the steps of the method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Fully-automatic mechanical equipment installation leak detection method and device
CN109146860A
Bar code image angle correction method and device
CN111311497A
Powder leakage detection method and device for flexible connection device, electronic equipment and storage medium
CN114708193A
Gas leakage infrared imaging monitoring method and device, electronic equipment and storage medium
CN114913211A
Bubble form processing method, device, medium and program product
CN115601385A