Smoking recognition method and related apparatus

After preprocessing and correcting the images, a pre-trained target detection model is used to identify smoking behavior, which solves the problems of lighting changes and complex background interference, and achieves high-precision and efficient smoking behavior recognition.

CN122369094APending Publication Date: 2026-07-10GUANGZHOU GUOXUN ROBOT TECH CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
GUANGZHOU GUOXUN ROBOT TECH CO LTD
Filing Date
2026-03-12
Publication Date
2026-07-10

AI Technical Summary

Technical Problem

In existing technologies, image recognition of smoking behavior is easily affected by changes in lighting and complex backgrounds, leading to frequent missed detections and false detections, which reduces the accuracy of smoking behavior recognition.

Method used

By acquiring the target image, candidate region images are extracted based on preset region parameters, and after image correction processing, they are input into a pre-trained target detection model (such as the YOLOv5 model). The existence of smoking behavior is determined by the target constraint conditions, and a valid region image is generated.

Benefits of technology

It improves the accuracy and efficiency of identifying smoking behavior, and reduces false detections and missed detections.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122369094A_ABST
    Figure CN122369094A_ABST
Patent Text Reader

Abstract

The application relates to a smoking identification method and a related device, which comprises the following steps: obtaining a target image to be processed, and extracting a candidate region image from the target image based on preset region parameters; performing image correction processing on the candidate region image to obtain a target region image; inputting the target region image into a pre-trained target detection model to obtain at least one candidate detection frame and a confidence corresponding to the candidate detection frame; judging whether a target detection frame meeting a target constraint condition exists in the candidate detection frame, and if the target detection frame exists, determining that a smoking behavior exists in the target image to be processed, and generating an effective region image. The scheme provided by the application can pre-process the image to be detected, and then input the image into a target detection model for detection, so as to judge whether a smoking behavior exists in the image to be detected, improve the identification precision and efficiency of the smoking behavior, and reduce the false detection and missed detection.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of image processing technology, and in particular to a smoking recognition method and related apparatus. Background Technology

[0002] Smoke detection technology has wide applications in ecosystems, especially in forest fires and human production and daily life. Smoke detection technology plays a crucial role in preventing the early spread of fires, and accurate and fast smoke detection algorithms have significant practical value. In recent years, with the rapid development of machine vision and image processing technologies, various technologies for smoke recognition through images have emerged.

[0003] Currently, the common method is to extract the color features of smoke or cigarettes from images through color space conversion and combine them with relevant thresholds to determine whether smoke or cigarettes are present in the image. However, this detection method is easily affected by changes in lighting and complex backgrounds, and it cannot identify the dynamic features of smoking actions, leading to frequent missed detections and false detections, which reduces the accuracy of smoking behavior recognition. Summary of the Invention

[0004] To address or partially address the problems existing in related technologies, this application provides a smoking recognition method and related apparatus, which can preprocess the image to be detected and then input it into a target detection model for detection to determine whether smoking behavior exists in the image to be detected. This can improve the recognition accuracy and efficiency of smoking behavior and reduce false detections and missed detections.

[0005] This application provides a smoking detection method, comprising: acquiring a target image to be processed, and extracting candidate region images from the target image based on preset region parameters; performing image correction processing on the candidate region images to obtain a target region image; inputting the target region image into a pre-trained target detection model, performing image detection processing on the target region image through the target detection model to obtain at least one candidate detection box and a confidence level corresponding to the candidate detection box; determining from the candidate detection boxes whether there is a target detection box that satisfies the target constraint conditions, and if the target detection box exists, determining that smoking behavior exists in the target image to be processed, and generating a valid region image; wherein the valid region image includes the target detection box.

[0006] In conjunction with the first aspect, in one possible implementation of the first aspect, the step of extracting candidate region images from the target image based on preset region parameters includes: obtaining coordinate information of at least one preset effective monitoring region based on the preset region parameters; determining an initial region image corresponding to the coordinate information from the target image based on the coordinate information; generating a polygon mask corresponding to the mask information according to the mask information in the preset region parameters; and performing bitwise operations on the initial region image based on the polygon mask to obtain the candidate region image.

