Smoking behavior detection method and device, electronic equipment and storage medium

By using the pre-trained face and cigarette detection model at the construction site to identify the positional relationship between the face and the rectangular frame surrounding the cigarette in the video, the problem of difficulty in detecting smoking behavior with existing technology is solved, and the safety of the construction site is achieved. monitor.

CN118609209APending Publication Date: 2024-09-06SHANGHAI JIANKE ENG CONSULTING

Patent Information

Application Number
CN202410667674.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-27
Publication Date
2024-09-06

AI Technical Summary

Technical Problem

At complex construction sites, existing technology is difficult to accurately detect smoking behavior, resulting in the inability to effectively ensure construction safety.

Method used

By acquiring the surveillance video and inputting it into the pre-trained face and cigarette detection model, the spatial positional relationship between the face and the rectangular frame surrounding the cigarette in the video is identified, and whether there is smoking behavior is determined. The YOLOv5s model and simulation optimal transmission are used The distribution algorithm trains the detection model to achieve accurate identification of smoking behavior.

Benefits of technology

There is no need to use smoke characteristics, it is highly flexible and has a wide range of applications. It can accurately identify smoking behavior and ensure construction safety.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118609209A
    Figure CN118609209A
Patent Text Reader

Abstract

The invention provides a smoking behavior detection method and device, electronic equipment and a storage medium, and relates to the technical field of computer vision. The smoking behavior detection method comprises the following steps: acquiring a current monitoring video; inputting the current monitoring video into a pre-trained face and cigarette detection model to obtain a face bounding rectangular frame and a cigarette bounding rectangular frame corresponding to each frame of image in the current monitoring video; and according to the spatial position relationship between the face external rectangular frame and the cigarette external rectangular frame, identifying whether a smoking behavior exists in the current monitoring video. By adopting the smoking behavior detection method disclosed by the invention, the smoking behavior can be accurately detected without using smoke characteristics, the flexibility is high, and the construction safety is ensured.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure generally relates to the field of computer vision technology, and in particular to a smoking behavior detection method, device, electronic device and storage medium. Background Art

[0002] In complex construction sites such as construction sites, smoking may cause serious accidents such as fire and explosion, endangering the safety of personnel, so smoking behavior must be strictly managed at construction sites.

[0003] Currently, the relevant technology uses smoke alarms to detect smoke concentration or uses image recognition technology to detect smoke in images to determine whether someone is smoking. However, since the environment around the construction site is open and ventilated, smoke is difficult to gather and cannot be detected, which has limitations. Summary of the invention

[0004] In view of the above-mentioned defects or deficiencies in the related art, it is desired to provide a smoking behavior detection method, device, electronic device and storage medium, which can accurately detect smoking behavior, ensure construction safety and have a wide range of applications.

[0005] In a first aspect, the present disclosure provides a smoking behavior detection method, the method comprising:

[0006] Get the current surveillance video;

[0007] Input the current monitoring video into a pre-trained face and cigarette detection model to obtain a face circumscribed rectangular frame and a cigarette circumscribed rectangular frame corresponding to each frame image in the current monitoring video;

[0008] According to the spatial position relationship between the circumscribed rectangular frame of the human face and the circumscribed rectangular frame of the cigarette, it is identified whether there is smoking behavior in the current monitoring video.

[0009] Optionally, in some embodiments of the present disclosure, the pre-trained face and cigarette detection model is obtained by the following steps:

[0010] Get historical surveillance videos;

[0011] Extracting key frame images containing at least one of face information and cigarette information from the historical surveillance video, and annotating the key frame images with information to form a training data set and a verification data set;

[0012] Using the training data set and the simulated optimal transmission allocation algorithm to train a pre-constructed face and cigarette detection model, the pre-constructed face and cigarette detection model is obtained based on a YOLOv5s model;

[0013] The trained pre-built face and cigarette detection model is verified using the verification data set to obtain the pre-trained face and cigarette detection model.

[0014] Optionally, in some embodiments of the present disclosure, the pre-built face and cigarette detection model includes a connected convolution module, a first feature extraction module, a second feature extraction module, an attention-based intra-scale feature interaction module, an upsampling module, and a vector splicing module.

