Image processing method and apparatus, electronic device, vehicle, and computer program product

By performing sparse optical flow calculation and optical flow compensation on two facial images of the driver, the problem of inaccurate driver fatigue detection in the prior art is solved, and accurate monitoring of the driver's driving status is achieved, reducing the risk of accidents caused by fatigued driving.

CN123161202APending Publication Date: 2026-11-24BEIJING CO WHEELS TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510662843.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-21
Publication Date
2026-11-24

AI Technical Summary

Technical Problem

Existing methods for detecting driver fatigue have the problem of inaccurate results, making it difficult to effectively identify the driver's fatigue state.

Method used

By acquiring two facial images of the same driver, sparse optical flow calculation is performed to obtain optical flow vectors for multiple facial key points. Based on the optical flow vectors, optical flow compensation and brightness compensation are performed to output information indicating the driver's driving status.

Benefits of technology

It improves the accuracy of facial landmark localization, enabling accurate monitoring of the driver's driving status and reducing the probability of traffic accidents caused by fatigue driving.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123161202A_ABST
    Figure CN123161202A_ABST
Patent Text Reader

Abstract

This application provides an image processing method, apparatus, electronic device, vehicle, and computer program product. The method includes: acquiring a first image and a second image, both of which include a facial image of the same driver; performing sparse optical flow calculation on multiple first facial key points in the first image and the second image to obtain optical flow vectors for the multiple first facial key points; and outputting first information based on the optical flow vectors of the multiple first facial key points, wherein the first information indicates the driver's driving state. This application enables accurate monitoring of the driver's driving state, thereby reducing the probability of traffic accidents caused by driver fatigue.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to image processing technology, and more particularly to an image processing method, apparatus, electronic device, vehicle, and computer program product. Background Technology

[0002] Driver fatigue refers to the physiological and psychological imbalance that occurs when a driver drives continuously for a long time, resulting in a decline in driving skills.

[0003] Driver fatigue easily leads to traffic accidents. By monitoring the driver's condition in real time, signs of fatigue can be identified early, reducing the likelihood of accidents caused by drowsy driving. Related technologies typically use sensors or cameras to monitor driver fatigue. Specific solutions and their corresponding drawbacks are as follows:

[0004] Option 1: Use a steering wheel sensor to detect the frequency and force of steering wheel operations to determine if the driver is fatigued; however, the information that a steering wheel sensor can detect is limited and is easily affected by road conditions, leading to inaccurate detection results.

[0005] Option 2: Use seat pressure sensors to monitor the pressure distribution and changes on the driver's seat to determine if the driver is fatigued; however, due to the influence of the driver's body shape and sitting posture, the data collected by the seat pressure sensors is not stable enough, which may lead to inaccurate detection results.

[0006] Option 3: Use a camera monitoring system to capture the driver's facial expressions, eye movements, yawning, and attention to determine if the driver is fatigued; however, since different people have different facial expressions and / or demeanor, the detection results may be inaccurate.

[0007] Option 4 involves using infrared sensors to detect the driver's eye movements, blinking frequency, and head posture to determine if the driver is fatigued. However, this option is costly and may be affected by external environmental factors (such as wearing glasses), leading to inaccurate results.

[0008] In summary, existing methods for identifying driver fatigue suffer from inaccurate detection results. Summary of the Invention

[0009] This application provides an image processing method, apparatus, electronic device, vehicle, and computer program product that can accurately monitor the driver's driving status to reduce the probability of traffic accidents caused by driver fatigue.

[0010] The technical solution of this application embodiment is implemented as follows:

[0011] This application provides an image processing method, the method comprising:

[0012] Acquire a first image and a second image, both of which include the same driver's face image;

[0013] Sparse optical flow calculation is performed on multiple first facial key points in the first image and the second image to obtain the optical flow vectors of the multiple first facial key points;

[0014] Based on the optical flow vectors of the plurality of first facial key points, first information is output, which indicates the driver's driving state.

[0015] This application also provides an image processing apparatus, including:

[0016] The acquisition module is used to acquire a first image and a second image, both of which include the same driver's face image;

[0017] The calculation module is used to perform sparse optical flow calculation on multiple first facial key points in the first image and the second image to obtain the optical flow vector of the multiple first facial key points;

[0018] The state detection module is used to output first information based on the optical flow vectors of the plurality of first facial key points, the first information indicating the driver's driving state.

[0019] In the above scheme, the state detection module is further configured to perform optical flow compensation on the second image based on the optical flow vectors of the plurality of first facial key points to obtain a third image, wherein the second image is captured after the first image; and to output first information based on the plurality of second facial key points of the third image.

[0020] In the above scheme, the state detection module is further used for:

[0021] Based on the optical flow vectors of the plurality of first facial key points, a third facial key point is determined in the second image. The third facial key point is a first facial key point whose optical flow vector displacement is greater than a first threshold.

[0022] Brightness compensation is performed on the first pixel in the second image to obtain a brightness-compensated second image, wherein the first pixel includes at least the pixel corresponding to the third facial key point.

[0023] Based on the optical flow vectors of the multiple first facial key points, optical flow compensation is performed on the brightness-compensated second image to obtain the third image.

[0024] In the above scheme, the state detection module is further used for:

[0025] Based on the optical flow vectors of the plurality of first facial key points, a first face region is determined in the second image, wherein the first face region includes at least the plurality of first facial key points;

[0026] Based on the pixel values ​​of the pixels in the second face region of the first image, brightness compensation is performed on the first face region to obtain a third image, wherein the second face region includes at least the plurality of first face key points.

[0027] In the above scheme, the state detection module is further used for:

[0028] Based on the optical flow vectors of the plurality of first facial key points, the first position corresponding to each of the plurality of first facial key points in the second image is determined;

[0029] Based on the pixel values ​​of the pixels surrounding each first facial key point in the first image, brightness compensation is performed on the corresponding pixels at the first position to obtain the third image.

[0030] In the above scheme, the state detection module is further used for:

[0031] Based on the pixel values ​​of the second pixels surrounding the first pixel, perform brightness compensation on the first pixel; and / or

[0032] Based on the pixel value of the third pixel in the first image, brightness compensation is performed on the first pixel, wherein the third pixel includes at least the pixel corresponding to the third facial key point in the first image.

[0033] In the above scheme, the state detection module is further used for:

[0034] Second information is determined based on the optical flow vectors of the plurality of first facial key points, and the second information represents information related to the driver's expression;

[0035] The first information is output based on the second information.

[0036] This application embodiment also provides an electronic device, the electronic device comprising:

[0037] Memory is used to store executable instructions for a computer;

[0038] The processor, when executing computer-executable instructions stored in the memory, implements the image processing method provided in the embodiments of this application.

[0039] This application provides a vehicle, which includes the electronic equipment provided in this application.

[0040] This application also provides a computer-readable storage medium storing computer-executable instructions for implementing the image processing method provided in this application when executed by a processor.

[0041] This application also provides a computer program product, including computer-executable instructions, which, when executed by a processor, implement the image processing method provided in this application.

[0042] The embodiments of this application have the following beneficial effects:

[0043] This application performs sparse optical flow calculations on multiple first facial key points in a first image and a second image containing facial images of the same driver, obtaining the optical flow vector of each first facial key point, and outputting first information based on the optical flow vector of each first facial key point. Since the optical flow vector of any first facial key point can be understood as the motion vector of the same first facial key point in the first and second images, after selecting any first facial key point in the first or second image, the first facial key point can be accurately located in another image based on its motion vector, improving the accuracy of determining the first facial key point. Based on the optical flow vectors of the first facial key points in different images, the driver's driving state can be accurately monitored. Since the output first information can indicate the driver's driving state, when the driving state is fatigued, the output first information can provide a warning to the driver so that the driver can adjust their state or change drivers, thereby reducing the probability of traffic accidents caused by driver fatigue. Attached Figure Description

[0044] Figure 1 This is a first flowchart illustrating the image processing method provided in the embodiments of this application;

[0045] Figure 2 This is a schematic diagram of the structure of the face detection model provided in the embodiments of this application;

[0046] Figure 3 This is a schematic diagram of the second process of the image processing method provided in the embodiments of this application;

[0047] Figure 4 A schematic diagram of the third process of the image processing method provided in the embodiments of this application;

[0048] Figure 5 This is a schematic diagram of the structure of the image processing apparatus provided in the embodiments of this application;

[0049] Figure 6This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application.

[0050] It should be noted that the terms "first" and "second" mentioned above are only used to distinguish between different options and do not represent the degree of superiority or inferiority of the options or their priority in the implementation process. Detailed Implementation