[0007] In conjunction with the first aspect, in one possible implementation of the first aspect, the step of performing image correction processing on the candidate region image to obtain the target region image includes: extracting the target positioning region from the candidate region image; performing similarity matching calculation between the auxiliary positioning region and the preset reference region template based on a preset template matching algorithm to obtain the optimal offset of the candidate region image; and performing image correction processing on the candidate region image according to the optimal offset to obtain the target region image.

[0008] In conjunction with the first aspect, in one possible implementation of the first aspect, the pre-trained object detection model is a YOLOv5 model, and the pre-trained object detection model is in ONNX format.

[0009] In conjunction with the first aspect, in one possible implementation of the first aspect, before inputting the target region image into the pre-trained target detection model, the method further includes: normalizing and scaling the target region image to obtain an effective region image that matches the input size of the target detection model.

[0010] In conjunction with the first aspect, one possible implementation of the first aspect further includes: sorting the candidate detection boxes in descending order based on the confidence level corresponding to the candidate detection boxes; calculating the intersection-union ratio (IUU) between each candidate detection box and other candidate detection boxes based on the sorted order; and deleting redundant detection boxes if there are redundant detection boxes whose IUU with the current candidate detection box is greater than a preset IUU threshold.

[0011] In conjunction with the first aspect, in one possible implementation of the first aspect, the target constraint includes: the confidence level of the candidate detection box is greater than a preset confidence threshold, and the category ID of the candidate detection box is a preset category ID.

[0012] A second aspect of this application provides a smoking detection device, comprising: an acquisition module for acquiring a target image to be processed and extracting candidate region images from the target image based on preset region parameters; a correction module for performing image correction processing on the candidate region images to obtain a target region image; a processing module for inputting the target region image into a pre-trained target detection model and performing image detection processing on the target region image through the target detection model to obtain at least one candidate detection box and a confidence score corresponding to the candidate detection box; and a judgment module for judging whether there is a target detection box that satisfies the target constraint conditions from the candidate detection boxes. If the target detection box exists, it is determined that smoking behavior exists in the target image to be processed, and a valid region image is generated; wherein the valid region image includes the target detection box.

[0013] A third aspect of this application provides an electronic device, comprising: Processor; and A memory that stores executable code, which, when executed by the processor, causes the processor to perform the method described above.

[0014] A fourth aspect of this application provides a computer-readable storage medium having executable code stored thereon, which, when executed by a processor of an electronic device, causes the processor to perform the method described above.

[0015] The technical solution provided in this application may include the following beneficial effects: This application discloses a smoking detection method and related apparatus, comprising: acquiring a target image to be processed, and extracting candidate region images from the target image based on preset region parameters; performing image correction processing on the candidate region images to obtain a target region image; inputting the target region image into a pre-trained target detection model, and performing image detection processing on the target region image through the target detection model to obtain at least one candidate detection box and a confidence score corresponding to the candidate detection box; determining from the candidate detection boxes whether there is a target detection box that satisfies the target constraint conditions; if a target detection box exists, determining that smoking behavior exists in the target image to be processed, and generating a valid region image; wherein the valid region image includes the target detection box. This method can preprocess the image to be detected and then input it into the target detection model for detection to determine whether smoking behavior exists in the image to be detected, thereby improving the accuracy and efficiency of smoking behavior recognition and reducing false detections and missed detections.

[0016] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and do not limit this application. Attached Figure Description

[0017] The above and other objects, features and advantages of this application will become more apparent from the more detailed description of exemplary embodiments thereof in conjunction with the accompanying drawings, wherein the same reference numerals generally represent the same components in the exemplary embodiments thereof.

[0018] Figure 1 This is a schematic flowchart illustrating the smoking identification method according to an embodiment of this application; Figure 2 This is a schematic diagram of the structure of the smoking recognition device shown in the embodiments of this application; Figure 3 This is a schematic diagram of the structure of an electronic device shown in an embodiment of this application. Detailed Implementation

[0019] Embodiments of this application will now be described in more detail with reference to the accompanying drawings. While embodiments of this application are shown in the drawings, it should be understood that this application may be implemented in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided to make this application more thorough and complete, and to fully convey the scope of this application to those skilled in the art.

[0020] The terminology used in this application is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. The singular forms “a,” “the,” and “the” used in this application and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used herein refers to and includes any or all possible combinations of one or more of the associated listed items.

[0021] It should be understood that although the terms "first," "second," "third," etc., may be used in this application to describe various information, this information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, without departing from the scope of this application, first information may also be referred to as second information, and similarly, second information may also be referred to as first information. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of this application, "multiple" means two or more, unless otherwise explicitly specified.

