Flame detection boundary dynamic expansion method, flame image cutting method and medium
Through the dynamic expansion of flame detection boundary and image cropping technology, the YOLOv5 model and obstacle density adjustment expansion step size is used to solve the problems of flame detection accuracy and environmental factors, and achieve more accurate and timely flame recognition.
Patent Information
- Application Number
- CN202411164562.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-23
- Publication Date
- 2024-12-03
AI Technical Summary
The existing flame detection methods have shortcomings in accurately identifying the source of the flame, and are greatly affected by spatial and environmental factors, resulting in untimely detection, missed or missed detection, affecting the fire extinguishing effect.
The flame detection boundary dynamic expansion method and flame image cropping method are used to obtain the flame boundary box through the YOLOv5-based object detection model, and dynamically adjust the expansion step size based on the obstacle density, gradually expand the flame boundary box until specific conditions are met, ensuring the flame in the image Accuracy of detection.
Improve the accuracy and real-time nature of flame detection. Through dynamic expansion and cropping technology, multi-objective images are turned into single-objective images, including sufficient background information, enhance the model's ability to recognize objects indefinite shapes, and improve the accuracy of flame detection. .
Smart Images

Figure CN119068176A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of flame image recognition, and in particular to a flame detection boundary dynamic expansion method, a flame image clipping method and a medium. Background Art
[0002] At present, the technology used in the domestic automatic fire detection and alarm system is relatively simple, mainly based on various sensors and detectors, such as smoke detectors, photosensitive detectors, etc. However, these detectors have two obvious disadvantages: first, they can only detect whether a fire has occurred, but cannot accurately identify the source of the fire, and cannot provide further assistance in the subsequent fire extinguishing stage; second, they are greatly affected by spatial and environmental factors, which may lead to untimely detection, missed detection, and false detection of fires, thus causing greater losses.
[0003] Compared with traditional machine vision methods, the increasingly mature deep learning technology has higher feature extraction efficiency. Among some current flame detection methods, the single-point multi-box detector is combined with the MobileNet model to design a construction site robot with a flame warning accuracy of more than 90% for multi-frame videos. The single-point multi-box detector combines the regression idea and anchor box idea in the Yolo algorithm to improve the real-time detection while ensuring the detection accuracy. In some other detection methods, Yolo and convolutional neural networks (CNN) are combined to make it more effective in generalized target representation while reducing accuracy loss. It is not difficult to see that among the existing target detection algorithms, the Yolo algorithm stands out among many target detection models due to its extremely fast detection speed.
[0004] Unlike many detection targets with fixed shapes, the shape of flames is constantly changing, so improving the model's ability to recognize objects with indefinite shapes is crucial to improving the model's detection accuracy. Therefore, some methods propose a target detection model based on DETR (Detection Transformer), which uses an end-to-end detection method to automatically extract features from the original image, and uses an attention mechanism to highlight important features and improve the accuracy of multi-scale target detection.
[0005] However, the above flame detection method still has the problem of low accurate flame recognition rate. Summary of the invention
[0006] The technical problem to be solved by the present application is to provide a method for dynamically expanding the boundary of flame detection, a method for cutting flame images and a medium, which have the characteristics of improving the accuracy of flame detection in images.
[0007] In a first aspect, an embodiment provides a method for dynamically expanding a flame detection boundary, comprising: Get the image object containing the flame; The image object is input into a target detection model based on YOLOv5 to obtain a flame bounding box and an obstacle bounding box, and each bounding box has a unique identifier; wherein each flame bounding box corresponds to only one flame, and there is no overlap between any two flame bounding boxes, the obstacle is a non-flame object, and each obstacle bounding box corresponds to only one obstacle; Get the coordinates of each bounding box and calculate the area of each flame bounding box; For any flame bounding box, expanding it based on a preset initial expansion ratio to obtain a first expanded bounding box; Expanding step by step based on the first expanded bounding box until an expansion end condition is met; wherein, for each step of expansion, an expansion step length is calculated, and expansion is performed based on the current expanded bounding box and the expansion step length; For each step of expansion, the expansion step length is calculated, and the expansion is performed based on the current expansion bounding box and the expansion step length, including: Calculate the number of obstacles within the current extended bounding box; Based on the calculated number of obstacles, the density of obstacles in the current extended bounding box is calculated; Based on the density of obstacles in the current extended bounding box, an expansion step is calculated, and the current extended bounding box is expanded based on the expansion step.
[0008] In one embodiment, obtaining the coordinates of each bounding box and calculating the area of the region contained in each flame bounding box includes: ; in, represents the area of any flame bounding box m, represents the coordinate of the upper right corner of any flame bounding box m in the x-axis direction, represents the coordinate of the upper right corner of any flame bounding box m in the y-axis direction, represents the coordinate of the lower left corner of any flame bounding box m in the x-axis direction, Represents the coordinate of the lower left corner of any flame bounding box m in the y-axis direction.
[0009] In one embodiment, the step of expanding any flame bounding box based on a preset initial expansion ratio to obtain a first expanded bounding box includes: The initial expansion ratio is preset based on the initial size of the flame bounding box and the size of the entire image object. ,in, ; Based on the preset initial expansion ratio, expand the flame bounding box up, down, left and right.
[0010] In one embodiment, the step of gradually expanding based on the first expanded bounding box until an expansion end condition is met includes: The expansion is performed step by step based on the first expansion boundary box until any one of a plurality of preset expansion end conditions is met; the plurality of expansion end conditions include: The first extension end condition is that the extension area exceeds or reaches the boundary of the image object; The second extension end condition is that the ratio of the area of the flame area within the extended boundary box to the area of the background area reaches a preset ratio threshold; The third extension end condition is that the change rate of the density of obstacles in the current extended bounding box compared to the density of obstacles in the previous extended bounding box reaches a preset change rate threshold; as well as, The fourth extension end condition is that the bounding box of the current extended bounding box touches other flame bounding boxes during or after the expansion.
[0011] In one embodiment, the step of calculating the number of obstacles in the current extended bounding box includes: Determine whether the area contained in the current extended bounding box covers the area contained in any obstacle bounding box, or overlaps with the area contained in any obstacle bounding box; if it covers the area contained in any obstacle bounding box, add 1 to the number of obstacles; if it overlaps with the area contained in any obstacle bounding box, calculate the ratio of the overlapping area to the area contained in any obstacle bounding box, and add the ratio to the number of obstacles.
[0012] In one embodiment, if the area included in any obstacle bounding box is covered, the number of obstacles is increased by 1, including: ; in, represents the number of fully covered obstacle bounding boxes, and Respectively represent the coordinates of the upper right corner of any obstacle bounding box i in the x-axis direction and the y-axis direction, and Respectively represent the coordinates of the lower left corner of any obstacle bounding box i in the x-axis direction and the y-axis direction; and Respectively represent the coordinates of the upper right corner of the current extended bounding box in the x-axis direction and the y-axis direction, and Respectively represent the coordinates of the lower left corner of the current extended bounding box in the x-axis direction and the y-axis direction; 1≤i≤N, N represents the total number of obstacle bounding boxes; Indicates an indicator function. The value of the function expression is 1 when it is true and 0 when it is false. Represents the AND logical operator.
[0013] In one embodiment, the step of calculating the density of obstacles in the current extended bounding box based on the calculated number of obstacles includes: ; in, Indicates the density of obstacles within the current extended bounding box. represents the number of obstacles calculated, Indicates the area of the current extended bounding box.
[0014] In one embodiment, the step of calculating the expansion step size based on the density of obstacles in the current expansion bounding box includes: ; in, Indicates the density of obstacles within the current extended bounding box. represents the extended step size, B represents the preset step size adjustment coefficient, B>0, and is used to represent the rate of controlling the step size adjustment.
[0015] In a second aspect, an embodiment provides a flame image cropping method, which crops an image object after the flame boundary box is expanded based on the flame detection boundary dynamic expansion method described in any of the above embodiments to obtain a target image of a single flame object.
[0016] In a third aspect, an embodiment provides a computer-readable storage medium, wherein the medium stores a program, and the program can be loaded by a processor to execute the method for dynamically expanding a flame detection boundary and / or the method for cropping a flame image described in any one of the above embodiments.
[0017] The beneficial effects of the present invention are: For any flame bounding box, on the one hand, the first extended bounding box is obtained by expanding based on a preset initial expansion ratio so that the flame bounding box is first expanded to obtain certain background information; on the other hand, the number of obstacles in the current extended bounding box is calculated, and the density of the obstacles in the current extended bounding box is calculated based on the calculated number of obstacles, and the expansion step is calculated based on the density of the obstacles in the current extended bounding box, and the current extended bounding box is expanded based on the expansion step, so that the flame bounding box is dynamically and step by step expanded, and the expansion step of each step of expansion is considered based on the obstacle density in the dynamic step by step expansion, so that the expansion step is dynamically adjusted based on the obstacle density, so that the original multi-target image is transformed into a single-target image containing sufficient background information, thereby improving the accuracy of flame detection in the image. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] Figure 1 This is a schematic diagram of a flow chart of a method for dynamically expanding a flame detection boundary according to an embodiment of the present application; Figure 2 It is a schematic diagram of an expansion process based on a current expansion bounding box and an expansion step size according to an embodiment of the present application. DETAILED DESCRIPTION
[0019] The present invention is further described in detail below by specific embodiments in conjunction with the accompanying drawings. Wherein similar elements in different embodiments adopt associated similar element numbers. In the following embodiments, many detailed descriptions are for making the present application better understood. However, those skilled in the art can easily recognize that some features can be omitted in different situations, or can be replaced by other elements, materials, methods. In some cases, some operations related to the present application are not shown or described in the specification, this is to avoid the core part of the present application being overwhelmed by too much description, and for those skilled in the art, it is not necessary to describe these related operations in detail, and they can fully understand the related operations according to the description in the specification and the general technical knowledge in the art.
[0020] In addition, the features, operations or characteristics described in the specification can be combined in any appropriate manner to form various implementations. At the same time, the steps or actions in the method description can also be interchanged or adjusted in a manner that is obvious to those skilled in the art. Therefore, the various sequences in the specification and the drawings are only for the purpose of clearly describing a certain embodiment and are not meant to be a required sequence, unless otherwise specified that a certain sequence must be followed.
[0021] The serial numbers assigned to the components in this article, such as "first", "second", etc., are only used to distinguish the objects described and do not have any order or technical meaning.
[0022] To facilitate the description of the inventive concept of the present application, the flame recognition technology is briefly described below.
[0023] The training sets of common flame recognition models are all flame images. Although this can reduce the false negative rate of the model in flame recognition, the flame entities in the data set are unevenly distributed and the generalization is poor. In some current technologies, when conducting similar data processing experiments, it is found that in the same training batch, the named entities with small frequencies will have a high false positive rate and poor recognition effect due to the small number of training times. Therefore, a series of data enhancement methods will be used to increase the generalization of the data set, reduce the false positive rate of the model, and improve the accuracy.
[0024] However, the applicant found in the study that in order to expand the data set of small samples, the most commonly used method in existing research is to randomly crop the image, and random cropping may cause effective information to be removed or partially lost.
[0025] In view of this, for a picture containing multiple target frames, in order to prevent the target frames from being cut and the generated picture from containing more background, the present application provides a method for dynamic expansion of flame detection boundaries, a flame image cropping method and a medium, by dynamically and gradually expanding the flame boundary box, and considering the expansion step length of each step of expansion based on the obstacle density in the dynamic step-by-step expansion, so that the expansion step length is dynamically adjusted based on the obstacle density, so that the original multi-target image is transformed into a single target image containing sufficient background information, thereby improving the accuracy of flame detection in the image.
[0026] In one embodiment of the present application, a method for dynamically expanding the flame detection boundary is provided. Figure 1 ,include: Step S10, obtaining an image object containing flames. The image object includes at least one flame target.
[0027] Step S20, input the image object into a target detection model based on YOLOv5 to obtain a flame bounding box and an obstacle bounding box, and each bounding box has a unique identifier.
[0028] Pre-trained object detection model based on YOLOv5, which is trained with labeled training data. The training dataset contains images of various flames and other objects, along with their corresponding bounding boxes and category labels.
[0029] Use the trained object detection model to perform object detection on the input image and obtain the bounding box and category label of each detected object. The bounding box varies according to the size of the object.
[0030] There is only one flame in each flame boundary box, and there is no intersection or overlap between any two flame boundary boxes. The obstacle is a non-flame object, and there is only one obstacle in each obstacle boundary box.
[0031] Step S30, obtaining the coordinates of each bounding box, and calculating the area of the region contained in each flame bounding box.
[0032] Read the input image and the corresponding target detection label information, including the bounding box coordinates of each target. Assume that the coordinates of the upper left corner of any flame bounding box m are , the coordinates of the lower right corner are . Then the area of the region contained in any flame boundary box can be expressed as: ; in, represents the area of any flame bounding box m, represents the coordinate of the upper right corner of any flame bounding box m in the x-axis direction, represents the coordinate of the upper right corner of any flame bounding box m in the y-axis direction, represents the coordinate of the lower left corner of any flame bounding box m in the x-axis direction, Represents the coordinate of the lower left corner of any flame bounding box m in the y-axis direction.
[0033] Step S40: For any flame boundary frame, expand it based on a preset initial expansion ratio to obtain a first expanded boundary frame.
[0034] For any flame bounding box, when it is first expanded, it is expanded according to a preset initial expansion ratio. The flame is expanded. During the expansion, the flame boundary frame is expanded to the surroundings based on a preset initial expansion ratio with the flame as the center. In one embodiment, the flame boundary frame is expanded upward, downward, leftward, and rightward, and the left and right expansion sizes are the same, and the upper and lower expansion sizes are the same.
[0035] In one embodiment, the preset initial expansion ratio can be determined based on the initial size of the flame bounding box and the size of the entire image. If the initial size is small and the size of the entire image is large, a larger initial expansion ratio is used. If the initial size is large and the size of the entire image is large, a smaller initial expansion ratio is used. The specific setting is made according to actual needs so that the expanded bounding box contains more background information.
[0036] In one embodiment, the setting range of the initial expansion ratio can be .
[0037] However, the applicant found in the study that the boundary expansion may exceed the image boundary. Based on this, in order to ensure that the image boundary is not exceeded during the expansion process, the size of the expansion area is adjusted according to the initial expansion ratio. The expansion area can be represented as: ; ; ; ; in, and They represent the coordinates of the upper right corner of the first extended bounding box of any flame bounding box m in the x-axis direction and the y-axis direction, respectively. and Respectively represent the coordinates of the lower left corner of the first extended bounding box of any flame bounding box m in the x-axis direction and the y-axis direction; , ; W and H represent the width and height of the image respectively.
[0038] Then we have: ; Represents the area of the region contained in the first extended bounding box of any flame bounding box m.
[0039] Step S50, gradually expand based on the first expanded bounding box until the expansion end condition is met. For each step of expansion, the expansion step length is calculated, and expansion is performed based on the current expanded bounding box and the expansion step length.
[0040] In one embodiment, please refer to Figure 2 , for each step of expansion, calculate the expansion step size, and expand based on the current expansion bounding box and the expansion step size, including: Step S501, calculating the number of obstacles in the current extended bounding box.
[0041] Those skilled in the art can understand that, for any flame bounding box, when expansion is performed based on the first expanded bounding box, the current expanded bounding box is the first expanded bounding box.
[0042] In one embodiment, the number of obstacles within the current extended boundary is divided into two cases, one is that the obstacle boundary box is completely within the current extended boundary box, and the other is that the obstacle boundary box is partially within the current extended boundary box. That is, it is determined whether the area included in the current extended boundary box covers the area included in any obstacle boundary box, or overlaps with the area included in any obstacle boundary box.
[0043] In the former case, that is, if the area included in any obstacle bounding box is covered, the number of obstacles is increased by 1. In the latter case, that is, if there is an overlap with the area included in any obstacle bounding box, the ratio of the overlapping area to the area included in any obstacle bounding box is calculated, and the ratio is added to the number of obstacles.
[0044] In one embodiment, if the area included in any obstacle bounding box is covered, the number of obstacles is increased by 1, including: ; in, represents the number of fully covered obstacle bounding boxes, and Respectively represent the coordinates of the upper right corner of any obstacle bounding box i in the x-axis direction and the y-axis direction, and Respectively represent the coordinates of the lower left corner of any obstacle bounding box i in the x-axis direction and the y-axis direction; and Respectively represent the coordinates of the upper right corner of the current extended bounding box in the x-axis direction and the y-axis direction, and Respectively represent the coordinates of the lower left corner of the current extended bounding box in the x-axis direction and the y-axis direction; 1≤i≤N, N represents the total number of obstacle bounding boxes; Indicates an indicator function. The value of the function expression is 1 when it is true and 0 when it is false. Represents the AND logical operator.
[0045] Based on the above formula, and Indicates checking whether the upper left corner is within the extended area; and Indicates checking whether the upper right corner is within the extended area; and Indicates checking whether the lower left corner is within the extended area; and Indicates checking whether the lower right corner is within the extended area. If all of the above relationships are satisfied, it means that any obstacle bounding box is within the current extended bounding box. If one of them is not satisfied, it means that there is only overlap.
[0046] For overlapping situations, in one embodiment, the method for obtaining the number of obstacles includes: First, for any obstacle bounding box that is in an overlapping situation, the overlapping area between the obstacle bounding box and the current extended bounding box is calculated, which can be expressed as: ; ; ; in, represents the length of overlap of any obstacle bounding box i in the x direction, represents the length of overlap of any obstacle bounding box i in the y direction, Represents the area of overlap between any obstacle bounding box i and the current extended bounding box.
[0047] Secondly, for any obstacle bounding box that belongs to the overlapping situation, calculate the overlap ratio, which can be expressed as: ; in, Indicates the overlap ratio, which can be a decimal or a fraction. Represents the area of the region contained by any obstacle bounding box i.
[0048] In this way, the overlap ratio corresponding to each obstacle bounding box belonging to the overlapping situation can be obtained, and all these overlap ratios are accumulated to the number of obstacles in the current bounding box, so as to calculate the final number of obstacles.
[0049] Step S502: Calculate the density of obstacles in the current extended bounding box based on the calculated number of obstacles.
[0050] In one embodiment, calculating the density of obstacles in the current extended bounding box based on the calculated number of obstacles may include: ; in, Indicates the density of obstacles within the current extended bounding box. represents the number of obstacles calculated, Indicates the area of the current extended bounding box.
[0051] Step S503: Calculate an expansion step length based on the density of obstacles in the current expanded bounding box, and expand the current expanded bounding box based on the expansion step length.
[0052] In one embodiment, step S503 may include: ; in, Indicates the density of obstacles within the current extended bounding box. represents the extended step size, B represents the preset step size adjustment coefficient, B>0, and is used to represent the rate of controlling the step size adjustment.
[0053] B can be adjusted to make the expansion amplitude of each step moderate, neither too large to cause over-expansion nor too small to affect efficiency. In one embodiment, B can be in the range of 1≤B≤4.
[0054] In one embodiment, the length, width and expansion step of the bounding box are all in pixels.
[0055] Retaining appropriate background information helps to learn the representation of flames in different environments and enhance the generalization ability in different scenarios. Based on the above expansion method, obstacles are an important part of the background information, and obstacle density is used as the adjustment standard of the expansion step, which can help learn this information more effectively.
[0056] The applicant found in the study that when the density of obstacles in the extended area is high, it means that there are more other targets or obstacles in the area. If it continues to expand significantly, it may include more non-flame targets, thereby affecting the accuracy of flame detection in the enhanced image. In addition, if the extended area is too large, it may introduce too much irrelevant background information, increase noise, and reduce the accuracy of detection.
[0057] In view of this, when the obstacle density in the expansion area is high, reducing the expansion step size can avoid over-expansion into the obstacle-dense area; areas with high obstacle density require more refined expansion to ensure that the boundaries of the flame target are captured without including too much background and other obstacles. A smaller expansion step size can provide more refined expansion control. By adjusting the expansion step size according to the obstacle density, unnecessary expansion can be prevented and the relevance of information in the expansion area can be maintained.
[0058] During the expansion process, by considering the obstacle density, a balance of the expansion area can be achieved. That is, in areas with low obstacle density, the step size can be larger to retain more background information; in areas with high obstacle density, the step size should be smaller to avoid introducing too much interference information. This ensures that each enhanced single target image contains an appropriate amount of background information and improves the quality of the training data.
[0059] Based on the above scheme, by reasonably controlling the expansion step size, unnecessary calculations can be avoided and the efficiency of data processing and enhancement can be optimized. Dynamically adjusting the expansion step size according to the obstacle density can improve the utilization efficiency of computing resources while ensuring the data enhancement effect.
[0060] In one embodiment, the step of gradually expanding based on the first expanded bounding box until an expansion end condition is met includes: The expansion is performed step by step based on the first expansion boundary box until any one of a plurality of preset expansion end conditions is met.
[0061] In one embodiment, multiple expansion end conditions may include: a first expansion end condition, the expansion area exceeds or reaches the boundary of the image object; a second expansion end condition, the ratio of the area of the flame area in the expansion boundary box to the area of the background area reaches a preset ratio threshold; a third expansion end condition, the rate of change of the density of the obstacle in the current expansion boundary box compared to the density of the obstacle in the previous expansion boundary box reaches a preset rate of change threshold; and a fourth expansion end condition, the boundary box of the current expansion boundary box touches other flame boundary boxes during or after expansion.
[0062] Among them, for the first extension end condition, if the extension area exceeds or reaches the boundary of the image object during the current extension, then in this extension, the extension is limited to the boundary of the image object and the extension is stopped.
[0063] For the second extension end condition, in one embodiment, the preset ratio threshold can take a value between 0.2 and 0.5. Specifically, it can be determined based on the obstacle density calculated based on the first extended bounding box. When the obstacle density is large, a larger ratio threshold is set, and when the obstacle density is small, a smaller ratio threshold is set.
[0064] For the third extension end condition, the rate of change of the density of obstacles in the current extended bounding box compared to the density of obstacles in the previous extended bounding box can be expressed as: ; in, represents the rate of change, Represents the obstacle density obtained after the current expansion step is expanded. Represents the obstacle density obtained after the expansion of the previous expansion step.
[0065] In each step of the expansion process, if the rate of change of the number of obstacles in the expansion area is lower than the preset rate of change threshold, the expansion is terminated.
[0066] In one embodiment, the preset change rate threshold may be between 0.01 and 0.06.
[0067] For the fourth extension end condition, if the boundary box of the current extension boundary box touches other flame boundary boxes during or after the extension, the extension is stopped at the position where the other flame boundary boxes are located.
[0068] In one embodiment, during the flame boundary frame expansion process, when any one of the above four expansion end conditions is reached, the expansion is stopped. In some embodiments, based on actual needs, the art can also arbitrarily set the expansion to stop when any two, three, or four of the above four expansion end conditions are reached.
[0069] Those skilled in the art can understand that, based on the above ideas, those skilled in the art can set other extension end conditions, all of which are within the protection scope of this application.
[0070] In one embodiment of the present application, a flame image cropping method is provided, which crops an image object after the flame boundary box is expanded based on the flame detection boundary dynamic expansion method of any of the above embodiments to obtain a target image of a single flame object. In this way, the target image of the single flame object obtained retains sufficient background information, thereby improving the accuracy of flame detection in the image.
[0071] In one embodiment of the present application, a computer-readable storage medium is provided, on which a program is stored. The stored program includes a method for dynamically expanding a flame detection boundary and / or a method for cropping a flame image in any of the above embodiments that can be loaded by a processor and processed.
[0072] Those skilled in the art will appreciate that all or part of the functions of the various methods in the above-mentioned embodiments can be implemented by hardware or by computer programs. When all or part of the functions in the above-mentioned embodiments are implemented by computer programs, the program can be stored in a computer-readable storage medium, and the storage medium can include: read-only memory, random access memory, disk, optical disk, hard disk, etc., and the program is executed by a computer to implement the above-mentioned functions. For example, the program is stored in the memory of the device, and when the program in the memory is executed by the processor, all or part of the above-mentioned functions can be implemented. In addition, when all or part of the functions in the above-mentioned embodiments are implemented by computer programs, the program can also be stored in a storage medium such as a server, another computer, disk, optical disk, flash disk or mobile hard disk, and can be downloaded or copied and saved in the memory of the local device, or the system of the local device is updated, and when the program in the memory is executed by the processor, all or part of the functions in the above-mentioned embodiments can be implemented.
[0073] The above specific examples are used to illustrate the present invention, which is only used to help understand the present invention and is not intended to limit the present invention. For those skilled in the art, according to the concept of the present invention, some simple deductions, modifications or substitutions can be made.
Claims
1. A method for dynamically expanding a flame detection boundary, characterized in that: include: Get the image object containing the flame; The image object is input into a target detection model based on YOLOv5 to obtain a flame bounding box and an obstacle bounding box, and each bounding box has a unique identifier; wherein each flame bounding box corresponds to only one flame, and there is no overlap between any two flame bounding boxes, the obstacle is a non-flame object, and each obstacle bounding box corresponds to only one obstacle; Get the coordinates of each bounding box and calculate the area of each flame bounding box; For any flame bounding box, expanding it based on a preset initial expansion ratio to obtain a first expanded bounding box; Expanding step by step based on the first expanded bounding box until an expansion end condition is met; wherein, for each step of expansion, an expansion step length is calculated, and expansion is performed based on the current expanded bounding box and the expansion step length; For each step of expansion, the expansion step length is calculated, and the expansion is performed based on the current expansion bounding box and the expansion step length, including: Calculate the number of obstacles within the current extended bounding box; Based on the calculated number of obstacles, the density of obstacles in the current extended bounding box is calculated; Based on the density of obstacles in the current extended bounding box, an expansion step is calculated, and the current extended bounding box is expanded based on the expansion step.
2. The method for dynamically expanding the flame detection boundary as claimed in claim 1, characterized in that: The obtaining of the coordinates of each bounding box and calculating the area of the region contained in each flame bounding box includes: ; in, represents the area of any flame bounding box m, represents the coordinate of the upper right corner of any flame bounding box m in the x-axis direction, represents the coordinate of the upper right corner of any flame bounding box m in the y-axis direction, represents the coordinate of the lower left corner of any flame bounding box m in the x-axis direction, Represents the coordinate of the lower left corner of any flame bounding box m in the y-axis direction.
3. The method for dynamically expanding the flame detection boundary as claimed in claim 1, characterized in that: The method of expanding any flame boundary frame based on a preset initial expansion ratio to obtain a first expanded boundary frame includes: The initial expansion ratio is preset based on the initial size of the flame bounding box and the size of the entire image object. ,in, ; Based on the preset initial expansion ratio, expand the flame bounding box up, down, left and right.
4. The method for dynamically expanding the flame detection boundary according to claim 1, characterized in that: The step of gradually expanding based on the first expanded bounding box until an expansion end condition is met includes: The expansion is performed step by step based on the first expansion boundary box until any one of a plurality of preset expansion end conditions is met; the plurality of expansion end conditions include: The first extension end condition is that the extension area exceeds or reaches the boundary of the image object; The second extension end condition is that the ratio of the area of the flame area within the extended boundary box to the area of the background area reaches a preset ratio threshold; The third extension end condition is that the change rate of the density of obstacles in the current extended bounding box compared to the density of obstacles in the previous extended bounding box reaches a preset change rate threshold; as well as, The fourth extension end condition is that the bounding box of the current extended bounding box touches other flame bounding boxes during or after the expansion.
5. The method for dynamically expanding the flame detection boundary according to claim 1, characterized in that: The calculation of the number of obstacles in the current extended bounding box includes: Determine whether the area contained in the current extended bounding box covers the area contained in any obstacle bounding box, or overlaps with the area contained in any obstacle bounding box; if it covers the area contained in any obstacle bounding box, add 1 to the number of obstacles; if it overlaps with the area contained in any obstacle bounding box, calculate the ratio of the overlapping area to the area contained in any obstacle bounding box, and add the ratio to the number of obstacles.
6. The method for dynamically expanding the flame detection boundary as claimed in claim 5, characterized in that: If the area covered by any obstacle bounding box is included, the number of obstacles is increased by 1, including: ; in, represents the number of fully covered obstacle bounding boxes, and Respectively represent the coordinates of the upper right corner of any obstacle bounding box i in the x-axis direction and the y-axis direction, and Respectively represent the coordinates of the lower left corner of any obstacle bounding box i in the x-axis direction and the y-axis direction; and Respectively represent the coordinates of the upper right corner of the current extended bounding box in the x-axis direction and the y-axis direction, and Respectively represent the coordinates of the lower left corner of the current extended bounding box in the x-axis direction and the y-axis direction; 1≤i≤N, N represents the total number of obstacle bounding boxes; Indicates an indicator function. The value of the function expression is 1 when it is true and 0 when it is false. Represents the AND logical operator.
7. The method for dynamically expanding the flame detection boundary according to claim 1, characterized in that: The calculation of the density of obstacles in the current extended bounding box based on the calculated number of obstacles includes: ; in, Indicates the density of obstacles within the current extended bounding box. represents the number of obstacles calculated, Indicates the area of the current extended bounding box.
8. The method for dynamically expanding the flame detection boundary as claimed in claim 1, characterized in that: The calculation of the expansion step length based on the density of obstacles in the current expansion bounding box includes: ; in, Indicates the density of obstacles within the current extended bounding box. represents the extended step size, B represents the preset step size adjustment coefficient, B>0, and is used to represent the rate of controlling the step size adjustment.
9. A flame image cutting method, characterized in that: The target image of a single flame object is obtained by cropping the image object after the flame boundary box is expanded based on the flame detection boundary dynamic expansion method according to any one of claims 1 to 8.
10. A computer-readable storage medium, characterized in that: The medium stores a program, which can be loaded by a processor and execute the method for dynamically expanding the flame detection boundary according to any one of claims 1 to 8 and / or the method for cutting the flame image according to claim 9.