[0015] Optionally, in some embodiments of the present disclosure, the first feature extraction module includes a first convolution unit, a second convolution unit, a first bottleneck unit, a first vector splicing unit and a third convolution unit; the input end of the first convolution unit is connected to the input end of the second convolution unit, the output end of the first convolution unit is connected to the first input end of the first vector splicing unit, the output end of the second convolution unit is connected to the input end of the first bottleneck unit, the output end of the first bottleneck unit is connected to the second input end of the first vector splicing unit, and the output end of the first vector splicing unit is connected to the input end of the third convolution unit;

[0016] Among them, the first bottleneck unit includes a fourth convolution unit, a fifth convolution unit and a first addition unit, the input end of the fourth convolution unit and the first input end of the first addition unit are both connected to the output end of the second convolution unit, the output end of the fourth convolution unit is connected to the input end of the fifth convolution unit, the output end of the fifth convolution unit is connected to the second input end of the first addition unit, and the output end of the first addition unit is connected to the second input end of the first vector splicing unit.

[0017] Optionally, in some embodiments of the present disclosure, the attention-based intra-scale feature interaction module includes a position encoding unit, a second addition unit, a multi-head self-attention unit, a first normalization unit, a feedforward neural network unit, and a second normalization unit;

[0018] The input end of the position encoding unit is connected to the first input end of the second addition unit and the first input end of the first normalization unit, the output end of the position encoding unit is connected to the second input end of the second addition unit, the input end of the multi-head self-attention unit is respectively connected to the first input end of the second addition unit, the first output end of the second addition unit and the second output end of the second addition unit, the output end of the multi-head self-attention unit is connected to the second input end of the first normalization unit, the output end of the first normalization unit is connected to the input end of the feedforward neural network unit and the first input end of the second normalization unit, and the output end of the feedforward neural network unit is connected to the second input end of the second normalization unit.

[0019] Optionally, in some embodiments of the present disclosure, identifying whether there is smoking behavior in the current monitoring video according to the spatial position relationship between the face circumscribed rectangular frame and the cigarette circumscribed rectangular frame includes:

[0020] Traversing each frame image, if the circumscribed rectangular frame of the human face and the circumscribed rectangular frame of the cigarette have an intersection, and the ratio of the area of ​​the circumscribed rectangular frame of the human face to the area of ​​the circumscribed rectangular frame of the cigarette is greater than a preset threshold, it is determined that smoking behavior exists in the current surveillance video.

[0021] In a second aspect, the present disclosure provides a smoking behavior detection device, the device comprising:

[0022] An acquisition module, configured to acquire the current surveillance video;

[0023] An input module configured to input the current surveillance video into a pre-trained face and cigarette detection model to obtain a face circumscribed rectangular frame and a cigarette circumscribed rectangular frame corresponding to each frame image in the current surveillance video;

[0024] The recognition module is configured to recognize whether there is smoking behavior in the current monitoring video based on the spatial position relationship between the circumscribed rectangular frame of the face and the circumscribed rectangular frame of the cigarette.

[0025] Optionally, in some embodiments of the present disclosure, the input module includes:

[0026] An acquisition unit configured to acquire historical surveillance videos;

[0027] a labeling unit configured to extract key frame images containing at least one of face information and cigarette information from the historical surveillance video, and label the key frame images to form a training data set and a verification data set;

[0028] A training unit, configured to train a pre-built face and cigarette detection model using the training data set and a simulated optimal transmission allocation algorithm, wherein the pre-built face and cigarette detection model is obtained based on a YOLOv5s model;

[0029] A verification unit is configured to verify the trained pre-built face and cigarette detection model using the verification data set to obtain the pre-trained face and cigarette detection model.

[0030] In a third aspect, the present disclosure provides an electronic device, comprising a processor and a memory, wherein the memory stores at least one instruction, at least one program, a code set or an instruction set, and the instruction, the program, the code set or the instruction set is loaded and executed by the processor to implement the steps of the smoking behavior detection method described in any one of the first aspects.

[0031] In a fourth aspect, the present disclosure provides a computer-readable storage medium storing one or more programs, wherein the one or more programs can be executed by one or more processors to implement the steps of the smoking behavior detection method described in any one of the first aspects.