[0022] Smoke detection technology has wide applications in ecosystems, especially in forest fires and human production and daily life. Smoke detection technology plays a crucial role in preventing the early spread of fires, and accurate and fast smoke detection algorithms have significant practical value. In recent years, with the rapid development of machine vision and image processing technologies, various technologies for smoke recognition through images have emerged.

[0023] Currently, the common method is to extract the color features of smoke or cigarettes from images through color space conversion and combine them with relevant thresholds to determine whether smoke or cigarettes are present in the image. However, this detection method is easily affected by changes in lighting and complex backgrounds, and it cannot identify the dynamic features of smoking actions, leading to frequent missed detections and false detections, which reduces the accuracy of smoking behavior recognition.

[0024] To address the aforementioned issues, this application provides a smoking identification method and related apparatus, which can preprocess the image to be detected and then input it into a target detection model for detection to determine whether smoking behavior exists in the image to be detected. This can improve the accuracy and efficiency of smoking behavior identification and reduce false detections and missed detections.

[0025] The technical solutions of the embodiments of this application are described in detail below with reference to the accompanying drawings.

[0026] Figure 1 This is a schematic flowchart illustrating the smoking identification method in an embodiment of this application.

[0027] See Figure 1 A method for identifying smoking includes: S110: Acquire the target image to be processed, and extract candidate region images from the target image based on preset region parameters.

[0028] Specifically, a camera can be used to capture images of the target area to obtain the target image to be processed. The target image is the original image to be used for smoking behavior recognition. The preset area parameters can be set according to the actual application scenario to limit the effective monitoring range in the image. For example, multiple coordinates can form corresponding areas in the image. Through the preset area parameters, local images can be extracted from the target image to obtain the required monitoring area, reducing the number of images that need to be processed later and improving processing efficiency and accuracy.

[0029] S120: Perform image correction processing on the candidate region image to obtain the target region image.

[0030] Specifically, after obtaining the candidate region image, the candidate region image can be corrected. For example, when the surveillance camera shakes slightly or the image shifts, the content in the candidate region image may deviate from its standard position. After correction, the target region image that meets the expectations can be obtained.

[0031] S130: Input the target region image into the pre-trained target detection model, and perform image detection processing on the target region image through the target detection model to obtain at least one candidate detection box and the confidence level corresponding to the candidate detection box.

[0032] Specifically, a pre-trained object detection model refers to a deep learning model that has been trained with labeled data and has the ability to recognize specific types of targets (such as cigarettes, hand gestures, etc.). For example, it can be a CNN model. The target region image is input into the pre-trained object detection model, which analyzes the target region image and outputs multiple candidate detection boxes. Each detection box represents the location that the object detection model believes may contain smoking behavior, and outputs the confidence score of each candidate detection box. For example, the object detection model may detect a "cigarette" target in one region and give a confidence score of 0.75; and detect a "hand" target in another region and give a confidence score of 0.82.

[0033] S140: Determine whether there is a target detection box that satisfies the target constraint from the candidate detection box. If there is a target detection box, it is determined that there is smoking behavior in the target image to be processed, and an effective region image is generated; wherein, the effective region image includes the target detection box.

[0034] Specifically, the target detection box is a candidate detection box that satisfies the target constraint. After obtaining multiple candidate detection boxes and their confidence scores, it can be determined whether there is a target detection box that satisfies the target constraint based on the confidence scores of the candidate detection boxes. If there is a target detection box, it can be determined that there is smoking behavior in the target image. Through the collaborative working mechanism of region limitation, image correction, model detection and condition judgment, it can avoid the problems of background interference, image offset and false detection rate caused by the decline in accuracy and false detection rate in the existing technology, and improve the accuracy and detection efficiency of smoking behavior judgment.

[0035] This application discloses a smoking detection method, comprising: acquiring a target image to be processed, and extracting candidate region images from the target image based on preset region parameters; performing image correction processing on the candidate region images to obtain a target region image; inputting the target region image into a pre-trained target detection model, and performing image detection processing on the target region image through the target detection model to obtain at least one candidate detection box and a confidence score corresponding to the candidate detection box; determining from the candidate detection boxes whether there is a target detection box that satisfies the target constraint conditions; if a target detection box exists, determining that smoking behavior exists in the target image to be processed, and generating a valid region image; wherein the valid region image includes the target detection box. This method can preprocess the image to be detected and then input it into the target detection model for detection to determine whether smoking behavior exists in the image to be detected, thereby improving the accuracy and efficiency of smoking behavior recognition and reducing false detections and missed detections.