[0051] To make the objectives, technical solutions, and advantages of this application clearer, the application will be further described in detail below with reference to the accompanying drawings. The described embodiments should not be regarded as limitations on this application. All other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0052] In the following description, references are made to “some embodiments,” which describe a subset of all possible embodiments. However, it is understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.

[0053] In the following description, the terms "first, second, third" are used merely to distinguish similar objects and do not represent a specific ordering of objects. It is understood that "first, second, third" may be interchanged in a specific order or sequence where permitted, so that the embodiments of this application described herein can be implemented in an order other than that illustrated or described herein.

[0054] In this application, the terms "module" or "unit" refer to computer-executable instructions or a portion of computer-executable instructions that have a predetermined function, work together with other related parts to achieve a predetermined goal, and can be implemented wholly or partially using software, hardware (such as processing circuitry or memory), or a combination thereof. Similarly, a processor (or multiple processors or memory) can be used to implement one or more modules or units. Furthermore, each module or unit can be part of an overall module or unit that includes the functionality of that module or unit.

[0055] Unless otherwise defined, all technical and scientific terms used in the embodiments of this application have the same meaning as commonly understood by one of ordinary skill in the art. The terminology used in the embodiments of this application is for the purpose of describing the embodiments of this application only and is not intended to limit this application.

[0056] In the implementation of this application, the collection and processing of relevant data should strictly comply with the requirements of relevant national laws and regulations, obtain the informed consent or separate consent of the personal information subject, and carry out subsequent data use and processing within the scope of laws and regulations and the authorization of the personal information subject.

[0057] Before providing a further detailed description of the embodiments of this application, the nouns and terms involved in the embodiments of this application will be explained, and the nouns and terms involved in the embodiments of this application shall be interpreted as follows.

[0058] 1) The A-pillar refers to the pillar on either side of the windshield of a vehicle, located between the engine compartment and the passenger compartment. Specifically, the A-pillar is located on both sides of the windshield, connecting the roof and the body, and is situated above the left and right side mirrors.

[0059] 2) Facial landmarks refer to the key points of a person's face, including key points of the eyebrows, eyes, nose, mouth, and facial contour areas. The number of facial landmarks to be collected can vary depending on the application scenario. For example, in a basic pose alignment scenario, the number of facial landmarks can be 5, mainly including the center of the eyes, the tip of the nose, and the corners of the mouth; as another example, in general scenarios such as face recognition or identity recognition, the total number of facial landmarks can be 68, including 51 internal key points and 17 key points of the facial contour areas.

[0060] 3) Facial landmark detection model, used to detect faces in images or videos and return the region and landmarks of each face. For example, input the image to be tested into the facial landmark detection model and obtain the image output by the facial landmark detection model marked with face regions and facial landmarks.

[0061] 4) Optical flow refers to the movement of an image object across two consecutive frames due to the movement of the target object or camera. For example, the movement of a vehicle causes the driver captured by a camera inside the vehicle to move across two consecutive frames. Optical flow can also be understood as the motion vector or motion vector of the same pixel in two adjacent images, that is, the direction and speed of the pixel's movement.

[0062] 5) Sparse optical flow refers to calculating the optical flow vector of a subset of pixels or key points in an image. For example, tracking the driver's face or facial key points in an image and calculating the optical flow vector of the driver's face or facial key points.

[0063] 6) Optical flow compensation is a technique used in computer vision and video processing. It is mainly used to reduce or compensate for differences caused by motion by estimating the optical flow or optical flow vector between adjacent frames, thereby improving the effect of motion analysis or image stabilization. For example, based on the optical flow vector of facial key points in two adjacent frames, and based on the pixel values ​​of facial key points or pixels surrounding facial key points in the first frame of the two adjacent frames, brightness compensation is performed on the second frame of the two adjacent frames.

[0064] 7) Head and Face Detection Model: Used to acquire the coordinates of heads, faces, and mobile phones appearing in images or videos in real time. For example, the head and face detection model can be used to identify facial images captured by cameras inside vehicles.

[0065] The present application will now be described in further detail with reference to the accompanying drawings and embodiments.

[0066] This application provides an image processing method applied to an electronic device, including but not limited to a terminal and / or a server, with the terminal including but not limited to in-vehicle infotainment systems. The electronic device can take pictures of the vehicle's driver, or can acquire or receive images of the driver captured by a camera installed inside the vehicle. For example, the electronic device may be equipped with a camera to take pictures of the vehicle's driver; or, the electronic device may communicate with a camera or camera system installed inside the vehicle to acquire or receive images of the driver captured by that camera or camera system. Figure 1 As shown, the method includes:

[0067] Step 101: Obtain a first image and a second image, both of which include the same driver's face image.

[0068] Here, in a scenario where the electronic device is equipped with a camera that supports capturing a frontal image of the vehicle's driver, the electronic device can acquire multiple frontal images of the driver in real time, or acquire multiple frontal images of the driver at a first time interval, to obtain an image sequence of the driver. The electronic device can determine or acquire two images including facial images from the driver's image sequence to obtain a first image and a second image. Here, a frontal image of the driver refers to an image obtained by taking a picture of the driver from the front or in front of the driver. The first time interval can be fixed or dynamically adjusted according to actual needs. It should be noted that in the image sequence, the first image and the second image can be adjacent or non-adjacent. For example, in a scenario where multiple images in the image sequence all include facial images of the same driver, the first image and the second image are adjacent. In a scenario where some images in the image sequence do not include facial images, the first image and the second image can be non-adjacent. For example, if the image sequence includes images A, B, and C, and image B does not include a facial image of the driver, then the first image and the second image can be images A and C, respectively. Considering that bumps may occur during vehicle operation, or the driver's face may be outside the camera's field of view, resulting in the camera capturing images that do not include the driver's face, the electronic device can detect in real time whether the captured images contain a face image while taking pictures of the driver. If a face image is not detected multiple times consecutively, for example, if the number of consecutive times a face image is not detected is greater than or equal to a second threshold, i.e., a face image is not detected in multiple consecutive images, a third piece of information can be output. This third piece of information can be understood as an abnormal alarm message, used to prompt relevant personnel (such as the driver) that a face image has not been detected in multiple consecutive images, so that the shooting angle and / or the interior brightness can be adjusted in time, thereby enabling the electronic device to capture the driver's face image.

[0069] In scenarios where the electronic device is not equipped with a camera, the electronic device receives an image sequence from a camera or camera system installed inside the vehicle. This image sequence includes multiple images captured of the driver. The electronic device can sequentially determine or acquire two images, including facial images, from the received image sequence to obtain a first image and a second image. It should be noted that the camera or camera system installed inside the vehicle can send one image to the electronic device after each image of the driver is captured; alternatively, it can send multiple captured images to the electronic device at a second time interval, without limitation. The second time interval can be the same as or different from the first time interval.

[0070] It should be noted that in the scenario of executing step 101 for the first time, the first image can be the first image including a face image in the image sequence of the same driver, and the second image can be the second image including a face image in the image sequence; in the scenario of executing step 101 for the second time, the first image can be the second image determined in the most recent execution of step 101 or the processed second image, such as the third image obtained after optical flow compensation of the second image.

[0071] Step 102: Perform sparse optical flow calculation on multiple first facial key points in the first image and the second image to obtain the optical flow vectors of the multiple first facial key points.

[0072] Here, "first facial landmark" refers to facial landmarks in the first image and facial landmarks in the second image.

[0073] An electronic device identifies multiple first facial key points in a first image and multiple first facial key points in a second image. Sparse optical flow calculations are performed on each first facial key point in the first and second images to obtain the optical flow vector of each first facial key point. For example, any first facial key point can be selected in the first image, and sparse optical flow calculations can be performed on that first facial key point in both the first and second images to obtain its optical flow vector. Following this method, the optical flow vectors of all first facial key points in the first image can be calculated. Existing sparse optical flow algorithms can be used to perform sparse optical flow calculations on each first facial key point in the first and second images. Existing sparse optical flow algorithms include, but are not limited to, the Lucas-Kanade optical flow algorithm, a classic sparse optical flow algorithm used to estimate the motion direction and velocity of facial key points in an image.

[0074] It should be noted that if the first image was captured before the second image, then the optical flow vector of the first facial keypoint points from its position in the first image to its position in the second image; if the first image was captured after the second image, then the optical flow vector of the first facial keypoint points from its position in the second image to its position in the first image. The optical flow vector can be described as a motion vector.

[0075] It should be noted that facial recognition technology, such as facial recognition algorithms, can be used to identify each first facial landmark in the first and second images; alternatively, a facial landmark detector can be used to identify each first facial landmark in the first and second images. Facial landmark detectors include, but are not limited to, PFLD (A Practical Facial Landmark Detector), a lightweight deep learning-based facial landmark detector characterized by high accuracy and speed; or a facial landmark detection model can be used to identify each first facial landmark in the first and second images. The facial landmark detection model is trained on training samples that at least partially contain images of faces; the model is used to detect whether the input image contains facial landmarks and, if so, to mark the facial landmarks in the input image. Methods for training a facial landmark detection model include, but are not limited to: inputting one or more first training samples into the facial landmark detection model to obtain one or more second training samples output by the facial landmark detection model; adjusting the parameters of the facial landmark detection model based on the loss value between the second training samples and the calibration images of the first training samples; wherein at least a portion of the first training samples include facial images, the first training samples and the second training samples correspond one-to-one, at least a portion of the second sample images are marked with facial landmarks, and the calibration images of the first training samples are marked with facial landmarks.

[0076] Figure 2 A structural example of a facial landmark detection model provided in an embodiment of this application is given. For example... Figure 2 As shown, a facial landmark detection model can include a face detection network and a landmark detection network. The face detection network is used to detect face regions contained in the input image, and the landmark detection network is used to detect and label facial landmarks. The implementation process of the landmark detection network detecting facial landmarks can include: cropping the face region detected by the face detection network from the image; normalizing the size of the cropped face region; extracting the feature information of the face region; identifying facial landmarks based on the feature information; and mapping the identified facial landmarks to the input original image to output an image labeled with facial landmarks. Of course, the facial landmark detection model can also be an existing model with facial landmark detection capabilities; for example, the facial landmark detection model can be a convolutional neural network model with facial landmark detection capabilities, including but not limited to RetinaFace. RetinaFace has face detection and facial landmark localization capabilities; the model structure of RetinaFace is not described here.

[0077] Considering that different lighting conditions or changes in lighting in the driving environment can easily lead to deviations in the localization of facial landmarks, for example, sunlight may shine through the car window, and streetlights or vehicle headlights may cause changes in light and shadow during driving. These changes in lighting can cause inconsistent brightness in the driver's facial image captured by the camera, potentially leading to deviations in the localization of facial landmarks. Furthermore, when a light source directly illuminates the driver's face, it can cause overexposure or excessive shadows in certain areas of the face, resulting in inaccurate facial landmark detection. Therefore, to improve the detection accuracy of the facial landmark detection model and reduce or eliminate the impact of different lighting conditions or changes in lighting in the driving environment on the detection results, thereby improving the robustness of the facial landmark detection model, in any of the above embodiments, training samples containing at least facial images collected under different lighting conditions can be used to train the facial landmark detection model. That is, the facial landmark detection model can be trained based on facial images collected under different lighting conditions, and the facial landmark detection model is used to identify and label facial landmarks in the input facial image.

[0078] In practical applications, facial images of vehicle drivers can be acquired under both normal and special lighting conditions. Data augmentation techniques can then be used to enhance these images, generating facial images under different lighting conditions to train a facial landmark detection model. For example, under normal lighting conditions, facial images of different genders, expressions, postures, and head angles can be acquired, and the locations of facial landmarks and head tilt markers can be labeled. Normal lighting conditions include, but are not limited to, scenarios where the driver is driving on an open road where sunlight does not reach the driver's cabin or face. Head tilt markers include, but are not limited to, one or more of the following: upward head tilt, downward head tilt, left head tilt, and right head tilt. For example, under special lighting conditions, the lighting conditions and light sources are constantly changed to collect facial images of different genders, expressions, sitting postures, and head angles, and the positions of key facial points and head tilt marks are marked. Special lighting conditions include, but are not limited to, one or more of the following: sunlight shining through the car window into the driver's cabin, streetlights or vehicle lights causing changes in light and shadow during driving, and light sources directly shining on the driver's face; light sources include, but are not limited to, one or more of sunlight, streetlights, and vehicle lights.

[0079] Step 103: Based on the optical flow vectors of the plurality of first facial key points, output first information, which indicates the driver's driving state.

[0080] Here, the electronic device determines the driver's driving state based on the optical flow vectors of multiple first facial key points obtained in step 102, and outputs first information according to the driver's driving state.

[0081] A driver's driving state includes at least their physiological state and may also include their psychological state. The psychological state includes, but is not limited to, one or more of the following: impatience, excitement, and anger. A driver's physiological state includes at least normal driving and / or abnormal driving states. Normal driving refers to driving the vehicle when the driver is in good physical and mental condition, able to maintain sufficient attention and reaction time to ensure driving safety. Abnormal driving states include, but are not limited to, fatigued driving and / or distracted driving. Distracted driving includes, but is not limited to, making or receiving phone calls and / or yawning while driving.

[0082] Of course, a driver's driving condition can also be divided into two main categories: fatigued driving condition and non-fatigue driving condition.

[0083] The process of determining the driver's driving state based on the optical flow vectors of multiple first facial key points includes, but is not limited to:

[0084] Based on key points of the eyes included in multiple first-face key points, the driver's eye opening angle is determined, and the driver's driving state is determined based on the eye opening angle. For example, if the driver's eye opening angle is less than a third threshold, the driver is in an abnormal driving state or a fatigued driving state; if the driver's eye opening angle is greater than or equal to the third threshold, the driver is in a normal driving state or a non-fatigue driving state. The opening angle can be described as the opening and closing angle.

[0085] Based on the mouth key points included in multiple first-face key points, the driver's mouth opening angle is determined, and the driver's driving state is determined based on the mouth opening angle. For example, if the driver's mouth opening angle is greater than or equal to the fourth threshold, the driver is in an abnormal driving state or a fatigued driving state; if the driver's mouth opening angle is less than the fourth threshold, the driver is in a normal driving state or a non-fatigue driving state. Here, the fourth threshold is greater than the third threshold, and the fourth and third thresholds can be set according to actual conditions and are not restricted here.

[0086] The methods for outputting the first information include, but are not limited to, outputting the first information via text or voice. Specifically, the first information can be output through the vehicle's in-vehicle infotainment system, or through one or more of a terminal (e.g., a mobile phone), server, and control system that has established a communication connection with the vehicle. For example, if the first information indicates that the driver is in a state of fatigued driving and / or abnormal driving, the electronic device will broadcast the first information via voice to warn the driver or to road or vehicle-related control personnel.

[0087] In this embodiment, sparse optical flow calculation is performed on multiple first facial key points in a first image and a second image containing facial images of the same driver to obtain the optical flow vector of each first facial key point. First information is then output based on the optical flow vector of each first facial key point. Since the optical flow vector of any first facial key point can be understood as the motion vector of the same first facial key point in the first and second images, after selecting any first facial key point in the first or second image, the first facial key point can be accurately located in another image based on its motion vector. This improves the accuracy of determining the first facial key point. The optical flow vectors of first facial key points in different images can accurately monitor the driver's driving state. Since the output first information can indicate the driver's driving state, when the driving state is fatigued, the output first information can provide a warning to the driver so that the driver can adjust their state or a replacement driver can be chosen, thereby reducing the probability of traffic accidents caused by driver fatigue.

[0088] Considering that changes in lighting may cause inconsistent brightness in the driver's facial image captured by the camera, and may also lead to overexposure or excessive shadows in some areas of the driver's face image, directly performing facial landmark detection based on the acquired facial image may result in inaccurate results. To reduce or eliminate artifacts caused by lighting changes in facial landmark detection, and to accurately detect facial landmarks, thereby accurately identifying the driver's driving state, optical flow compensation can be applied to the acquired image. Based on this, in one embodiment, the output of first information based on the optical flow vectors of the plurality of first facial landmarks includes:

[0089] Optical flow compensation is performed on the second image based on the optical flow vectors of the plurality of first facial key points to obtain a third image, wherein the second image is captured after the first image;

[0090] Based on multiple second facial key points in the third image, first information is output.

[0091] Here, the electronic device performs brightness compensation on the second image based on the optical flow vectors of multiple first facial key points obtained in step 102, and based on the pixel values ​​of the first facial key points in the first image or the pixel values ​​of the pixels surrounding the first facial key points, to achieve optical flow compensation on the second image and obtain a third image; then, based on the multiple second facial key points of the third image, it outputs first information. The method for recognizing the second facial key points in the third image is the same as the method for recognizing the first facial key points, and will not be described in detail here.

[0092] Among them, brightness compensation of the second image is used to reduce or eliminate artifacts caused by changes in lighting to the detection of facial key points.

[0093] The methods for performing brightness compensation on the second image may include:

[0094] First, based on the optical flow vectors of multiple first facial keypoints, a coordinate transformation is performed on the first facial keypoints in the first image. Specifically, based on the optical flow vectors of multiple first facial keypoints, the position of each first facial keypoint in the first image in the second image is determined. Assuming the coordinates of any first facial keypoint in the first image are (x, y), and the corresponding optical flow vector of the first facial keypoint is (u, v), then the coordinates of the corresponding position of the first facial keypoint in the second image are (x', y'), where x' = x + u, y' = y + v.

[0095] Then, based on the pixel value of the first facial key point in the first image or the pixel value of the pixels around the first facial key point, and based on the position of the first facial key point in the second image, brightness compensation is performed on the second image to obtain the third image.

[0096] For example, based on the pixel values ​​of the first facial keypoint at coordinates (x, y) in the first image, brightness compensation is performed on the pixels of the first facial keypoint at coordinates (x', y') in the second image. Specifically, the pixel values ​​of the pixels of the first facial keypoint at coordinates (x', y') in the second image can be modified to the average of the pixel values ​​of all pixels of the first facial keypoint at coordinates (x, y) in the first image. Following this method, brightness compensation can be performed sequentially on other first facial keypoints in the second image.

[0097] For example, based on the pixel values ​​of the pixels surrounding the first facial keypoint at coordinates (x, y) in the first image, brightness compensation is performed on the pixels contained in the first facial keypoint at coordinates (x', y') in the second image. Specifically, the pixel values ​​of the pixels surrounding the first facial keypoint at coordinates (x, y) in the first image are weighted and summed to obtain the first pixel value of the first facial keypoint, and the pixel values ​​of the pixels contained in the first facial keypoint at coordinates (x', y') in the second image are modified to the first pixel value. Following this method, brightness compensation can be performed sequentially on other first facial keypoints in the second image.

[0098] For example, based on the pixel values ​​of the first facial keypoint at coordinates (x, y) in the first image, and the pixel values ​​of the pixels surrounding the first facial keypoint at coordinates (x, y) in the first image, brightness compensation is performed on the pixels containing the first facial keypoint at coordinates (x', y') in the second image. Specifically, the pixel values ​​of all pixels containing the first facial keypoint at coordinates (x, y) in the first image, and the pixel values ​​of the pixels surrounding the first facial keypoint, are weighted and summed to obtain the second pixel value of the first facial keypoint; the pixel value of the pixels containing the first facial keypoint at coordinates (x', y') in the second image is then modified to this second pixel value. Following this method, brightness compensation can be performed sequentially on other first facial keypoints in the second image. The pixel values ​​closer to the first facial keypoint have a higher weight. In this embodiment, the pixel values ​​can also be replaced with grayscale values.

[0099] It should be noted that after transforming the coordinates of the first facial keypoint in the first image, the coordinates of the first facial keypoint in the second image may not be integers, meaning the location of the first facial keypoint in the second image may not be the center of the pixel. In this case, when performing brightness compensation on the second image, an interpolation algorithm is needed to calculate the pixel value of the location of the first facial keypoint in the second image. Interpolation algorithms include, but are not limited to, bilinear interpolation. Specifically, the pixel value of the location of the first facial keypoint in the second image can be calculated based on the pixel values ​​of at least four neighboring pixels in the first image. To make the third image smoother and reduce the probability of jagged edges or holes in the pixels in the third image, a weighted average can be calculated based on the pixel value of the first facial keypoint in the first image and the pixel values ​​of the aforementioned at least four neighboring pixels in the first image, and the pixel value of the location of the first facial keypoint in the second image can be modified to this weighted average. In this method, the pixel value of a pixel closer to the location of the first facial key point in the first image has a higher weight. The weight of the pixel value of the first facial key point in the first image can be greater than or equal to the weight of the pixel values ​​of other pixels. The sum of the weights of all pixel values ​​can be equal to 1 or greater than 1. By using a weighted average, the brightness-compensated image is made smoother, avoiding problems such as jagged edges or holes.

[0100] It should be noted that the electronic device can perform optical flow compensation on the second image based on the optical flow vectors of the multiple first facial key points in scenarios where the brightness of the face region in the first image is significantly higher than that in the second image (e.g., the brightness difference between the first and second images exceeds a fifth threshold) to obtain a third image. Similarly, in scenarios where the brightness of the face region in the first image is significantly lower than that in the second image, the electronic device can also perform optical flow compensation on the first image based on the optical flow vectors of the multiple first facial key points to obtain a third image. The implementation method for optical flow compensation on the first image based on the optical flow vectors of the multiple first facial key points includes: performing brightness compensation on the first image based on the optical flow vectors of the multiple first facial key points obtained in step 102, and based on the pixel values ​​of the first facial key points in the second image or the pixel values ​​of the pixels surrounding the first facial key points. The specific implementation process is similar to that of optical flow compensation on the second image based on the optical flow vectors of the multiple first facial key points, and will not be elaborated here.

[0101] Considering that real-world driving environments may experience changes or sudden shifts in global illumination, such as a vehicle entering or exiting a tunnel, or a streetlight suddenly shining directly on the face, the brightness of the driver's facial image captured by the camera may be inconsistent. Directly performing facial landmark detection based on the acquired facial image could lead to significant deviations in the detection results. To reduce or eliminate the impact of global illumination changes on facial landmark detection and accurately detect facial landmarks, thereby accurately identifying the driver's driving state, brightness compensation can be applied to facial landmarks affected by global illumination changes, followed by optical flow compensation to the processed image. Therefore, in one embodiment, the optical flow compensation of the second image based on the optical flow vectors of the plurality of first facial landmarks to obtain a third image includes:

[0102] Based on the optical flow vectors of the plurality of first facial key points, a third facial key point is determined in the second image. The third facial key point is a first facial key point whose optical flow vector displacement is greater than a first threshold.

[0103] Brightness compensation is performed on the first pixel in the second image to obtain a brightness-compensated second image, wherein the first pixel includes at least the pixel corresponding to the third facial key point.

[0104] Based on the optical flow vectors of the multiple first facial key points, optical flow compensation is performed on the brightness-compensated second image to obtain the third image.

[0105] Here, since the displacement of facial key points caused by global light changes is relatively large, while the displacement of facial key points caused by vehicle movement is relatively small, the first facial key point whose displacement of the optical flow vector is greater than the first threshold can be determined in the second image based on the optical flow vectors of multiple first facial key points obtained in step 102, thus obtaining the third facial key point. The third facial key point is the facial key point affected by global light changes. Based on the location of the third facial key point in the second image, the first pixel is determined in the second image, and brightness compensation is performed on the first pixel in the second image to obtain the brightness-compensated second image. Then, optical flow compensation is performed on the brightness-compensated second image based on the optical flow vectors of multiple first facial key points to obtain the third image.

[0106] Wherein, if the displacement of the optical flow vector of the first facial key point is less than or equal to the first threshold, it indicates that the position change of the first facial key point in different images is caused by vehicle movement; if the displacement of the optical flow vector of the first facial key point is greater than the first threshold, it indicates that the position change of the first facial key point in different images is caused by global light changes.

[0107] The number of first pixels can be one or more. For example, a first pixel can include only the pixels contained in the location of the third facial keypoint, or it can include one or more pixels surrounding the location of the third facial keypoint. One third facial keypoint can correspond to one or more first pixels.

[0108] Brightness compensation of the first pixel in the second image can be used to reduce or eliminate artifacts caused by global illumination variations in facial keypoint detection. The process of brightness compensation for the first pixel in the second image can include: performing brightness compensation on the first pixel in the second image based on the pixel values ​​of pixels in the face region of the first image; and / or, performing brightness compensation on the first pixel in the second image based on the pixel values ​​of second pixels in the second image. The second pixels can be located in the face region or a non-face region of the second image, and there can be one or more second pixels. Second pixels can be adjacent to or not adjacent to first pixels; for example, second pixels may be located around first pixels, or there may be other pixels between them. The correspondence between second pixels can be one-to-one, one-to-many, or many-to-many.

[0109] It should be noted that during the brightness compensation of the first pixel in the second image, brightness correction can also be performed on the third key point and the pixels surrounding the third key point. For the implementation process of optical flow compensation of the brightness-compensated second image based on the optical flow vectors of multiple first facial key points, please refer to the relevant description above regarding optical flow compensation of the second image based on the optical flow vectors of multiple first facial key points; it will not be repeated here.

[0110] It should be noted that since the first pixel includes at least the pixel corresponding to the third facial key point in the second image, and the position change of the third facial key point in the first and second images is caused by global light changes, the third facial key point in the second image is an artifact caused by light and not a real facial key point. Therefore, at least the brightness of the third facial key point in the second image needs to be compensated to modify the pixel value of the pixel at the location of the third facial key point in the second image, so that the modified pixel can be distinguished from the pixel corresponding to the real facial key point. The real facial key point can be understood as the first facial key point whose optical flow vector displacement is less than or equal to the first threshold.

[0111] In any of the above embodiments, the step of performing brightness compensation on the first pixel in the second image includes:

[0112] Based on the pixel values ​​of the second pixels surrounding the first pixel, perform brightness compensation on the first pixel; and / or

[0113] Based on the pixel value of the third pixel in the first image, brightness compensation is performed on the first pixel, wherein the third pixel includes at least the pixel corresponding to the third facial key point in the first image.

[0114] Here, for each first pixel, the pixel value of the first pixel can be adjusted based on the pixel values ​​of the second pixels surrounding it to achieve brightness compensation for the first pixel. For example, the mean or weighted average of the pixel values ​​of the second pixels surrounding the first pixel can be calculated, and the pixel value of the first pixel can be modified to that mean or weighted average.

[0115] For each third facial landmark, the position of the third facial landmark in the second image and its corresponding position in the first image can be determined based on its optical flow vector. Based on this position, a third pixel is identified in the first image. The mean or weighted average of the pixel values ​​of the third pixel is calculated, and the pixel value of the first pixel is then modified to this mean or weighted average. The third pixel may include only the pixels within the position corresponding to the third facial landmark in the first image, or it may include one or more pixels surrounding that position. The closer the third pixel is to the location of the third facial landmark, the greater its pixel value's weight.

[0116] In this embodiment, two brightness compensation methods are provided. One or both methods can be selected to compensate the brightness of the first pixel according to the actual situation. This improves the flexibility of brightness compensation for the first pixel and can also reduce the impact of global light changes on the detection results of facial key points to a greater extent, thereby improving the accuracy of facial key point detection results and thus improving the accuracy of driver's driving status recognition.

[0117] After determining the optical flow vectors of multiple first facial key points in the first and second images, optical flow compensation needs to be performed on the second image or the brightness-compensated second image to reduce or eliminate the impact of lighting changes on facial key point detection. Therefore, in any of the above embodiments, optical flow compensation is performed on the second image based on the optical flow vectors of the multiple first facial key points to obtain a third image, including:

[0118] Based on the optical flow vectors of the plurality of first facial key points, a first face region is determined in the second image, wherein the first face region includes at least the plurality of first facial key points;

[0119] Based on the pixel values ​​of the pixels in the second face region of the first image, brightness compensation is performed on the first face region to obtain a third image, wherein the second face region includes at least the plurality of first face key points.

[0120] Here, based on the optical flow vectors of multiple first facial key points obtained in step 102, the location of each first facial key point is determined in the second image; based on the location of each first facial key point in the second image, a first face region is determined in the second image; based on the location of multiple first facial key points in the first image obtained in step 102, a second face region is determined in the first image. For example, based on the optical flow vectors of multiple first facial key points obtained in step 102, the location of each first facial key point is determined in the first image, thereby determining the second face region; based on the pixel values ​​of the pixels in the second face region of the first image, brightness compensation is performed on the first face region in the second image to obtain a third image. For example, based on the mean or weighted average of the pixel values ​​of the pixels in the second face region of the first image, brightness compensation is performed on the first face region in the second image.

[0121] The first face region includes at least some or all of the obtained multiple first facial key points, and may also include pixels near the first facial key points in the second image. The first face region may include multiple sub-regions, each corresponding to one first facial key point. The sub-regions may be regular or irregular regions centered on the first facial key points. The second face region includes at least some or all of the obtained multiple first facial key points, and may also include pixels near the first facial key points in the first image. The second face region may include multiple sub-regions, each corresponding to one first facial key point. The sub-regions may be regular or irregular regions centered on the first facial key points.

[0122] It should be noted that since the second image after brightness compensation is obtained by performing brightness compensation on the third facial key points, when performing optical flow compensation on the second image after brightness compensation based on the optical flow vectors of multiple first facial key points, the third facial key points can be removed from the first region to reduce the time consumed in performing optical flow compensation on the second image.

[0123] In this embodiment, a first face region is determined in the second image based on the optical flow vectors of multiple first face key points, and a second face region is determined in the first image. Brightness compensation is then performed on the first face region based on the pixel values ​​of the pixels included in the second face region. This allows for regional brightness compensation and improves the efficiency of optical flow compensation on the second image.

[0124] After determining the optical flow vectors of multiple first facial key points in the first and second images, optical flow compensation needs to be performed on the second image or the brightness-compensated second image to reduce or eliminate the impact of lighting changes on facial key point detection. Therefore, in any of the above embodiments, optical flow compensation is performed on the second image based on the optical flow vectors of the multiple first facial key points to obtain a third image, including:

[0125] Based on the optical flow vectors of the plurality of first facial key points, the first position corresponding to each of the plurality of first facial key points in the second image is determined;

[0126] Based on the pixel values ​​of the pixels surrounding each first facial key point in the first image, brightness compensation is performed on the corresponding pixels at the first position to obtain the third image.

[0127] Here, based on the optical flow vectors of multiple first facial key points, the first position of each first facial key point in the second image is determined. For the specific implementation process, please refer to the relevant description above, which will not be repeated here.

[0128] For each first facial key point, the pixel value of the corresponding first position in the second image can be adjusted based on the mean or weighted average of the pixel values ​​of the pixels surrounding the first facial key point in the first image, so as to achieve brightness compensation for the pixel at the first position; for example, the pixel value of the pixel at the first position can be modified to the determined mean or weighted average.

[0129] For each first facial key point, the mean or weighted average of the pixel values ​​of the pixels surrounding the first facial key point in the first image, as well as the pixel values ​​of the pixels contained in the location of the first facial key point in the first image, can be calculated. Based on the determined mean or weighted average, the pixel values ​​of the pixels at the first position corresponding to the first facial key point in the second image are adjusted.

[0130] It should be noted that after performing coordinate transformation on the first facial keypoint in the first image, the coordinates of the first facial keypoint in the second image may not be integers, meaning the location of the first facial keypoint in the second image may not be the center of the pixel. In this case, when performing optical flow compensation on the second image, an interpolation algorithm can be used to calculate the pixel value of the first facial keypoint at its first location in the second image. This interpolation algorithm includes, but is not limited to, bilinear interpolation. Specifically, the pixel value of the first facial keypoint at its first location in the second image can be calculated based on the pixel values ​​of at least four neighboring pixels surrounding it in the first image. To make the third image smoother and reduce the probability of jagged edges or holes in the pixels, a weighted average can be calculated based on the pixel value of the first facial keypoint in the first image and the pixel values ​​of the aforementioned at least four neighboring pixels surrounding it. The pixel value of the first facial keypoint at its first location in the second image can then be modified to this weighted average. In this method, the pixel value of a pixel closer to the location of the first facial key point in the first image has a higher weight. The weight of the pixel value of the first facial key point in the first image can be greater than or equal to the weight of the pixel values ​​of other pixels. The sum of the weights of all pixel values ​​can be equal to 1 or greater than 1. By using a weighted average, the brightness-compensated image is made smoother, avoiding problems such as jagged edges or holes.

[0131] In this embodiment, based on the pixel values ​​of the pixels surrounding each first facial key point in the first image, brightness compensation is performed on the pixels at the first position of the corresponding first facial key point in the second image. This can adjust the local brightness in the second image, compensate for the inconsistent image brightness caused by changes in ambient light, thereby reducing the impact of light changes on facial key point detection and improving the accuracy of facial key points identified from the compensated second image. For example, it can improve the accuracy of second facial key points identified from the third image, and further improve the accuracy of driver's driving status identified based on facial key points.

[0132] Considering that drivers making or receiving phone calls, inattention, distracted driving, and fatigued driving can all lead to traffic accidents, in order to reduce the probability of traffic accidents caused by driver behavior, the driver's facial expressions can be analyzed to identify their driving status, allowing for early detection of signs of fatigue and distracted driving, and timely warnings. Based on this, in any of the above embodiments, the step of outputting first information based on the optical flow vectors of the plurality of first facial key points includes:

[0133] Second information is determined based on the optical flow vectors of the plurality of first facial key points, and the second information represents information related to the driver's expression;

[0134] The first information is output based on the second information.

[0135] Here, based on the optical flow vectors of multiple first facial key points obtained, information related to the driver's expression in the first image and / or the second image is determined to obtain second information; the driver's driving state is determined based on the second information, and first information is generated based on the driver's driving state. The driver's expression-related information includes, but is not limited to, one or more of the following: eye opening angle, mouth opening degree, and eye movement.

[0136] In this embodiment, the driver's facial expression-related information is determined by the optical flow vector of the first facial key point, and the driver's driving state is determined based on the driver's facial expression-related information. This can identify the driver's driving state as early and accurately as possible, reducing the probability of false alarms about fatigue driving.

[0137] The following section provides a more detailed description of this application with reference to application examples.

[0138] Application Example 1

[0139] Figure 3 A flowchart illustrating the process of sparse optical flow calculation and optical flow compensation for images is provided, such as... Figure 3 As shown, the method includes:

[0140] Step 1: Input the first image sequence into the face landmark detection model.

[0141] Here, the first image sequence is input into the facial landmark detection model to obtain the second image sequence output by the model. The second image sequence is obtained by marking facial landmarks in the images included in the first image sequence. The second image sequence is used for subsequent sparse optical flow calculation and optical flow compensation operations. The first and second image sequences may include multiple consecutive image frames. The facial landmark detection model includes, but is not limited to, […]. Figure 2 The facial landmark detection model shown above is used to train a facial landmark detection model. Please refer to the relevant description above for the training method. It will not be repeated here.

[0142] Step 2: Perform sparse optical flow calculation on two frames of images containing the same driver's face to obtain the optical flow vectors of multiple first facial key points in the two frames.

[0143] Here, in the second image sequence, two frames containing facial images of the same driver are selected for sparse optical flow calculation; these can be two consecutive frames. Facial key points can be referred to as facial feature points.

[0144] The following explanation uses the calculation of optical flow for the first frame (Frame1) and the second frame (Frame2) in the second image sequence as an example.

[0145] For example, if both the first frame (Frame1) and the second frame (Frame2) in the second image sequence contain the same facial keypoints of the driver, then Frame1 and Frame2 are selected for sparse optical flow calculation. The implementation process is as follows:

[0146] (1) Select facial landmarks: Select some prominent first facial landmarks in Frame1, such as the first facial landmarks of the eyes and / or mouth. These first facial landmarks will be used to track optical flow.

[0147] (2) Determine the neighborhood window: Determine a neighborhood window for each first facial key point. It is usually assumed that the optical flow remains constant within this window. Among them, a neighborhood window can be determined with the first facial key point as the center. The size of the neighborhood window can be set according to the actual situation and is not limited here.

[0148] (3) Establish optical flow constraint equations: Based on the assumption of constant brightness, establish optical flow constraint equations.

[0149] Here, it is assumed that the brightness of the same first facial key point between adjacent frames Frame1 and Frame2 remains unchanged. That is, for the brightness E(x,y,t) of the first facial key point (x,y) at time t, after moving to (x+Δx,y+Δy) at time t+Δt, it satisfies: E(x,y,t)=E(x+Δx,y+Δy,t+Δt). This assumption is the basis of optical flow calculation.

[0150] Performing a first-order Taylor expansion on the brightness change, and ignoring higher-order terms, we obtain:

[0151]

[0152] Assuming constant brightness, subtracting both sides of the equation and dividing by Δt, then setting Δt→0, we get: in,

[0153] Let the image gradient be... Then the optical flow constraint equation It can be simplified to: I x u+I y v+I t = 0. This equation describes the relationship between pixel grayscale (brightness) gradient and optical flow velocity.

[0154] (4) Solving for the optical flow vector

[0155] Since a single equation cannot solve for two unknowns u and v, the Lucas-Kanade algorithm, through the assumption of local window smoothing, constructs multiple constraint equations within a neighborhood (e.g., 5×5 pixels), forming a system of linear equations:

[0156]

[0157] By solving the linear equations using the least squares method, the optical flow vector (u,v) of the first facial key point can be obtained. The optical flow vector (u,v) of the first facial key point is the displacement of the first facial key point between the two frames Frame1 and Frame2, where u is the horizontal motion component and v is the vertical motion component.

[0158] (5) Output optical flow vector results: Output the optical flow vector (u,v) of each first face key point in Frame1 and Frame2 to complete the calculation of sparse optical flow.

[0159] Step 3: Based on the optical flow vectors of multiple first face key points in the two frames, perform optical flow compensation on one of the frames.

[0160] Here, continuing with adjacent frames Frame1 and Frame2 as an example, after obtaining the optical flow vector (u,v) of each first facial keypoint in output Frame1 and Frame2, optical flow compensation is performed on Frame2 using the obtained optical flow vector (u,v) of each first facial keypoint. The specific implementation process is as follows:

[0161] (1) Coordinate transformation: Assume that the coordinates of any first face key point in Frame1 are (x,y) and the optical flow vector corresponding to the first face key point is (u,v). Then the coordinates of the first face key point in Frame2 are (x',y'), where x'=x+u,y'=y+v.

[0162] (2) Interpolation Processing: After transforming the coordinates of the first facial keypoint in Frame1, the coordinates of the first facial keypoint in Frame2 may not be integers, meaning the position of the first facial keypoint in Frame2 may not be the center of the pixel. Since it is impossible to confirm whether the position of the first facial keypoint after coordinate transformation is at the center of the pixel in practical applications, an interpolation algorithm is needed to calculate the pixel value of the first facial keypoint in Frame2. The interpolation algorithm includes, but is not limited to, bilinear interpolation. Specifically, the pixel value of the first facial keypoint in Frame2 can be calculated based on the pixel values ​​of at least four adjacent pixels around the position of the first facial keypoint in Frame1, so that the processed Frame2 is smoother and the probability of jagged edges or holes in the pixels of the processed Frame2 is reduced. Please refer to the relevant description above for the implementation process, which will not be repeated here.

[0163] (3) Image fusion: The pixel values ​​of each first face key point in Frame2 are adjusted to the corresponding pixel values ​​obtained after interpolation to complete the optical flow compensation of Frame2.

[0164] (4) Store the optical flow compensated image: Store the optical flow compensated Frame2 for subsequent image processing with the next frame image (e.g., sparse optical flow calculation and optical flow compensation).

[0165] Application Example 2

[0166] like Figure 4 As shown, the image processing methods include:

[0167] Step 401: Obtain the current frame image F2.

[0168] Here, after obtaining the previous frame image F1 and determining the first facial key point in the previous frame image F1, the current frame image F2 is obtained, for example, by receiving or capturing the current frame image F2. The previous frame image F1 and the current frame image F2 can be two adjacent frames, that is, the previous frame image F1 and the current frame image F2 are two consecutive frames captured by the same driver. The previous frame image F1 and the current frame image F2 correspond to the first image and the second image mentioned above.

[0169] Step 402: Perform face detection on the current frame image F2 to obtain the face detection results.

[0170] Here, a face detection model or algorithm can be used to perform face detection on the current frame image F2 to obtain the face detection result.

[0171] Step 403: Based on the face detection results, determine whether the current frame image F2 contains a face.

[0172] Here, if the face detection result indicates that no face is detected in the current frame image F2, steps 404 to 405 are executed; if the face detection result indicates that a face is detected in the current frame image F2, step 407 is executed.

[0173] Step 404: Return None (no face detected) and accumulate the number of times no face was detected.

[0174] Step 405: Determine whether the number of times a face was not detected exceeds the cumulative threshold.

[0175] Here, if the number of times no face is detected exceeds the cumulative threshold, step 406 is executed; if the number of times no face is detected does not exceed the cumulative threshold, step 401 is executed. The cumulative threshold corresponds to the second threshold mentioned above.

[0176] Step 406: Output the third information.

[0177] The third piece of information can be understood as an abnormal alarm message, which is used to prompt relevant personnel (such as the driver) that no face image has been detected in multiple consecutive images, so that the shooting angle and / or the brightness inside the vehicle can be adjusted in time, so that the electronic equipment can capture the driver's face image.

[0178] Step 407: Perform facial landmark detection on the current frame image F2 to obtain the first facial landmark included in the current frame image F2.

[0179] Here, facial landmark detection can be performed on the current frame image F2 using a facial landmark detection model, or facial landmark detection algorithm or facial landmark detector. For the specific implementation process, please refer to the relevant description above, which will not be repeated here.

[0180] Step 408: Determine whether the first facial landmarks included in the current frame image F2 have been corrected.

[0181] Here, the first facial key points included in the current frame image F2 are corrected, including optical flow compensation for the first facial key points included in the current frame image F2.

[0182] If all the first facial landmarks included in the current frame image F2 have been corrected, then proceed to steps 409 to 410; if the first facial landmarks included in the current frame image F2 have not been corrected, then proceed to step 411.

[0183] Step 409: Calculate the eye opening angle based on the second facial key points.

[0184] Here, the corrected current frame image F2 can be input as a facial landmark to detect the second facial landmark in the current frame image F2; based on the second facial landmark in the current frame image F2, the eye opening angle is calculated. The implementation process of step 409 is described above and will not be repeated here.

[0185] The second facial landmark in the current frame image F2 includes the first facial landmark remaining after removing the third facial landmark from the first facial landmark in the current frame image F2.

[0186] Step 410: Output first information based on the eye opening angle. The first information indicates that the driver's driving state is fatigued driving.

[0187] Among them, when the eye opening angle is less than the third threshold, the first information indicates that the driver's driving state is fatigued driving.

[0188] Step 411: Call the first facial key points of the previous frame image F1, perform Lucas-Kanade sparse optical flow calculation on the previous frame image F1 and the current frame image F2, and obtain the optical flow vector of each first facial key point.

[0189] The implementation process of step 411 is described in the above text and will not be repeated here.

[0190] Step 412: Perform optical flow compensation on the current frame image F2 to obtain the third image.

[0191] The implementation process of step 412 is described above in the section on optical flow compensation for the second image, and will not be repeated here. The third image can be understood as the new current frame image F2.

[0192] Specifically, based on the optical flow vectors of each first facial key point, a third facial key point can be identified in the current frame image F2. The third facial key point is the first facial key point whose optical flow vector displacement is greater than a first threshold, meaning that the displacement of the optical flow vector of the third facial key point is caused by global brightness changes due to illumination. Brightness compensation is performed on the first pixel in the current frame image F2 to obtain the brightness-compensated current frame image F2. The first pixel includes at least the pixel corresponding to the third facial key point. Based on the optical flow vectors of each first facial key point, optical flow compensation is performed on the brightness-compensated current frame image F2 to obtain the third image.

[0193] In various embodiments of this application, by monitoring the driver's driving status in real time, signs of fatigue can be identified as early as possible, reducing the possibility of accidents caused by fatigued driving. Real-world driving scenarios often involve bumpy roads, direct sunlight, and streetlights. In such environments, the detection of facial landmarks becomes more difficult. Bumps and lighting conditions can easily cause blurring or loss of facial features, leading to errors or failures in facial landmark recognition. This results in incorrect fatigue assessments from the model, such as correctly identifying a normal situation as fatigued driving, causing frequent false alarms and impacting user experience. Alternatively, errors in facial landmark detection may prevent the detection of fatigue, leading to accidents. To address these scenarios, this application introduces an image processing scheme based on optical flow calculation and compensation. This scheme corrects the brightness and smoothness of each frame of the image, improving the accuracy of facial landmark detection and providing reliable support for outputting accurate fatigue monitoring conclusions. Because the solution proposed in this application can train a facial landmark detection model using facial images under different lighting conditions, it reduces the impact of lighting changes on facial landmark detection. This makes the driver fatigue monitoring function unrestricted by scene and environment, and can significantly reduce the incidence of accidents caused by fatigue driving. In addition, the solution proposed in this application can still maintain high robustness in scenarios with sudden changes in lighting, such as alternating light and dark tunnels and switching between high and low beams of oncoming vehicles. This is of great significance for the practical application of fatigue monitoring and safe driving.

[0194] To implement the method of the embodiments of this application, the embodiments of this application also provide an image processing apparatus, disposed on an electronic device, such as... Figure 5 As shown, the device includes:

[0195] The acquisition module 501 is used to acquire a first image and a second image, both of which include the same driver's face image;

[0196] The calculation module 502 is used to perform sparse optical flow calculation on a plurality of first facial key points in the first image and the second image to obtain the optical flow vector of the plurality of first facial key points;

[0197] The state detection module 503 is used to output first information based on the optical flow vectors of the plurality of first facial key points, the first information indicating the driving state of the driver.

[0198] In one embodiment, the state detection module 503 is further configured to perform optical flow compensation on the second image based on the optical flow vectors of the plurality of first facial key points to obtain a third image, wherein the second image is captured after the first image; and to output first information based on the plurality of second facial key points of the third image.

[0199] In any of the above embodiments, the state detection module 503 is further configured to:

[0200] Based on the optical flow vectors of the plurality of first facial key points, a third facial key point is determined in the second image. The third facial key point is a first facial key point whose optical flow vector displacement is greater than a first threshold.

[0201] Brightness compensation is performed on the first pixel in the second image to obtain a brightness-compensated second image, wherein the first pixel includes at least the pixel corresponding to the third facial key point.

[0202] Based on the optical flow vectors of the multiple first facial key points, optical flow compensation is performed on the brightness-compensated second image to obtain the third image.

[0203] In any of the above embodiments, the state detection module 503 is further configured to:

[0204] Based on the optical flow vectors of the plurality of first facial key points, a first face region is determined in the second image, wherein the first face region includes at least the plurality of first facial key points;

[0205] Based on the pixel values ​​of the pixels in the second face region of the first image, brightness compensation is performed on the first face region to obtain a third image, wherein the second face region includes at least the plurality of first face key points.

[0206] In any of the above embodiments, the state detection module 503 is further configured to:

[0207] Based on the optical flow vectors of the plurality of first facial key points, the first position corresponding to each of the plurality of first facial key points in the second image is determined;

[0208] Based on the pixel values ​​of the pixels surrounding each first facial key point in the first image, brightness compensation is performed on the corresponding pixels at the first position to obtain the third image.

[0209] In any of the above embodiments, the state detection module 503 is further configured to:

[0210] Based on the pixel values ​​of the second pixels surrounding the first pixel, perform brightness compensation on the first pixel; and / or

[0211] Based on the pixel value of the third pixel in the first image, brightness compensation is performed on the first pixel, wherein the third pixel includes at least the pixel corresponding to the third facial key point in the first image.

[0212] In any of the above embodiments, the state detection module 503 is further configured to:

[0213] Second information is determined based on the optical flow vectors of the plurality of first facial key points, and the second information represents information related to the driver's expression;

[0214] The first information is output based on the second information.

[0215] In practical applications, the calculation module 502 can be implemented by the processor in the image processing device, and the acquisition module 501 and the state detection module 503 can be implemented by the processor in the image processing device in combination with the communication interface.

[0216] It should be noted that the image processing apparatus provided in the above embodiments is only illustrated by the division of the above program modules. In practical applications, the above processing can be assigned to different program modules as needed, that is, the internal structure of the apparatus can be divided into different program modules to complete all or part of the processing described above. In addition, the image processing apparatus and the image processing method embodiments provided in the above embodiments belong to the same concept, and their specific implementation process can be found in the method embodiments, which will not be repeated here.

[0217] Based on the hardware implementation of the above program modules, and in order to implement the image processing method of the embodiments of this application, the embodiments of this application also provide an electronic device, such as... Figure 6 As shown, the electronic device 600 includes:

[0218] The communication interface 601 enables information exchange with other network nodes;

[0219] The processor 602 is connected to the communication interface 601 to enable information interaction with other network nodes and to execute the methods provided by one or more of the above-described technical solutions when running computer-executable instructions. The computer-executable instructions are stored in the memory 603.

[0220] Specifically, the communication interface 601 is used to acquire a first image and a second image, both of which include the same driver's face image;

[0221] The processor 602 is configured to perform sparse optical flow calculation on a plurality of first facial key points in the first image and the second image to obtain optical flow vectors of the plurality of first facial key points; and to output first information based on the optical flow vectors of the plurality of first facial key points, wherein the first information indicates the driving state of the driver.

[0222] In one embodiment, the processor 602 is further configured to perform optical flow compensation on the second image based on the optical flow vectors of the plurality of first facial key points to obtain a third image, wherein the second image is captured after the first image; and to output first information based on the plurality of second facial key points of the third image.

[0223] In any of the above embodiments, the processor 602 is further configured to:

[0224] Based on the optical flow vectors of the plurality of first facial key points, a third facial key point is determined in the second image. The third facial key point is a first facial key point whose optical flow vector displacement is greater than a first threshold.

[0225] Brightness compensation is performed on the first pixel in the second image to obtain a brightness-compensated second image, wherein the first pixel includes at least the pixel corresponding to the third facial key point.

[0226] Based on the optical flow vectors of the multiple first facial key points, optical flow compensation is performed on the brightness-compensated second image to obtain the third image.

[0227] In any of the above embodiments, the processor 602 is further configured to:

[0228] Based on the optical flow vectors of the plurality of first facial key points, a first face region is determined in the second image, wherein the first face region includes at least the plurality of first facial key points;

[0229] Based on the pixel values ​​of the pixels in the second face region of the first image, brightness compensation is performed on the first face region to obtain a third image, wherein the second face region includes at least the plurality of first face key points.

[0230] In any of the above embodiments, the processor 602 is further configured to:

[0231] Based on the optical flow vectors of the plurality of first facial key points, the first position corresponding to each of the plurality of first facial key points in the second image is determined;

[0232] Based on the pixel values ​​of the pixels surrounding each first facial key point in the first image, brightness compensation is performed on the corresponding pixels at the first position to obtain the third image.

