Electronic cigarette smoke detection method and system based on image recognition
Through the e-cigarette smoke detection method based on image recognition, using the residual frame stacking method and dual recognition model, combined with image enhancement technology, the problem of traditional methods being insensitive to e-cigarette smoke recognition and low detection efficiency in complex environments is solved. Highly accurate and efficient smoke identification.
Patent Information
- Application Number
- CN202410896905.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-05
- Publication Date
- 2024-10-11
- Estimated Expiration
- 2044-07-05
AI Technical Summary
Traditional smoke detection methods are not sensitive enough to identify e-cigarette smoke and cannot effectively distinguish e-cigarette smoke from other types of smoke or vapor. The detection efficiency is low in open or ventilated conditions, especially in complex outdoor environments where there is severe interference and early smoke diffusion. Subtle problems.
The e-cigarette smoke detection method based on image recognition is used to extract the smoke image to be identified through the residual frame stacking method, combined with the dual recognition process of the smoke coarse recognition model and the fine recognition model, and image enhancement technology is used to detect the smoke under different lighting conditions and complex backgrounds. Identify e-cigarette smoke and determine the optimal parameter configuration through a group optimization algorithm.
It improves the identification accuracy and efficiency of e-cigarette smoke, realizes real-time monitoring and automatic identification of public places, reduces the consumption of manual monitoring resources, is highly adaptable, can operate stably in a variety of environments, and improves identification accuracy.
Smart Images