[0036] In one possible implementation, extracting candidate region images from a target image based on preset region parameters includes: obtaining coordinate information of at least one preset effective monitoring region based on the preset region parameters; determining an initial region image corresponding to the coordinate information from the target image based on the coordinate information; generating a polygon mask corresponding to the mask information according to the mask information in the preset region parameters; and performing bitwise operations on the initial region image based on the polygon mask to obtain candidate region images.

[0037] Specifically, based on preset region parameters, the coordinate information of a preset effective monitoring region can be obtained. This effective monitoring region can be a rectangular area, and the coordinate information can be the coordinates of the four vertices of the rectangular area. Based on the obtained coordinate information, the corresponding region is identified from the target image to obtain an initial region image. This initial region image can be obtained by cropping the target image. Then, a polygon mask is generated using mask information. The polygon mask can exclude non-target regions in the initial region image. By performing pixel-by-pixel logical operations between the initial region image and the polygon mask, the region covered by the mask can be retained, while the region outside the mask is removed. The bitwise operation is a bitwise AND operation, which performs a bitwise AND operation between each pixel value of the initial region image and the corresponding pixel value of the polygon mask. If the mask pixel is a valid value, the original image pixel value is retained; if the mask pixel is an invalid value, the original image pixel value is set to an invalid value. This achieves region cropping and background removal, enabling the target detection model to better focus on potential smoking behavior areas, thereby significantly improving the efficiency and accuracy of the entire smoking recognition method.

[0038] For example, for a target image to be detected, the system reads preset region parameters from a preset configuration file, which includes the vertex coordinates of the irregular region, such as the coordinates of the four vertices of a quadrilateral. Based on this coordinate information, a rectangular initial region image containing the quadrilateral region can be cropped from the original target image. Simultaneously, according to the precise mask information of the quadrilateral stored in the preset region parameters, a polygon mask of the same size as the initial region image is generated. In this mask, the pixel values ​​inside the quadrilateral are 1, and the values ​​outside are 0. Subsequently, by performing a bitwise AND operation on the initial region image and the polygon mask, a candidate region image precisely defined within the quadrilateral can be obtained, thereby ensuring that subsequent processing is performed only on this specific monitoring area.

[0039] In one possible implementation, image correction processing is performed on the candidate region image to obtain the target region image, including: extracting the target positioning region from the candidate region image; calculating the similarity between the auxiliary positioning region and the preset reference region template based on a preset template matching algorithm to obtain the optimal offset of the candidate region image; and performing image correction processing on the candidate region image according to the optimal offset to obtain the target region image.

[0040] Specifically, the target localization region is a specific image region identified from the candidate region image for subsequent image correction processing. This region may include reference points or patterns of preset geometric shapes. By using a preset region of interest (ROI) detection algorithm, such as segmentation methods based on color, texture, or shape features, specific localization markers or structures are identified from the candidate region image. Then, the similarity between the target localization region and a known standard template is compared. For example, a normalized cross-correlation (NCC) algorithm can be used for template matching. This algorithm calculates the correlation coefficient between the target localization region and the reference region template at different positions, finds the position with the largest correlation coefficient as the optimal matching point, and then determines the optimal offset. Finally, the candidate region image is geometrically transformed according to the optimal offset to align it with the standard pose, thereby eliminating the influence of offset, rotation, or deformation. This ensures that the image input into the pre-trained target detection model has a consistent pose and size, reducing the impact of image pose changes on the model's recognition performance, and thus improving the accuracy and robustness of smoking behavior recognition.

[0041] In one possible implementation, the pre-trained object detection model is a YOLOv5 model, and the pre-trained object detection model is in ONNX format.

[0042] Specifically, the pre-trained object detection model can be a lightweight YOLOv5 model, based on ONNX Runtime inference, which reduces computational power consumption and improves inference speed. The YOLOv5 model can quickly and accurately locate smoking-related targets in images, such as cigarettes, the action of holding a cigarette, or smoke, to improve detection accuracy.

[0043] In one possible implementation, before inputting the target region image into the pre-trained target detection model, the method further includes: normalizing and scaling the target region image to obtain an effective region image that matches the input size of the target detection model.

[0044] Specifically, normalization refers to adjusting the pixel values ​​of an image to a specific numerical range, such as mapping pixel values ​​of 0-255 to the range of 0-1 or -1 to 1. This can eliminate the influence of differences in brightness, contrast, etc. between different images, enabling the object detection model to maintain better stability when processing images under different lighting conditions. Then, the target region image is scaled to adjust the image size to the fixed input size required by the object detection model. This ensures that the effective region image input into the model can better meet the requirements of the object detection model, thereby enabling the object detection model to perform image detection on the effective region image more efficiently.

[0045] For example, if a pre-trained object detection model requires an input image size of 640x640 pixels with pixel values ​​ranging from 0 to 1, after acquiring the target region image, its size can first be adjusted to 640x640 pixels using bilinear interpolation. Subsequently, the resized image is normalized; for example, the original grayscale value of each pixel (typically 0-255) is divided by 255, thus mapping the pixel value range to between 0 and 1, resulting in an effective region image with a size of 640x640 pixels and pixel values ​​ranging from 0 to 1.

[0046] In one possible implementation, the method further includes: sorting the candidate detection boxes in descending order based on the confidence level corresponding to the candidate detection boxes; calculating the intersection-union ratio (IUR) between each candidate detection box and other candidate detection boxes based on the sorted order; and deleting redundant detection boxes if there are redundant detection boxes whose IUR with the current candidate detection box is greater than a preset IUR threshold.

[0047] Specifically, based on the confidence score output by the target detection model for each detection box, all candidate detection boxes can be reordered in descending order of confidence. After the candidate detection boxes are sorted in descending order of confidence, these detection boxes can be traversed, and the intersection-union ratio (IoU) of each detection box with the remaining unprocessed detection boxes can be calculated. For example, the IoU can be obtained by dividing the intersection area of ​​two bounding boxes by their union area, or by using the IoU calculation function provided in the image processing library, inputting the coordinate information of two detection boxes (such as the coordinates of the top left and bottom right corners), and directly obtaining their IoU value. After calculating the IoU value, it is compared with a preset IoU threshold. If the IoU value between a candidate detection box and the currently selected detection box exceeds this preset threshold, the candidate detection box is determined to be a redundant detection box and removed from the detection result list, thereby ensuring that the final output detection boxes are independent and accurate.

[0048] For example, after processing the target region image using a pre-trained target detection model, multiple candidate detection boxes are obtained, each with its corresponding confidence score. For instance, detection box A (confidence 0.9), detection box B (confidence 0.85), and detection box C (confidence 0.92). First, these detection boxes are sorted in descending order of confidence, resulting in the following order: C (0.92), A (0.9), B (0.85). Next, for detection box C, the remaining detection boxes A and B are iterated through, and their intersection-union ratio (IU) with detection box C is calculated. A preset IU threshold can be 0.5. If the IU of detection box A with C is 0.7, then 0.7 is greater than 0.5, so A is considered a redundant detection box and is removed. If the IU of detection box B with C is 0.3, then 0.3 is less than 0.5, so detection box B can be retained.

[0049] In one possible implementation, the target constraints include: the confidence level of the candidate detection box is greater than a preset confidence threshold, and the category ID of the candidate detection box is a preset category ID.

[0050] Specifically, the preset confidence threshold can be set in advance, for example, it can be 0.6 or 0.8. Different confidence thresholds can be set according to different scenarios. The preset category ID is the identifier for the object detection model to classify the detected object. For example, "cigarette" and "smoke" are defined as category ID 1, and "person" is defined as category ID 0.

[0051] For example, after a pre-trained object detection model detects a target region image, it outputs multiple candidate detection boxes. Each candidate detection box has a confidence score and a class ID. For instance, the object detection model can output a detection box with a confidence score of 0.95 and a class ID of 1; a detection box with a confidence score of 0.60 and a class ID of 0; and a detection box with a confidence score of 0.45 and a class ID of 1. The preset confidence threshold can be 0.7, the preset class ID "1" is "cigarette", and the preset class ID "0" is "person". The detection box with a confidence score of 0.95 satisfies the constraint, while the candidate detection boxes with a confidence score of 0.60 and 0.45 do not. For detection boxes with a confidence score greater than the confidence threshold, the system further checks whether their class ID is "1". If it is, the candidate detection box is the target detection box.