[0032] It can be seen from the above technical solutions that the embodiments of the present disclosure have the following advantages:

[0033] The disclosed embodiments provide a smoking behavior detection method, device, electronic device and storage medium. By acquiring a current surveillance video and inputting the current surveillance video into a pre-trained face and cigarette detection model, the face circumscribed rectangular frame and the cigarette circumscribed rectangular frame corresponding to each frame image in the current surveillance video are obtained. Based on the spatial position relationship between the face circumscribed rectangular frame and the cigarette circumscribed rectangular frame, it is possible to accurately identify whether there is smoking behavior in the current surveillance video. There is no need to use smoke features, the method has strong flexibility, a wide range of applications, and ensures construction safety. BRIEF DESCRIPTION OF THE DRAWINGS

[0034] Other features, objects and advantages of the present disclosure will become more apparent from the detailed description of non-limiting embodiments made with reference to the following drawings:

[0035] Figure 1 A flowchart of a smoking behavior detection method provided in an embodiment of the present disclosure;

[0036] Figure 2 A schematic diagram of a pre-built face and cigarette detection model structure provided in an embodiment of the present disclosure;

[0037] Figure 3 A schematic diagram of the structure of a first feature extraction module provided in an embodiment of the present disclosure;

[0038] Figure 4 A schematic diagram of the structure of a second feature extraction module provided in an embodiment of the present disclosure;

[0039] Figure 5 A schematic diagram of the structure of an attention-based intra-scale feature interaction module provided in an embodiment of the present disclosure;

[0040] Figure 6 A specific example of a smoking behavior detection method provided in an embodiment of the present disclosure;

[0041] Figure 7 A schematic diagram of the structure of a smoking behavior detection device provided in an embodiment of the present disclosure;

[0042] Figure 8A schematic diagram of the structure of another smoking behavior detection device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION

[0043] In order to enable those skilled in the art to better understand the disclosed solution, the technical solution in the disclosed embodiment will be clearly and completely described below in conjunction with the drawings in the disclosed embodiment. Obviously, the described embodiment is only a part of the disclosed embodiment, not all of the embodiments. Based on the embodiments in the disclosed embodiment, all other embodiments obtained by ordinary technicians in the field without creative work are within the scope of protection of the disclosed embodiment.

[0044] The terms "first", "second", "third", "fourth", etc. (if any) in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the numbers used in this way can be interchanged where appropriate, so that the embodiments of the present disclosure described can be implemented in sequences other than those illustrated or described herein.

[0045] In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product, or apparatus that includes a series of steps or modules is not necessarily limited to those steps or modules explicitly listed, but may include other steps or modules not explicitly listed or inherent to these processes, methods, products, or apparatuses.

[0046] It should be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present disclosure can be combined with each other. Figures 1 to 8 The smoking behavior detection method, device, electronic device and storage medium provided by the embodiments of the present disclosure are described in detail.

[0047] Please refer to Figure 1 , which is a flow chart of a smoking behavior detection method provided by an embodiment of the present disclosure, the method specifically comprises the following steps:

[0048] S101, obtaining the current surveillance video.

[0049] For example, the monitoring video in the embodiments of the present disclosure may be a video of a construction site, such as a building site, or a video of a closed environment, such as an indoor environment, without limitation.

[0050] S102, input the current monitoring video into a pre-trained face and cigarette detection model to obtain the face circumscribed rectangular frame and the cigarette circumscribed rectangular frame corresponding to each frame image in the current monitoring video.

[0051] It should be noted that, when obtaining the pre-trained face and cigarette detection model, the disclosed embodiment can first obtain historical surveillance videos, such as surveillance videos of construction sites such as construction sites. Then, extract the key frame images containing at least one of the face information and the cigarette information in the historical surveillance video, and annotate the key frame images with information to form a training data set and a verification data set. Among them, in order to ensure the diversity of the data set, the retained key frame images need to include pictures of different angles, different environments, different lighting and different personnel, and after determining the pictures of the data set, use the LabelImg tool to manually annotate the pictures, that is, annotate the face information and cigarette information in the pictures respectively, and save the annotated content as a txt file, and after completing the information annotation, randomly divide the data set into a training data set and a verification data set according to a ratio of 9:1. Optionally, the disclosed embodiment can also use the Mosaic data enhancement method to improve the generalization performance of the data set, that is, randomly select four pictures, and splice them together after degrading the pictures such as scaling, blurring and brightness adjustment. The advantage of such a setting is that it can greatly enrich the image information and improve the model's detection ability for small targets.