Figure CN118429901B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image processing, and in particular to an electronic cigarette smoke detection method and system based on image recognition. Background Art
[0002] Traditional smoke detection methods mainly rely on smoke sensors, which are usually based on the physical properties of smoke particles in the air for detection. However, these methods have certain limitations in practical applications, such as insufficient sensitivity in detecting smoke produced by electronic cigarettes, inability to effectively distinguish electronic cigarette smoke from other types of smoke or steam, and low detection efficiency under open or ventilated conditions. Electronic cigarette smoke detection methods based on image recognition are being promoted, but the outdoor environment is very complex. For example, pedestrians and outdoor cluttered scenes will cause serious interference to electronic cigarette smoke detection, and in the early stages of smoking, smoke diffuses slowly and is not easy to detect.
[0003] Therefore, we urgently need to provide an electronic cigarette smoke detection method and system based on image recognition that can recognize smoke characteristics in real time and accurately. Summary of the invention
[0004] The present invention aims to provide an electronic cigarette smoke detection method and system based on image recognition to improve the accuracy of electronic cigarette smoke recognition.
[0005] An electronic cigarette smoke detection method based on image recognition, comprising:
[0006] S1. Obtain real-time surveillance video, extract the current frame image in the real-time surveillance video at a preset time interval, and obtain a real-time surveillance video frame screenshot P i , i=im,i-m+1,…,i,…I; m represents the m frames before the current i-th frame; the residual frame stacking method is used to obtain the screenshot P based on the real-time monitoring video frame i The residual frame smoke image to be identified is input into the smoke rough recognition model to perform smoke recognition, and obtain an initial smoke recognition result; if the initial smoke recognition result is that smoke exists, the residual frame smoke image to be identified is used as the electronic cigarette smoke image to be identified; otherwise, the electronic cigarette smoke detection is continued at a preset time interval;
[0007] S2. Perform image enhancement operation on the electronic cigarette smoke image to be identified to obtain an enhanced electronic cigarette smoke image to be identified; input the enhanced electronic cigarette smoke image to be identified into the smoke precision recognition model to perform smoke recognition and obtain an electronic cigarette smoke recognition result; if the electronic cigarette smoke recognition result is that electronic cigarette smoke exists, notify relevant personnel to perform corresponding operations; otherwise, continue to perform electronic cigarette smoke detection at preset time intervals.
[0008] As a preferred technical solution of the present invention, the specific steps of obtaining a residual frame of a real-time monitoring video to be identified smoke image by using a residual frame stacking method include:
[0009] L1. Extract real-time surveillance video frame screenshot P i and real-time monitoring video frame screenshots i-u ; Use the formula to monitor the video residual frame image C in real time i =|Real-time monitoring video frame screenshot P i - Real-time monitoring video frame screenshot P i-u |, get the real-time monitoring video residual frame image C i ; u represents real-time monitoring video frame screenshot P i-u and real-time monitoring video frame screenshots i The number of frames between
[0010] L2. Based on the real-time monitoring video, multiple continuous real-time monitoring video residual frame images are combined to obtain a real-time monitoring video residual frame image set; real-time monitoring video residual frame image set = {real-time monitoring video residual frame image C i , real-time monitoring video residual frame image C i-1 ,…,Real-time monitoring video residual frame image C i-d}; d+1 is the number of real-time monitoring video residual frame images contained in the real-time monitoring video residual frame image set;
[0011] L3. Use the residual frame stacking method to stack all the real-time monitoring video residual frame images in the real-time monitoring video residual frame image set to obtain the residual frame smoke image to be identified.
[0012] As a preferred technical solution of the present invention, it also includes using a swarm optimization algorithm to determine the value of u in step L1 and the value of d in step L2, specifically the following steps:
[0013] Construct K individuals H to be optimized k , each individual H to be optimized k contains a set of u and d values, and the values of u and d fluctuate within a preset range; k Combine to obtain the iterative population of values to be optimized; set the maximum number of iterations;
[0014] According to the value to be optimized, iterate the individuals H in the population to be optimized. k Perform simulation calculations to obtain the value evaluation score W k ; The evaluation score W will be k As the individual H to be optimized k The fitness S k ;
[0015] The specific steps of simulation calculation are:
[0016] Construct J simulated real-time monitoring videos V j , j=1,2,…,J; the individual H to be optimized k The value of u in is applied to step L1, and the value of d is applied to step L2. j The residual frame stacking method is used to obtain the simulated residual frame smoke image G to be identified kj ; Simulate the residual frame to be identified smoke image G kj Input into the smoke rough recognition model for smoke recognition, and obtain the simulated smoke recognition result R kj ;
[0017] Using the formula W k= O a *(1 / A k )+O b *B k , and get the individual H to be optimized k The value evaluation score W k ; A k Indicates that all simulated residual frames are to be identified smoke images G kj The numerical mean of the time input to the smoke rough recognition model for smoke recognition; B k Represents all simulated smoke recognition results R kj The average accuracy of the simulated smoke recognition result R kj If the recognition is accurate, the simulated smoke recognition result R kj The accuracy value is 1; otherwise, the simulated smoke recognition result R kj The accuracy value of is 0; a Indicates the value evaluation score W k Middle A k The weight of O b Indicates the value evaluation score W k Medium k The weight of
[0018] When the maximum number of iterations is reached, the output is the individual to be optimized H corresponding to the maximum fitness k , that is, the optimal individual to be optimized. The value of u in step L1 and the value of d in step L2 are determined according to the values of u and d in the optimal individual to be optimized.
[0019] As a preferred technical solution of the present invention, the smoke rough recognition model includes an image preprocessing layer, a feature recognition layer and a result output layer;
[0020] The image preprocessing layer is used to perform image preprocessing on the residual frame to-be-recognized smoke image to obtain a preprocessed residual frame to-be-recognized smoke image;
[0021] The feature recognition layer is used to perform image feature recognition based on the smoke image to be recognized in the preprocessed residual frame to obtain the initial smoke recognition result;
[0022] The result output layer is used to output the initial smoke recognition results.
[0023] As a preferred technical solution of the present invention, the specific steps of training the smoke rough recognition model include:
[0024] Collect several smoke rough recognition training images with target value annotations; the smoke rough recognition training images are in the same form as the residual frame smoke image to be recognized; the target value indicates whether there is smoke in the smoke rough recognition training image; combine several smoke rough recognition training images with target value annotations to obtain a smoke rough recognition training set;
[0025] The smoke rough recognition training set is input into the smoke rough recognition initial model, and the model training is performed with the target value as the target to obtain the trained smoke rough recognition initial model; the trained smoke rough recognition initial model is evaluated to obtain the smoke rough recognition initial model evaluation result; if the smoke rough recognition initial model evaluation result is passed, the trained smoke rough recognition initial model is used as the smoke rough recognition model; otherwise, the smoke rough recognition training set is used to continue the model training.
[0026] As a preferred technical solution of the present invention, the specific steps of performing an image enhancement operation on the electronic cigarette smoke image to be identified to obtain an enhanced electronic cigarette smoke image to be identified include:
[0027] Q1. Use background removal technology to remove the background of the electronic cigarette smoke image to be identified, and obtain the background-removed electronic cigarette smoke image to be identified;
[0028] Q2. Use the filtering enhancement algorithm to enhance the background-removed electronic cigarette smoke image to be identified, and obtain the enhanced electronic cigarette smoke image to be identified; use the Laplace operator to perform fuzzy detection on the enhanced electronic cigarette smoke image to be identified, and obtain the edge detection variance; if the edge detection variance is lower than the preset fuzzy variance threshold, continue to use the filtering enhancement algorithm to enhance the electronic cigarette smoke image to be identified, until the edge detection variance reaches the preset fuzzy variance threshold; otherwise, perform fuzzy detection on the enhanced electronic cigarette smoke image to be identified as the enhanced electronic cigarette smoke image to be identified.
[0029] As a preferred technical solution of the present invention, in step S2, the self-attention model is used as the basic model of the smoke essence recognition model, and the smoke essence recognition model includes a shallow smoke feature extraction layer, a deep smoke feature extraction layer, and a result output layer;
[0030] The shallow smoke feature extraction layer is used to extract and combine the local features of the enhanced electronic cigarette smoke image to be identified by using convolution operation, so as to obtain the deep features of the enhanced electronic cigarette smoke image to be identified;
[0031] The deep smoke feature extraction layer is used to perform feature recognition on the deep features of the electronic cigarette smoke image to be identified, and obtain the electronic cigarette smoke recognition result;
[0032] The result output layer is used to output the electronic cigarette smoke recognition results.
[0033] As a preferred technical solution of the present invention, the specific steps of training the smoke essence recognition model include:
[0034] Collect several electronic cigarette smoke images and other smoke images with manually annotated electronic cigarette recognition results; the electronic cigarette smoke images and other smoke images have the same image form as the enhanced electronic cigarette smoke images to be recognized; combine several electronic cigarette smoke images and other smoke images with manually annotated electronic cigarette recognition results to obtain a smoke essence recognition training set; the manually annotated electronic cigarette recognition results are used as target values of the smoke essence recognition training set;
[0035] The smoke spirit recognition training set is input into the smoke spirit recognition initial model, and the model training is performed with the target value as the target to obtain the trained smoke spirit recognition initial model; the trained smoke spirit recognition initial model is evaluated to obtain the smoke spirit recognition initial model evaluation result; if the smoke spirit recognition initial model evaluation result is passed, the trained smoke spirit recognition initial model is used as the smoke spirit recognition model; otherwise, the smoke spirit recognition training set is used to continue the model training.
[0036] An electronic cigarette smoke detection system based on image recognition, comprising:
[0037] The image coarse recognition module is used to deploy the smoke coarse recognition model, obtain the real-time monitoring video, extract the current frame image in the real-time monitoring video at a preset time interval, and obtain the real-time monitoring video frame screenshot P i , i=im,i-m+1,…,i,…I; m represents the m frames before the current i-th frame; the residual frame stacking method is used to obtain the screenshot P based on the real-time monitoring video frame i The residual frame smoke image to be identified is input into the smoke rough recognition model to perform smoke recognition, and obtain an initial smoke recognition result; if the initial smoke recognition result is that smoke exists, the residual frame smoke image to be identified is used as the electronic cigarette smoke image to be identified; otherwise, the electronic cigarette smoke detection is continued at a preset time interval;
[0038] An image enhancement module is used to perform an image enhancement operation on the electronic cigarette smoke image to be identified to obtain an enhanced electronic cigarette smoke image to be identified;
[0039] The image precision recognition module is used to deploy the smoke precision recognition model, input the enhanced electronic cigarette smoke image to be recognized into the smoke precision recognition model for smoke recognition, and obtain the electronic cigarette smoke recognition result; if the electronic cigarette smoke recognition result is that electronic cigarette smoke exists, the relevant personnel are notified to perform corresponding operations; otherwise, electronic cigarette smoke detection continues at the preset time interval.
[0040] The present invention has the following advantages:
[0041] 1. The present invention extracts smoke images to be identified by the residual frame stacking method, and combines the dual identification process of the smoke coarse identification model and the smoke fine identification model to effectively improve the identification accuracy of electronic cigarette smoke; the smoke coarse identification model quickly screens out images that may contain smoke, and the fine identification model further improves the accuracy of identification. This step-by-step processing method can greatly improve the overall recognition efficiency; the method can continuously capture frames of real-time monitoring videos and automatically identify electronic cigarette smoke, thereby realizing real-time monitoring and automatic identification of electronic cigarette use behavior in public places, and effectively reducing the resource consumption of manual monitoring; through image enhancement operations, the electronic cigarette smoke image to be identified is enhanced, so that smoke images under different lighting conditions and complex backgrounds can be effectively identified. This strong adaptability enables the method to operate stably in a variety of environments.
[0042] 2. The present invention determines the optimal u and d values through a swarm optimization algorithm, which can ensure that the residual frame stacking method can achieve the best recognition effect in different monitoring environments and different smoke scenarios. This dynamic optimization process is more flexible and effective than static fixed parameter settings, and can adapt to various complex practical application scenarios; through simulation calculation and fitness evaluation, the parameter configuration that can improve the accuracy of smoke recognition is selected, thereby directly improving the recognition accuracy of electronic cigarette smoke. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] Figure 1 This is a schematic diagram of the structure of an electronic cigarette smoke detection system based on image recognition adopted in an embodiment of the present invention. DETAILED DESCRIPTION
[0044] In order to enable persons skilled in the art to better understand the technical solutions in the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present invention.
[0045] Embodiment 1, an electronic cigarette smoke detection method based on image recognition, comprising:
[0046] S1. Obtain real-time surveillance video, extract the current frame image in the real-time surveillance video at a preset time interval, and obtain a real-time surveillance video frame screenshot P i, i=im,i-m+1,…,i,…I; m represents the m frames before the current i-th frame; the residual frame stacking method is used to obtain the screenshot P based on the real-time monitoring video frame i The residual frame smoke image to be identified is input into the smoke rough recognition model to perform smoke recognition, and obtain an initial smoke recognition result; if the initial smoke recognition result is that smoke exists, the residual frame smoke image to be identified is used as the electronic cigarette smoke image to be identified; otherwise, the electronic cigarette smoke detection is continued at a preset time interval;
[0047] Real-time surveillance video is obtained from cameras placed in legal areas of public places; the preset time interval is set by professional technicians based on actual conditions, and real-time surveillance video frame screenshots P i Indicates the current frame image in the real-time monitoring video when acquiring; m indicates the function of acquiring the real-time monitoring video frame screenshot P i At the same time, multiple images in the real-time monitoring video that are continuous in time sequence are obtained, so as to obtain the smoke image to be identified in the residual frame later;
[0048] The specific steps of using the residual frame stacking method to obtain the residual frame smoke image to be identified of the real-time monitoring video include:
[0049] L1. Extract real-time surveillance video frame screenshot P i and real-time monitoring video frame screenshots i-u ; Use the formula to monitor the video residual frame image C in real time i =|Real-time monitoring video frame screenshot P i - Real-time monitoring video frame screenshot P i-u |, get the real-time monitoring video residual frame image C i ; u represents real-time monitoring video frame screenshot P i-u and real-time monitoring video frame screenshots i The number of frames between
[0050] L2. Based on the real-time monitoring video, multiple continuous real-time monitoring video residual frame images are combined to obtain a real-time monitoring video residual frame image set; real-time monitoring video residual frame image set = {real-time monitoring video residual frame image C i , real-time monitoring video residual frame image C i-1 ,…,Real-time monitoring video residual frame image C i-d}; d+1 is the number of real-time monitoring video residual frame images contained in the real-time monitoring video residual frame image set;
[0051] L3. Using the residual frame stacking method, all the real-time monitoring video residual frame images in the real-time monitoring video residual frame image set are stacked to obtain the residual frame smoke image to be identified;
[0052] By calculating the difference between consecutive frames, the residual frame image obtained can highlight the dynamic changes of smoke, and the characteristics of smoke can be effectively highlighted even in a complex background. This helps to improve the accuracy of smoke recognition; in real-time surveillance videos, the background may contain a variety of interference factors, such as human flow, lighting changes, etc. Through the calculation of residual frames, these static or slowly changing background factors are greatly weakened or eliminated, thereby reducing background interference and focusing on capturing dynamically changing targets such as smoke; compared to directly analyzing the original video frames, the residual frames have a smaller amount of data and lower complexity; by stacking multiple residual frames, the characteristics of smoke changing over time can be further enhanced, making the dynamic diffusion process of smoke more obvious. This helps to improve the ability to recognize the dynamic behavior of smoke, especially in the initial diffusion stage of smoke;
[0053] The method also includes using a swarm optimization algorithm to determine the value of u in step L1 and the value of d in step L2, specifically:
[0054] Construct K individuals H to be optimized k , each individual H to be optimized k contains a set of u and d values, and the values of u and d fluctuate within a preset range; k The combination obtains the iterative population of values to be optimized; the maximum number of iterations is set; the maximum number of iterations is obtained by professional and technical personnel based on actual conditions; the values of u and d fluctuate within the preset value range and take integers; the preset value range is set by professional and technical personnel based on actual conditions, for example, the value range of u is 15~20; the value range of d is 20~40;
[0055] According to the value to be optimized, iterate the individuals H in the population to be optimized. k Perform simulation calculations to obtain the value evaluation score W k ; The evaluation score W will be k As the individual H to be optimized k The fitness S k ;
[0056] The specific steps of simulation calculation are:
[0057] Construct J simulated real-time monitoring videos V j , j=1,2,…,J; the individual H to be optimized k The value of u in is applied to step L1, and the value of d is applied to step L2. j The residual frame stacking method is used to obtain the simulated residual frame smoke image G to be identified kj ; Simulate the residual frame to be identified smoke image G kj Input into the smoke rough recognition model for smoke recognition, and obtain the simulated smoke recognition result Rkj ; J simulated real-time monitoring video V j The simulated videos collected in different monitoring environments and different smoke scenarios can simulate various situations that may be encountered in reality, including different lighting conditions, background complexity, smoke density, etc. By testing the simulated videos in different environments and scenarios, the key parameters in the residual frame stacking method, such as the values of u and d, can be adjusted and optimized more accurately.
[0058] Using the formula W k= O a *(1 / A k )+O b *B k , and get the individual H to be optimized k The value evaluation score W k ; A k Indicates that all simulated residual frames are to be identified smoke images G kj The numerical mean of the time input to the smoke rough recognition model for smoke recognition; B k Represents all simulated smoke recognition results R kj The average accuracy of the simulated smoke recognition result R kj If the recognition is accurate, the simulated smoke recognition result R kj The accuracy value is 1; otherwise, the simulated smoke recognition result R kj The accuracy value of is 0; a Indicates the value evaluation score W k Middle A k The weight of O b Indicates the value evaluation score W k Medium k The weight of a +O b =1,O a and O b The value is set by professional technicians based on actual conditions;
[0059] When the population optimization algorithm is a genetic algorithm, it also includes update operations on the iterative population of optimized values, such as recombination, selection, and mutation operations;
[0060] The reorganization operation is to take two random individuals H to be optimized in the iterative population of optimized values. k Perform cross-exchange of values and exchange the two individuals H to be optimized k The value of u or the value of d;
[0061] The selection operation is to optimize the individual H k The fitness S k Based on this, the roulette wheel selection algorithm is used to select the individuals H to be optimized in the optimization value iteration population.k Select and choose the better individual H to be optimized k Form a new iterative population of values to be optimized;
[0062] The mutation operation is to iterate each individual H to be optimized in the population for the value to be optimized k , randomly generate a value of mutation probability, and randomly select a part of individuals H to be optimized according to the mutation probability k For the individual H selected for mutation, k , randomly select the value of u or d to change;
[0063] When the maximum number of iterations is reached, the output is the individual to be optimized H corresponding to the maximum fitness k , that is, the optimal individual to be optimized, and the value of u in step L1 and the value of d in step L2 are determined according to the values of u and d in the optimal individual to be optimized;
[0064] The smoke rough recognition model includes an image preprocessing layer, a feature recognition layer and a result output layer;
[0065] The image preprocessing layer is used to perform image preprocessing on the residual frame to-be-recognized smoke image to obtain a preprocessed residual frame to-be-recognized smoke image;
[0066] The feature recognition layer is used to perform image feature recognition based on the smoke image to be recognized in the preprocessed residual frame to obtain the initial smoke recognition result;
[0067] The result output layer is used to output the initial smoke recognition results;
[0068] The specific steps for training the rough smoke recognition model include:
[0069] Collect several smoke rough recognition training images with target value annotations; the smoke rough recognition training images are in the same form as the residual frame smoke images to be recognized, and can both be input into the smoke rough recognition model for recognition; the target value indicates whether there is smoke in the smoke rough recognition training image; combine several smoke rough recognition training images with target value annotations to obtain a smoke rough recognition training set;
[0070] Input the smoke rough recognition training set into the smoke rough recognition initial model to perform model training with the target value as the target, and obtain a trained smoke rough recognition initial model; perform model evaluation on the trained smoke rough recognition initial model to obtain an evaluation result of the smoke rough recognition initial model; if the evaluation result of the smoke rough recognition initial model is passed, the trained smoke rough recognition initial model is used as the smoke rough recognition model; otherwise, continue to perform model training using the smoke rough recognition training set;
[0071] The CNN model is used as the basic model of the smoke rough recognition model. By annotating the target values of the smoke rough recognition training images, the model can learn the difference between smoke and non-smoke images. By collecting a variety of smoke rough recognition training images, the model can be trained in different monitoring environments and smoke situations.
[0072] S2. Perform image enhancement operation on the electronic cigarette smoke image to be identified to obtain an enhanced electronic cigarette smoke image to be identified; input the enhanced electronic cigarette smoke image to be identified into the smoke recognition model to perform smoke recognition and obtain an electronic cigarette smoke recognition result; if the electronic cigarette smoke recognition result is that electronic cigarette smoke exists, notify relevant personnel to perform corresponding operations, such as if the detected area is equipped with a ventilation system, the ventilation system can be automatically or manually started to reduce the concentration and impact of the smoke; otherwise, continue to perform electronic cigarette smoke detection at preset time intervals;
[0073] The specific steps of performing an image enhancement operation on the electronic cigarette smoke image to be identified to obtain an enhanced electronic cigarette smoke image to be identified include:
[0074] Q1. Use background removal technology to remove the background of the electronic cigarette smoke image to be identified, and obtain the background-removed electronic cigarette smoke image to be identified;
[0075] Q2. Perform image enhancement on the background-removed electronic cigarette smoke image to be identified using a filtering enhancement algorithm to obtain an enhanced electronic cigarette smoke image to be identified; perform fuzzy detection on the enhanced electronic cigarette smoke image to be identified using a Laplace operator to obtain an edge detection variance; if the edge detection variance is lower than a preset fuzzy variance threshold, continue to perform image enhancement on the enhanced electronic cigarette smoke image to be identified using a filtering enhancement algorithm until the edge detection variance reaches a preset fuzzy variance threshold; otherwise, perform fuzzy detection on the enhanced electronic cigarette smoke image to be identified as an enhanced electronic cigarette smoke image to be identified;
[0076] By using background removal technology, background information irrelevant to smoke in the image is removed, making the features of the electronic cigarette smoke image to be identified more prominent; by using the filtering enhancement algorithm to enhance the background-removed electronic cigarette smoke image to be identified, the contrast and clarity of the image can be improved, and the edge and texture features of the smoke can be more obvious, thereby providing a higher quality image for smoke identification; by using the Laplace operator to calculate the fuzzy detection and edge detection variance, the level of image enhancement can be automatically adjusted according to the actual situation of the image; the Laplace operator is used to detect the edge of the electronic cigarette smoke image to be judged and enhanced to be identified, and the edge detection variance is obtained; for images with higher clarity, the edge information is rich, so the corresponding variance value is larger; conversely, the edge information of the blurred image is less, resulting in a smaller variance value; when the variance value obtained after the image is detected by the edge is lower than the preset fuzzy variance threshold, it indicates that the clarity of the image is insufficient and further enhancement processing is needed to improve its clarity; the preset fuzzy variance threshold is set by professional and technical personnel according to the actual situation, for example, the preset fuzzy variance threshold can be taken as 0.02;
[0077] In step S2, the self-attention model is used as the basic model of the smoke essence recognition model, and the smoke essence recognition model includes a shallow smoke feature extraction layer, a deep smoke feature extraction layer, and a result output layer;
[0078] The shallow smoke feature extraction layer is used to extract and combine the local features of the enhanced electronic cigarette smoke image to be identified by using convolution operation, so as to obtain the deep features of the enhanced electronic cigarette smoke image to be identified;
[0079] The deep smoke feature extraction layer is used to perform feature recognition on the deep features of the electronic cigarette smoke image to be identified, and obtain the electronic cigarette smoke recognition result;
[0080] The result output layer is used to output the electronic cigarette smoke recognition results;
[0081] The specific steps for training the smoke essence recognition model include:
[0082] Collect several electronic cigarette smoke images and other smoke images with manually annotated electronic cigarette recognition results; the electronic cigarette smoke images and other smoke images have the same image form as the enhanced electronic cigarette smoke images to be recognized, and can be input into the smoke essence recognition model for recognition; combine several electronic cigarette smoke images and other smoke images with manually annotated electronic cigarette recognition results to obtain a smoke essence recognition training set; the manually annotated electronic cigarette recognition results are used as the target value of the smoke essence recognition training set;
[0083] Input the smoke spirit recognition training set into the smoke spirit recognition initial model to perform model training with the target value as the target, and obtain a trained smoke spirit recognition initial model; perform model evaluation on the trained smoke spirit recognition initial model to obtain a smoke spirit recognition initial model evaluation result; if the smoke spirit recognition initial model evaluation result is passed, the trained smoke spirit recognition initial model is used as the smoke spirit recognition model; otherwise, continue to perform model training using the smoke spirit recognition training set;
[0084] By adopting the self-attention model as the basic model and combining it with shallow and deep smoke feature extraction layers, this method can effectively capture the subtle features and complex patterns in electronic cigarette smoke images; by collecting and using electronic cigarette smoke images and other smoke images with human annotations for training, the model can learn the characteristic differences of different types of smoke, thereby showing better generalization and robustness when facing unknown smoke images; by combining the self-attention mechanism to jointly extract the features of the object, the model has a stronger representation ability for smoke features while keeping the network structure lightweight, and shows excellent recognition performance in the task of smoke recognition.
[0085] Example 2, an electronic cigarette smoke detection system based on image recognition, see Figure 1 As shown, including:
[0086] The image coarse recognition module is used to deploy the smoke coarse recognition model, obtain the real-time monitoring video, extract the current frame image in the real-time monitoring video at a preset time interval, and obtain the real-time monitoring video frame screenshot P i , i=im,i-m+1,…,i,…I; m represents the m frames before the current i-th frame; the residual frame stacking method is used to obtain the screenshot P based on the real-time monitoring video frame i The residual frame smoke image to be identified is input into the smoke rough recognition model to perform smoke recognition, and obtain an initial smoke recognition result; if the initial smoke recognition result is that smoke exists, the residual frame smoke image to be identified is used as the electronic cigarette smoke image to be identified; otherwise, the electronic cigarette smoke detection is continued at a preset time interval;
[0087] An image enhancement module is used to perform an image enhancement operation on the electronic cigarette smoke image to be identified to obtain an enhanced electronic cigarette smoke image to be identified;
[0088] The image precision recognition module is used to deploy the smoke precision recognition model, input the enhanced electronic cigarette smoke image to be recognized into the smoke precision recognition model for smoke recognition, and obtain the electronic cigarette smoke recognition result; if the electronic cigarette smoke recognition result is that electronic cigarette smoke exists, the relevant personnel are notified to perform corresponding operations; otherwise, electronic cigarette smoke detection continues at the preset time interval.
[0089] It should be understood that those skilled in the art can make improvements or changes based on the above description, and all such improvements and changes should fall within the scope of protection of the appended claims of the present invention. Parts not described in detail in this specification belong to the prior art known to those skilled in the art.
Claims
1. An electronic cigarette smoke detection method based on image recognition, characterized in that: include: S1. Obtain real-time surveillance video, extract the current frame image in the real-time surveillance video at a preset time interval, and obtain a real-time surveillance video frame screenshot P i , i=im,i-m+1,…,i,…I; m represents the m frames before the current i-th frame; The residual frame stacking method is used to obtain the real-time monitoring video frame screenshot P i The residual frame of the smoke image to be identified; The residual frame smoke image to be identified is input into the smoke rough identification model for smoke identification to obtain an initial smoke identification result; if the initial smoke identification result is that smoke exists, the residual frame smoke image to be identified is used as the electronic cigarette smoke image to be identified; otherwise, the electronic cigarette smoke detection is continued at a preset time interval; S2. performing an image enhancement operation on the electronic cigarette smoke image to be identified to obtain an enhanced electronic cigarette smoke image to be identified; The enhanced electronic cigarette smoke image to be identified is input into the smoke precision recognition model for smoke recognition, and the electronic cigarette smoke recognition result is obtained; If the electronic cigarette smoke identification result shows that there is electronic cigarette smoke, the relevant personnel are notified to perform corresponding operations; otherwise, the electronic cigarette smoke detection continues at the preset time interval; The specific steps of using the residual frame stacking method to obtain the residual frame smoke image to be identified of the real-time monitoring video include: L1. Extract real-time surveillance video frame screenshot P i and real-time monitoring video frame screenshots i-u ; Use the formula to monitor the video residual frame image C in real time i =|Real-time monitoring video frame screenshot P i - Real-time monitoring video frame screenshot P i-u |, get the real-time monitoring video residual frame image C i ; u represents real-time monitoring video frame screenshot P i-u and real-time monitoring video frame screenshots i The number of frames between L2. Based on the real-time monitoring video, multiple continuous real-time monitoring video residual frame images are combined to obtain a real-time monitoring video residual frame image set; real-time monitoring video residual frame image set = {real-time monitoring video residual frame image C i , real-time monitoring video residual frame image C i-1 ,…,Real-time monitoring video residual frame image C i-d }; d+1 is the number of real-time monitoring video residual frame images contained in the real-time monitoring video residual frame image set; L3. Use the residual frame stacking method to stack all the real-time monitoring video residual frame images in the real-time monitoring video residual frame image set to obtain the residual frame smoke image to be identified.
2. The electronic cigarette smoke detection method based on image recognition according to claim 1, characterized in that: The method also includes using a swarm optimization algorithm to determine the value of u in step L1 and the value of d in step L2, specifically: Construct K individuals H to be optimized k , each individual H to be optimized k contains a set of u and d values, and the values of u and d fluctuate within a preset range; k Combine to obtain the iterative population of values to be optimized; set the maximum number of iterations; According to the value to be optimized, iterate the individuals H in the population to be optimized. k Perform simulation calculations to obtain the value evaluation score W k ; The evaluation score W will be k As the individual H to be optimized k The fitness S k ; The specific steps of simulation calculation are: Construct J simulated real-time monitoring videos V j , j=1,2,…,J; the individual H to be optimized k The value of u in is applied to step L1, and the value of d is applied to step L2. j The residual frame stacking method is used to obtain the simulated residual frame smoke image G to be identified kj ; Simulate the residual frame to be identified smoke image G kj Input into the smoke rough recognition model for smoke recognition, and obtain the simulated smoke recognition result R kj ; Using the formula W k= O a *(1 / A k )+O b *B k , and get the individual H to be optimized k The value evaluation score W k ; A k Indicates that all simulated residual frames are to be identified smoke images G kj The numerical mean of the time input to the smoke rough recognition model for smoke recognition; B k Represents all simulated smoke recognition results R kj The average accuracy of the simulated smoke recognition result R kj If the recognition is accurate, the simulated smoke recognition result R kj The accuracy value is 1; otherwise, the simulated smoke recognition result R kj The accuracy value of is 0; a Indicates the value evaluation score W k Middle A k The weight of O b Indicates the value evaluation score W k Medium k The weight of When the maximum number of iterations is reached, the output is the individual to be optimized H corresponding to the maximum fitness k , that is, the optimal individual to be optimized. The value of u in step L1 and the value of d in step L2 are determined according to the values of u and d in the optimal individual to be optimized.
3. The electronic cigarette smoke detection method based on image recognition according to claim 2 is characterized in that the smoke The coarse recognition model includes image preprocessing layer, feature recognition layer and result output layer: The image preprocessing layer is used to perform image preprocessing on the residual frame to-be-recognized smoke image to obtain a preprocessed residual frame to-be-recognized smoke image; The feature recognition layer is used to perform image feature recognition based on the smoke image to be recognized in the preprocessed residual frame to obtain the initial smoke recognition result; The result output layer is used to output the initial smoke recognition results.
4. The electronic cigarette smoke detection method based on image recognition according to claim 3 is characterized in that: The specific steps for training the rough smoke recognition model include: Collect several smoke rough recognition training images with target value annotations; the smoke rough recognition training images are in the same form as the residual frame smoke image to be recognized; the target value indicates whether there is smoke in the smoke rough recognition training image; combine several smoke rough recognition training images with target value annotations to obtain a smoke rough recognition training set; The smoke rough recognition training set is input into the smoke rough recognition initial model, and the model training is performed with the target value as the target to obtain the trained smoke rough recognition initial model; the trained smoke rough recognition initial model is evaluated to obtain the smoke rough recognition initial model evaluation result; if the smoke rough recognition initial model evaluation result is passed, the trained smoke rough recognition initial model is used as the smoke rough recognition model; otherwise, the smoke rough recognition training set is used to continue the model training.
5. The electronic cigarette smoke detection method based on image recognition according to claim 4 is characterized in that: The specific steps of performing an image enhancement operation on the electronic cigarette smoke image to be identified to obtain an enhanced electronic cigarette smoke image to be identified include: Q1. Use background removal technology to remove the background of the electronic cigarette smoke image to be identified, and obtain the background-removed electronic cigarette smoke image to be identified; Q2. Use the filtering enhancement algorithm to enhance the background-removed electronic cigarette smoke image to be identified, and obtain the enhanced electronic cigarette smoke image to be identified; use the Laplace operator to perform fuzzy detection on the enhanced electronic cigarette smoke image to be identified, and obtain the edge detection variance; if the edge detection variance is lower than the preset fuzzy variance threshold, continue to use the filtering enhancement algorithm to enhance the electronic cigarette smoke image to be identified, until the edge detection variance reaches the preset fuzzy variance threshold; otherwise, perform fuzzy detection on the enhanced electronic cigarette smoke image to be identified as the enhanced electronic cigarette smoke image to be identified.
6. The electronic cigarette smoke detection method based on image recognition according to claim 5, characterized in that: In step S2, the self-attention model is used as the basic model of the smoke essence recognition model, and the smoke essence recognition model includes a shallow smoke feature extraction layer, a deep smoke feature extraction layer, and a result output layer; The shallow smoke feature extraction layer is used to extract and combine the local features of the enhanced electronic cigarette smoke image to be identified by using convolution operation, so as to obtain the deep features of the enhanced electronic cigarette smoke image to be identified; The deep smoke feature extraction layer is used to perform feature recognition on the deep features of the electronic cigarette smoke image to be identified, and obtain the electronic cigarette smoke recognition result; The result output layer is used to output the electronic cigarette smoke recognition results.
7. The electronic cigarette smoke detection method based on image recognition according to claim 6, characterized in that: The specific steps for training the smoke essence recognition model include: Collect several electronic cigarette smoke images and other smoke images with manually annotated electronic cigarette recognition results; the electronic cigarette smoke images and other smoke images have the same image form as the enhanced electronic cigarette smoke images to be recognized; combine several electronic cigarette smoke images and other smoke images with manually annotated electronic cigarette recognition results to obtain a smoke essence recognition training set; the manually annotated electronic cigarette recognition results are used as target values of the smoke essence recognition training set; The smoke spirit recognition training set is input into the smoke spirit recognition initial model, and the model training is performed with the target value as the target to obtain the trained smoke spirit recognition initial model; the trained smoke spirit recognition initial model is evaluated to obtain the smoke spirit recognition initial model evaluation result; if the smoke spirit recognition initial model evaluation result is passed, the trained smoke spirit recognition initial model is used as the smoke spirit recognition model; otherwise, the smoke spirit recognition training set is used to continue the model training.
8. An electronic cigarette smoke detection system based on image recognition, characterized in that: The system applies an electronic cigarette smoke detection method based on image recognition as described in any one of claims 1 to 7, including: The image coarse recognition module is used to deploy the smoke coarse recognition model, obtain the real-time monitoring video, extract the current frame image in the real-time monitoring video at a preset time interval, and obtain the real-time monitoring video frame screenshot P i , i=im,i-m+1,…,i,…I; m represents the m frames before the current i-th frame; the residual frame stacking method is used to obtain the real-time monitoring video frame screenshot P i The residual frame smoke image to be identified is input into the smoke rough recognition model to perform smoke recognition, and obtain an initial smoke recognition result; if the initial smoke recognition result is that smoke exists, the residual frame smoke image to be identified is used as the electronic cigarette smoke image to be identified; otherwise, the electronic cigarette smoke detection is continued at a preset time interval; An image enhancement module is used to perform an image enhancement operation on the electronic cigarette smoke image to be identified to obtain an enhanced electronic cigarette smoke image to be identified; The image precision recognition module is used to deploy the smoke precision recognition model, input the enhanced electronic cigarette smoke image to be recognized into the smoke precision recognition model for smoke recognition, and obtain the electronic cigarette smoke recognition result; if the electronic cigarette smoke recognition result is that electronic cigarette smoke exists, the relevant personnel are notified to perform corresponding operations; otherwise, electronic cigarette smoke detection continues at the preset time interval.