[0052] Furthermore, the target detection boxes can be colored in the generated effective region image for identification, and the category and confidence level of the detection box can be labeled.

[0053] This application discloses a smoking detection method, comprising: acquiring a target image to be processed, and extracting candidate region images from the target image based on preset region parameters; performing image correction processing on the candidate region images to obtain a target region image; inputting the target region image into a pre-trained target detection model, and performing image detection processing on the target region image through the target detection model to obtain at least one candidate detection box and a confidence score corresponding to the candidate detection box; determining from the candidate detection boxes whether there is a target detection box that satisfies the target constraint conditions; if a target detection box exists, determining that smoking behavior exists in the target image to be processed, and generating a valid region image; wherein the valid region image includes the target detection box. This method can preprocess the image to be detected and then input it into the target detection model for detection to determine whether smoking behavior exists in the image to be detected, thereby improving the accuracy and efficiency of smoking behavior recognition and reducing false detections and missed detections.

[0054] Corresponding to the aforementioned application function implementation method embodiments, this application also provides a smoking recognition device, an electronic device, and corresponding embodiments.

[0055] Figure 2 This is a schematic diagram of the structure of the smoking recognition device shown in the embodiments of this application.

[0056] See Figure 2 A smoking detection device 200 includes: The acquisition module 210 is used to acquire the target image to be processed and extract candidate region images from the target image based on preset region parameters.

[0057] In one possible implementation, the acquisition module 210 is further configured to acquire coordinate information of at least one preset effective monitoring area based on preset area parameters; determine an initial area image corresponding to the coordinate information from the target image based on the coordinate information; generate a polygon mask corresponding to the mask information according to the mask information in the preset area parameters; and perform bitwise operations on the initial area image based on the polygon mask to obtain a candidate area image.

[0058] The correction module 220 is used to perform image correction processing on the candidate region image to obtain the target region image.

[0059] In one possible implementation, the correction module 220 is further configured to extract the target location region from the candidate region image; based on a preset template matching algorithm, perform similarity matching calculation between the auxiliary location region and the preset reference region template to obtain the optimal offset of the candidate region image; and perform image correction processing on the candidate region image according to the optimal offset to obtain the target region image.

[0060] The processing module 230 is used to input the target region image into a pre-trained target detection model, and perform image detection processing on the target region image through the target detection model to obtain at least one candidate detection box and the confidence level corresponding to the candidate detection box.

[0061] In one possible implementation, the processing module 230 is further configured to pre-train the target detection model as a YOLOv5 model, and the pre-trained target detection model is in ONNX format.

[0062] In one possible implementation, the processing module 230 is further configured to normalize and scale the target region image to obtain an effective region image that matches the input size of the target detection model.

[0063] The judgment module 240 is used to determine whether there is a target detection box that satisfies the target constraint from the candidate detection box. If there is a target detection box, it is determined that there is smoking behavior in the target image to be processed, and an effective region image is generated; wherein, the effective region image includes the target detection box.

[0064] In one possible implementation, the judgment module 240 is further configured to: sort the candidate detection boxes in descending order based on the confidence level corresponding to the candidate detection boxes; calculate the intersection-union ratio (IUU) between each candidate detection box and other candidate detection boxes based on the sorted order; and delete redundant detection boxes if there are redundant detection boxes whose IUU with the current candidate detection box is greater than a preset IUU threshold.

[0065] In one possible implementation, the judgment module 240 is further configured to include target constraints including: the confidence level of the candidate detection box is greater than a preset confidence threshold, and the category ID of the candidate detection box is a preset category ID.

[0066] This application discloses a smoking detection device, comprising: an acquisition module for acquiring a target image to be processed and extracting candidate region images from the target image based on preset region parameters; a correction module for performing image correction processing on the candidate region images to obtain a target region image; a processing module for inputting the target region image into a pre-trained target detection model, performing image detection processing on the target region image through the target detection model to obtain at least one candidate detection box and a confidence score corresponding to the candidate detection box; and a judgment module for judging whether there is a target detection box that satisfies the target constraint conditions from the candidate detection boxes. If a target detection box exists, it is determined that smoking behavior exists in the target image to be processed, and a valid region image is generated; wherein the valid region image includes the target detection box. This method can preprocess the image to be detected and then input it into the target detection model for detection to determine whether smoking behavior exists in the image to be detected, thereby improving the recognition accuracy and efficiency of smoking behavior and reducing false detections and missed detections.

[0067] Regarding the apparatus in the above embodiments, the specific manner in which each module performs its operation has been described in detail in the embodiments related to the method, and will not be elaborated further here.

[0068] This application also provides an electronic device. Figure 3 This is a schematic diagram of the hardware structure of an embodiment of the electronic device of this application. The electronic device includes a memory 320 and at least one processor 310. The memory 320 is electrically connected to the at least one processor 310. The memory 320 stores instructions. The at least one processor 310 calls the instructions in the memory 320 to cause the electronic device to execute the smoking recognition method according to any of the foregoing embodiments of this application.

[0069] Specifically, the processor 310 may include a central processing unit (CPU), an application-specific integrated circuit (ASIC), or one or more integrated circuits that can be configured to implement the embodiments of this application.

[0070] Memory 320 may include a mass storage device for data or instructions. For example, and not limitingly, memory 320 may include a hard disk drive (HDD), floppy disk drive, flash memory, optical disk, magneto-optical disk, magnetic tape, or Universal Serial Bus (USB) drive, or a combination of two or more of these. Where appropriate, memory 320 may include removable or non-removable (or fixed) media. Where appropriate, memory 320 may be internal or external to the integrated gateway disaster recovery device. In a particular embodiment, memory 320 is non-volatile solid-state memory. In a particular embodiment, memory 320 includes read-only memory (ROM). Where appropriate, the ROM may be a mask-programmed ROM, a programmable ROM (PROM), an erasable PROM (EPROM), an electrically erasable PROM (EEPROM), an electrically rewritable ROM (EAROM), or flash memory, or a combination of two or more of these.

[0071] In one example, the control device may also include a communication interface 330 and a bus 340. The processor 310, memory 320, and communication interface 330 are connected via the bus 340 and communicate with each other.

[0072] The communication interface 330 is mainly used to realize communication between various modules, devices, units and / or equipment in the embodiments of this application.

[0073] Bus 340 includes hardware, software, or both, that couples components of an online data traffic metering device together. For example, and not limitingly, the bus may include an Accelerated Graphics Port (AGP) or other graphics bus, an Enhanced Industry Standard Architecture (EISA) bus, a Front Side Bus (FSB), HyperTransport (HT) interconnect, an Industry Standard Architecture (ISA) bus, an Infinite Bandwidth Interconnect, a Low Pin Count (LPC) bus, a Microchannel Architecture (MCA) bus, a Peripheral Component Interconnect (PCI) bus, a PCI-Express (PCI-X) bus, a Serial Advanced Technology Attachment (SATA) bus, a Video Electronics Standards Association Local (VLB) bus, or other suitable buses, or combinations of two or more of these. Where appropriate, bus 340 may include one or more buses. Although specific buses are described and illustrated in embodiments of this application, any suitable bus or interconnect is contemplated herein.

[0074] Furthermore, in conjunction with the smoking detection methods in the above embodiments, this application embodiment can provide a computer-readable storage medium for implementation. This computer-readable storage medium stores instructions that, when executed by a processor, implement any of the smoking detection methods in the above embodiments.

[0075] This application is not limited to the specific configurations and processes described above and shown in the figures. For the sake of brevity, detailed descriptions of known methods are omitted here. In the above embodiments, several specific steps are described and shown as examples. However, the method process of this application is not limited to the specific steps described and shown. Those skilled in the art can make various changes, modifications, and additions, or change the order of steps, after understanding the spirit of this application.

[0076] The functional blocks shown in the above block diagram can be implemented as hardware, software, firmware, or a combination thereof. When implemented in hardware, they can be, for example, electronic circuits, application-specific integrated circuits (ASICs), appropriate firmware, plug-ins, function cards, etc. When implemented in software, the elements of this application are programs or code segments used to perform the required tasks. Programs or code segments can be stored on a machine-readable medium or transmitted over a transmission medium or communication link via data signals carried on a carrier wave. "Machine-readable medium" can include any medium capable of storing or transmitting information. Examples of machine-readable media include electronic circuits, semiconductor memory devices, ROM, flash memory, erasable ROM (EROM), floppy disks, CD-ROMs, optical disks, hard disks, fiber optic media, radio frequency (RF) links, etc. Code segments can be downloaded via computer networks such as the Internet, intranets, etc.