[0052] Furthermore, the disclosed embodiment uses a training data set and a Simulated Optimal Transport Assignment (SIMOTA) algorithm to train a pre-built face and cigarette detection model, which is based on a YOLOv5s model. Figure 2 As shown, the pre-built face and cigarette detection model includes but is not limited to the connected convolution modules (corresponding to Figure 2 Conv), the first feature extraction module (corresponding to Figure 2 C3), the second feature extraction module (corresponding to Figure 2 ODC3), attention-based intra-scale feature interaction module (corresponding to Figure 2 AIFI, Attention-based Intra-scale Feature Interaction), upsampling module (corresponding to Figure 2 Upsample) and vector concatenation module (corresponding to Figure 2 Concat) etc.

[0053] For example, the convolution module (corresponding to Figure 2 Conv) can include convolution layer, normalization layer and activation function layer (such as activation function SiLu), and the input of the module is output after being operated by these three layers in sequence. Figure 3 As shown, the first feature extraction module (corresponding to Figure 2C3) may include a first convolution unit, a second convolution unit, a first bottleneck unit, a first vector splicing unit and a third convolution unit, the input end of the first convolution unit is connected to the input end of the second convolution unit, the output end of the first convolution unit is connected to the first input end of the first vector splicing unit, the output end of the second convolution unit is connected to the input end of the first bottleneck unit, the output end of the first bottleneck unit is connected to the second input end of the first vector splicing unit, and the output end of the first vector splicing unit is connected to the input end of the third convolution unit, wherein the first bottleneck unit may include a fourth convolution unit, a fifth convolution unit and a first addition unit, the input end of the fourth convolution unit and the first input end of the first addition unit are both connected to the second convolution unit. The output end of the convolution unit, the output end of the fourth convolution unit is connected to the input end of the fifth convolution unit, and the output end of the fifth convolution unit is connected to the second input end of the first addition unit, and the output end of the first addition unit is connected to the second input end of the first vector splicing unit. That is to say, the first feature extraction module divides the input into two paths, and the two paths pass through different convolution units to adjust the vector scale, one branch passes through the bottleneck layer, and the other branch does not pass through the bottleneck layer. The two vectors are then spliced ​​as output, and the bottleneck layer adds the original input with the output of the two convolution units as the bottleneck layer output. The convolution unit may include a convolution layer, a normalization layer, an activation function layer, etc., thereby being able to extract features from the input information.

