Method, Apparatus, Electronic Device and Readable Storage Medium for Detecting Gas Leakage
Patent Information
- Application Number
- AE202602558
- Authority / Receiving Office
- AE · AE
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2024-02-02
- Filing Date
- 2024-11-21
Smart Images

Figure ABST_ABST
Abstract
Description
METHOD, APPARATUS, ELECTRONIC DEVICE AND READABLE STORAGE MEDIUM FOR DETECTING GAS LEAKAGECROSS REFERENCE TO RELATED APPLICATION[1] The present application claims priority to Chinese patent application No. 202410160078.3, entitled “METHOD, SYSTEM, ELECTRONIC DEVICE, AND STORAGE MEDIUM FOR IDENTIFYING GULLY EROSION IN BLACK SOIL REGIONS”, filed on February 02, 2024, the disclosure of which is hereby incorporated by reference in its entirety. No new matter has been introduced.TECHNICAL FIELD[2] The present disclosure relates to the technical field of leakage detection, and in particular to a method, apparatus, electronic device and readable storage medium for detecting gas leakage.BACKGROUND[3] In the chemical industry, the transmission and storage of chemical raw materials are of critical importance. Chemical raw materials are generally toxic, flammable, explosive and volatile substances, such as propane, propylene, benzene and the like. Once leakage occurs, the raw materials will volatilize into gas and spread, which may lead to explosions or other safety accidents. Therefore, effective gas leakage detection technologies are particularly vital.[4] Existing gas leakage detection technologies mostly rely on gas detection sensors. For such detection methods, the gas detection sensors must come into contact with gas to detect leakage, which belongs to single-point detection and cannot identify the shape and size of gas clouds. Furthermore, gas detection sensors are difficult to install and maintain in certain scenarios (such as the top of chemical gas tanks).SUMMARY[5] In view of this, the purpose of the present disclosure is to provide a gas leakage detection method, an apparatus, an electronic device and a readable storage medium, which can detect the gas cloud contour of leaked gas and help improve the comprehensiveness of gas leakage detection.[6] In a first aspect, embodiments of the present disclosure provide a method for detecting gas leakage, comprising:[7] converting, for each spectral image containing a target object to be detected, the spectral image into a grayscale image;[8] extracting dynamic foreground in the grayscale image through background subtraction to generate a corresponding first binary image, wherein white region in the first binary image represents an area of dynamic object and black region represents background area;[9] extracting dynamic object contour from the first binary image, and determining whether the dynamic object contour is a gas cloud contour;
[10] taking, when the dynamic object contour is the gas cloud contour, a minimum pixel value and a maximum pixel value of pixel within a region enclosed by the dynamic object contour in the grayscale image as a lower and upper bounds of a pixel interval; converting pixels with pixel value within the pixel interval in the grayscale image to white and pixel with pixel value outside the pixel interval to black, to generate a corresponding second binary image;
[11] extracting static object contour from the second binary image, and determining whether the static object contour is a gas cloud contour; and
[12] fusing, when the static object contour is the gas cloud contour, the static object contour and the dynamic object contour to obtain the gas cloud contour of the detected leaked gas.
[13] In combination with the first aspect, embodiments of the present disclosure provide a first possible implementation manner of the first aspect, wherein extracting dynamic foreground in the grayscale image through background subtraction to generate a corresponding first binary image, comprises:
[14] performing noise reduction processing on the grayscale image via Gaussian filtering to obtain a denoised smoothed image; and
[15] extracting dynamic foreground in the smoothed image by Gaussian background subtraction to generate a corresponding first binary image.
[16] In combination with the first aspect, embodiments of the present disclosure provide a second possible implementation manner of the first aspect, wherein before extracting dynamic object contour from the first binary image, the method further comprises:
[17] evenly dividing the first binary image into a grid mesh image;
[18] determining, for each grid cell in the grid mesh image, the grid cell as a target grid cell and making the grid cell as a first value when the grid cell contains a white region, and marking the grid cell as a second value when the grid cell contains no white region;
[19] calculating a ratio of number of target grid cells to number of all grid cells in the grid mesh image to obtain a first ratio;
[20] determining the first binary image as a non-rain-snow scene image when the first ratio is smaller than a first threshold;
[21] calculating, if the first ratio is greater than or equal to the first threshold, for each row of grid cells in the grid mesh image, a value of the each row of grid cells to obtain a first sum value of the each row of grid cells according to a value of each grid cell in the row, and calculating, for each column of grid cells in the grid mesh image, a value of each column of grid cells to obtain a second sum value of the column of grid cells according to the value of each grid cell in the column of grid cells; the values including the first value and the second value;
[22] determining, for the first sum value respectively corresponding to each row of grid cells, whether all first sum values follow a uniform distribution, and for the second sum value respectively corresponding to each column of grid cells, determining whether all second sum values follow a uniform distribution;
[23] determining the first binary image as a rain-snow scene image when all first sum values follow the uniform distribution and all second sum values follow the uniform distribution; and
[24] determining the first binary image as a non-rain-snow scene image when all first sum values do not follow the uniform distribution and / or all second sum values do not follow the uniform distribution;
[25] wherein extracting dynamic object contour from the first binary image, comprises:
[26] extracting dynamic object contour from the first binary image when the first binary image is a non-rain-snow scene image.
[27] In combination with the first aspect, embodiments of the present disclosure provide a third possible implementation manner of the first aspect, wherein determining whether the dynamic object contour is a gas cloud contour, comprises:
[28] Calculating number of contour points on the dynamic object contour and a region area of the dynamic object contour;
[29] determining the dynamic object contour as a point-shaped gas cloud contour when the number of contour points is less than a second threshold and the region area is less than a third threshold;
[30] fitting, when the number of contour points is not less than the second threshold and / or the region area is not less than the third threshold, a fitted contour of the dynamic object contour according to each contour point on the dynamic object contour, wherein smoothness of the fitted contour is higher than smoothness of the dynamic object contour;
[31] calculating a ratio of the number of fitted contour points on the fitted contour to the number of contour points on the dynamic object contour to obtain a second ratio;
[32] determining the dynamic object contour as a gas cloud contour when the second ratio is greater than a fourth threshold; and
[33] determining the dynamic object contour as a non-gas cloud contour when the second ratio is not greater than the fourth threshold.
[34] In combination with the first aspect, embodiments of the present disclosure provide a fourth possible implementation manner of the first aspect, wherein extracting static object contour from the second binary image, and determining whether the static object contour is a gas cloud contour, comprises:
[35] extracting static object contour from the second binary image, and determining whether the static object contour intersects the dynamic object contour; and
[36] determining, if the static object contour intersects the dynamic object contour, whether the static object contour is a gas cloud contour.
[37] In combination with the first aspect, embodiments of the present disclosure provide a fifth possible implementation manner of the first aspect, wherein before converting, for each spectral image containing a target object to be detected, the spectral image into a grayscale image, the method further comprises:
[38] acquiring a visible light image containing a target object to be detected and a plurality of consecutive spectral images;
[39] after fusing, when the static object contour is the gas cloud contour, the static object contour and the dynamic object contour to obtain the gas cloud contour of the detected leaked gas, the method further comprises:
[40] determining, for each pixel in the grayscale image, a preset pixel value interval to which a pixel value of the pixel in the grayscale image belongs;
[41] coloring a position of the pixel in the grayscale image by adopting a preset color value preconfigured for the preset pixel value interval, and obtaining a colored image corresponding to the grayscale image after each pixel position in the grayscale image is colored;
[42] cropping a colored gas cloud region at a position where the gas cloud contour is located from the colored image according to the gas cloud contour of the detected leaked gas; and
[43] superimposing the colored gas cloud region on a corresponding position of the visible light image to obtain a marked image.
[44] In combination with the first aspect, embodiments of the present disclosure provide a second possible implementation manner of the first aspect, wherein each spectral image corresponds to a respective marked image; after obtaining the marked image corresponding to each spectral image, the method further comprises:
[45] sorting each marked images according to a sequence of each spectral image and the marked image corresponding to each spectral image, and generating a leakage video of leaked gas based on the sorted marked image.
[46] In a second aspect, embodiments of the present disclosure provide a device for detecting gas leakage, comprising:
[47] a first conversion module, configured to convert, for each spectral image containing a target object to be detected, the spectral image into a grayscale image;
[48] a first extraction module, configured to extract dynamic foreground in the grayscale image through background subtraction to generate a corresponding first binary image, wherein white region in the first binary image represents an area of dynamic object and black region represents background area;
[49] a second extraction module, configured to extract dynamic object contour from the first binary image, and determining whether the dynamic object contour is a gas cloud contour;
[50] a second conversion module, configured to take, when the dynamic object contour is the gas cloud contour, a minimum pixel value and a maximum pixel value of pixel within a region enclosed by the dynamic object contour in the grayscale image as a lower and upper bounds of a pixel interval; converting pixels with pixel value within the pixel interval in the grayscale image to white and pixel with pixel value outside the pixel interval to black, to generate a corresponding second binary image;
[51] a third extraction module, configured to extract static object contour from the second binary image, and determining whether the static object contour is a gas cloud contour; and
[52] a fusion module, configured to fuse, when the static object contour is the gas cloud contour, the static object contour and the dynamic object contour to obtain the gas cloud contour of the detected leaked gas.
[53] In combination with the first aspect, embodiments of the present disclosure provide a first possible implementation manner of the first aspect, the first extraction module is configured to extract dynamic foreground in the grayscale image through background subtraction to generate a corresponding first binary image, specifically configured to:
[54] perform noise reduction processing on the grayscale image via Gaussian filtering to obtain a denoised smoothed image; and
[55] extract dynamic foreground in the smoothed image by Gaussian background subtraction to generate a corresponding first binary image.
[56] In combination with the second aspect, embodiments of the present disclosure provide a second possible implementation manner of the second aspect, wherein the device comprises:
[57] a dividing module, configured to evenly divide the first binary image into a grid square image before the second extraction module extracts the dynamic object contour from the first binary image;
[58] a first determination module, configured to determine, for each grid cell in the grid mesh image, the grid cell as a target grid cell and making the grid cell as a first value when the grid cell contains a white region, and marking the grid cell as a second value when the grid cell contains no white region;
[59] a first calculation module, configured to calculate a ratio of number of target grid cells to number of all grid cells in the grid mesh image to obtain a first ratio;
[60] a second determination module, configured to determine the first binary image as a non-rain-snow scene image when the first ratio is smaller than a first threshold;
[61] a second calculation module, configured to calculate, if the first ratio is greater than or equal to the first threshold, for each row of grid cells in the grid mesh image, a value of the each row of grid cells to obtain a first sum value of the each row of grid cells according to a value of each grid cell in the row, and calculating, for each column of grid cells in the grid mesh image, a value of each column of grid cells to obtain a second sum value of the column of grid cells according to the value of each grid cell in the column of grid cells; the values including the first value and the second value;
[62] a judgment module, configured to determine, for the first sum value respectively corresponding to each row of grid cells, whether all first sum values follow a uniform distribution, and for the second sum value respectively corresponding to each column of grid cells, determining whether all second sum values follow a uniform distribution;
[63] a third determination module, configured to determine the first binary image as a rain-snow scene image when all first sum values follow the uniform distribution and all second sum values follow the uniform distribution; and
[64] a fourth determination module, configured to determine the first binary image as a non-rain-snow scene image when all first sum values do not follow the uniform distribution and / or all second sum values do not follow the uniform distribution;
[65] the second extraction module is configured to extract dynamic object contour from the first binary image, specifically configured to:
[66] extract dynamic object contour from the first binary image when the first binary image is a non-rain-snow scene image.
[67] In combination with the second aspect, embodiments of the present disclosure provide a third possible implementation manner of the second aspect, the second extraction module is configured to determine whether the dynamic object contour is a gas cloud contour, specifically configured to:
[68] calculate number of contour points on the dynamic object contour and a region area of the dynamic object contour;
[69] determine the dynamic object contour as a point-shaped gas cloud contour when the number of contour points is less than a second threshold and the region area is less than a third threshold;
[70] fit, when the number of contour points is not less than the second threshold and / or the region area is not less than the third threshold, a fitted contour of the dynamic object contour according to each contour point on the dynamic object contour, wherein smoothness of the fitted contour is higher than smoothness of the dynamic object contour;
[71] calculate a ratio of the number of fitted contour points on the fitted contour to the number of contour points on the dynamic object contour to obtain a second ratio;
[72] determine the dynamic object contour as a gas cloud contour when the second ratio is greater than a fourth threshold; and
[73] determine the dynamic object contour as a non-gas cloud contour when the second ratio is not greater than the fourth threshold.
[74] In combination with the second aspect, embodiments of the present disclosure provide a fourth possible implementation manner of the second aspect, the third extraction module is configured to extract static object contour from the second binary image, and determining whether the static object contour is a gas cloud contour, specifically configured to:
[75] extract static object contour from the second binary image, and determining whether the static object contour intersects the dynamic object contour; and
[76] determine, if the static object contour intersects the dynamic object contour, whether the static object contour is a gas cloud contour.
[77] In combination with the second aspect, embodiments of the present disclosure provide a fifth possible implementation manner of the second aspect, wherein the device comprises:
[78] an acquisition module, configured to acquire a visible light image containing a target object to be detected and a plurality of consecutive spectral images before the first conversion module converts each spectral image containing the target object to be detected into a grayscale image;
[79] a fifth determination module, configured to, after the fusion module fuses the static object contour and the dynamic object contour to obtain a gas cloud contour of detected leaked gas when the static object contour is a gas cloud contour, determine a preset pixel value interval to which the pixel value of each pixel in the grayscale image belongs for every pixel in the grayscale image;
[80] a coloring module, configured to color a position of the pixel in the grayscale image by adopting a preset color value preconfigured for the preset pixel value interval, and obtaining a colored image corresponding to the grayscale image after each pixel position in the grayscale image is colored;
[81] a cropping module, configured to crop a colored gas cloud region at a position where the gas cloud contour is located from the colored image according to the gas cloud contour of the detected leaked gas; and
[82] an overlay module, configured to superimpose the colored gas cloud region on a corresponding position of the visible light image to obtain a marked image.
[83] In combination with the fifth possible implementation manner of the second aspect, embodiments of the present disclosure provide a sixth possible implementation manner of the second aspect, wherein each spectral image corresponds to a respective marked image; the device further comprises:
[84] a generation module, configured to, after the fusion module obtains the marked image corresponding to each of the spectral images, sort each marked images according to a sequence of each spectral image and the marked image corresponding to each spectral image, and generating a leakage video of leaked gas based on the sorted marked image.
[85] In a third aspect, embodiments of the present disclosure further provide 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 communicates with the memory through the bus; the machine-readable instructions, when executed by the processor, perform steps in any possible implementation manner of the foregoing first aspect during execution.
[86] In a fourth aspect, embodiments of the present disclosure further provide a computer-readable storage medium having a computer program stored thereon; when the computer program is executed by a processor, the monitoring method for a dental brace for monitoring health indicators according to the foregoing first aspect is implemented.
[87] The embodiments of the present disclosure provide a gas leakage detection method, an apparatus, an electronic device and a readable storage medium. When the static object contour is a gas cloud contour, the static object contour (i.e., static gas cloud contour) is fused with the dynamic object contour (i.e., dynamic gas cloud contour) to form an intact gas cloud contour of leaked gas. Compared with the single-point detection mode in the prior art, the solution of the present embodiment can detect a more complete gas cloud contour of leaked gas, which helps improve the comprehensiveness of gas leakage detection.
[88] To make the foregoing objectives, features and advantages of the present disclosure more apparent and understandable, preferred embodiments are described hereinafter in detail with reference to the accompanying drawings.BRIEF DESCRIPTION OF DRAWINGS
[89] In order to provide a clearer explanation of the technical solution in the embodiments of the present invention, a brief introduction will be given to the drawings required for the description of the embodiments. It is obvious that the accompanying drawings are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative labor.
[90] FIG. 1 illustrates a flowchart of a gas leakage detection method provided by embodiments of the present disclosure.
[91] FIG. 2 illustrates schematic diagrams of a grayscale image and a smoothed image provided by embodiments of the present disclosure.
[92] FIG. 3 illustrates a structural schematic diagram of a gas leakage detection apparatus provided by embodiments of the present disclosure.
[93] FIG. 4 illustrates a structural schematic diagram of an electronic device provided by embodiments of the present disclosure.DETAILED DESCRIPTION
[94] The following will provide a clear and complete description of the technical solution in the embodiments of the present invention, with reference to the drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, not all of them. Generally, the components of the embodiments of the present disclosure described and illustrated in the accompanying drawings herein may be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present disclosure provided in the accompanying drawings is not intended to limit the scope of the claimed present disclosure, but merely to illustrate selected embodiments of the present disclosure. All other embodiments obtained by those skilled in the art based on the embodiments of the present disclosure without creative efforts shall fall within the protection scope of the present disclosure.
[95] At present, gas leakage detection technologies are roughly divided into two categories.
[96] The first category is gas leakage detection based on gas detection sensors. For this detection method, the gas detection sensor must be in contact with gas to detect leakage. It belongs to single-point detection and cannot detect the shape and size of gas clouds. Furthermore, gas detection sensors are difficult to install and maintain in certain scenarios (such as the top of chemical gas tanks).
[97] The second category is gas detection based on infrared optical gas imaging. Optical gas imagers are specially designed to "visualize" various gases including hydrocarbons. They can detect gas within the imaging area with a wide detection range and reflect gas distribution. With the advancement of optical gas imaging technology, this gas detection method has been increasingly widely adopted.
[98] There are roughly two ways to detect gas leaks with optical gas imagers: the first is manual inspection: personnel hold an optical gas imager to capture footage of the detection area and identify gas clouds visually from the video stream. The second is fixed-point monitoring: the optical gas imager is installed at a fixed position to record the detection area, video footage is automatically transmitted to an identification system, and computer vision technology automatically identifies gas and marks gas clouds from the video. This approach is evidently timelier and more efficient.
[99] Gas visual recognition technologies based on optical gas imager video generally consist of two stages:
[100] Stage 1: Extract moving targets using consecutive frames based on gas motion characteristics. All detected moving targets are preliminarily regarded as potential gas clouds. Common algorithms for this stage include frame differencing, background subtraction, optical flow, etc.
[101] Stage 2: Further analyze the extracted moving targets to determine whether they are gas clouds. This stage is divided into two subcategories:
[102] 1) Traditional machine learning Feature values of gas clouds are extracted, such as texture features (LBP, DWT) and morphological features (HOG). Classification algorithms then categorize targets into gas and non-gas groups according to the extracted features. Widely used classification algorithms include SVM, KNN, AdaBoost, Random Forest, and so on.
[103] 2) Deep CNN machine learning Custom neural network models may be self-designed, or off-the-shelf models such as YOLO can be utilized.
[104] For gas recognition technology based on optical imager videos, the core foundation lies in Step 1, which is extracting moving gas clouds. Nevertheless, this approach has the following disadvantage: portions of a gas cloud may stay static across successive frames, and such static regions will be classified as background and fail to be extracted, leading to missed detection of static gas clouds. This defect severely impairs the accuracy of gas leakage volume estimation.
[105] The primary challenge of optical imager video-based gas recognition lies in Step 2, determining whether a detected moving target is a gas cloud. Existing solutions for this step have the following drawbacks.
[106] Deep learning requires massive labeled datasets. However, gas leakage events occur rarely under highly variable field conditions, making image data collection extremely difficult and obstructing the effective training of stable, reliable recognition models.
[107] Traditional machine learning methods that extract gas feature values from static images for classification also yield suboptimal results, for the following reasons: optical imagers capture infrared imagery which can only be processed as grayscale images (all color features are lost), and the captured images have relatively low resolution. As a result, texture features of gas clouds cannot be easily distinguished from background textures. In addition, gas clouds present irregular, variable shapes, so morphological features also deliver poor discriminative performance.
[108] In view of the aforementioned problems, embodiments of the present disclosure provide a gas leakage detection method, an apparatus, an electronic device, and a computer-readable storage medium, which will be described in detail through the following embodiments.
[109] Embodiment 1
[110] To facilitate comprehension of the present embodiment, the gas leakage detection method disclosed in the embodiments of the present disclosure is elaborated in detail first. FIG. 1 illustrates a flowchart of a gas leakage detection method provided by embodiments of the present disclosure. As shown in FIG. 1, the method includes the following steps S101 to S106:
[111] S101: converting, for each spectral image containing a target object to be detected, the spectral image into a grayscale image.
[112] In this embodiment, the target object to be detected refers to equipment with gas leakage risks that requires gas leakage inspection, such as gas tanks, pipelines and valves for gas storage or transportation. Since gas is generally colorless and invisible to human eyes, regular gas leakage inspection shall be carried out on the target object to be detected.
[113] In this embodiment, one visible light camera and one spectral camera are arranged around the target object to be detected. The distance between the lens of the visible light camera and the lens of the spectral camera is smaller than a preset distance, that is, the two lenses are placed closely to each other. The visible light camera and the spectral camera adopt the same shooting angle when capturing the target object to be detected, and both cameras remain stationary during shooting.
[114] The spectral camera captures one spectral image at preset time intervals. For example, one frame is captured every 10 seconds, and a total of 50 frames of spectral images are collected. During the collection of spectral images, one visible light image containing the target object to be detected is captured by the visible light camera.
[115] In one possible implementation manner, before executing S101, the following operation may also be performed: acquiring the visible light image containing the target object to be detected from the visible light camera and acquiring a plurality of consecutive spectral images containing the target object to be detected from the spectral camera.
[116] The multiple consecutive spectral images are, for example, spectral images captured at the 1st second, the 6th second, the 11th second, and so on.
[117] In this embodiment, after acquiring the multiple consecutive spectral images, each spectral image is converted into a grayscale image. FIG. 2 shows schematic diagrams of a grayscale image and a smoothed image provided by the embodiments of the present disclosure. As shown in FIG. 2, the left diagram is the schematic diagram of the grayscale image. Each spectral image corresponds to one grayscale image.
[118] S102: extracting dynamic foreground in the grayscale image through background subtraction to generate a corresponding first binary image, wherein white region in the first binary image represents an area of dynamic object and black region represents background.
[119] In one possible implementation manner, S102 may be specifically executed according to the following steps S1021 to S1022:
[120] S1021: performing noise reduction processing on the grayscale image via Gaussian filtering to obtain a denoised smoothed image; and
[121] S1022: extracting dynamic foreground in the smoothed image by Gaussian background subtraction to generate a corresponding first binary image.
[122] In S1021, Gaussian filtering was adopted to perform image smoothing on the grayscale image, whose primary purpose is denoising the grayscale image. As shown in FIG. 2, the right graph is the schematic diagram of the smoothed image. Each grayscale image corresponds to one denoised smoothed image; therefore, each spectral image corresponds to one smoothed image.
[123] In S1022, each smoothed image corresponds to a first binary image, i.e., each grayscale image corresponds to a first binary image. The first binary image is a black-and-white image.
[124] In one possible implementation manner, the target object to be detected is generally arranged outdoors, and rainy or snowy weather interferes with gas leakage detection and causes inaccurate detection results. Accordingly, after generating the first binary image and before executing S103, the following S1023 to S10210 may be further performed to determine whether the current weather is rainy or snowy.
[125] S1023: evenly dividing the first binary image into a grid mesh image.
[126] In this embodiment, each first binary image is evenly divided into a grid image with N1 rows and N2 columns. N1 and N2 may be the same or different.
[127] S1024: determining, for each grid cell in the grid mesh image, the grid cell as a target grid cell and making the grid cell as a first value when the grid cell contains a white region and marking the grid cell as a second value when the grid cell contains no white region.
[128] In this embodiment, since the first binary image is a black-and-white image, the grid square image is also a black-and-white image. For each square in the grid square image:If the square contains a white area (e.g., the square is entirely white, or partially white and partially black), assign a first value to the square and identify the square as a target square. If the square is entirely filled with a black area, assign a second value to the square. The first value may be 1, and the second value may be 0.
[129] calculating a ratio of number of target grid cells to number of all grid cells in the grid mesh image to obtain a first ratio.
[130] In this embodiment, calculating a ratio of number of target grid cells to number of all grid cells in the grid mesh image to obtain a first ratio.
[131] determining the first binary image as a non-rain-snow scene image when the first ratio is smaller than a first threshold.
[132] S1027: calculating, if the first ratio is greater than or equal to the first threshold, for each row of grid cells in the grid mesh image, a value of the each row of grid cells to obtain a first sum value of the each row of grid cells according to a value of each grid cell in the row, and calculating, for each column of grid cells in the grid mesh image, a value of each column of grid cells to obtain a second sum value of the column of grid cells according to the value of each grid cell in the column of grid cells; the values including the first value and the second value.
[133] In this embodiment, if the first ratio is greater than or equal to the first threshold, sum the values of each row in the grid image horizontally to obtain N1 first sum values. Further, sum the values of each column in the grid image vertically to obtain N2 second sum values.
[134] S1028: determining, for the first sum value respectively corresponding to each row of grid cells, whether all first sum values follow a uniform distribution, and for the second sum value respectively corresponding to each column of grid cells, determining whether all second sum values follow a uniform distribution.
[135] In this embodiment, an equal distribution algorithm (such as the Kolmogorov-Smirnov Test, K-S test for short) is used to judge whether all first sum values follow a uniform distribution and whether all second sum values follow a uniform distribution.
[136] S1029: determining the first binary image as a rain-snow scene image when all first sum values follow the uniform distribution and all second sum values follow the uniform distribution.
[137] In this embodiment, if the first binary image is determined to be an image captured under rainy or snowy conditions, the gas leakage detection process will be terminated, that is, S103 and all subsequent steps will not be executed.
[138] S10210: determining the first binary image as a rain-snow scene image when all first sum values follow the uniform distribution and all second sum values follow the uniform distribution.
[139] In this embodiment, if the first binary image is identified as an image captured under non-rainy and non-snowy conditions, the gas leakage detection process proceeds, that is, S103 and all subsequent steps are continuously executed.
[140] S103: extracting dynamic object contour from the first binary image and determining whether the dynamic object contour is a gas cloud contour.
[141] In one possible implementation manner, when executing S103 to extract moving object contours from the first binary image, the following operations may be performed specifically: if the first binary image corresponds to a non-rainy and non-snowy scene, extract moving object contours from the first binary image.
[142] In this embodiment, the first binary image is a black-and-white image, in which white areas represent regions of moving objects and black areas represent background regions. Accordingly, the black-white boundaries in the first binary image are taken as moving object contours.
[143] Each first binary image corresponds to one moving object contour; thus, each grayscale image corresponds to one moving object contour, and similarly each spectral image corresponds to one moving object contour.
[144] When extracting moving object contours from the first binary image under non-rainy and non-snowy conditions, the following sub-steps may also be adopted.
[145] First, define a detection region within the first binary image that covers the target object to be detected, and the detection region accounts for 60% of the total area of the first binary image. This setup helps mitigate background interference.
[146] Next, further denoise the image within the detection region to eliminate motion noise. Specifically, a rectangular filter in morphological opening and closing operations is used to perform opening operation followed by closing operation on the image in the detection region. The opening operation removes small white speckles, while the closing operation fills tiny black cavities. Finally, extract moving object contours from the denoised detection region.
[147] In one possible implementation manner, when executing S103 to determine whether a moving object contour is a gas cloud contour, the process may be implemented through the following Steps S1031 to S1036:
[148] S1031: Calculating number of contour points on the dynamic object contour and a region area of the dynamic object contour.
[149] In this embodiment, a moving object contour is composed of a plurality of contour points.
[150] S1032: determining the dynamic object contour as a point-shaped gas cloud contour when the number of contour points is less than a second threshold and the region area is less than a third threshold.
[151] Point-shaped gas contours are a type of gas cloud contour. Therefore, if the number of contour points of a moving object contour is less than a second threshold and the enclosed region area is less than a third threshold, the moving object contour can be identified as a gas cloud contour.
[152] S1033: fitting, when the number of contour points is not less than the second threshold and / or the region area is not less than the third threshold, a fitted contour of the dynamic object contour according to each contour point on the dynamic object contour, wherein smoothness of the fitted contour is higher than smoothness of the dynamic object contour.
[153] S1034: calculating a ratio of the number of fitted contour points on the fitted contour to the number of contour points on the dynamic object contour to obtain a second ratio.
[154] In this embodiment, the fitted contour is smoother than the moving object contour, so their shapes differ. That is to say, the number of fitted contour points on the fitted contour may not equal the number of contour points on the moving object contour.
[155] S1035: determining the dynamic object contour as a gas cloud contour when the second ratio is greater than a fourth threshold.
[156] In this embodiment, a larger second ratio indicates that the moving object contour is less smooth. Since gas cloud contours are generally irregular and rough, a higher second ratio implies that the moving object contour is a gas cloud contour.
[157] S1036: determining the dynamic object contour as a gas cloud contour when the second ratio is greater than a fourth threshold.
[158] In this embodiment, a smaller second ratio means the moving object contour is smoother. Since gas cloud contours are generally rough and uneven, a lower second ratio indicates that the moving object contour is not a gas cloud contour.
[159] S104: taking, when the dynamic object contour is the gas cloud contour, a minimum pixel value and a maximum pixel value of pixel within a region enclosed by the dynamic object contour in the grayscale image as a lower and upper bounds of a pixel interval; converting pixels with pixel value within the pixel interval in the grayscale image to white and pixel with pixel value outside the pixel interval to black, to generate a corresponding second binary image.
[160] In this embodiment, for each first binary image, if the moving object contour therein is identified as a gas cloud contour, the grayscale image corresponding to this first binary image is determined. The minimum pixel value and maximum pixel value of all pixel points within the region enclosed by the moving object contour are extracted from the grayscale image, and the minimum pixel value and maximum pixel value are taken as the lower and upper limits of the pixel interval, respectively.
[161] S105: extracting static object contour from the second binary image and determining whether the static object contour is a gas cloud contour.
[162] In one possible implementation manner, S105 may be specifically executed according to the following steps S1051 to S1052:
[163] S1051: extracting static object contour from the second binary image and determining whether the static object contour intersects the dynamic object contour.
[164] In this embodiment, the second binary image is a black-and-white image, where white areas represent candidate regions of static gas clouds and black areas represent non-static gas cloud regions. The black-white boundaries in the second binary image are taken as static object contours.
[165] S1052: determining, if the static object contour intersects the dynamic object contour, whether the static object contour is a gas cloud contour.
[166] In this embodiment, whether a static object contour is a gas cloud contour can be determined by the following method.
[167] Calculate the number of contour points on the static object contour and the area of the region enclosed by the static object contour.
[168] If the number of contour points on the static object contour is less than the second threshold and the area of the region enclosed by the static object contour is less than the third threshold, the static object contour is identified as a point-shaped gas cloud contour.
[169] If the number of contour points on the static object contour is not less than the second threshold, and / or the area of the region enclosed by the static object contour is not less than the third threshold, a fitted contour of the static object contour is fitted according to each contour point on the static object contour; the smoothness of the fitted contour of the static object contour is higher than that of the static object contour.
[170] Calculate the ratio of the number of fitted contour points on the fitted contour of the static object contour to the number of contour points on the static object contour to obtain a third ratio.
[171] If the third ratio is greater than the fourth threshold, the static object contour is determined to be a gas cloud contour.
[172] If the third ratio is not greater than the fourth threshold, the static object contour is determined to be a non-gas cloud contour.
[173] S106: fusing, when the static object contour is the gas cloud contour, the static object contour and the dynamic object contour to obtain the gas cloud contour of the detected leaked gas.
[174] In this embodiment, when the static object contour is a gas cloud contour, the static object contour is fused with the moving object contour to obtain the gas cloud contour of leaked gas detected. Each spectral image corresponds to one gas cloud contour.
[175] In one possible implementation manner, after S106 is executed, the following S1071 to S1074 may be further performed:
[176] S1071: determining, for each pixel in the grayscale image, a preset pixel value interval to which a pixel value of the pixel in the grayscale image belongs.
[177] In this embodiment, the size of the visible light image is adjusted to match the size of the spectral image. All spectral images share the same dimension. The size of each grayscale image is consistent with that of the spectral image.
[178] A preset number of color values are defined, where a smaller color value corresponds to a lighter color. For illustration, ten color values may be defined.
[179] The pixel value range 0-255 is divided into a preset number of segments to form multiple preset pixel value intervals. As an example, dividing the 0-255 pixel range into 10 segments yields sequential preset pixel intervals: 0-25, 26-50, and so forth.
[180] In this embodiment, for each pixel in the grayscale image, the preset pixel value interval containing the pixel’s grayscale value is identified. For instance, if a pixel has a pixel value of 14, it falls within the preset pixel interval 0-25.
[181] S1072: coloring a position of the pixel in the grayscale image by adopting a preset color value preconfigured for the preset pixel value interval, and obtaining a colored image corresponding to the grayscale image after each pixel position in the grayscale image is colored.
[182] In this embodiment, each preset pixel value interval corresponds to a predefined color value, and different preset pixel value intervals correspond to different color values.
[183] After determining the preset pixel value interval to which the pixel belongs, the position of the pixel in the grayscale image is colored with the color value corresponding to this preset pixel value interval, so as to obtain a colored image corresponding to the grayscale image.
[184] In this embodiment, each grayscale image corresponds to its respective colored image.
[185] S1073: cropping a colored gas cloud region at a position where the gas cloud contour is located from the colored image according to the gas cloud contour of the detected leaked gas.
[186] In this embodiment, based on the gas cloud contour corresponding to the grayscale image, the colored gas cloud region at the position of the gas cloud contour is cropped from the colored image corresponding to the grayscale image.
[187] S1074: superimposing the colored gas cloud region on a corresponding position of the visible light image to obtain a marked image.
[188] In this embodiment, the colored gas cloud region is superimposed onto the corresponding position of the visible light image. If there is only one colored gas cloud region corresponding to the same grayscale image, a bounding box is drawn to mark this colored gas cloud region on the visible light image, to obtain a marked image corresponding to the grayscale image.
[189] If multiple colored gas cloud regions correspond to the same grayscale image, calculate the distance between every two adjacent colored gas cloud regions; when the distance is less than a preset distance, the two adjacent colored gas cloud regions are classified as one group, and a single bounding box is used to frame and mark this group on the visible light image; when the distance is greater than or equal to the preset distance, separate bounding boxes are adopted to mark the two adjacent colored gas cloud regions respectively on the visible light image. A marked image corresponding to the grayscale image is generated accordingly.
[190] In one possible implementation manner, each grayscale image corresponds to an individual marked image. Based on the correspondence between grayscale images and spectral images, the marked image corresponding to each spectral image can be determined. After acquiring the marked image matched with each spectral image, the following operations may be further carried out.
[191] Sorting each marked images according to a sequence of each spectral image and the marked image corresponding to each spectral image and generating a leakage video of leaked gas based on the sorted marked image.
[192] In this embodiment, the movement trajectory of gas leakage can be observed through the leakage video.
[193] In this embodiment, regarding the judgment method for identifying whether the contours of moving object gas clouds and static object gas areas are gas cloud contours, this embodiment neither adopts deep learning nor the conventional scheme of extracting static and dynamic gas cloud features and then applying classification algorithms. Instead, object contours are extracted from the foreground image obtained after background subtraction, and dynamic and static gas clouds are identified simply and efficiently by utilizing inherent feature properties of gas cloud contours. This method is straightforward, simple, stable and effective. Moreover, static object contours are fused into moving object contours to form complete gas cloud outlines. A rain and snow weather detection module is integrated to reduce false alarm rates. Detection results (gas cloud contours) are overlaid on visible light images for improved visualization performance.
[194] Embodiment 2
[195] Based on the same technical concept, the present application further provides a gas leakage detection apparatus. FIG. 3 illustrates a structural schematic diagram of the gas leakage detection apparatus provided in the embodiment of the present application. As shown in FIG. 3, the apparatus includes:
[196] a first conversion module 301, configured to convert, for each spectral image containing a target object to be detected, the spectral image into a grayscale image;
[197] a first extraction module 302, configured to extract dynamic foreground in the grayscale image through background subtraction to generate a corresponding first binary image, wherein white region in the first binary image represents an area of dynamic object and black region represents background area;
[198] a second extraction module 303, configured to extract dynamic object contour from the first binary image, and determining whether the dynamic object contour is a gas cloud contour;
[199] a second conversion module 304, configured to take, when the dynamic object contour is the gas cloud contour, a minimum pixel value and a maximum pixel value of pixel within a region enclosed by the dynamic object contour in the grayscale image as a lower and upper bounds of a pixel interval; converting pixels with pixel value within the pixel interval in the grayscale image to white and pixel with pixel value outside the pixel interval to black, to generate a corresponding second binary image;
[200] a third extraction module 305, configured to extract static object contour from the second binary image, and determining whether the static object contour is a gas cloud contour; and
[201] a fusion module 306, configured to fuse, when the static object contour is the gas cloud contour, the static object contour and the dynamic object contour to obtain the gas cloud contour of the detected leaked gas.
[202] In combination with the first aspect, embodiments of the present disclosure provide a first possible implementation manner of the first aspect, the first extraction module 302 is configured to extract dynamic foreground in the grayscale image through background subtraction to generate a corresponding first binary image. specifically configured to:
[203] perform noise reduction processing on the grayscale image via Gaussian filtering to obtain a denoised smoothed image; and
[204] extract dynamic foreground in the smoothed image by Gaussian background subtraction to generate a corresponding first binary image.
[205] Optionally, the device further comprises:
[206] a dividing module, configured to divide the first binary image into a grid of square cells evenly before the second extraction module 303 extracts moving object contours from the first binary image;
[207] a first determination module, configured to determine, for each grid cell in the grid mesh image, the grid cell as a target grid cell and making the grid cell as a first value when the grid cell contains a white region, and marking the grid cell as a second value when the grid cell contains no white region;
[208] a first calculation module, configured to calculate a ratio of number of target grid cells to number of all grid cells in the grid mesh image to obtain a first ratio;
[209] a second determination module, configured to determine the first binary image as a non-rain-snow scene image when the first ratio is smaller than a first threshold;
[210] a second calculation module, configured to calculate, if the first ratio is greater than or equal to the first threshold, for each row of grid cells in the grid mesh image, a value of the each row of grid cells to obtain a first sum value of the each row of grid cells according to a value of each grid cell in the row, and calculating, for each column of grid cells in the grid mesh image, a value of each column of grid cells to obtain a second sum value of the column of grid cells according to the value of each grid cell in the column of grid cells; the values including the first value and the second value;
[211] a judgment module, configured to determine, for the first sum value respectively corresponding to each row of grid cells, whether all first sum values follow a uniform distribution, and for the second sum value respectively corresponding to each column of grid cells, determining whether all second sum values follow a uniform distribution;
[212] a third determination module, configured to determine the first binary image as a rain-snow scene image when all first sum values follow the uniform distribution and all second sum values follow the uniform distribution; and
[213] a fourth determination module, configured to determine the first binary image as a non-rain-snow scene image when all first sum values do not follow the uniform distribution and / or all second sum values do not follow the uniform distribution;
[214] the second extraction module 303 is configured to extract dynamic object contour from the first binary image, specifically configured to:
[215] extract dynamic object contour from the first binary image when the first binary image is a non-rain-snow scene image.
[216] Optionally, the second extraction module is configured to determine whether the dynamic object contour is a gas cloud contour, specifically configured to:
[217] calculate number of contour points on the dynamic object contour and a region area of the dynamic object contour;
[218] determine the dynamic object contour as a point-shaped gas cloud contour when the number of contour points is less than a second threshold and the region area is less than a third threshold;
[219] fit, when the number of contour points is not less than the second threshold and / or the region area is not less than the third threshold, a fitted contour of the dynamic object contour according to each contour point on the dynamic object contour, wherein smoothness of the fitted contour is higher than smoothness of the dynamic object contour;
[220] calculate a ratio of the number of fitted contour points on the fitted contour to the number of contour points on the dynamic object contour to obtain a second ratio;
[221] determine the dynamic object contour as a gas cloud contour when the second ratio is greater than a fourth threshold; and
[222] determine the dynamic object contour as a non-gas cloud contour when the second ratio is not greater than the fourth threshold.
[223] Optionally, the third extraction module 305, configured to extract static object contour from the second binary image, and determining whether the static object contour is a gas cloud contour; specifically configured to:
[224] extract static object contour from the second binary image, and determining whether the static object contour intersects the dynamic object contour; and
[225] determine, if the static object contour intersects the dynamic object contour, whether the static object contour is a gas cloud contour.
[226] Optionally, the device further comprises:
[227] an acquisition module, configured to acquire a visible light image containing a target object to be detected and a plurality of consecutive spectral images before the first conversion module 301 converts each spectral image containing the target object to be detected into a grayscale image;
[228] a fifth determination module, configured to, after the fusion module fuses the static object contour and the dynamic object contour to obtain a gas cloud contour of detected leaked gas when the static object contour is a gas cloud contour, determine a preset pixel value interval to which the pixel value of each pixel in the grayscale image belongs for every pixel in the grayscale image;
[229] a coloring module, configured to color a position of the pixel in the grayscale image by adopting a preset color value preconfigured for the preset pixel value interval, and obtaining a colored image corresponding to the grayscale image after each pixel position in the grayscale image is colored;
[230] a cropping module, configured to crop a colored gas cloud region at a position where the gas cloud contour is located from the colored image according to the gas cloud contour of the detected leaked gas; and
[231] an overlay module, configured to superimpose the colored gas cloud region on a corresponding position of the visible light image to obtain a marked image.
[232] Optionally, each of the spectral images corresponds to a respective marked image; the apparatus further comprises:
[233] a generation module, configured to, after the fusion module obtains the marked image corresponding to each of the spectral images, sort each marked images according to a sequence of each spectral image and the marked image corresponding to each spectral image, and generating a leakage video of leaked gas based on the sorted marked image.
[234] Embodiment 3
[235] FIG. 4 is a structural schematic diagram of an electronic device provided by an embodiment of the present application, which includes 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 executes the foregoing information processing method, the processor 401 communicates with the memory 402 via the bus 403, and the processor 401 executes the machine-readable instructions to implement the method steps described in Embodiment 1.
[236] Embodiment 4
[237] Embodiment 4 of the present application further provides a computer-readable storage medium storing a computer program thereon. When the computer program is run by a processor, the method steps set forth in Embodiment 1 are performed.
[238] Those skilled in the art may clearly understand that for the sake of concise description, the specific working processes of the apparatus, electronic device and computer-readable storage medium described above may refer to the corresponding processes in the foregoing method embodiments, and repeated descriptions are omitted herein.
[239] In the several embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other manners. The apparatus embodiments described above are merely illustrative. For example, the division of modules is merely a logical function division, and alternative division manners may be adopted in actual implementation. For another example, multiple modules or components may be combined or integrated into another system, or some features may be omitted or not executed. In addition, the displayed or discussed mutual coupling, direct coupling or communication connection may be indirect coupling or communication connection through certain communication interfaces between apparatuses or units, and may be electrical, mechanical or in other forms.
[240] Units described as separate components may or may not be physically separated, and components displayed as units may or may not be physical units, i.e., they may be located at a single position or distributed over multiple network units. Part or all of the units may be selected according to actual needs to achieve the objectives of the solutions of the present embodiments.
[241] Furthermore, each functional unit in each embodiment of the present application may be integrated into one processing unit, each unit may exist physically and independently, or two or more units may be integrated into a single unit.
[242] If the functions are implemented in the form of software functional units and sold or used as an independent product, they may be stored in a non-volatile computer-readable storage medium executable by a processor. Based on such understanding, the technical solutions of the present application, or the portions contributing to the prior art, or partial parts of the technical solutions may be embodied in the form of a software product stored in a storage medium and containing several instructions for instructing a computer device (which may be a personal computer, a server, a network device, etc.) to execute all or part of the steps of the methods described in each embodiment of the present application. The aforementioned storage medium includes various media capable of storing 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 disc.
[243] Finally, it should be noted that the above embodiments merely represent specific implementations of the present application and are intended to illustrate rather than limit the technical solutions thereof. The protection scope of the present application is not limited thereto. Although the present application has been described in detail with reference to the foregoing embodiments, a person of ordinary skill in the relevant art shall appreciate that any person skilled in the technical field may still modify the technical solutions recorded in the foregoing embodiments, or readily conceive variations thereto, or perform equivalent replacements for part of the technical features within the technical scope disclosed by the present application. Such modifications, variations or replacements shall not depart from the spirit and scope of the technical solutions of the embodiments of the present application, and all shall fall within the protection scope of the present application. Accordingly, the protection scope of the present application shall be subject to the protection scope of the appended claims.
Claims
A method for detecting gas leakage, comprising:converting, for each spectral image containing a target object to be detected, the spectral image into a grayscale image;extracting dynamic foreground in the grayscale image through background subtraction to generate a corresponding first binary image, wherein white region in the first binary image represents an area of dynamic object and black region represents background area;extracting dynamic object contour from the first binary image, and determining whether the dynamic object contour is a gas cloud contour;taking, when the dynamic object contour is the gas cloud contour, a minimum pixel value and a maximum pixel value of pixel within a region enclosed by the dynamic object contour in the grayscale image as a lower and upper bounds of a pixel interval; converting pixels with pixel value within the pixel interval in the grayscale image to white and pixel with pixel value outside the pixel interval to black, to generate a corresponding second binary image;extracting static object contour from the second binary image, and determining whether the static object contour is a gas cloud contour; andfusing, when the static object contour is the gas cloud contour, the static object contour and the dynamic object contour to obtain the gas cloud contour of the detected leaked gas. The method according to claim 1, whereinextracting dynamic foreground in the grayscale image through background subtraction to generate a corresponding first binary image, comprises:performing noise reduction processing on the grayscale image via Gaussian filtering to obtain a denoised smoothed image; andextracting dynamic foreground in the smoothed image by Gaussian background subtraction to generate a corresponding first binary image. The method according to claim 1, whereinbefore extracting dynamic object contour from the first binary image, the method further comprises:evenly dividing the first binary image into a grid mesh image;determining, for each grid cell in the grid mesh image, the grid cell as a target grid cell and making the grid cell as a first value when the grid cell contains a white region, and marking the grid cell as a second value when the grid cell contains no white region;calculating a ratio of number of target grid cells to number of all grid cells in the grid mesh image to obtain a first ratio;determining the first binary image as a non-rain-snow scene image when the first ratio is smaller than a first threshold;calculating, if the first ratio is greater than or equal to the first threshold, for each row of grid cells in the grid mesh image, a value of the each row of grid cells to obtain a first sum value of the each row of grid cells according to a value of each grid cell in the row, and calculating, for each column of grid cells in the grid mesh image, a value of each column of grid cells to obtain a second sum value of the column of grid cells according to the value of each grid cell in the column of grid cells; the values including the first value and the second value;determining, for the first sum value respectively corresponding to each row of grid cells, whether all first sum values follow a uniform distribution, and for the second sum value respectively corresponding to each column of grid cells, determining whether all second sum values follow a uniform distribution;determining the first binary image as a rain-snow scene image when all first sum values follow the uniform distribution and all second sum values follow the uniform distribution; anddetermining the first binary image as a non-rain-snow scene image when all first sum values do not follow the uniform distribution and / or all second sum values do not follow the uniform distribution;wherein extracting dynamic object contour from the first binary image, comprises:extracting dynamic object contour from the first binary image when the first binary image is a non-rain-snow scene image. The method according to claim 1, whereinwherein determining whether the dynamic object contour is a gas cloud contour, comprises:Calculating number of contour points on the dynamic object contour and a region area of the dynamic object contour;determining the dynamic object contour as a point-shaped gas cloud contour when the number of contour points is less than a second threshold and the region area is less than a third threshold;fitting, when the number of contour points is not less than the second threshold and / or the region area is not less than the third threshold, a fitted contour of the dynamic object contour according to each contour point on the dynamic object contour, wherein smoothness of the fitted contour is higher than smoothness of the dynamic object contour;calculating a ratio of the number of fitted contour points on the fitted contour to the number of contour points on the dynamic object contour to obtain a second ratio;determining the dynamic object contour as a gas cloud contour when the second ratio is greater than a fourth threshold; anddetermining the dynamic object contour as a non-gas cloud contour when the second ratio is not greater than the fourth threshold. The method according to claim 1, whereinextracting static object contour from the second binary image, and determining whether the static object contour is a gas cloud contour, comprises:extracting static object contour from the second binary image, and determining whether the static object contour intersects the dynamic object contour; anddetermining, if the static object contour intersects the dynamic object contour, whether the static object contour is a gas cloud contour. The method according to claim 1, whereinbefore converting, for each spectral image containing a target object to be detected, the spectral image into a grayscale image, the method further comprises:acquiring a visible light image containing a target object to be detected and a plurality of consecutive spectral images;after fusing, when the static object contour is the gas cloud contour, the static object contour and the dynamic object contour to obtain the gas cloud contour of the detected leaked gas, the method further comprises:determining, for each pixel in the grayscale image, a preset pixel value interval to which a pixel value of the pixel in the grayscale image belongs;coloring a position of the pixel in the grayscale image by adopting a preset color value preconfigured for the preset pixel value interval, and obtaining a colored image corresponding to the grayscale image after each pixel position in the grayscale image is colored;cropping a colored gas cloud region at a position where the gas cloud contour is located from the colored image according to the gas cloud contour of the detected leaked gas; andsuperimposing the colored gas cloud region on a corresponding position of the visible light image to obtain a marked image. The method according to claim 6, whereineach spectral image corresponds to a respective marked image; after obtaining the marked image corresponding to each spectral image, the method further comprises:sorting each marked images according to a sequence of each spectral image and the marked image corresponding to each spectral image, and generating a leakage video of leaked gas based on the sorted marked image. A device for detecting gas leakage, comprising:a first conversion module, configured to convert, for each spectral image containing a target object to be detected, the spectral image into a grayscale image;a first extraction module, configured to extract dynamic foreground in the grayscale image through background subtraction to generate a corresponding first binary image, wherein white region in the first binary image represents an area of dynamic object and black region represents background area;a second extraction module, configured to extract dynamic object contour from the first binary image, and determining whether the dynamic object contour is a gas cloud contour;a second conversion module, configured to take, when the dynamic object contour is the gas cloud contour, a minimum pixel value and a maximum pixel value of pixel within a region enclosed by the dynamic object contour in the grayscale image as a lower and upper bounds of a pixel interval; converting pixels with pixel value within the pixel interval in the grayscale image to white and pixel with pixel value outside the pixel interval to black, to generate a corresponding second binary image;a third extraction module, configured to extract static object contour from the second binary image, and determining whether the static object contour is a gas cloud contour; anda fusion module, configured to fuse, when the static object contour is the gas cloud contour, the static object contour and the dynamic object contour to obtain the gas cloud contour of the detected leaked gas. 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 communicates with the memory through the bus; the machine-readable instructions, when executed by the processor, perform steps of the method according to any one of claims 1 to 7. A computer-readable storage medium storing a computer program thereon, wherein the computer program, when executed by a processor, implements steps of the method according to any one of claims 1 to 7.