Image recognition method and system
By identifying the smoking behavior in the vehicle in the vehicle recognition system and using the difference in trajectory length to determine the authenticity of the smoking behavior, the problem of misjudgment caused by stains or reflections on the vehicle windshield affecting the recognition is solved, and the accuracy and applicability of the recognition are improved.
Patent Information
- Application Number
- CN202411422295.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-12
- Publication Date
- 2025-01-24
- Estimated Expiration
- 2044-10-12
AI Technical Summary
In the prior art, when a vehicle is taking photos in violation of regulations, stains or reflections on the vehicle windshield can easily affect the accuracy of smoking behavior identification, resulting in misjudgment of identification.
By obtaining the video stream of the target vehicle passing through the detection area, key frames are selected for smoking behavior recognition, and facial eyes and suspected cigarette trajectories are identified from the recognition video stream, and the trajectory length differences are compared to determine whether there is smoking behavior while driving.
It effectively eliminates misjudgment of windshield reflections and stains, improves the accuracy of smoking behavior recognition, has high applicability and robustness, consumes less computing power, and facilitates the transformation of existing equipment.
Smart Images

Figure CN118918570B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image recognition, and in particular to an image recognition method and system. Background Art
[0002] The hazards of smoking while driving include: when driving, you need to concentrate on observing the road conditions, vehicles and pedestrians, and smoking will distract the driver's attention, increase reaction time, and reduce driving safety; at the same time, when smoking, the driver needs to hold the steering wheel with one hand and hold or light a cigarette with the other hand. This one-handed driving behavior will seriously affect driving stability and increase the risk of traffic accidents; and the smoke in the car will block the driver's vision, especially at night or in bad weather conditions, the obstruction of vision is more serious, and it may cause the driver to be unable to detect obstacles or emergencies ahead in time. Therefore, many regions have clear regulations prohibiting smoking while driving.
[0003] In the prior art, a Chinese patent with application number 202110207092.0 discloses a real-time smoking and calling identification method, comprising the following steps: S1: establishing a real-time smoking and calling identification model; S2: locating the pedestrian area based on the surveillance video of the target scene using a multi-target tracking algorithm; S3: performing real-time identification of smoking and calling in the pedestrian area based on the real-time smoking and calling identification model. The present invention constructs a backbone network based on Se-Res2Block as the basic module, which can not only integrate more features but also improve the detection speed; in order to solve the problem of low recognition accuracy of small targets, the resolution of the input image is increased, and the SPP module and the ASFF module are introduced to enhance the information interaction between contexts and improve the recognition accuracy of small targets. However, in actual applications of taking photos of vehicle violations, stains or reflections on the windshield of the vehicle may affect the recognition results and cause misjudgment of recognition. Summary of the invention
[0004] In order to at least overcome the above-mentioned deficiencies in the prior art, the purpose of the present application is to provide an image recognition method and system.
[0005] In a first aspect, an embodiment of the present application provides an image recognition method, comprising:
[0006] When the target vehicle passes through the detection area, the video stream containing the image inside the vehicle is obtained as the recognition video stream;
[0007] Selecting key frames from the recognition video stream, performing smoking behavior recognition on the key frames, and using the key frames in which smoking behavior is recognized as suspected behavior frames;
[0008] Recognize the trajectory of the face and eyes from the identification video stream corresponding to the suspected behavior frame as the first trajectory, and recognize the trajectory of the suspected cigarette from the identification video stream corresponding to the suspected behavior frame as the second trajectory;
[0009] The difference between the length values of the first trajectory and the second trajectory is compared, and when the difference between the length values is less than a preset value, it is determined that the target vehicle corresponding to the suspected behavior frame has a smoking-while-driving behavior.
[0010] When the embodiment of the present application is implemented, it is necessary to obtain the identification video stream through the camera equipment preset in the detection area. Generally speaking, the camera equipment will be set on a gantry or a crossbar, so the collected identification video streams are all in-vehicle images taken from the direction of the vehicle windshield. At this time, stains and reflections on the vehicle windshield can easily cause inaccurate recognition. In the embodiment of the present application, the selection of key frames generally selects the frames in the middle of the identification video stream. The identification video stream often starts shooting when a vehicle is recognized to appear and ends shooting when the vehicle leaves the shooting area, so at this time, the frames in the middle of the identification video stream can be selected as key frames. Smoking behavior can be identified by a preset recognition model, such as the technical solution provided in the prior art 202110207092.0, and this embodiment does not make much limitation.
[0011] When a smoking behavior is identified, in order to determine whether the smoking behavior is a real smoking behavior or a misjudgment due to the influence of the vehicle windshield, the embodiment of the present application needs to identify the first track and the second track from the identification video stream. Figure 2 , the inventor discovered in scientific practice that, for the shooting device, the first track and the second track are actually tracks formed on the imaging plane after the point movement; when smoking, the distance between the cigarette position and the eye position can be approximately considered to be a fixed distance, while the reflections and stains on the windshield will be closer to the shooting device, which means that if the cigarette position corresponds to the real smoking behavior, the length of the corresponding second track will be closer to the first track. If the cigarette position corresponds to the reflections and stains on the windshield, it will produce a shooting angle difference that is different from the first track, so the length will change significantly. Therefore, based on this length, it can be judged whether the cigarette position identified by the shooting corresponds to the real smoking behavior. The embodiment of the present application realizes the elimination of misjudgment of reflections and stains on the windshield through the above-mentioned technical solution, effectively improves the accuracy of smoking behavior recognition, and eliminates misjudgment based on distance recognition, which has high applicability and robustness, and at the same time consumes less computing power, which is convenient for the transformation and realization of existing equipment.
[0012] In a possible implementation manner, the identifying of the first trajectory includes:
[0013] Acquire a frame before a preset time length of the suspected behavior frame as a front recognition frame, and acquire a frame after the preset time length of the suspected behavior frame as a rear recognition frame;
[0014] Identify the positions of both eyes from the front recognition frame, and use the center point of the positions of both eyes as the first center point; identify the positions of both eyes from the key frame, and use the center point of the positions of both eyes as the second center point; identify the positions of both eyes from the rear recognition frame, and use the center point of the positions of both eyes as the third center point;
[0015] A first vector is constructed with the first center point as a starting point and the second center point as an end point; a second vector is constructed with the second center point as a starting point and the third center point as an end point;
[0016] The first vector and the second vector are taken as the first trajectory.
[0017] In a possible implementation manner, the identifying of the second trajectory includes:
[0018] Identify the cigarette position from the front recognition frame, and use the center point of the cigarette as the first cigarette point; identify the cigarette position from the key frame, and use the center point of the cigarette as the second cigarette point; identify the cigarette position from the rear recognition frame, and use the center point of the cigarette as the third cigarette point;
[0019] A third vector is constructed with the first cigarette point as a starting point and the second cigarette point as an end point; a fourth vector is constructed with the second cigarette point as a starting point and the third cigarette point as an end point;
[0020] The third vector and the fourth vector are used as the second trajectory.
[0021] In a possible implementation, comparing the difference between the length values of the first trajectory and the second trajectory, and determining that the target vehicle corresponding to the suspected behavior frame has the smoking-while-driving behavior when the difference in the length values is less than a preset value includes:
[0022] Calculate the absolute value of the difference between the length value of the first vector and the length value of the third vector as a first length difference, and calculate the absolute value of the difference between the length value of the second vector and the length value of the fourth vector as a second length difference;
[0023] When any one of the first length difference and the second length difference is smaller than a threshold, it is determined that the target vehicle corresponding to the suspected behavior frame has a smoking while driving behavior.
[0024] In a possible implementation, the smoking behavior recognition, the eye position recognition and the cigarette position recognition are all performed through an image recognition model.
[0025] In a possible implementation, the generation of the image recognition model includes:
[0026] Acquire multiple images of vehicle interior as sample images;
[0027] Annotating the sample image, wherein the annotation contents include a face, eyes, a mouth, and a cigarette;
[0028] A feature recognition model is formed by training the model through the labeled sample images; the input data of the feature recognition model is the image data, and the output data of the feature recognition model includes the face area, the eye area, the mouth area and the cigarette area;
[0029] Constructing a judgment model; the input data of the judgment model is the face area, the mouth area and the cigarette area, and the output data of the judgment model is whether there is a smoking behavior;
[0030] When the mouth area is located within the face area, and the distance between the cigarette area and the mouth area is less than a preset value, the output data of the judgment model is that there is a smoking behavior;
[0031] The image recognition model is formed by using the output data of the feature recognition model as the input data of the judgment model.
[0032] In a possible implementation, the smoking behavior recognition includes:
[0033] Inputting the key frame into the feature recognition model, and inputting the face area, mouth area and cigarette area output by the feature recognition model into the judgment model;
[0034] The output data of the judgment model is used as the smoking behavior recognition result.
[0035] In a possible implementation, the identification of the positions of both eyes and the position of the cigarette includes:
[0036] An image requiring recognition of eye positions and cigarette positions is input into the feature recognition model, and the eye positions are recognized based on the eye regions output by the feature recognition model, and the cigarette positions are recognized based on the cigarette regions output by the feature recognition model.
[0037] Second invention, the embodiment of the present application also provides an image recognition system, including:
[0038] An acquisition unit is configured to acquire a video stream containing an image inside the vehicle when the target vehicle passes through the detection area as a recognition video stream;
[0039] A selection unit is configured to select key frames from the recognition video stream, perform smoking behavior recognition on the key frames, and use the key frames in which the smoking behavior is recognized as suspected behavior frames;
[0040] an identification unit configured to identify a trajectory of a face eye from the identification video stream corresponding to the suspected behavior frame as a first trajectory, and to identify a trajectory of a suspected cigarette from the identification video stream corresponding to the suspected behavior frame as a second trajectory;
[0041] The comparison unit is configured to compare the difference in length values between the first trajectory and the second trajectory, and determine that the target vehicle corresponding to the suspected behavior frame has a smoking behavior while driving when the difference in length values is less than a preset value.
[0042] In a possible implementation manner, the identification unit is further configured to:
[0043] Acquire a frame before a preset time length of the suspected behavior frame as a front recognition frame, and acquire a frame after a preset time length of the suspected behavior frame as a rear recognition frame;
[0044] Identify the positions of both eyes from the front recognition frame, and use the center point of the positions of both eyes as the first center point; identify the positions of both eyes from the key frame, and use the center point of the positions of both eyes as the second center point; identify the positions of both eyes from the rear recognition frame, and use the center point of the positions of both eyes as the third center point;
[0045] A first vector is constructed with the first center point as a starting point and the second center point as an end point; a second vector is constructed with the second center point as a starting point and the third center point as an end point;
[0046] The first vector and the second vector are taken as the first trajectory.
[0047] Compared with the prior art, the present invention has the following advantages and beneficial effects:
[0048] Through the above technical scheme, the present invention realizes the elimination of misjudgments of reflections and stains on the windshield, effectively improves the accuracy of smoking behavior recognition, and eliminates misjudgments based on distance recognition. It has high applicability and robustness, and at the same time consumes less computing power, which is convenient for the transformation of existing equipment. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] The drawings described herein are used to provide a further understanding of the embodiments of the present invention, constitute a part of this application, and do not constitute a limitation of the embodiments of the present invention. In the drawings:
[0050] Figure 1 This is a schematic diagram of the steps of the method of the embodiment of the present application;
[0051] Figure 2 This is a schematic diagram of an application scenario of an embodiment of the present application. DETAILED DESCRIPTION
[0052] To make the purpose, technical scheme and advantages of the embodiment of the present application clearer, the technical scheme in the embodiment of the present application will be clearly and completely described below in conjunction with the drawings in the embodiment of the present application. It should be understood that the drawings in the present application only serve the purpose of explanation and description and are not used to limit the scope of protection of the present application. In addition, it should be understood that the schematic drawings are not drawn in real proportion. The flowchart used in this application shows the operations implemented according to some embodiments of the embodiment of the present application. It should be understood that the operations of the flowchart can be implemented out of sequence, and the steps without logical context can be reversed in order or implemented simultaneously. In addition, those skilled in the art can add one or more other operations to the flowchart under the guidance of the content of the present application, or remove one or more operations from the flowchart.
[0053] In addition, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. The components of the embodiments of the present application described and shown in the drawings here can be arranged and designed in various configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the application claimed for protection, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present application.
[0054] Please refer to Figure 1 , is a flow chart of an image recognition method provided in an embodiment of the present invention. Furthermore, the image recognition method may specifically include the contents described in the following steps S1 to S4.
[0055] S1: When the target vehicle passes through the detection area, the video stream containing the image inside the vehicle is obtained as the recognition video stream;
[0056] S2: selecting key frames from the recognition video stream, performing smoking behavior recognition on the key frames, and taking the key frames in which smoking behavior is recognized as suspected behavior frames;
[0057] S3: identifying the trajectory of the face and eyes from the identification video stream corresponding to the suspected behavior frame as the first trajectory, and identifying the trajectory of the suspected cigarette from the identification video stream corresponding to the suspected behavior frame as the second trajectory;
[0058] S4: comparing the difference in length values between the first trajectory and the second trajectory, and determining that the target vehicle corresponding to the suspected behavior frame has a smoking-while-driving behavior when the difference in length values is less than a preset value.
[0059] When the embodiment of the present application is implemented, it is necessary to obtain the identification video stream through the camera equipment preset in the detection area. Generally speaking, the camera equipment will be set on a gantry or a crossbar, so the collected identification video streams are all in-vehicle images taken from the direction of the vehicle windshield. At this time, stains and reflections on the vehicle windshield can easily cause inaccurate recognition. In the embodiment of the present application, the selection of key frames generally selects the frames in the middle of the identification video stream. The identification video stream often starts shooting when a vehicle is recognized to appear and ends shooting when the vehicle leaves the shooting area, so at this time, the frames in the middle of the identification video stream can be selected as key frames. Smoking behavior can be identified by a preset recognition model, such as the technical solution provided in the prior art 202110207092.0, and this embodiment does not make much limitation.
[0060] When a smoking behavior is identified, in order to determine whether the smoking behavior is a real smoking behavior or a misjudgment due to the influence of the vehicle windshield, the embodiment of the present application needs to identify the first track and the second track from the identification video stream. Figure 2 , the inventor discovered in scientific practice that, for the shooting device, the first track and the second track are actually tracks formed on the imaging plane after the point movement; when smoking, the distance between the cigarette position and the eye position can be approximately considered to be a fixed distance, while the reflections and stains on the windshield will be closer to the shooting device, which means that if the cigarette position corresponds to the real smoking behavior, the length of the corresponding second track will be closer to the first track. If the cigarette position corresponds to the reflections and stains on the windshield, it will produce a shooting angle difference that is different from the first track, so the length will change significantly. Therefore, based on this length, it can be judged whether the cigarette position identified by the shooting corresponds to the real smoking behavior. The embodiment of the present application realizes the elimination of misjudgment of reflections and stains on the windshield through the above-mentioned technical solution, effectively improves the accuracy of smoking behavior recognition, and eliminates misjudgment based on distance recognition, which has high applicability and robustness, and at the same time consumes less computing power, which is convenient for the transformation and realization of existing equipment.
[0061] In a possible implementation manner, the identifying of the first trajectory includes:
[0062] Acquire a frame before a preset time length of the suspected behavior frame as a front recognition frame, and acquire a frame after a preset time length of the suspected behavior frame as a rear recognition frame;
[0063] Identify the positions of both eyes from the front recognition frame, and use the center point of the positions of both eyes as the first center point; identify the positions of both eyes from the key frame, and use the center point of the positions of both eyes as the second center point; identify the positions of both eyes from the rear recognition frame, and use the center point of the positions of both eyes as the third center point;
[0064] A first vector is constructed with the first center point as a starting point and the second center point as an end point; a second vector is constructed with the second center point as a starting point and the third center point as an end point;
[0065] The first vector and the second vector are taken as the first trajectory.
[0066] When implementing the embodiment of the present application, in order to improve the recognition accuracy, the center point of the two eyes is used as the basis for vector construction. The main reason is that during actual shooting, the head of a person may slightly shift left and right, and the position of the center point of the two eyes will be relatively fixed. The first vector is the vector from the front recognition frame to the key frame, and the second vector is the vector from the key frame to the back recognition frame.
[0067] In a possible implementation manner, the identifying of the second trajectory includes:
[0068] Identify the cigarette position from the front recognition frame, and use the center point of the cigarette as the first cigarette point; identify the cigarette position from the key frame, and use the center point of the cigarette as the second cigarette point; identify the cigarette position from the rear recognition frame, and use the center point of the cigarette as the third cigarette point;
[0069] A third vector is constructed with the first cigarette point as a starting point and the second cigarette point as an end point; a fourth vector is constructed with the second cigarette point as a starting point and the third cigarette point as an end point;
[0070] The third vector and the fourth vector are used as the second trajectory.
[0071] When the embodiment of the present application is implemented, similarly, the third vector and the fourth vector can be constructed through the position of the center point of the cigarette.
[0072] In a possible implementation, comparing the difference between the length values of the first trajectory and the second trajectory, and determining that the target vehicle corresponding to the suspected behavior frame has the smoking-while-driving behavior when the difference in the length values is less than a preset value includes:
[0073] Calculate the absolute value of the difference between the length value of the first vector and the length value of the third vector as a first length difference, and calculate the absolute value of the difference between the length value of the second vector and the length value of the fourth vector as a second length difference;
[0074] When any one of the first length difference and the second length difference is smaller than a threshold, it is determined that the target vehicle corresponding to the suspected behavior frame has a smoking while driving behavior.
[0075] When the embodiment of the present application is implemented, the process of video acquisition is the process of the vehicle approaching the video acquisition device, and the change in vector length caused by this may have certain differences. Therefore, in the embodiment of the present application, the vector length from the front recognition frame to the key frame is compared separately, and the vector length from the key frame to the rear recognition frame is compared separately, which can effectively improve the recognition accuracy.
[0076] In a possible implementation, the smoking behavior recognition, the eye position recognition and the cigarette position recognition are all performed through an image recognition model.
[0077] In a possible implementation, the generation of the image recognition model includes:
[0078] Acquire multiple images of vehicle interior as sample images;
[0079] Annotating the sample image, wherein the annotation contents include a face, eyes, a mouth, and a cigarette;
[0080] A feature recognition model is formed by training the model through the labeled sample images; the input data of the feature recognition model is the image data, and the output data of the feature recognition model includes the face area, the eye area, the mouth area and the cigarette area;
[0081] Constructing a judgment model; the input data of the judgment model is the face area, the mouth area and the cigarette area, and the output data of the judgment model is whether there is a smoking behavior;
[0082] When the mouth area is located within the face area, and the distance between the cigarette area and the mouth area is less than a preset value, the output data of the judgment model is that there is a smoking behavior;
[0083] The image recognition model is formed by using the output data of the feature recognition model as the input data of the judgment model.
[0084] When the embodiment of the present application is implemented, a specific recognition model construction scheme is provided. In order to simplify the operation and reduce the cost of model construction, the recognition of smoking behavior, the recognition of the position of both eyes and the recognition of the position of cigarettes are all recognized by the same image recognition model. The image recognition model needs to include a feature recognition model and a judgment model in series. Among them, the feature recognition model preferably uses YOLO5 for model training. During training, the sample images sampled need to be divided into training sets, verification sets and test sets according to the ratio of 8:1:1 as needed, and the model training is performed. It can identify the face area, eye area, mouth area and cigarette area according to the annotated content. The judgment model preferably uses a binary classifier to identify the smoking behavior by the positional relationship between the mouth area, the face area and the cigarette area.
[0085] In a possible implementation, the smoking behavior recognition includes:
[0086] Inputting the key frame into the feature recognition model, and inputting the face area, mouth area and cigarette area output by the feature recognition model into the judgment model;
[0087] The output data of the judgment model is used as the smoking behavior recognition result.
[0088] In a possible implementation, the identification of the positions of both eyes and the position of the cigarette includes:
[0089] An image requiring recognition of eye positions and cigarette positions is input into the feature recognition model, and the eye positions are recognized based on the eye regions output by the feature recognition model, and the cigarette positions are recognized based on the cigarette regions output by the feature recognition model.
[0090] Based on the same inventive concept, the embodiment of the present application also provides an image recognition system, including:
[0091] An acquisition unit is configured to acquire a video stream containing an image inside the vehicle when the target vehicle passes through the detection area as a recognition video stream;
[0092] A selection unit is configured to select key frames from the recognition video stream, perform smoking behavior recognition on the key frames, and use the key frames in which the smoking behavior is recognized as suspected behavior frames;
[0093] an identification unit configured to identify a trajectory of a face eye from the identification video stream corresponding to the suspected behavior frame as a first trajectory, and to identify a trajectory of a suspected cigarette from the identification video stream corresponding to the suspected behavior frame as a second trajectory;
[0094] The comparison unit is configured to compare the difference in length values between the first trajectory and the second trajectory, and determine that the target vehicle corresponding to the suspected behavior frame has a smoking behavior while driving when the difference in length values is less than a preset value.
[0095] In a possible implementation manner, the identification unit is further configured to:
[0096] Acquire a frame before a preset time length of the suspected behavior frame as a front recognition frame, and acquire a frame after a preset time length of the suspected behavior frame as a rear recognition frame;
[0097] Identify the positions of both eyes from the front recognition frame, and use the center point of the positions of both eyes as the first center point; identify the positions of both eyes from the key frame, and use the center point of the positions of both eyes as the second center point; identify the positions of both eyes from the rear recognition frame, and use the center point of the positions of both eyes as the third center point;
[0098] A first vector is constructed with the first center point as a starting point and the second center point as an end point; a second vector is constructed with the second center point as a starting point and the third center point as an end point;
[0099] The first vector and the second vector are taken as the first trajectory.
[0100] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of function in the above description. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0101] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, or it can be an electrical, mechanical or other form of connection.
[0102] The units described as separate components may or may not be physically separated. As units, it is obvious that a person of ordinary skill in the art can realize that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of function in the above description. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0103] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0104] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a grid device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.
[0105] The specific implementation methods described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific implementation method of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. An image recognition method, characterized in that: include: When the target vehicle passes through the detection area, the video stream containing the image inside the vehicle is obtained as the recognition video stream; Selecting key frames from the recognition video stream, performing smoking behavior recognition on the key frames, and using the key frames in which smoking behavior is recognized as suspected behavior frames; Recognize the trajectory of the face and eyes from the identification video stream corresponding to the suspected behavior frame as the first trajectory, and recognize the trajectory of the suspected cigarette from the identification video stream corresponding to the suspected behavior frame as the second trajectory; Comparing the difference in length values between the first trajectory and the second trajectory, and determining that the target vehicle corresponding to the suspected behavior frame has a smoking behavior while driving when the difference in length values is less than a preset value; The identification of the first trajectory includes: obtaining a frame before a preset time length of the suspected behavior frame as a front identification frame, and obtaining a frame after the preset time length of the suspected behavior frame as a rear identification frame; Identify the positions of both eyes from the front recognition frame, and use the center point of the positions of both eyes as the first center point; identify the positions of both eyes from the key frame, and use the center point of the positions of both eyes as the second center point; identify the positions of both eyes from the rear recognition frame, and use the center point of the positions of both eyes as the third center point; A first vector is constructed with the first center point as a starting point and the second center point as an end point; a second vector is constructed with the second center point as a starting point and the third center point as an end point; Taking the first vector and the second vector as the first trajectory; The identification of the second trajectory includes: identifying the cigarette position from the front identification frame, and taking the center point position of the cigarette as the first cigarette point; identifying the cigarette position from the key frame, and taking the center point position of the cigarette as the second cigarette point; identifying the cigarette position from the rear identification frame, and taking the center point position of the cigarette as the third cigarette point; A third vector is constructed with the first cigarette point as a starting point and the second cigarette point as an end point; a fourth vector is constructed with the second cigarette point as a starting point and the third cigarette point as an end point; Taking the third vector and the fourth vector as the second trajectory; Comparing the difference between the length values of the first trajectory and the second trajectory, and judging that the target vehicle corresponding to the suspected behavior frame has the smoking behavior while driving when the difference between the length values is less than a preset value, comprises: calculating the absolute value of the difference between the length value of the first vector and the length value of the third vector as the first length difference, and calculating the absolute value of the difference between the length value of the second vector and the length value of the fourth vector as the second length difference; When any one of the first length difference and the second length difference is smaller than a threshold, it is determined that the target vehicle corresponding to the suspected behavior frame has a smoking while driving behavior.
2. An image recognition method according to claim 1, characterized in that: Smoking behavior recognition, eye position recognition, and cigarette position recognition are all performed through image recognition models.
3. An image recognition method according to claim 2, characterized in that: The generation of the image recognition model includes: acquiring a plurality of in-vehicle images as sample images; Annotating the sample image, wherein the annotation contents include a face, eyes, a mouth, and a cigarette; A feature recognition model is formed by training the model through the labeled sample images; the input data of the feature recognition model is the image data, and the output data of the feature recognition model includes the face area, the eye area, the mouth area and the cigarette area; Constructing a judgment model; the input data of the judgment model is the face area, the mouth area and the cigarette area, and the output data of the judgment model is whether there is a smoking behavior; When the mouth area is located within the face area, and the distance between the cigarette area and the mouth area is less than a preset value, the output data of the judgment model is that there is a smoking behavior; The image recognition model is formed by using the output data of the feature recognition model as the input data of the judgment model.
4. An image recognition method according to claim 3, characterized in that: The smoking behavior recognition includes: inputting the key frame into the feature recognition model, and inputting the face area, mouth area and cigarette area output by the feature recognition model into the judgment model; The output data of the judgment model is used as the smoking behavior recognition result.
5. An image recognition method according to claim 3, characterized in that: The recognition of the position of both eyes and the position of a cigarette include: inputting the image on which the recognition of the position of both eyes and the position of a cigarette is required into the feature recognition model, and recognizing the position of both eyes based on the eye area output by the feature recognition model, and recognizing the position of the cigarette based on the cigarette area output by the feature recognition model.
6. An image recognition system using the method according to any one of claims 1 to 5, characterized in that: include: An acquisition unit is configured to acquire a video stream containing an image inside the vehicle when the target vehicle passes through the detection area as a recognition video stream; A selection unit is configured to select key frames from the recognition video stream, perform smoking behavior recognition on the key frames, and use the key frames in which the smoking behavior is recognized as suspected behavior frames; an identification unit configured to identify a trajectory of a face eye from the identification video stream corresponding to the suspected behavior frame as a first trajectory, and to identify a trajectory of a suspected cigarette from the identification video stream corresponding to the suspected behavior frame as a second trajectory; The comparison unit is configured to compare the difference in length values between the first trajectory and the second trajectory, and determine that the target vehicle corresponding to the suspected behavior frame has a smoking behavior while driving when the difference in length values is less than a preset value.
7. An image recognition system according to claim 6, characterized in that: The recognition unit is further configured to: obtain a frame before a preset duration of the suspected behavior frame as a front recognition frame, and obtain a frame after a preset duration of the suspected behavior frame as a rear recognition frame; Identify the positions of both eyes from the front recognition frame, and use the center point of the positions of both eyes as the first center point; identify the positions of both eyes from the key frame, and use the center point of the positions of both eyes as the second center point; identify the positions of both eyes from the rear recognition frame, and use the center point of the positions of both eyes as the third center point; A first vector is constructed with the first center point as a starting point and the second center point as an end point; a second vector is constructed with the second center point as a starting point and the third center point as an end point; The first vector and the second vector are taken as the first trajectory.
Citation Information
Patent Citations
A method for real-time identification of smoking and phone calls
CN112818913B
Dangerous driving behavior detection method and camera
CN110046560A
Smoking behavior detection method, electronic equipment and readable storage medium
CN113505707A