[0054] For example Figure 4 As shown, the second feature extraction module (corresponding to Figure 2 ODC3) can also process the input in two ways, one branch passes through the bottleneck layer, and the other branch directly passes through the convolution unit, and then the outputs of the two branches are concatenated, while the bottleneck layer combines the original input with the output after two full-dimensional convolution units (corresponding to Figure 4 The output of ODConv in the bottleneck layer is added as the output of the bottleneck layer, where ODConv replaces the full-dimensional convolution unit of the ordinary convolution operation in the convolution unit Conv with a full-dimensional dynamic convolution. The advantage of this setting is that it can greatly improve the feature extraction capability and enhance the model's detection effect on faces and cigarettes.

[0055] For example Figure 5 As shown, the attention-based intra-scale feature interaction module (corresponding to Figure 2The AIFI (in Chinese) may include a position encoding (Build Position) unit, a second adding unit, a multi-head self-attention (Multi-Head Self-Attention) unit, a first normalization unit, a feedforward neural network (FFN) unit and a second normalization unit. The input end of the position encoding unit is connected to the first input end of the second adding unit and the first input end of the first normalization unit, the output end of the position encoding unit is connected to the second input end of the second adding unit, the input end of the multi-head self-attention unit is respectively connected to the first input end of the second adding unit, the first output end of the second adding unit and the second output end of the second adding unit, the output end of the multi-head self-attention unit is connected to the second input end of the first normalization unit, the output end of the first normalization unit is connected to the input end of the feedforward neural network unit and the first input end of the second normalization unit, and the output end of the feedforward neural network unit is connected to the second input end of the second normalization unit. The advantage of this setting is that the embodiment of the present disclosure can ensure that the model can identify the position information of each element in the sequence by encoding the position of the input generation, and use the multi-head self-attention mechanism to simultaneously focus on multiple subspace information to improve the model's expression and generalization capabilities, which helps to capture the correlation of different positions in the input sequence, and use the feedforward neural network to learn more complex features and memories through nonlinear transformation. For example, the upsampling module (corresponding to Figure 2 Upsample) uses the nearest neighbor interpolation method to upsample, thereby increasing the size of the feature map, and the vector concatenation module (corresponding to Figure 2 Concat) can concatenate feature maps of different scales in the channel dimension and form a feature map of a new scale.

[0056] For example, the simulated optimal transmission allocation algorithm regards the label allocation problem as an optimal transmission problem and allocates it according to the principle of minimizing transmission loss. In the label allocation process, the real object is regarded as the supplier, the prediction box is regarded as the demander, and the loss of classification and regression is regarded as the cost in the transportation process. Under the constraint that each real object is assigned to at least one prediction box and each prediction box is only assigned to one real object, the optimal mapping relationship between the two is solved. In actual use, the embodiment of the present disclosure first constructs a cost matrix to represent the cost relationship between each real object (such as a face, a cigarette) and a prediction frame (such as a face circumscribed rectangular frame, a cigarette circumscribed rectangular frame); then, in order to determine the optimal condition for network convergence, the number of positive samples is obtained by calculating the intersection and union ratios of the real object and each prediction frame and summing them, rounding them down, and comparing the rounded result with 1 and taking the maximum value of the two. For example, if the intersection and union ratio summation result is 0.3 and the rounded result is 0, then after comparing the rounded result with 1, the number of positive samples is 1, thereby ensuring that each real object can be assigned to at least one prediction frame. For another example, if the intersection and union ratio summation result is 2.3 and the rounded result is 2, then after comparing the rounded result with 1, the number of positive samples is 2; thus, each real object can be assigned k prediction frames with the lowest cost as an approximate solution to the optimal transmission problem, where k represents the number of positive samples required for the real object.

[0057] Furthermore, the embodiment of the present disclosure uses the validation data set to validate the trained pre-built face and cigarette detection model to obtain the pre-trained face and cigarette detection model. For example, in the training phase, the input image size of the model is 640×640, the batch size is 24, the number of iterations is 300, and the initial learning rate is 0.01. Then, in the validation phase, the validation data set is used to validate the trained pre-built face and cigarette detection model to obtain the final result.

[0058] For example, Figure 6 As shown, in the embodiment of the present disclosure, after the current surveillance video is input into the pre-trained face and cigarette detection model, m cigarette circumscribed rectangular frames are obtained, for example, P c1 (x c1 ,y c1 ,w c1 ,h c1 ),…,P cm (x cm ,y cm ,w cm ,h cm ), and n face bounding rectangles, such as P f1 (x f1 ,y f1 ,w f1 ,h f1 ),…,Pfn (x fn ,y fn ,w fn ,h fn ), where x represents the horizontal coordinate of the center point of the target frame, y represents the vertical coordinate of the center point of the target frame, w represents the horizontal width of the target frame, and h represents the vertical height of the target frame.

[0059] S103, identifying whether there is smoking behavior in the current monitoring video based on the spatial position relationship between the circumscribed rectangular frame of the face and the circumscribed rectangular frame of the cigarette.

[0060] For example, the disclosed embodiment traverses each frame image, and if the face circumscribed rectangular frame and the cigarette circumscribed rectangular frame have an intersection, and the ratio of the area of ​​the face circumscribed rectangular frame to the area of ​​the cigarette circumscribed rectangular frame is greater than a preset threshold, it is determined that there is smoking behavior in the current monitoring video. Figure 6 As shown in the example, S (i,j) represents the intersection area of ​​the face circumscribed rectangle and the cigarette circumscribed rectangle.

[0061]

[0062] r (i,j) It represents the ratio of the area of ​​the rectangular frame surrounding the face to the area of ​​the rectangular frame surrounding the cigarette.

[0063]

[0064] Assuming the preset threshold is 3, then in S (i,j) >0 and r (i,j) When >3, it indicates that the current surveillance video contains frame images that are identified as smoking behavior. At this time, it can be determined that smoking behavior exists in the current surveillance video.

[0065] The smoking behavior detection method provided by the embodiment of the present disclosure obtains the current monitoring video and inputs the current monitoring video into a pre-trained face and cigarette detection model to obtain the face circumscribed rectangular frame and the cigarette circumscribed rectangular frame corresponding to each frame image in the current monitoring video. Based on the spatial position relationship between the face circumscribed rectangular frame and the cigarette circumscribed rectangular frame, it can accurately identify whether there is smoking behavior in the current monitoring video. There is no need to use smoke features, the method has strong flexibility, a wide range of applications, and ensures construction safety.

[0066] Based on the above embodiments, the present disclosure provides a smoking behavior detection device. The smoking behavior detection device 100 can be applied to Figure 1 to Figure 6 In the smoking behavior detection method of the corresponding embodiment. Please refer to Figure 7 , the smoking behavior detection device 100 comprises:

[0067] An acquisition module 101 is configured to acquire the current surveillance video;

[0068] An input module 102 is configured to input the current surveillance video into a pre-trained face and cigarette detection model to obtain a face circumscribed rectangular frame and a cigarette circumscribed rectangular frame corresponding to each frame image in the current surveillance video;

[0069] The recognition module 103 is configured to recognize whether there is smoking behavior in the current monitoring video according to the spatial position relationship between the circumscribed rectangular frame of the face and the circumscribed rectangular frame of the cigarette.

[0070] Alternatively, if Figure 8 As shown, in some embodiments of the present disclosure, the input module 102 includes:

[0071] An acquisition unit 1021 is configured to acquire historical surveillance videos;

[0072] The labeling unit 1022 is configured to extract key frame images containing at least one of face information and cigarette information from the historical surveillance video, and label the key frame images to form a training data set and a verification data set;

[0073] A training unit 1023 is configured to train a pre-built face and cigarette detection model using a training data set and a simulated optimal transmission allocation algorithm, where the pre-built face and cigarette detection model is obtained based on a YOLOv5s model;

[0074] The verification unit 1024 is configured to verify the trained pre-built face and cigarette detection model using a verification data set to obtain a pre-trained face and cigarette detection model.

[0075] Optionally, the pre-built face and cigarette detection model in some embodiments of the present disclosure includes a connected convolution module, a first feature extraction module, a second feature extraction module, an attention-based intra-scale feature interaction module, an upsampling module, and a vector splicing module.

[0076] Optionally, in some embodiments of the present disclosure, the first feature extraction module includes a first convolution unit, a second convolution unit, a first bottleneck unit, a first vector splicing unit and a third convolution unit; the input end of the first convolution unit is connected to the input end of the second convolution unit, the output end of the first convolution unit is connected to the first input end of the first vector splicing unit, the output end of the second convolution unit is connected to the input end of the first bottleneck unit, the output end of the first bottleneck unit is connected to the second input end of the first vector splicing unit, and the output end of the first vector splicing unit is connected to the input end of the third convolution unit;

[0077] Among them, the first bottleneck unit includes a fourth convolution unit, a fifth convolution unit and a first addition unit, the input end of the fourth convolution unit and the first input end of the first addition unit are both connected to the output end of the second convolution unit, the output end of the fourth convolution unit is connected to the input end of the fifth convolution unit, the output end of the fifth convolution unit is connected to the second input end of the first addition unit, and the output end of the first addition unit is connected to the second input end of the first vector splicing unit.

[0078] Optionally, the attention-based intra-scale feature interaction module in some embodiments of the present disclosure includes a position encoding unit, a second addition unit, a multi-head self-attention unit, a first normalization unit, a feedforward neural network unit, and a second normalization unit;

[0079] The input end of the position encoding unit is connected to the first input end of the second addition unit and the first input end of the first normalization unit, the output end of the position encoding unit is connected to the second input end of the second addition unit, the input end of the multi-head self-attention unit is respectively connected to the first input end of the second addition unit, the first output end of the second addition unit and the second output end of the second addition unit, the output end of the multi-head self-attention unit is connected to the second input end of the first normalization unit, the output end of the first normalization unit is connected to the input end of the feedforward neural network unit and the first input end of the second normalization unit, and the output end of the feedforward neural network unit is connected to the second input end of the second normalization unit.

[0080] Optionally, in some embodiments of the present disclosure, the recognition module 103 is specifically used to traverse each frame image. If the circumscribed rectangular frame of the face and the circumscribed rectangular frame of the cigarette have an intersection, and the ratio of the area of ​​the circumscribed rectangular frame of the face to the area of ​​the circumscribed rectangular frame of the cigarette is greater than a preset threshold, it is determined that smoking behavior exists in the current surveillance video.

[0081] It should be noted that, for the description of the same steps and the same contents in this embodiment as those in other embodiments, reference can be made to the description in other embodiments and will not be repeated here.

[0082] The smoking behavior detection device provided by the embodiment of the present disclosure has an acquisition module in which the current monitoring video can be acquired, and the input module can input the current monitoring video into a pre-trained face and cigarette detection model to obtain the face circumscribed rectangular frame and the cigarette circumscribed rectangular frame corresponding to each frame image in the current monitoring video. Then, the recognition module can accurately recognize whether there is smoking behavior in the current monitoring video based on the spatial position relationship between the face circumscribed rectangular frame and the cigarette circumscribed rectangular frame. There is no need to use smoke features, the device has strong flexibility, a wide range of applications, and ensures construction safety.

[0083] Based on the above embodiments, the present disclosure provides an electronic device, which includes a processor and a memory. The memory stores at least one instruction, at least one program, code set or instruction set, which is loaded and executed by the processor to implement Figure 1 to Figure 6 The steps of the smoking behavior detection method of the corresponding embodiment.

[0084] As another aspect, the present disclosure provides a computer-readable storage medium for storing program code, the program code for executing the aforementioned Figure 1 to Figure 6 Any implementation manner of the smoking behavior detection method of the corresponding embodiment.

[0085] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and modules described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0086] In the several embodiments provided in the present disclosure, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the modules is only a logical function division. There may be other division methods in actual implementation, such as multiple modules or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or modules, which can be electrical, mechanical or other forms. The modules described as separate components may or may not be physically separated, and the components displayed as modules may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the scheme of this embodiment.

[0087] In addition, each functional module in each embodiment of the present disclosure may be integrated into a processing unit, or each module may exist physically separately, or two or more units may be integrated into one module. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of a software functional unit. If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it may be stored in a computer-readable storage medium.

[0088] Based on this understanding, the technical solution of the present disclosure, or the part that contributes to the prior art, or the whole or part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the smoking behavior detection method of each embodiment of the present disclosure. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk, etc., various media that can store program codes.

[0089] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present disclosure, rather than to limit them. Although the present disclosure has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present disclosure.

Claims

1. A smoking behavior detection method, characterized in that: The method comprises: Get the current surveillance video; Input the current monitoring video into a pre-trained face and cigarette detection model to obtain a face circumscribed rectangular frame and a cigarette circumscribed rectangular frame corresponding to each frame image in the current monitoring video; According to the spatial position relationship between the circumscribed rectangular frame of the human face and the circumscribed rectangular frame of the cigarette, it is identified whether there is smoking behavior in the current monitoring video.

2. The smoking behavior detection method according to claim 1, characterized in that: The pre-trained face and cigarette detection model is obtained by the following steps: Get historical surveillance videos; Extracting key frame images containing at least one of face information and cigarette information from the historical surveillance video, and annotating the key frame images with information to form a training data set and a verification data set; Using the training data set and the simulated optimal transmission allocation algorithm to train a pre-constructed face and cigarette detection model, the pre-constructed face and cigarette detection model is obtained based on a YOLOv5s model; The trained pre-built face and cigarette detection model is verified using the verification data set to obtain the pre-trained face and cigarette detection model.

3. The smoking behavior detection method according to claim 2, characterized in that: The pre-built face and cigarette detection model includes a connected convolution module, a first feature extraction module, a second feature extraction module, an attention-based intra-scale feature interaction module, an upsampling module and a vector splicing module.

4. The smoking behavior detection method according to claim 3, characterized in that: The first feature extraction module includes a first convolution unit, a second convolution unit, a first bottleneck unit, a first vector splicing unit and a third convolution unit; an input end of the first convolution unit is connected to an input end of the second convolution unit, an output end of the first convolution unit is connected to a first input end of the first vector splicing unit, an output end of the second convolution unit is connected to an input end of the first bottleneck unit, an output end of the first bottleneck unit is connected to a second input end of the first vector splicing unit, and an output end of the first vector splicing unit is connected to an input end of the third convolution unit; Among them, the first bottleneck unit includes a fourth convolution unit, a fifth convolution unit and a first addition unit, the input end of the fourth convolution unit and the first input end of the first addition unit are both connected to the output end of the second convolution unit, the output end of the fourth convolution unit is connected to the input end of the fifth convolution unit, the output end of the fifth convolution unit is connected to the second input end of the first addition unit, and the output end of the first addition unit is connected to the second input end of the first vector splicing unit.

5. The smoking behavior detection method according to claim 3, characterized in that: The attention-based intra-scale feature interaction module includes a position encoding unit, a second addition unit, a multi-head self-attention unit, a first normalization unit, a feedforward neural network unit and a second normalization unit; The input end of the position encoding unit is connected to the first input end of the second addition unit and the first input end of the first normalization unit, the output end of the position encoding unit is connected to the second input end of the second addition unit, the input end of the multi-head self-attention unit is respectively connected to the first input end of the second addition unit, the first output end of the second addition unit and the second output end of the second addition unit, the output end of the multi-head self-attention unit is connected to the second input end of the first normalization unit, the output end of the first normalization unit is connected to the input end of the feedforward neural network unit and the first input end of the second normalization unit, and the output end of the feedforward neural network unit is connected to the second input end of the second normalization unit.

6. The smoking behavior detection method according to any one of claims 1 to 5, characterized in that: The identifying whether there is a smoking behavior in the current monitoring video according to the spatial position relationship between the face circumscribed rectangular frame and the cigarette circumscribed rectangular frame includes: Traversing each frame image, if the circumscribed rectangular frame of the human face and the circumscribed rectangular frame of the cigarette have an intersection, and the ratio of the area of ​​the circumscribed rectangular frame of the human face to the area of ​​the circumscribed rectangular frame of the cigarette is greater than a preset threshold, it is determined that smoking behavior exists in the current surveillance video.

7. A smoking behavior detection device, characterized in that: The device comprises: An acquisition module, configured to acquire the current surveillance video; An input module configured to input the current surveillance video into a pre-trained face and cigarette detection model to obtain a face circumscribed rectangular frame and a cigarette circumscribed rectangular frame corresponding to each frame image in the current surveillance video; The recognition module is configured to recognize whether there is smoking behavior in the current monitoring video based on the spatial position relationship between the circumscribed rectangular frame of the face and the circumscribed rectangular frame of the cigarette.

8. The smoking behavior detection device according to claim 7, characterized in that: The input module comprises: An acquisition unit configured to acquire historical surveillance videos; a labeling unit configured to extract key frame images containing at least one of face information and cigarette information from the historical surveillance video, and label the key frame images to form a training data set and a verification data set; A training unit, configured to train a pre-built face and cigarette detection model using the training data set and a simulated optimal transmission allocation algorithm, wherein the pre-built face and cigarette detection model is obtained based on a YOLOv5s model; A verification unit is configured to verify the trained pre-built face and cigarette detection model using the verification data set to obtain the pre-trained face and cigarette detection model.

9. An electronic device, characterized in that: The electronic device includes a processor and a memory, wherein the memory stores at least one instruction, at least one program, code set or instruction set, and the instruction, the program, the code set or the instruction set is loaded and executed by the processor to implement the steps of the smoking behavior detection method described in any one of claims 1 to 6.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the steps of the smoking behavior detection method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Smoking and calling detection method and system combining action recognition and target detection

    CN116580452A

  • Image target detection method and device

    CN117237599A

Cited By

  • Intelligent security and protection method based on machine vision

    CN119445472A