[0233] In any of the above embodiments, the processor 602 is further configured to:

[0234] Based on the pixel values ​​of the second pixels surrounding the first pixel, perform brightness compensation on the first pixel; and / or

[0235] Based on the pixel value of the third pixel in the first image, brightness compensation is performed on the first pixel, wherein the third pixel includes at least the pixel corresponding to the third facial key point in the first image.

[0236] In any of the above embodiments, the processor 602 is further configured to:

[0237] Second information is determined based on the optical flow vectors of the plurality of first facial key points, and the second information represents information related to the driver's expression;

[0238] The first information is output based on the second information.

[0239] It should be noted that the specific processing procedures of processor 602 and communication interface 601 can be understood by referring to the above method.

[0240] Of course, in practical applications, the various components in electronic device 600 are coupled together through bus system 604. It can be understood that bus system 604 is used to realize the connection and communication between these components. In addition to a data bus, bus system 604 also includes a power bus, a control bus, and a status signal bus. However, for the sake of clarity, in... Figure 6 The general designated all buses as Bus System 604.

[0241] The memory 603 in this embodiment is used to store various types of data to support the operation of the electronic device 600. Examples of such data include any computer-executable instructions for operation on the electronic device 600.

[0242] The methods disclosed in the embodiments of this application can be applied to, or implemented by, the processor 602. The processor 602 may be an integrated circuit chip with signal processing capabilities. During implementation, each step of the above method can be completed by the integrated logic circuitry of the hardware in the processor 602 or by instructions in software form. The processor 602 may be a general-purpose processor, a digital signal processor (DSP), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The processor 602 can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor may be a microprocessor or any conventional processor, etc. The steps of the methods disclosed in the embodiments of this application can be directly manifested as execution by a hardware decoding processor, or execution by a combination of hardware and software modules in the decoding processor. The software modules may be located in a storage medium, specifically memory 603. The processor 602 reads information from memory 603 and, in conjunction with its hardware, completes the steps of the aforementioned method.

[0243] In an exemplary embodiment, the electronic device 600 may be implemented by one or more application-specific integrated circuits (ASICs), DSPs, programmable logic devices (PLDs), complex programmable logic devices (CPLDs), field-programmable gate arrays (FPGAs), general-purpose processors, controllers, microcontrollers (MCUs), microprocessors, or other electronic components to perform the aforementioned method.

[0244] It is understood that the memory (memory 603) in this embodiment of the application can be volatile memory or non-volatile memory, or both. The non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), ferromagnetic random access memory (FRAM), flash memory, magnetic surface memory, optical disc, or compact disc read-only memory (CD-ROM); the magnetic surface memory can be disk storage or magnetic tape storage. The volatile memory can be random access memory (RAM), which is used as an external cache. By way of example, but not limitation, many forms of RAM are available, such as Static Random Access Memory (SRAM), Synchronous Static Random Access Memory (SSRAM), Dynamic Random Access Memory (DRAM), Synchronous Dynamic Random Access Memory (SDRAM), Double Data Rate Synchronous Dynamic Random Access Memory (DDRSDRAM), Enhanced Synchronous Dynamic Random Access Memory (ESDRAM), SyncLink Dynamic Random Access Memory (SLDRAM), and Direct Rambus Random Access Memory (DRRAM).The memories described in the embodiments of this application are intended to include, but are not limited to, these and any other suitable types of memories.

[0245] In an exemplary embodiment, this application also provides a computer-readable storage medium, such as a memory 603 storing computer-executable instructions, which can be executed by a processor 602 of an electronic device 600 to complete the steps described in the aforementioned method. The computer-readable storage medium may be a memory such as FRAM, ROM, PROM, EPROM, EEPROM, Flash Memory, magnetic surface memory, optical disk, or CD-ROM. The computer-executable instructions can be described as a computer program.

[0246] For example, this application also provides a computer program product, including computer-executable instructions, which can be executed by a processor 602 of an electronic device 600 to perform the steps described in the foregoing method.

[0247] For example, this application also provides a vehicle that includes the above-described electronic equipment.

[0248] It is understood that in this application embodiment, relevant images of the driver are involved. When this application embodiment is applied to specific products or technologies, user permission or consent is required, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of the relevant countries and regions.

[0249] It should be noted that terms such as "first" and "second" are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. "Multiple" can refer to two or more items, and "multiple" can refer to two or more items. The term "and / or" in this document merely describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. Furthermore, the term "one or more" in this document refers to any combination of at least two of the multiple elements. For example, including one or more of A, B, and C can represent including any one or at least two or more elements selected from the set consisting of A, B, and C.

[0250] Furthermore, the technical solutions described in the embodiments of this application can be combined arbitrarily without conflict.

[0251] The above description is merely a preferred embodiment of this application and is not intended to limit the scope of protection of this application.

Claims

1. An image processing method, characterized by, The method includes: Acquire a first image and a second image, both of which include the same driver's face image; Sparse optical flow calculation is performed on multiple first facial key points in the first image and the second image to obtain the optical flow vectors of the multiple first facial key points; Based on the optical flow vectors of the plurality of first facial key points, first information is output, which indicates the driver's driving state.

2. The method of claim 1, wherein, The first information output based on the optical flow vectors of the plurality of first facial key points includes: Optical flow compensation is performed on the second image based on the optical flow vectors of the plurality of first facial key points to obtain a third image, wherein the second image is captured after the first image; Based on multiple second facial key points in the third image, first information is output.

3. The method of claim 2, wherein, The process of performing optical flow compensation on the second image based on the optical flow vectors of the plurality of first facial key points to obtain a third image includes: Based on the optical flow vectors of the plurality of first facial key points, a third facial key point is determined in the second image. The third facial key point is a first facial key point whose optical flow vector displacement is greater than a first threshold. Brightness compensation is performed on the first pixel in the second image to obtain a brightness-compensated second image, wherein the first pixel includes at least the pixel corresponding to the third facial key point. Based on the optical flow vectors of the multiple first facial key points, optical flow compensation is performed on the brightness-compensated second image to obtain the third image.

4. The method according to claim 2 or 3, characterized in that, Optical flow compensation is performed on the second image based on the optical flow vectors of the plurality of first facial key points to obtain a third image, including: Based on the optical flow vectors of the plurality of first facial key points, a first face region is determined in the second image, wherein the first face region includes at least the plurality of first facial key points; Based on the pixel values ​​of the pixels in the second face region of the first image, brightness compensation is performed on the first face region to obtain a third image, wherein the second face region includes at least the plurality of first face key points.

5. The method according to any one of claims 2 to 4, characterized in that, Optical flow compensation is performed on the second image based on the optical flow vectors of the plurality of first facial key points to obtain a third image, including: Based on the optical flow vectors of the plurality of first facial key points, the first position corresponding to each of the plurality of first facial key points in the second image is determined; Based on the pixel values ​​of the pixels surrounding each first facial key point in the first image, brightness compensation is performed on the corresponding pixels at the first position to obtain the third image.

6. The method of claim 3, wherein, The step of performing brightness compensation on the first pixel in the second image includes: Based on the pixel values ​​of the second pixels surrounding the first pixel, perform brightness compensation on the first pixel; and / or Based on the pixel value of the third pixel in the first image, brightness compensation is performed on the first pixel, wherein the third pixel includes at least the pixel corresponding to the third facial key point in the first image.

7. The method according to any one of claims 1 to 6, characterized in that, The first information output based on the optical flow vectors of the plurality of first facial key points includes: Second information is determined based on the optical flow vectors of the plurality of first facial key points, and the second information represents information related to the driver's expression; The first information is output based on the second information.

8. An image processing apparatus characterized by comprising: The image processing device includes: The acquisition module is used to acquire a first image and a second image, both of which include the same driver's face image; The calculation module is used to perform sparse optical flow calculation on multiple first facial key points in the first image and the second image to obtain the optical flow vector of the multiple first facial key points; The state detection module is used to output first information based on the optical flow vectors of the plurality of first facial key points, the first information indicating the driver's driving state.

9. An electronic device, characterized in that, The electronic device includes: Memory is used to store executable instructions for a computer; A processor, when executing computer-executable instructions stored in the memory, implements the method according to any one of claims 1 to 7.

10. A vehicle, characterized in that, The vehicle includes the electronic equipment as described in claim 9.

11. A computer-readable storage medium storing computer-executable instructions, characterized in that, When the computer-executable instructions are executed by a processor, they implement the method described in any one of claims 1 to 7.

12. A computer program product comprising computer-executable instructions, characterized in that, When the computer-executable instructions are executed by a processor, they implement the method described in any one of claims 1 to 7.