[0077] It should also be noted that the exemplary embodiments mentioned in this application describe methods or systems based on a series of steps or apparatus. However, this application is not limited to the order of the above steps; that is, the steps can be performed in the order mentioned in the embodiments, or in a different order, or several steps can be performed simultaneously.

[0078] Alternatively, this application also provides a computer program product capable of implementing some or all of the steps of the methods in the above embodiments. The computer program product includes a computer program / instruction that, when executed by a processor, implements some or all of the steps of the methods in the above embodiments.

[0079] The above description is merely a specific implementation of this application. Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, modules, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here. It should be understood that the protection scope of this application is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in this application, and these modifications or substitutions should all be covered within the protection scope of this application.

Claims

1. A method for identifying smoking, characterized in that, include: Acquire the target image to be processed, and extract candidate region images from the target image based on preset region parameters; The candidate region image is subjected to image correction processing to obtain the target region image; The target region image is input into a pre-trained target detection model, and the target detection model performs image detection processing on the target region image to obtain at least one candidate detection box and the confidence score corresponding to the candidate detection box. Determine whether there is a target detection box that satisfies the target constraint from the candidate detection boxes. If the target detection box exists, it is determined that there is smoking behavior in the target image to be processed, and an effective region image is generated; wherein the effective region image includes the target detection box.

2. The method according to claim 1, characterized in that, The step of extracting candidate region images from the target image based on preset region parameters includes: Based on the preset area parameters, obtain the coordinate information of at least one preset effective monitoring area; Based on the coordinate information, an initial region image corresponding to the coordinate information is determined from the target image; Based on the mask information in the preset region parameters, a polygon mask corresponding to the mask information is generated; The candidate region image is obtained by performing bitwise operations on the initial region image based on the polygon mask.

3. The method according to claim 1, characterized in that, The step of performing image correction processing on the candidate region image to obtain the target region image includes: Extract the target location region from the candidate region image; Based on a preset template matching algorithm, the auxiliary positioning region is matched and calculated with a preset reference region template to obtain the optimal offset of the candidate region image. Based on the optimal offset, the candidate region image is subjected to image correction processing to obtain the target region image.

4. The method according to claim 1, characterized in that, The pre-trained object detection model is a YOLOv5 model, and the pre-trained object detection model is in ONNX format.

5. The method according to claim 1, characterized in that, Before inputting the target region image into the pre-trained target detection model, the method further includes: The target region image is normalized and scaled to obtain an effective region image that matches the input size of the target detection model.

6. The method according to claim 1, characterized in that, Also includes: Based on the confidence scores corresponding to the candidate detection boxes, the candidate detection boxes are sorted in descending order; Calculate the intersection-union ratio (IU / U) between each candidate bounding box and other candidate bounding boxes based on the sorted order; If there is a redundant detection box whose cross-union ratio (CUNR) with the current candidate detection box is greater than a preset CUNR threshold, then the redundant detection box is deleted.

7. The method according to claim 1, characterized in that, The target constraints include: the confidence level of the candidate detection box is greater than a preset confidence threshold, and the category ID of the candidate detection box is a preset category ID.

8. A smoking detection device, characterized in that, include: The acquisition module is used to acquire the target image to be processed and extract candidate region images from the target image based on preset region parameters; The correction module is used to perform image correction processing on the candidate region image to obtain the target region image; The processing module is used to input the target region image into a pre-trained target detection model, and perform image detection processing on the target region image through the target detection model to obtain at least one candidate detection box and the confidence score corresponding to the candidate detection box; The judgment module is used to determine whether there is a target detection box that satisfies the target constraint condition from the candidate detection boxes. If the target detection box exists, it is determined that there is smoking behavior in the target image to be processed, and an effective region image is generated; wherein, the effective region image includes the target detection box.

9. An electronic device, characterized in that, include: processor; as well as A memory having executable code stored thereon, which, when executed by the processor, causes the processor to perform the method as described in any one of claims 1-7.

10. A computer-readable storage medium, characterized in that, It stores executable code that, when executed by a processor of an electronic device, causes the processor to perform the method as described in any one of claims 1-7.