CN116935496B - Electronic cigarette smoke visual detection method - Google Patents
Electronic cigarette smoke visual detection method Download PDFInfo
- Publication number
- CN116935496B CN116935496B CN202311195814.0A CN202311195814A CN116935496B CN 116935496 B CN116935496 B CN 116935496B CN 202311195814 A CN202311195814 A CN 202311195814A CN 116935496 B CN116935496 B CN 116935496B
- Authority
- CN
- China
- Prior art keywords
- pixel point
- electronic cigarette
- gray level
- cigarette smoke
- target pixel
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
- 239000003571 electronic cigarette Substances 0.000 title claims abstract description 167
- 239000000779 smoke Substances 0.000 title claims abstract description 165
- 238000001514 detection method Methods 0.000 title claims abstract description 16
- 230000000007 visual effect Effects 0.000 title claims abstract description 8
- 238000000034 method Methods 0.000 claims abstract description 57
- 241000270295 Serpentes Species 0.000 claims abstract description 41
- 238000012545 processing Methods 0.000 claims abstract description 20
- 238000003708 edge detection Methods 0.000 claims abstract description 12
- 238000013507 mapping Methods 0.000 claims description 3
- 230000000694 effects Effects 0.000 description 4
- 230000007423 decrease Effects 0.000 description 3
- 238000004458 analytical method Methods 0.000 description 2
- 230000003247 decreasing effect Effects 0.000 description 2
- 238000001914 filtration Methods 0.000 description 2
- 230000001788 irregular Effects 0.000 description 2
- 238000012544 monitoring process Methods 0.000 description 2
- 238000012935 Averaging Methods 0.000 description 1
- 230000003044 adaptive effect Effects 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 235000019504 cigarettes Nutrition 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 238000000605 extraction Methods 0.000 description 1
- 238000012804 iterative process Methods 0.000 description 1
- 238000007781 pre-processing Methods 0.000 description 1
- 230000000750 progressive effect Effects 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06V—IMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
- G06V40/00—Recognition of biometric, human-related or animal-related patterns in image or video data
- G06V40/20—Movements or behaviour, e.g. gesture recognition
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06V—IMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
- G06V10/00—Arrangements for image or video recognition or understanding
- G06V10/40—Extraction of image or video features
- G06V10/44—Local feature extraction by analysis of parts of the pattern, e.g. by detecting edges, contours, loops, corners, strokes or intersections; Connectivity analysis, e.g. of connected components
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06V—IMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
- G06V10/00—Arrangements for image or video recognition or understanding
- G06V10/70—Arrangements for image or video recognition or understanding using pattern recognition or machine learning
- G06V10/74—Image or video pattern matching; Proximity measures in feature spaces
- G06V10/75—Organisation of the matching processes, e.g. simultaneous or sequential comparisons of image or video features; Coarse-fine approaches, e.g. multi-scale approaches; using context analysis; Selection of dictionaries
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06V—IMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
- G06V10/00—Arrangements for image or video recognition or understanding
- G06V10/70—Arrangements for image or video recognition or understanding using pattern recognition or machine learning
- G06V10/764—Arrangements for image or video recognition or understanding using pattern recognition or machine learning using classification, e.g. of video objects
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02P—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN THE PRODUCTION OR PROCESSING OF GOODS
- Y02P90/00—Enabling technologies with a potential contribution to greenhouse gas [GHG] emissions mitigation
- Y02P90/30—Computing systems specially adapted for manufacturing
Abstract
The invention relates to the field of image processing, in particular to a visual detection method for electronic cigarette smoke. The method comprises the following steps: performing edge detection on a gray level image of the electronic cigarette smoke to obtain an initial curve, iteratively selecting a target pixel point from any pixel point on the initial curve to obtain a plurality of target pixel point groups, obtaining local gray level change degrees according to gray level differences and position distribution of the target pixel points in the target pixel point groups, further obtaining overall gray level change degrees, and obtaining external force weights according to the overall gray level change degrees and first gradients of the pixel points; according to the external force weight and the second gradient of the pixel point, the weighted external force of the pixel point is obtained, the weighted external force is used as the external force parameter of the snake model, and the electronic cigarette smoke is detected.
Description
Technical Field
The invention relates to the technical field of image processing, in particular to a visual detection method for electronic cigarette smoke.
Background
In recent years, the electronic cigarette industry around the world has tremendous development, and the monitoring of the use condition of the electronic cigarette is not slow, and because people using the electronic cigarette in public places are scattered, the use of manual data statistics can lead to inaccurate data and untimely feedback, a more timely and efficient method is needed for monitoring the people using the electronic cigarette, and smoke is generated in the process of using the electronic cigarette, so the method is an important index for detecting the use condition of the electronic cigarette.
In the process of detecting the electronic cigarette smoke, the detection of the electronic cigarette smoke can be realized by extracting the outline of the electronic cigarette smoke, and the method for extracting the outline commonly used in the prior art comprises the following steps: the snake model is used for realizing the contour extraction of the target, but because the edge condition of the electronic cigarette smoke is complex, a large number of irregular and deep concave boundaries exist, so that the evolution curve of the snake model cannot converge to the concave boundaries in the iteration process, the concave boundaries cannot be detected by the snake model, and the accuracy of the electronic cigarette smoke detection is reduced.
Disclosure of Invention
In order to solve the technical problems that a large number of irregular and deeply recessed boundaries exist at the edges of the electronic cigarette smoke, so that an evolution curve of a snake model cannot converge to the recessed boundaries in an iterative process, and further the recessed boundaries cannot be detected by using the snake model, and the accuracy of the electronic cigarette smoke detection is reduced, the invention aims to provide an electronic cigarette smoke visual detection method, which adopts the following specific technical scheme:
the invention provides a visual detection method for electronic cigarette smoke, which comprises the following steps:
acquiring a gray level image of electronic cigarette smoke;
performing edge detection processing on a gray level image to obtain an initial curve of the electronic cigarette smoke, taking a pixel point on the initial curve as an initial pixel point, taking any one initial pixel point as a target pixel point, constructing a preset neighborhood range by taking the target pixel point as a center, and obtaining a target pixel point group of each initial pixel point according to gray level difference between the target pixel point and other pixel points in the preset neighborhood range;
obtaining local gray level change degrees of the electronic cigarette smoke according to gray level differences among the target pixel points in each target pixel point group and positions of the target pixel points in the gray level image, and obtaining the overall gray level change degrees of the electronic cigarette smoke according to all the local gray level change degrees;
acquiring a first gradient and a second gradient of each pixel point in the gray image based on different edge detection operators, and acquiring external force weights of the pixel points according to the integral gray change degree and the first gradient of each pixel point in the gray image; obtaining weighted external force of the pixel points according to the external force weight and the second gradient of each pixel point in the gray level image;
and detecting the electronic cigarette smoke in the gray level image according to the weighted external force.
Further, the method for acquiring the initial curve of the electronic cigarette smoke comprises the following steps:
performing edge detection processing on the gray level image to obtain an edge contour in the gray level image;
acquiring a historical lip feature template, and performing template matching on the gray level image by using the historical lip feature template to acquire a lip region in the gray level image;
and taking the edge contour nearest to the lip area as an initial contour of the electronic cigarette smoke, and taking a curve of the initial contour and the lip area as an initial curve of the electronic cigarette smoke.
Further, the method for acquiring the target pixel point group of each initial pixel point includes:
taking the absolute value of the gray value difference value of each other pixel point in the target pixel point and the preset neighborhood range as the first gray difference of the other pixel points;
if the first gray level difference is smaller than a preset difference threshold, taking the gray level value difference between the target pixel point and other pixel points in the preset neighborhood range as the judgment parameters of the other pixel points, and if the first gray level difference is not smaller than the preset difference threshold, taking a preset constant as the judgment parameters of the other pixel points;
determining whether the judging parameters of other pixels in the preset neighborhood range of the target pixel meet preset conditions;
when the judging parameters meet preset conditions, taking other pixel points corresponding to the minimum positive values of all the judging parameters in the preset neighborhood range as the next target pixel point, and continuing to execute the selection process;
and stopping selecting when the judging parameters do not meet preset conditions, and taking the obtained target pixel point combination as a target pixel point group of the initial pixel points, so that all the initial pixel points are traversed, and the target pixel point group of each initial pixel point is obtained.
Further, determining whether the determination parameters of other pixels in the preset neighborhood range of the target pixel meet the preset conditions includes:
if the judgment parameters of other pixel points in the preset neighborhood range have positive values, a preset condition is met;
if the judgment parameters of other pixels in the preset neighborhood range have no positive values, the preset condition is not met.
Further, the method for acquiring the local gray level variation degree of the electronic cigarette smoke comprises the following steps:
constructing a regression curve of each target pixel point group by using a polynomial fitting method according to the position of the target pixel point in the gray level image;
taking the absolute value of the gray value difference value between adjacent target pixel points on each regression curve as a second gray difference value;
and taking the average value of the second gray level difference on each regression curve as the local gray level change degree of the electronic cigarette smoke corresponding to the regression curve.
Further, the method for acquiring the overall gray level variation degree of the electronic cigarette smoke comprises the following steps:
and taking the average value of all the local gray level variation degrees as the whole gray level variation degree of the electronic cigarette smoke.
Further, the method for acquiring the external force weight of the pixel point comprises the following steps:
taking the product value of the integral gray level variation degree and the first gradient of each pixel point as the external force weight of the pixel point.
Further, the method for acquiring the weighted external force of the pixel point comprises the following steps:
and carrying out negative correlation mapping on the product value of the external force weight and the second gradient of each pixel point to obtain the weighted external force of the pixel point.
Further, the first gradient is a result of processing the pixel point by the LOG gradient operator, and the second gradient is a result of processing the pixel point by the sobel operator.
Further, the detecting the electronic cigarette smoke in the gray level image according to the weighted external force includes:
and detecting the electronic cigarette smoke by using a snake model based on the weighted external force, wherein the weighted external force is an external force parameter used by the snake model.
The invention has the following beneficial effects:
the invention considers that the gray value of the electronic cigarette smoke has larger difference with the gray value of the background, and the electronic cigarette smoke has certain flowing characteristic in the process of being sprayed out from the mouth of a user, so that the gray value of the pixel points in the smoke area shows a gradually decreasing trend, therefore, firstly, an initial curve of the electronic cigarette smoke is obtained, the gray value of the pixel points on the initial curve is larger relative to the gray value of the pixel points in the smoke area, the pixel points on the initial curve are taken as initial pixel points, any one of the initial pixel points is selected as a target pixel point, a preset neighborhood range is constructed for the target pixel points based on the characteristic that the gray value of the pixel points in the electronic cigarette smoke area gradually decreases, a target pixel point group of each initial pixel point is obtained according to the gray difference between the target pixel point and other pixel points in the preset neighborhood range, the difference of the gray values of all the target pixel points in the target pixel point groups can reflect the change degree of the gray values of the local pixel points of the electronic cigarette smoke caused by the flow characteristic, the position distribution of the target pixel points in the gray image can reflect the flowing trend of the electronic cigarette smoke in the local area, and data support is provided for the subsequent analysis of the integral gray change degree of the electronic cigarette smoke, so the local gray change degree of the electronic cigarette smoke can be obtained according to the gray difference of the target pixel points in each target pixel point group and the position of the target pixel points in the gray image, the integral gray change degree of the electronic cigarette smoke can be obtained by combining all the local gray change degrees, the integral gray change degree can reflect the integral change condition of the gray values of the pixel points in the electronic cigarette smoke area, and the flowing trend of each electronic cigarette smoke in the air is different, therefore, the integral gray scale change degree of each electronic cigarette smoke is also different, so that the external force weight can be adaptively adjusted according to the integral gray scale change degree, the gradient of the pixel point is only used as the limitation of the external force in the original snake model, no matter how many times the iteration is performed, the evolution curve in the snake model is difficult to be converged to the boundary of the depth recess all the time, the external force weight is introduced on the basis of the original external force of the snake model, the external force weight of the pixel point is obtained according to the integral gray scale change degree and the first gradient of each pixel point in the gray scale image, the weighted external force can be obtained in the follow-up, the automatic control of the external force in the snake model is realized, and the evolution curve in the snake model can enter the boundary of the depth recess of the electronic cigarette under the action of the weighted external force. According to the method, the target pixel point group of each initial pixel point is obtained, the gray level change degree of the target pixel point group is obtained according to the gray level difference between the target pixel points in the target pixel point group and the position of the target pixel points in the gray level image, the overall gray level change degree of the electronic cigarette smoke is further obtained, the external force weight is obtained according to the overall gray level change degree and the first gradient of the pixel points, the external force weight is used as the weight of the second gradient of the pixel points, and the weighted external force is obtained, so that the evolution curve in the snake model can be converged to the boundary of the depth recess under the action of the weighted external force, the recess boundary of the electronic cigarette smoke can be detected, and the accuracy of detecting the electronic cigarette smoke is improved.
Drawings
In order to more clearly illustrate the embodiments of the invention or the technical solutions and advantages of the prior art, the following description will briefly explain the drawings used in the embodiments or the description of the prior art, and it is obvious that the drawings in the following description are only some embodiments of the invention, and other drawings can be obtained according to the drawings without inventive effort for a person skilled in the art.
Fig. 1 is a flowchart of a method for detecting smoke of an electronic cigarette according to an embodiment of the present invention.
Detailed Description
In order to further describe the technical means and effects adopted by the invention to achieve the preset aim, the following is a detailed description of specific implementation, structure, characteristics and effects of the electronic cigarette smoke vision detection method according to the invention with reference to the accompanying drawings and the preferred embodiment. In the following description, different "one embodiment" or "another embodiment" means that the embodiments are not necessarily the same. Furthermore, the particular features, structures, or characteristics of one or more embodiments may be combined in any suitable manner.
Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs.
The following specifically describes a specific scheme of the electronic cigarette smoke visual detection method provided by the invention with reference to the accompanying drawings.
Referring to fig. 1, a flowchart of a method for detecting smoke of an electronic cigarette according to an embodiment of the present invention is shown, where the method includes:
step S1: and acquiring a gray level image of the electronic cigarette smoke.
According to the embodiment of the invention, the RGB image of the surrounding environment of the public place is acquired through the camera monitor, noise in the acquired RGB image affects the quality of the image and is unfavorable for subsequent detection of the electronic cigarette smoke, so that denoising pretreatment is required to be carried out on the acquired RGB image, and the edge of the electronic cigarette smoke is complex, so that the problem of detail blurring caused to the image after denoising treatment is prevented in order to preserve the detail characteristics of the edge of the electronic cigarette smoke as much as possible, and the accuracy of subsequent detection of the electronic cigarette smoke is reduced.
In one embodiment of the present invention, the collected RGB image may be subjected to denoising preprocessing by using a median filtering method, and it should be noted that the median filtering is a technical means well known to those skilled in the art, and will not be described herein.
In order to reduce the calculation amount of the subsequent image processing and increase the processing speed, in one embodiment of the present invention, the acquired RGB image is converted into a single-channel gray image by performing gray processing, and it should be noted that the gray processing is a technical means well known to those skilled in the art, and will not be described herein.
After the gray level image is obtained, the gray level image can be analyzed in the follow-up process, and detection of the electronic cigarette smoke is achieved.
Step S2: performing edge detection processing on the gray level image to obtain an initial curve of the electronic cigarette smoke, taking a pixel point on the initial curve as an initial pixel point, taking any one initial pixel point as a target pixel point, constructing a preset neighborhood range by taking the target pixel point as a center, and obtaining a target pixel point group of each initial pixel point according to gray level difference between the target pixel point and other pixel points in the preset neighborhood range.
Because the electronic cigarette smoke can cause the rapid flow of air when being sprayed out from the mouth of a user, the electronic cigarette smoke has certain flow characteristics, the gray value of the pixel points in the electronic cigarette smoke is gradually reduced due to the flow characteristics, and the contrast between the electronic cigarette smoke in the gray image and the background is larger, so that the gray image can be subjected to edge detection processing to obtain an initial curve of the electronic cigarette smoke, the gray value of the pixel points on the initial curve is larger than the gray values of other pixel points in the electronic cigarette smoke, and the target pixel points which can reflect the flow characteristics of the electronic cigarette smoke can be selected from the pixel points on the initial curve in the follow-up.
Preferably, in one embodiment of the present invention, the method for acquiring the initial curve of the electronic cigarette smoke specifically includes:
performing edge detection processing on the gray level image to obtain an edge contour in the gray level image; acquiring a historical lip feature template, and performing template matching on the gray level image by using the historical lip feature template to acquire a lip region in the gray level image; and taking the edge contour closest to the lips as an initial contour of the electronic cigarette smoke, and taking a curve of the initial contour and the lip area as an initial curve of the electronic cigarette smoke. Because the electronic cigarette smoke is sprayed out from the mouth of a user, the gray value of the pixel point on the initial curve is larger, and the gray value of the pixel point in the electronic cigarette smoke is gradually reduced along with the flow of the electronic cigarette smoke.
Because the gray value of the pixel point on the initial curve is larger than the gray values of other pixel points in the electronic cigarette smoke, a target pixel point can be selected from the pixel points on the initial curve, any one pixel point on the initial curve is used as the initial pixel point, and the initial pixel point is used as the first selected target pixel point, because the gray value of the pixel point in the electronic cigarette smoke shows a gradually decreasing trend, a preset neighborhood range can be constructed for the target pixel point, and according to the gray difference between the target pixel point and other pixel points in the preset neighborhood range, iteratively selecting pixel points in a preset neighborhood range as next target pixel points, taking the selected target pixel points as target pixel point groups of each initial pixel point, wherein the target pixel points in each target pixel point group are selected from the initial pixel points on an initial curve, and the gray values of the target pixel points in each target pixel point group are gradually reduced according to the selection sequence, so that the change characteristic of the gray values of the target pixel points in each target pixel point group can reflect the flow characteristic of the electronic cigarette smoke in the local area, and the size of the preset neighborhood range is set as follows in one embodiment of the invention。
Preferably, in one embodiment of the present invention, the method for acquiring the target pixel point group of each initial pixel point specifically includes:
taking the absolute value of the gray value difference value of each other pixel point in the target pixel point and the preset neighborhood range as the first gray difference of the other pixel points; if the first gray level difference is smaller than the preset difference threshold, taking the gray level value difference between the target pixel point and other pixel points in the preset neighborhood range as the judgment parameters of the other pixel points, and if the first gray level difference is not smaller than the preset difference threshold, taking the preset constant as the judgment parameters of the other pixel points; determining whether the judging parameters of other pixels in the preset neighborhood range of the target pixel meet preset conditions; when the judging parameters meet the preset conditions, taking other pixel points corresponding to the minimum positive values of all the judging parameters in the preset neighborhood range as the next target pixel point, and continuously executing the selection process; and stopping selecting when the judgment parameters do not meet the preset conditions, and taking the obtained target pixel point combination as a target pixel point group of the initial pixel points, so that all the initial pixel points are traversed, and the target pixel point group of each initial pixel point is obtained.
Illustrating: after a certain pixel point is selected as a target pixel point, a preset neighborhood range is built by taking the target pixel point as a center, judging parameters of other pixel points in the preset neighborhood range are calculated, if the judging parameters of the other pixel points in the preset neighborhood range meet preset conditions, the other pixel points corresponding to the minimum positive value of the judging parameters are selected in the preset neighborhood range to serve as newly selected target pixel points, judging parameters of the other pixel points are calculated in the preset neighborhood range of the newly selected target pixel points, similarly, if the judging parameters of the other pixel points in the preset neighborhood range meet the preset conditions, the other pixel points corresponding to the minimum positive value of the judging parameters are continuously selected in the preset neighborhood range to serve as newly selected target pixel points, and if the judging parameters of the other pixel points in the preset neighborhood range do not meet the preset conditions in the selecting process, the next target pixel point is stopped being selected. In the process of selecting the target pixel point, when the selected target pixel point reaches the edge position of the electronic cigarette smoke, the next target pixel point is stopped, and when the selected target pixel point reaches the edge position, the gray value difference between the pixel point belonging to the background in the preset neighborhood range and the target pixel point is larger, at the moment, the judgment parameters of other pixel points in the preset neighborhood range are negative numbers or preset constants, and in one embodiment of the invention, the preset constants are set as negative numbers, at the moment, the judgment parameters of other pixel points in the preset neighborhood range have no positive value, so that in one embodiment of the invention, whether the judgment parameters of other pixel points in the preset neighborhood range of the target pixel point meet the preset conditions is determined as follows: if the judgment parameters of other pixel points in the preset neighborhood range have positive values, the preset condition is met; if the judgment parameters of other pixels in the preset neighborhood range have no positive values, the preset condition is not met.
The specific expression of the decision parameter in one embodiment of the present invention may be, for example:
wherein,represents the +.f. in the preset neighborhood except the center pixel>Judging parameters of other pixel points; />Represents the +.f. in the preset neighborhood except the center pixel>First gray scale differences of the other pixel points; />Representing the gray value of a target pixel point corresponding to a preset neighborhood range, namely the gray value of a central pixel point; />Represents the +.f. in the preset neighborhood except the center pixel>Gray values of the other pixels; />Representing a preset constant; />Representing a preset difference threshold; in one embodiment of the invention +.>Set to-1, < >>Set to 20, it should be noted that, < + >>A constant less than zero needs to be set.
In the process of acquiring the judging parameters of other pixel points in the preset neighborhood range,represents the +.f. in the preset neighborhood except the center pixel>First gray scale difference of other pixels, when first gray scale difference +.>Less than a preset difference threshold->In this case, two conditions exist, the first condition is the gray value difference between the target pixel and some other pixel within the preset neighborhood>Less than 0, i.e. the decision parameter of the pixel +.>Is smaller than 0, which indicates that the gray value of the target pixel point is smaller than the gray value of the pixel point, and the second condition is that the gray value difference value between the target pixel point and some other pixel point in the preset neighborhood rangeIs larger than 0, i.e. the decision parameter of the pixel +.>When the gray value of the selected target pixel point is larger than the gray value of the pixel point, the gray value of the selected next target pixel point needs to be smaller than the gray value of the current target pixel point because the gray value of the selected target pixel point needs to reflect the gradually reduced flow characteristic of the pixel point gray value in the electronic cigarette smoke, namely, the judgment parameter needs to be selected in the preset neighborhood range>In order to more accurately reflect the flow characteristics of the electronic cigarette smoke, in one embodiment of the invention, the pixel corresponding to the minimum positive value of all the judging parameters in the preset neighborhood range is used as the next target pixel, when the selected target pixel reaches the edge of the electronic cigarette smoke, the selection of the next target pixel is stopped, and at the moment, the first gray value of the pixel belonging to the background in the preset neighborhood range and the target pixel is greater than or equal to the first gray value of the pixel in the preset neighborhood range>Greater than a preset difference threshold->Presetting a judgment parameter of pixels belonging to the background in a neighborhood range>For the preset constant, the preset constant is set as a negative number in one embodiment of the invention, so the judgment parameters of other pixels in the preset neighborhood range are ∈>And if the positive value is not greater than 0, the selected target pixel point reaches the edge of the electronic cigarette smoke, and iteration is stopped to select the next target pixel point.
The change of the gray value of each target pixel point in the target pixel point group can reflect the change of the gray value of the pixel point in the local area of the electronic cigarette smoke caused by the flow characteristic, and the distribution of each target pixel point in the gray image in the target pixel point group can reflect the flowing trend of the electronic cigarette smoke in the local area, so that the data support is provided for the subsequent analysis of the integral gray change degree of the electronic cigarette smoke.
Step S3: according to the gray level difference between the target pixel points in each target pixel point group and the positions of the target pixel points in the gray level image, the local gray level change degree of the electronic cigarette smoke is obtained, and the overall gray level change degree of the electronic cigarette smoke is obtained according to all the local gray level change degrees.
The flow characteristic of the electronic cigarette smoke causes the gray value of the pixel points in the electronic cigarette smoke to gradually decrease, and the gray value of the target pixel points in each target pixel point group gradually decreases according to the selection sequence, so that the change of the gray value of the target pixel points in the target pixel point group can reflect the flow characteristic of the electronic cigarette smoke in a local area, and the local gray change degree of the electronic cigarette smoke can be obtained according to the gray difference among the target pixel points in each target pixel point group, and the gray change condition of the pixel points in the local area of the electronic cigarette smoke is reflected through the local gray change degree.
Preferably, in one embodiment of the present invention, the method for acquiring the local gray level variation degree of the electronic cigarette smoke specifically includes:
constructing a regression curve of each target pixel point group by using a polynomial fitting method according to the position of the target pixel point in the gray level image in each target pixel point group, wherein the trend of the regression curve can reflect the flow direction of the electronic cigarette smoke in a local area; taking the absolute value of the gray value difference value between the adjacent target pixel points on each regression curve as a second gray difference value; taking the average value of the second gray level difference on each regression curve as the local gray level change degree of the electronic cigarette smoke corresponding to the regression curve, it should be noted that polynomial fitting is a technical means well known to those skilled in the art, and will not be described herein. The specific expression of the local gray level variation degree may be, for example:
wherein,is represented by->The local gray level change degree of the electronic cigarette smoke obtained by the target pixel point group can be also understood as +.>Local gray scale variation levels; />Represents +.sup.th on regression curve>Gray values of the target pixel points; />Represents +.sup.th on regression curve>Gray values of the target pixel points; />Representing the number of target pixels on each regression curve.
In the process of obtaining the local gray level variation degree, the distribution of the target pixel points in each target pixel point group in the gray level image can reflect the local flow characteristic of the electronic cigarette smoke, so in one embodiment of the invention, a regression curve is constructed for each target pixel point group, wherein the trend of the regression curve reflects the local flow direction of the electronic cigarette smoke, so that the gray level variation condition of the electronic cigarette smoke in the local area can be analyzed according to the gray level difference between the target pixel points on the regression curve, and further the local flow characteristic of the electronic cigarette smoke is reflected,representing adjacencies on regression curvesThe second gray level differences among the pixel points can reflect the gray level change condition of the electronic cigarette smoke in the local area by averaging all the second gray level differences, so that the average value of all the second gray level differences is adopted in one embodiment of the inventionAs local gray level variation +.>。
The local gray level change degree obtained through each target pixel point group can reflect the gray level change condition of a local area caused by the flow characteristic of the electronic cigarette smoke, so that the whole gray level change degree of the electronic cigarette smoke can be obtained by combining all the local gray level change degrees.
Preferably, in one embodiment of the present invention, the method for acquiring the overall gray level variation degree of the electronic cigarette smoke specifically includes:
and taking the average value of all the local gray level variation degrees as the whole gray level variation degree of the electronic cigarette smoke. The specific expression of the overall gradation variation degree may be, for example:
wherein,representing the overall gray level variation of the e-cigarette smoke, wherein +.>Constant greater than 0; />Is represented by->The local gray level change degree of the electronic cigarette smoke obtained by the target pixel point group can be also understood as +.>Local gray scale variation levels;representing the number of target pixel groups.
In the process of acquiring the integral gray level change degree of the electronic cigarette smoke, the local gray level change degreeThe change condition of the gray value of the pixel point in a certain local area of the electronic cigarette smoke can be reflected, so that the average value of the change degree of all local gray values can be calculated +.>Obtaining the whole gray level variation degree of the electronic cigarette smoke>。
After each electronic cigarette smoke is sprayed out of the mouth of a user, the flowing conditions of the electronic cigarette smoke are different, so that the gray level change conditions of pixel points in the electronic cigarette smoke are different, the integral gray level change degree of each electronic cigarette smoke is also different, and the external force weight can be adaptively adjusted according to the integral gray level change degree in the follow-up process.
Step S4: and acquiring a first gradient and a second gradient of each pixel point in the gray image based on different edge detection operators, acquiring the external force weight of the pixel point according to the integral gray change degree and the first gradient of each pixel point in the gray image, and acquiring the weighted external force of the pixel point according to the external force weight and the second gradient of each pixel point in the gray image.
According to the embodiment of the invention, the outline of the electronic cigarette smoke is extracted through the snake model, so that the detection of the electronic cigarette smoke in a gray level image is realized, the basic idea of the original snake model is that an initial curve is gradually deformed and moved towards the direction of the outline of a target to be detected through energy minimization, a parameterized curve with an energy function is initialized around the target to be segmented, the physical mechanics principle is simulated, the energy minimization is utilized as a frame under the action of internal force and external force, deformation is continuously evolved and finally converged to the target boundary, a smooth and continuous outline is obtained, and as the gray level gradient of pixel points in the image is used as the limitation of external force by the original snake model, no matter how many times the original snake model is iterated, the evolution curve is difficult to converge to the boundary of the depth recess of the electronic cigarette smoke all the time, so that the problem that the evolution curve of the snake model cannot converge to the boundary of the depth recess of the electronic cigarette smoke is solved by introducing an external force with the weight which is automatically controlled, and the method is required to be explained.
The change degree of the integral gray of the electronic cigarette smoke can reflect the change characteristic of the gray value of the pixel point caused by the flow characteristic of the electronic cigarette smoke, and the external force parameters used in the snake model are related to the gradient of the pixel point, so that the external force weight of the pixel point can be obtained according to the integral gray change degree and the first gradient of each pixel point in the gray image, and when aiming at different electronic cigarette smoke, the external force weight can be adaptively adjusted through the integral gray change degree of the electronic cigarette smoke, and the accuracy of the external force weight of the pixel point is improved.
Preferably, in an embodiment of the present invention, the method for acquiring the external force weight of the pixel point specifically includes:
taking the product value of the integral gray level change degree and the first gradient of each pixel point as the external force weight of the pixel point, wherein the first gradient of the pixel point is the result of processing the pixel point by the LOG gradient operator. The specific expression of the external force weight may be, for example:
wherein,representing pixel dot +.>External force weight of (2); />Representing the position coordinates of the pixel points in the gray level image; />The overall gray level change degree of the electronic cigarette smoke is represented; />Representing pixel dot +.>Is a first gradient of (a).
In the process of obtaining the external force weight of the pixel point,the function of the electronic cigarette smoke control method is to utilize the whole gray level change degree of the electronic cigarette smoke aiming at different electronic cigarette smoke>Weight for external force>Adaptive adjustment is performed using the gradient of the pixel gray in the image as an external force in the original snake model, so the overall gray level variation degree +.>And a first gradient of the pixel dot +.>Is taken as the external force weight of the pixel point +.>Due to->So the external force weight ∈>Is>In direct proportion, the larger the first gradient is, the larger the external force weight is, and then the automatic control of the external force in the original snake model can be realized through the external force weight.
Because the original snake model uses the gray gradient of the pixel point in the image as the limitation of the external force, the evolution curve in the original snake model can not be converged to the boundary of the depth recess of the electronic cigarette smoke, and the external force weight can realize the automatic control of the external force, so the weighted external force of the pixel point can be obtained according to the external force weight and the second gradient of each pixel point in the gray image.
Preferably, in one embodiment of the present invention, the method for acquiring the weighted external force of the pixel point specifically includes:
and carrying out negative correlation mapping on the product value of the external force weight and the second gradient of each pixel point to obtain the weighted external force of the pixel point, wherein the second gradient of the pixel point is the result of processing the pixel point by the sobel operator. The specific expression of the weighted external force may be, for example:
wherein,representing pixel dot +.>Is (are) weighted external force, < >>Representing the position coordinates of the pixel points in the gray level image; />Representing pixel dot +.>External force weight of (2); />Representing pixel dot +.>Is a second gradient of (a).
In the process of acquiring the weighted external force, the external force expression in the original snake model is as followsWherein->External force representing pixel point, +.>The gradient of the pixel point is represented, and because the original snake model only uses the gray gradient of the pixel point in the image as the limitation of the external force, the evolution curve in the original snake model can not be converged to the boundary of the depth depression of the electronic cigarette smoke, so the embodiment of the invention introduces an external force weight for automatically controlling the external force on the basis of the external force used by the original snake model>In the external force weight->The larger the position of the pixel point, the greater the degree of shrinkage and expansion of the evolution curve in the original snake model, and the evolution curve is weighted with the external force +.>Can enter into the sunken boundary of electron cigarette smog degree of depth under the effect for the evolution curve better converges to the sunken boundary of degree of depth.
It should be noted that, in other embodiments of the present invention, other gradient operators may be used to obtain the first gradient of the pixel point and the second gradient of the pixel point, which is not limited herein.
After the obtained weighted external force acts on the evolution curve in the snake model, the convergence effect of the evolution curve can be improved, so that the evolution curve can enter the boundary of the depth recess of the electronic cigarette smoke, and the weighted external force can be used as the external force parameter of the snake model in the follow-up process, so that the accuracy of detecting the electronic cigarette smoke is improved.
Step S5: and detecting the electronic cigarette smoke in the gray level image according to the weighted external force.
Under the action of the weighted external force, the evolution curve of the snake model can continuously shrink inwards or expand outwards, so that the evolution curve can finally converge to the boundary of the depth recess of the electronic cigarette smoke, and the electronic cigarette smoke in the gray level image can be detected according to the weighted external force.
Preferably, detecting the e-cigarette smoke in one embodiment of the present invention comprises:
and detecting the electronic cigarette smoke by using a snake model based on the weighted external force, wherein the weighted external force is an external force parameter used by the snake model. The weighted external force is used as the external force parameter in the snake model, so that the evolution curve of the snake model can enter the boundary of the depth depression of the electronic cigarette smoke under the action of the weighted external force, further, the boundary outline of the more complete electronic cigarette smoke is obtained, and the accuracy of detecting the electronic cigarette smoke is improved.
It should be noted that the snake model is a technical means well known to those skilled in the art, and will not be described herein.
In summary, the embodiment of the invention firstly obtains the gray image containing the electronic cigarette smoke, carries out edge detection on the gray image to obtain an initial curve of the electronic cigarette smoke, takes a pixel point on the initial curve as an initial pixel point, takes any one of the initial pixel points as a first selected target pixel point, builds a preset neighborhood range by taking the target pixel point as a center, selects the next target pixel point in the preset neighborhood range according to the gray difference between the target pixel point and other pixel points in the preset neighborhood range, builds the preset neighborhood range by taking the newly selected target pixel point as the center, continues to select the target pixel point, carries out iterative selection, takes the selected target pixel point as a target pixel point group of each initial pixel point, builds a corresponding regression curve according to the position of the target pixel point in the gray image in the target pixel point group, obtains the local gray change degree of the electronic cigarette smoke according to the gray difference between the target pixel points on the regression curve, further obtains the integral gray change degree of the electronic cigarette smoke, obtains the weight of the first weight of the target pixel point and the second weight of the target pixel point according to the integral gray change degree and the first weight of the target pixel point, and obtains the external force gradient of the electronic cigarette smoke, and obtains the external force gradient of the external force, and the external force is weighted to obtain the smoke based on the smoke, and the external force is obtained by the external force. According to the embodiment of the invention, each target pixel point group is firstly obtained, the local gray level change degree of the electronic cigarette smoke is obtained according to the gray level difference between the target pixel points in each target pixel point group, the overall gray level change degree of the electronic cigarette smoke is further obtained, the external force weight of the pixel point is obtained according to the overall gray level change degree and the first gradient of the pixel point, the weighted external force of the pixel point is obtained according to the external force weight and the second gradient of the pixel point, the weighted external force is used as the external force parameter in the snake model, the evolution curve in the snake model can be converged to the boundary of the depth recess of the electronic cigarette smoke under the action of the weighted external force, and the accuracy of detecting the electronic cigarette smoke is improved.
It should be noted that: the sequence of the embodiments of the present invention is only for description, and does not represent the advantages and disadvantages of the embodiments. The processes depicted in the accompanying drawings do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
In this specification, each embodiment is described in a progressive manner, and identical and similar parts of each embodiment are all referred to each other, and each embodiment mainly describes differences from other embodiments.
Claims (6)
1. A method for visual detection of e-cigarette smoke, the method comprising:
acquiring a gray level image of electronic cigarette smoke;
performing edge detection processing on a gray level image to obtain an initial curve of the electronic cigarette smoke, taking a pixel point on the initial curve as an initial pixel point, taking any one initial pixel point as a target pixel point, constructing a preset neighborhood range by taking the target pixel point as a center, and obtaining a target pixel point group of each initial pixel point according to gray level difference between the target pixel point and other pixel points in the preset neighborhood range;
obtaining local gray level change degrees of the electronic cigarette smoke according to gray level differences among the target pixel points in each target pixel point group and positions of the target pixel points in the gray level image, and obtaining the overall gray level change degrees of the electronic cigarette smoke according to all the local gray level change degrees;
acquiring a first gradient and a second gradient of each pixel point in the gray image based on different edge detection operators, and acquiring external force weights of the pixel points according to the integral gray change degree and the first gradient of each pixel point in the gray image; obtaining weighted external force of the pixel points according to the external force weight and the second gradient of each pixel point in the gray level image;
detecting the electronic cigarette smoke in the gray level image according to the weighted external force;
the method for acquiring the external force weight of the pixel point comprises the following steps:
taking the product value of the integral gray level variation degree and the first gradient of each pixel point as the external force weight of the pixel point;
the method for acquiring the weighted external force of the pixel point comprises the following steps:
carrying out negative correlation mapping on the product value of the external force weight and the second gradient of each pixel point to obtain weighted external force of the pixel point;
the method for acquiring the initial curve of the electronic cigarette smoke comprises the following steps:
performing edge detection processing on the gray level image to obtain an edge contour in the gray level image;
acquiring a historical lip feature template, and performing template matching on the gray level image by using the historical lip feature template to acquire a lip region in the gray level image;
taking the edge contour nearest to the lip area as an initial contour of the electronic cigarette smoke, and taking a curve of the initial contour and the lip area as an initial curve of the electronic cigarette smoke;
the method for acquiring the local gray level change degree of the electronic cigarette smoke comprises the following steps:
constructing a regression curve of each target pixel point group by using a polynomial fitting method according to the position of the target pixel point in the gray level image;
taking the absolute value of the gray value difference value between adjacent target pixel points on each regression curve as a second gray difference value;
and taking the average value of the second gray level difference on each regression curve as the local gray level change degree of the electronic cigarette smoke corresponding to the regression curve.
2. The method for detecting the smoke vision of the electronic cigarette according to claim 1, wherein the method for acquiring the target pixel group of each initial pixel comprises the following steps:
taking the absolute value of the gray value difference value of each other pixel point in the target pixel point and the preset neighborhood range as the first gray difference of the other pixel points;
if the first gray level difference is smaller than a preset difference threshold, taking the gray level value difference between the target pixel point and other pixel points in the preset neighborhood range as the judgment parameters of the other pixel points, and if the first gray level difference is not smaller than the preset difference threshold, taking a preset constant as the judgment parameters of the other pixel points;
determining whether the judging parameters of other pixels in the preset neighborhood range of the target pixel meet preset conditions;
when the judging parameters meet preset conditions, taking other pixel points corresponding to the minimum positive values of all the judging parameters in the preset neighborhood range as the next target pixel point, and continuing to execute the selection process;
and stopping selecting when the judging parameters do not meet preset conditions, and taking the obtained target pixel point combination as a target pixel point group of the initial pixel points, so that all the initial pixel points are traversed, and the target pixel point group of each initial pixel point is obtained.
3. The method for detecting electronic cigarette smoke according to claim 2, wherein determining whether the decision parameters of other pixels in the preset neighborhood range of the target pixel point meet the preset conditions comprises:
if the judgment parameters of other pixel points in the preset neighborhood range have positive values, a preset condition is met;
if the judgment parameters of other pixels in the preset neighborhood range have no positive values, the preset condition is not met.
4. The method for visually inspecting electronic cigarette smoke according to claim 1, wherein the method for acquiring the overall gray scale variation degree of the electronic cigarette smoke comprises the following steps:
and taking the average value of all the local gray level variation degrees as the whole gray level variation degree of the electronic cigarette smoke.
5. The method for detecting the smoke vision of the electronic cigarette according to claim 1, wherein the first gradient is a result of processing pixels by a LOG gradient operator, and the second gradient is a result of processing pixels by a sobel operator.
6. The method of claim 1, wherein the detecting the electronic cigarette smoke in the gray scale image according to the weighted external force comprises:
and detecting the electronic cigarette smoke by using a snake model based on the weighted external force, wherein the weighted external force is an external force parameter used by the snake model.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202311195814.0A CN116935496B (en) | 2023-09-18 | 2023-09-18 | Electronic cigarette smoke visual detection method |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202311195814.0A CN116935496B (en) | 2023-09-18 | 2023-09-18 | Electronic cigarette smoke visual detection method |
Publications (2)
Publication Number | Publication Date |
---|---|
CN116935496A CN116935496A (en) | 2023-10-24 |
CN116935496B true CN116935496B (en) | 2023-11-17 |
Family
ID=88388250
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202311195814.0A Active CN116935496B (en) | 2023-09-18 | 2023-09-18 | Electronic cigarette smoke visual detection method |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN116935496B (en) |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107633212A (en) * | 2017-08-30 | 2018-01-26 | 清华大学苏州汽车研究院(吴江) | A kind of firework detecting method and device based on video image |
WO2019033568A1 (en) * | 2017-08-17 | 2019-02-21 | 平安科技(深圳)有限公司 | Lip movement capturing method, apparatus and storage medium |
CN110738186A (en) * | 2019-10-23 | 2020-01-31 | 德瑞姆创新科技(深圳)有限公司 | driver smoking detection method and system based on computer vision technology |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109035276B (en) * | 2018-06-26 | 2022-03-18 | 北京中科慧眼科技有限公司 | Image edge extraction method and device and automatic driving system |
-
2023
- 2023-09-18 CN CN202311195814.0A patent/CN116935496B/en active Active
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2019033568A1 (en) * | 2017-08-17 | 2019-02-21 | 平安科技(深圳)有限公司 | Lip movement capturing method, apparatus and storage medium |
CN107633212A (en) * | 2017-08-30 | 2018-01-26 | 清华大学苏州汽车研究院(吴江) | A kind of firework detecting method and device based on video image |
CN110738186A (en) * | 2019-10-23 | 2020-01-31 | 德瑞姆创新科技(深圳)有限公司 | driver smoking detection method and system based on computer vision technology |
Non-Patent Citations (1)
Title |
---|
改进snake模型的自动初始化轮廓检测方法;杨晓倩;毕惟红;;计算机应用研究(第S1期);全文 * |
Also Published As
Publication number | Publication date |
---|---|
CN116935496A (en) | 2023-10-24 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110853015A (en) | Aluminum profile defect detection method based on improved Faster-RCNN | |
CN109472788B (en) | Method for detecting flaw on surface of airplane rivet | |
CN114118144A (en) | Anti-interference accurate aerial remote sensing image shadow detection method | |
CN112085651B (en) | Automatic shock wave detection and tracking algorithm based on image self-adaptive threshold and feature extraction | |
CN109781737B (en) | Detection method and detection system for surface defects of hose | |
CN113327206B (en) | Image fuzzy processing method of intelligent power transmission line inspection system based on artificial intelligence | |
CN116342586B (en) | Road surface quality detection method based on machine vision | |
CN114926407A (en) | Steel surface defect detection system based on deep learning | |
CN115908410B (en) | Pressure vessel laser welding control method based on machine vision | |
CN117197140B (en) | Irregular metal buckle forming detection method based on machine vision | |
CN109671084B (en) | Method for measuring shape of workpiece | |
CN112102189B (en) | Line structure light bar center line extraction method | |
CN116935496B (en) | Electronic cigarette smoke visual detection method | |
CN106447683A (en) | Feature extraction algorithm of circles | |
CN110930358B (en) | Solar panel image processing method based on self-adaptive algorithm | |
CN113052794A (en) | Image definition recognition method based on edge features | |
CN112580634A (en) | Air tightness detection light source adjusting method and system based on computer vision | |
CN207319290U (en) | One kind interference far field beam test system | |
CN114862786A (en) | Retinex image enhancement and Ostu threshold segmentation based isolated zone detection method and system | |
CN112767321B (en) | Random forest based tubercle bacillus fluorescence detection method | |
CN115272184A (en) | Defect identification method based on optimization of industrial image quality | |
CN115719310A (en) | Pretreatment method of fundus image data set and fundus image training model | |
CN116704268B (en) | Strong robust target detection method for dynamic change complex scene | |
CN117541582B (en) | IGBT insulation quality detection method for high-frequency converter | |
CN117876353A (en) | Electronic equipment surface scratch detecting system based on visual recognition |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |