Image ranging method, device, equipment and storage medium
By obtaining the imaging deviation of the double-pupil midpoint and the head offset angle in the face image for ranging compensation, the problem of large calculation amount and low accuracy in the existing technology is solved, and efficient and accurate image ranging is achieved.
Patent Information
- Application Number
- CN201910785829.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-08-23
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2039-08-23
AI Technical Summary
Existing image ranging technology suffers from the problems of large amount of calculation, high hardware requirements and limited accuracy. In particular, monocular ranging requires a lot of time and has process errors, while binocular ranging requires large amount of calculation and high hardware requirements, and Image registration of camera pairs affects measurement accuracy.
By obtaining the face image of the target user, determine the imaging deviation of the midpoint of the double pupils and the offset angle of the head relative to the imaging plane of the camera, perform ranging compensation, calculate the actual distance from the midpoint of the double pupils to the camera, and reduce the amount of calculations and improve ranging accuracy.
There is no need to select feature samples and difference analysis in face images, which greatly reduces the amount of calculation, improves the ranging rate and accuracy, and reduces hardware requirements.
Smart Images

Figure CN112419399B
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the field of image processing, and in particular to an image ranging method, apparatus, device and storage medium. Background Art
[0002] Currently, when a user needs to observe an object for a long time during work or entertainment, he or she may unconsciously get close to the target object, which will affect the user's eyesight in the long run. Therefore, it is necessary to judge the distance between the user and the target object to remind the user when the distance is too close.
[0003] In the prior art, monocular ranging or binocular ranging is usually used to detect the distance between the midpoint of the user's pupils and the camera installed on the target object; monocular ranging is to first collect the user's face image through a mobile terminal, and then use the face detection algorithm to locate the features of the face image (such as the distance between the corners of the mouth, the size of the nose, the size of the face, etc.), and then use the principle of similar triangles to calculate the distance from the midpoint of the user's pupils to the camera based on the selected features; binocular ranging is to obtain a pair of user's face images from two cameras; the imaging results of the same user in the face image pair are different, which is called "parallax". At this time, the principle of similar triangles is also used in combination with the known camera spacing, the focal length of the camera and the parallax to obtain the distance between the midpoint of the pupils and the target object.
[0004] For monocular ranging, each distance measurement requires a lot of time to select and estimate feature samples in the face image, and will produce large process errors; while for binocular ranging, the amount of calculation is large, the hardware requirements are high, and the image registration results of the camera pair directly affect the accuracy of the final distance measurement. Summary of the invention
[0005] The embodiments of the present invention provide an image distance measurement method, device, equipment and storage medium, which reduce the amount of calculation for distance measurement and improve the accuracy of distance measurement results.
[0006] In a first aspect, an embodiment of the present invention provides an image ranging method, the method comprising:
[0007] Obtain the target user's facial image;
[0008] Determine the imaging deviation of the midpoint of the pupils in the face image;
[0009] Determining a head offset angle of the target user relative to an imaging plane of a camera;
[0010] The distance measurement of the target user is compensated according to the imaging deviation and the head deviation angle to obtain the actual distance from the midpoint of the target user's pupils to the camera.
[0011] In a second aspect, an embodiment of the present invention provides an image ranging device, the device comprising:
[0012] An image acquisition module is used to acquire a face image of a target user;
[0013] An imaging deviation acquisition module, used to determine the imaging deviation of the midpoint of the pupils in the face image;
[0014] A deviation angle determination module, used to determine the head deviation angle of the target user relative to the imaging plane of the camera;
[0015] The distance measurement module is used to compensate the distance measurement of the target user according to the imaging deviation and the head deviation angle, so as to obtain the actual distance from the midpoint of the pupils of the target user to the camera.
[0016] In a third aspect, an embodiment of the present invention provides a device, the device comprising:
[0017] one or more processors;
[0018] A storage device for storing one or more programs;
[0019] When the one or more programs are executed by the one or more processors, the one or more processors implement the image ranging method described in any embodiment of the present invention.
[0020] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the image ranging method described in any embodiment of the present invention.
[0021] An image ranging method, apparatus, device and storage medium provided by an embodiment of the present invention compensates for the distance measurement process from the midpoint of the double pupils of a target user to a camera according to the imaging deviation of the midpoint of the double pupils in a face image of the target user and the head offset angle of the target user relative to the imaging plane of the camera, and obtains the actual distance from the midpoint of the double pupils of the target user to the camera. This solution uses the imaging deviation of the midpoint of the double pupils in the face image and the head offset angle to correct the distance from the midpoint of the double pupils to the camera, thereby improving the accuracy of ranging. At the same time, there is no need to select feature samples in the face image and accurately analyze the differences between the face image pairs, thereby greatly reducing the amount of calculation in the image ranging process and improving the rate of image ranging. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] Other features, objects and advantages of the present invention will become more apparent from the detailed description of non-limiting embodiments made with reference to the following drawings:
[0023] Figure 1A A flowchart of an image ranging method provided in Embodiment 1 of the present invention;
[0024] Figure 1B A schematic diagram of a scene in which a target user faces the camera in the method provided in the first embodiment of the present invention;
[0025] Figure 1C A schematic diagram of a scene in which a target user looks sideways at a camera in the method provided in Embodiment 1 of the present invention;
[0026] Figure 2A A flowchart of an image ranging method provided in Embodiment 2 of the present invention;
[0027] Figure 2B A schematic diagram of the principle of the image ranging process provided in the second embodiment of the present invention;
[0028] Figure 3A A flowchart of an image ranging method provided in Embodiment 3 of the present invention;
[0029] Figure 3B A schematic diagram of the principle of the image ranging process provided in the third embodiment of the present invention;
[0030] Figure 4 A schematic diagram of the structure of an image distance measurement device provided in Embodiment 4 of the present invention;
[0031] Figure 5 A schematic diagram of the structure of a device provided in Embodiment 5 of the present invention. DETAILED DESCRIPTION
[0032] The present invention will be further described in detail below in conjunction with the accompanying drawings and embodiments. It is to be understood that the specific embodiments described herein are only used to explain the present invention, rather than to limit the present invention. It should also be noted that, for ease of description, only parts related to the present invention, rather than all structures, are shown in the accompanying drawings.
[0033] Embodiment 1
[0034] Figure 1A This is a flow chart of an image distance measurement method provided in Embodiment 1 of the present invention. This embodiment can be applied to the case of measuring the distance from the midpoint of the pupils of a target user to a camera in a face image of any posture. The image distance measurement method provided in this embodiment can be performed by an image distance measurement device provided in an embodiment of the present invention. The device can be implemented in software and / or hardware and integrated in a device that performs the method. The device can be any intelligent terminal that carries corresponding image processing capabilities.
[0035] Specifically, refer to Figure 1A , the method may include the following steps:
[0036] S110, acquiring a face image of a target user, and determining an imaging deviation of a midpoint of both pupils in the face image.
[0037] Specifically, when measuring the distance from the midpoint of the user's pupils to the camera by shooting a facial image of a certain user, there are two situations: the user is looking straight at the camera or looking sideways at the camera. In this case, the user is the target user in this embodiment. In the ideal case where the target user is looking straight at the camera, the target user is looking straight at the camera at a certain displacement from the camera. In this case, the camera is located directly in front of the target user, so that the straight line where the pupils of the target user in the three-dimensional space are located is parallel to the imaging plane of the camera, and the camera is located on the perpendicular bisector of the line connecting the pupils of the target user, so that the midpoint of the pupils in the facial image of the target user captured by the camera is located at the focus of the imaging plane, as shown in FIG. Figure 1B As shown in ; at this time, the principle of similar triangles is used to calculate the distance between the midpoint of the pupils of the target user when looking straight at the camera through the focal length of the camera, the imaging distance of the pupils in the face image, and the actual distance of the pupils of the target user in three-dimensional space; when the target user looks at the camera sideways, as shown in Figure 1C As shown, the straight line where the pupils of the target user in the three-dimensional space are located will have a certain angle error with the straight line where the pupils are located in the ideal situation where the target user is looking directly at the camera, resulting in the straight line where the pupils of the target user are located being unable to form a parallel relationship with the imaging plane of the camera. At this time, there is a large deviation between the distance between the midpoint of the pupils of the target user and the camera calculated using the method under the ideal situation. This embodiment mainly analyzes the situation where the target user is looking sideways at the camera.
[0038] The imaging deviation in this embodiment is the distance from the midpoint of the pupils in the face image to the imaging focus; for example, Figure 1C As shown, when the target user looks at the camera sideways, the target user's head is offset relative to the camera, so that the midpoint of the target user's pupils in the three-dimensional space will deviate from the focus of the camera's imaging plane when imaging, and be projected to other positions on the imaging plane. At this time, the imaging deviation is the distance between the position of the midpoint of the target user's pupils in the facial image captured by the camera in the imaging plane and the imaging focus set in the imaging plane of the camera.
[0039] Optionally, the target user looks sideways at the camera in front of the camera, and the camera first captures a facial image of the target user, and identifies the midpoint of the target user's pupils in the facial image based on various feature points in the face, thereby determining the position of the midpoint of the target user's pupils in the facial image in the imaging plane of the camera, and calculating the imaging deviation of the midpoint of the target user's pupils in the facial image captured this time based on the position of the midpoint of the pupils in the imaging plane and the imaging focus in the imaging plane, so as to subsequently compensate for the distance measurement process of the target user based on the imaging deviation of the midpoint of the pupils, thereby improving the accuracy of the distance from the midpoint of the target user's pupils to the camera in three-dimensional space.
[0040] S120: Determine a head offset angle of the target user relative to an imaging plane of the camera.
[0041] The head deviation angle is the gaze deviation angle of the target user relative to the camera. Specifically, with the imaging plane of the camera as a reference, when the target user looks at the camera from the side, it can be determined that the target user is currently not in front of the camera. At this time, compared with the target user looking directly at the camera, it can be considered that the user's head rotates a certain angle and continues to look at the camera, forming a certain angle with the imaging plane of the camera, such as Figure 1C As shown, the head offset angle is the angle at which the target user's head rotates relative to the ideal situation of looking straight at the camera.
[0042] Optionally, after the camera captures the facial image of the target user when the target user is currently looking sideways at the camera, the camera identifies feature information of the target user in the facial image, and determines the side-view facial posture of the target user in the facial image based on the position offset of each feature point in the facial image and each feature point in the facial image obtained when the target user is looking straight at the camera, thereby determining the head offset angle of the target user relative to the imaging plane of the camera, so as to subsequently compensate for the distance measurement process of the target user based on the head offset angle, thereby improving the accuracy of the distance from the midpoint of the target user's pupils to the camera in three-dimensional space.
[0043] S130, compensating the distance measurement of the target user according to the imaging deviation and the head deviation angle, and obtaining the actual distance from the midpoint of the pupils of the target user to the camera.
[0044] Optionally, when obtaining the imaging deviation of the midpoint of the double pupils and the head deviation angle in the facial image of the target user, when projecting the target user in the three-dimensional space into the two-dimensional imaging plane of the camera, based on the imaging deviation of the midpoint of the double pupils of the target user in the imaging plane and the head deviation angle of the target user in the three-dimensional space, similar triangles related to the midpoint of the double pupils can be accurately found in the projection process of the target user, thereby compensating for the similar triangles selected in the ranging method under ideal conditions when the target user looks sideways at the camera, and then accurately obtaining the actual distance from the midpoint of the double pupils of the target user to the camera.
[0045] For example, in this embodiment, when the camera captures the face image of the target user, Figure 1CAs shown, the similar triangles existing in the corresponding projection process are the triangle formed by the straight line where the pupils of the target user in the three-dimensional space are located after being rotated to form a parallel relationship with the imaging plane of the camera according to the head offset angle, and the camera acquisition head, and the triangle formed by the straight line where the pupils of the target user in the face image in the imaging plane of the camera and the camera acquisition head. At this time, in this embodiment, the distance measurement of the target user is compensated according to the imaging deviation and the head offset angle to obtain the actual distance from the midpoint of the pupils of the target user to the camera, which may specifically include: determining the distance from the midpoint of the pupils in the face image to the camera according to the imaging deviation and the focal length of the camera; determining the corresponding pupil offset distance according to the head offset angle and the actual pupil distance of the target user input in advance; determining the actual distance from the midpoint of the pupils of the target user to the camera according to the first pupil imaging distance of the face image, the distance from the midpoint of the pupils in the face image to the camera, and the pupil offset distance.
[0046] Specifically, after obtaining the imaging deviation d1 of the midpoint of the pupils of the target user in the face image, the distance from the midpoint of the pupils of the target user in the face image to the camera when the target user looks sideways at the camera can be calculated by applying the Pythagorean theorem based on the imaging deviation d1 and the focal length f of the camera. At this time, it can be determined that triangle AB'C is similar to triangle EDC, and point B' is the point where the pupil offset distance l2 that is parallel to the imaging plane of the camera is extended and intersects with the projection line. The similar triangle includes the distance d2 from the midpoint of the pupil in triangle EDC to the camera during the imaging stage of the camera, which is the side length EC in triangle EDC. At the same time, the distance l1 between the pupils in the face image is calculated, which is twice the side length ED in triangle EDC. Further, after determining the head offset angle of the target user relative to the imaging plane of the camera, since it is necessary to detect the actual distance from the midpoint of the pupil to the camera of the target user, the target user will pre-input the corresponding actual pupil distance IPD before taking the face image through the camera. At this time, according to the head offset angle and the actual pupil distance IPD of the target user in the three-dimensional space, the pupil offset distance l2 that is parallel to the imaging plane of the camera in the three-dimensional space is determined. When the camera collects the face image of the target user, the target user will not be far away from the central axis of the camera, otherwise the information of the target user will not be collected. At this time, when the target user is close to the central axis of the camera, Figure 1C The position error between the midpoint B of the target user's binocular offset distance l2 and the midpoint B' of the triangle AB'C in the three-dimensional space is small. At the same time, since the side length AB' in the triangle AB'C is unknown, and the side length AB is half of the binocular offset distance l2, point B is used instead of point B' in the calculation, that is, it is determined that triangle ABC and triangle EDC are similar; at this time, according to the similarity principle in similar triangles, it can be determined At this time, AC=d, EC=d2, AB=l2 / 2 and ED=l1 / 2, so we can determine So using the formula Calculate the actual distance from the midpoint of the target user's pupils to the camera in three-dimensional space, where d is the actual distance from the midpoint of the target user's pupils to the camera.
[0047] The technical solution provided in this embodiment compensates for the distance measurement process from the midpoint of the target user's pupils to the camera according to the imaging deviation of the midpoint of the pupils in the face image of the target user and the head offset angle of the target user relative to the imaging plane of the camera, and obtains the actual distance from the midpoint of the pupils to the camera. This solution uses the imaging deviation of the midpoint of the pupils in the face image and the head offset angle to correct the distance from the midpoint of the pupils to the camera, thereby improving the accuracy of distance measurement. At the same time, there is no need to select feature samples in the face image and accurately analyze the differences between the face image pairs, which greatly reduces the amount of calculation in the image distance measurement process and improves the rate of image distance measurement.
[0048] Embodiment 2
[0049] Figure 2A A flowchart of an image ranging method provided in Embodiment 2 of the present invention; Figure 2B The schematic diagram of the principle of the image ranging process provided by the second embodiment of the present invention. This embodiment is optimized on the basis of the above embodiment. Specifically, this embodiment mainly explains in detail the process of determining the head deviation angle of the target user in the face image.
[0050] Optional, such as Figure 2A As shown, this embodiment may include the following steps:
[0051] S210, obtaining an imaging deviation of a midpoint of both pupils in a face image of a target user.
[0052] S220, selecting a reference image of the target user from a pre-constructed image reference set according to the pupil imaging size of the face image.
[0053] Specifically, the image reference set is composed of a large number of face images of users in ideal conditions of looking straight at the camera at different positions collected in advance by the camera, and the reference image is an image taken when the target user looks straight at the camera; at this time, the image reference set contains images collected for each user at multiple different positions looking straight at the camera, such as Figure 2B As shown, the image reference set can partition and store the images corresponding to each user according to the user characteristics. If the reference image of the target user is not found in the pre-built image reference set, the target user is prompted to first capture an image facing the camera, so that the target user faces the camera, so as to capture the current image as the reference image of the target user.
[0054] Optionally, after acquiring the facial image of the target user, the facial image can be identified to determine which specific target user is, thereby selecting images corresponding to the target user at multiple different positions from a pre-constructed image reference set; and because the pupil imaging sizes in images at different positions are different when the user looks directly at the camera, images with the same pupil imaging size can be selected from the images corresponding to the target user at multiple different positions based on the pupil imaging size of the target user in the facial image captured when the target user looks sideways at the camera, indicating that the user position corresponding to the image is the same as the position of the target user when looking sideways at the camera, and therefore the image is used as the reference image in this embodiment.
[0055] S230, determining a head deviation angle of the target user according to a first binocular imaging distance in the face image and a second binocular imaging distance in the reference image.
[0056] Optionally, this embodiment refers to the above embodiment provided Figure 1C , at this time, the cosine value of the head offset angle is the ratio of the target user's binocular offset distance l2 in the three-dimensional space to the actual binocular distance IPD. Therefore, the head offset angle can be obtained by performing a corresponding arc cosine operation on the ratio of the binocular offset distance l2 to the actual binocular distance IPD using an inverse trigonometric function. In this embodiment, the binocular offset distance l2 is unknown, but after projecting the target user, since point B replaces point B', the first binocular imaging distance l1 in the face image is equivalent to the imaging result of the target user's binocular offset distance l2 in the three-dimensional space, and the second binocular imaging distance l1 in the reference image is re This is equivalent to the projection result when the actual binocular distance IPD of the target user is parallel to the imaging plane of the camera. At this time, the first binocular imaging distance l1 in the face image and the second binocular imaging distance l1 in the reference image are re The ratio of the binocular offset distance l2 to the actual binocular distance IPD is equal to the ratio of the binocular offset distance l2 to the actual binocular distance IPD. Therefore, this embodiment adopts the first binocular imaging distance l1 in the face image and the second binocular imaging distance l1 in the reference image. reThe ratio of the binocular pupil offset distance l2 to the actual binocular pupil distance IPD is used to replace the ratio of the binocular pupil offset distance l2 to the actual binocular pupil distance IPD to determine the head deviation angle of the target user. Specifically, after selecting the reference image of the target user, it is necessary to obtain the first binocular pupil imaging distance between the binocular pupils in the face image of the target user's side-view camera, and the first binocular pupil imaging distance corresponds to the binocular pupil offset distance corresponding to the target user when looking sideways at the camera; at the same time, obtain the second binocular pupil imaging distance between the binocular pupils of the target user in the reference image captured when the target user is looking straight at the camera at the same position, and the second binocular pupil imaging distance corresponds to the actual binocular pupil distance corresponding to the target user when looking straight at the camera. At this time, the head deviation angle of the target user is calculated according to the first binocular pupil imaging distance and the second binocular pupil imaging distance using the corresponding inverse trigonometric function. Exemplarily, the calculation formula for the head deviation angle of the target user is: Where θ is the head deviation angle of the target user; l1 is the first binocular imaging distance in the face image; l1 re is the second binocular imaging distance in the reference image.
[0057] S240, compensating the distance measurement of the target user according to the imaging deviation and the head deviation angle, and obtaining the actual distance from the midpoint of the pupils of the target user to the camera.
[0058] For example, referring to the above embodiment Figure 1C , triangle AB'C is similar to triangle EDC, then the similar triangle includes the distance d2 from the midpoint of the pupils in triangle EDC to the camera during the imaging stage of the camera, which is the side length EC in triangle EDC, and at the same time calculates the distance l1 between the pupils in the face image, which is twice the side length ED in triangle EDC; further, after determining the head offset angle of the target user relative to the face image, since it is necessary to detect the actual distance from the midpoint of the pupils of the target user to the camera, the target user will input the corresponding actual distance IPD of the pupils in advance. At this time, according to the head offset angle and the actual distance IPD of the pupils of the target user in the three-dimensional space, the pupil offset distance l2 that is parallel to the imaging plane of the camera in the three-dimensional space is determined. When the camera collects the face image of the target user, the target user will not be far away from the central axis of the camera, otherwise the information of the target user will not be collected. At this time, when the target user is close to the central axis of the camera, Figure 1C The position error between point B in the pupil offset distance l2 of the target user in the three-dimensional space and point B' in the triangle AB'C is small. At the same time, since the side length AB' in the triangle AB'C is unknown, and the side length AB is half of the pupil offset distance l2, point B is used instead of point B' in the calculation, that is, it is determined that triangle ABC and triangle EDC are similar; at this time, according to the similarity principle in similar triangles, it can be determined that At this time, AC=d, EC=d2, AB=l2 / 2 and ED=l1 / 2, so we can determine So using the formula Calculate the actual distance from the midpoint of the target user's pupils to the camera in three-dimensional space, where d is the actual distance from the midpoint of the target user's pupils to the camera.
[0059] The technical solution provided by this embodiment selects a reference image taken when the corresponding target user is facing the camera from a pre-constructed image reference set according to the binocular imaging size in the face image of the target user, and then determines the head offset angle of the target user according to the first binocular imaging distance in the face image and the second binocular imaging distance in the reference image, thereby ensuring the accuracy of the head offset angle. At the same time, according to the imaging deviation of the binocular midpoint in the face image of the target user and the head offset angle of the target user relative to the imaging plane of the camera, the distance measurement process from the binocular midpoint of the target user to the camera is compensated to obtain the actual distance from the binocular midpoint of the target user to the camera. This solution uses the imaging deviation of the binocular midpoint in the face image and the head offset angle to correct the distance from the binocular midpoint to the camera, thereby greatly reducing the amount of calculation in the image ranging process and improving the rate of image ranging while ensuring the accuracy of ranging.
[0060] Embodiment 3
[0061] Figure 3A A flowchart of an image ranging method provided in Embodiment 3 of the present invention; Figure 3B The schematic diagram of the principle of the image distance measurement process provided by the third embodiment of the present invention. This embodiment is optimized on the basis of the above embodiment. Specifically, this embodiment mainly explains in detail another process of determining the head deviation angle of the target user in the face image.
[0062] Optional, such as Figure 3A As shown, this embodiment may include the following steps:
[0063] S310, obtaining historical face images and corresponding head deviation angle labels.
[0064] Specifically, when the present embodiment trains the deviation angle calculation model, it is first necessary to obtain a large number of historical face images of users looking straight at or sideways at the camera, and manually annotate the head deviation angle of the user of each historical face image when it is collected, as the head deviation angle label corresponding to the historical face image, so as to subsequently determine whether the head deviation angle calculated by the neural network model is accurate; at this time, a historical face image is selected from a large number of historical face images, and the head deviation angle label corresponding to the historical face image is determined.
[0065] S320, inputting the historical face image into a preset neural network model to obtain the current head offset angle of the historical face image.
[0066] Optionally, the acquired historical facial image is input into the neural network model preset in the present embodiment, and the neural network model is trained for the final head offset angle calculation. The input historical facial image is analyzed through the relationship between the preset training parameters and each neural network structure in the neural network model, and the facial posture in the historical facial image is judged, so as to obtain the current head offset angle of the historical facial image, so as to subsequently compare the current head offset angle with the corresponding head offset angle label, and optimize the training parameters and neural network structure in the preset neural network model according to the comparison result, so as to iteratively train the preset neural network model, and judge the accuracy of the neural network model training in turn.
[0067] S330, determine the corresponding classification loss based on the head deviation angle label and the current head deviation angle, correct the training parameters in the neural network model, and continue to obtain new historical face images until the classification loss is lower than the preset loss threshold, then use the current neural network model as the deviation angle calculation model.
[0068] Specifically, when the current head offset angle of the historical face image is obtained, the current head offset angle is an estimated value. At this time, the current head offset angle is compared and analyzed with the head offset angle label corresponding to the historical face image, that is, the estimated head offset angle of the historical face image and the actual head offset angle are compared, so as to determine the classification loss existing in the preset neural network model when calculating the head offset angle this time. The classification loss can clearly indicate the classification accuracy of the currently trained neural network model; at this time, if the classification loss of this training exceeds the preset loss threshold, it means that the accuracy of the head offset angle calculation of the neural network model trained this time is still not high and needs to be trained again; at this time, the classification loss obtained from this training is back-propagated according to the model training process. , and according to the classification loss, the training parameters in the preset neural network model are corrected, so as to continuously adjust the training parameters in the model, continue to obtain new historical face images and corresponding head offset angle labels, and determine the current head offset angle of the new historical face image again through the corrected neural network model to obtain a new classification loss, and repeat the cycle in sequence until the obtained classification loss is lower than the preset loss threshold, indicating that the neural network model trained this time has achieved a certain accuracy in calculating the head offset angle, and there is no need to train the historical face images again. At this time, the current neural network model is used as the final offset angle calculation model to continuously improve the classification accuracy of the neural network model, so that the head offset angle of the target user in the face image can be accurately calculated through the offset angle calculation model in the future.
[0069] S340, obtaining an imaging deviation of a midpoint of both pupils in a face image of a target user.
[0070] S350: Input the face image into a pre-built deviation angle calculation model to obtain the head deviation angle of the target user.
[0071] Optionally, after the deviation angle calculation model is successfully trained, the facial image of the target user captured when looking sideways at the camera can be directly input into the trained deviation angle calculation model. The facial posture in the facial image of the target user is analyzed through the deviation angle calculation model to obtain the head deviation angle of the target user, thereby improving the accuracy of the head deviation angle.
[0072] S360: Compensate the distance measurement of the target user according to the imaging deviation and the head offset angle to obtain the actual distance from the midpoint of the target user's pupils to the camera.
[0073] The technical solution provided by this embodiment obtains the head deviation angle of the target user by inputting the face image of the target user into a pre-built deviation angle calculation model, thereby ensuring the accuracy of the head deviation angle. At the same time, according to the imaging deviation of the midpoint of the double pupils in the face image of the target user and the head deviation angle of the target user relative to the imaging plane of the camera, the distance measurement process from the midpoint of the double pupils of the target user to the camera is compensated to obtain the actual distance from the midpoint of the double pupils of the target user to the camera. This solution uses the imaging deviation of the midpoint of the double pupils in the face image and the head deviation angle to correct the distance from the midpoint of the double pupils to the camera. On the basis of ensuring the accuracy of ranging, the amount of calculation in the image ranging process is greatly reduced, and the rate of image ranging is improved.
[0074] Embodiment 4
[0075] Figure 4 This is a schematic diagram of the structure of an image distance measurement device provided in Embodiment 4 of the present invention. Specifically, Figure 4 As shown, the device may include:
[0076] An image acquisition module 410 is used to acquire a face image of a target user;
[0077] An imaging deviation acquisition module 420 is used to determine the imaging deviation of the midpoint of the pupils in the face image;
[0078] The deviation angle determination module 430 is used to determine the deviation angle of the head of the target user relative to the imaging plane of the camera;
[0079] The distance measurement module 440 is used to compensate the distance measurement of the target user according to the imaging deviation and the head deviation angle, and obtain the actual distance from the midpoint of the target user's pupils to the camera.
[0080] The technical solution provided in this embodiment compensates for the distance measurement process from the midpoint of the target user's pupils to the camera according to the imaging deviation of the midpoint of the pupils in the face image of the target user and the head offset angle of the target user relative to the imaging plane of the camera, and obtains the actual distance from the midpoint of the pupils to the camera. This solution uses the imaging deviation of the midpoint of the pupils in the face image and the head offset angle to correct the distance from the midpoint of the pupils to the camera, thereby improving the accuracy of distance measurement. At the same time, there is no need to select feature samples in the face image and accurately analyze the differences between the face image pairs, which greatly reduces the amount of calculation in the image distance measurement process and improves the rate of image distance measurement.
[0081] Furthermore, the above-mentioned offset angle determination module 430 can be specifically used for:
[0082] In the pre-built image reference set, a reference image of the target user is selected according to the pupil imaging size of the face image;
[0083] The head deviation angle of the target user is determined according to the first binocular imaging distance in the face image and the second binocular imaging distance in the reference image.
[0084] Furthermore, the reference image is an image taken when the target user is looking directly at the camera.
[0085] Furthermore, the above-mentioned offset angle determination module 430 may also be specifically used for:
[0086] The face image is input into the pre-built deviation angle calculation model to obtain the head deviation angle of the target user.
[0087] Furthermore, the above deviation angle calculation model can be constructed by a model training module, and the above model training module can be specifically used for:
[0088] Get historical face images and corresponding head offset angle labels;
[0089] Input the historical face image into a preset neural network model to obtain the current head offset angle of the historical face image;
[0090] According to the head offset angle label and the current head offset angle, the corresponding classification loss is determined, the training parameters in the neural network model are corrected, and new historical face images are continuously acquired until the classification loss is lower than the preset loss threshold. The current neural network model is then used as the offset angle calculation model.
[0091] Furthermore, the distance measurement module 440 may be specifically used for:
[0092] According to the imaging deviation and the focal length of the camera, the imaging distance from the midpoint of the pupils in the face image to the camera is determined;
[0093] Determine the corresponding binocular pupil offset distance according to the head offset angle and the actual binocular pupil distance of the target user;
[0094] The actual distance from the midpoint of the pupils of the target user to the camera is determined according to the first pupil imaging distance, the imaging distance and the pupil offset distance of the face image.
[0095] Furthermore, the above imaging deviation is the distance from the midpoint of the pupils to the imaging focus in the face image.
[0096] Furthermore, the head deviation angle is a gaze deviation angle of the target user relative to the camera.
[0097] The image ranging device provided in this embodiment can be applied to the image ranging method provided in any of the above embodiments, and has corresponding functions and beneficial effects.
[0098] Embodiment 5
[0099] Figure 5 A schematic diagram of a device provided in Embodiment 5 of the present invention is shown in FIG. Figure 5 As shown, the device includes a processor 50, a storage device 51 and a communication device 52; the number of processors 50 in the device can be one or more. Figure 5 A processor 50 is taken as an example; the processor 50, the storage device 51 and the communication device 52 in the device can be connected by a bus or other means. Figure 5 The example of connecting through bus is taken in the following.
[0100] The storage device 51 is a computer-readable storage medium that can be used to store software programs, computer executable programs and modules, such as program instructions / modules corresponding to the image ranging method provided in the embodiment of the present invention. The processor 50 executes various functional applications and data processing of the device by running the software programs, instructions and modules stored in the storage device 51, that is, realizing the above-mentioned image ranging method.
[0101] The storage device 51 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system and at least one application required for a function; the data storage area may store data created according to the use of the terminal, etc. In addition, the storage device 51 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some instances, the storage device 51 may further include a memory remotely arranged relative to the processor 50, and these remote memories may be connected to the device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0102] The communication device 52 may be used to implement a network connection or a mobile data connection between devices.
[0103] A device provided in this embodiment can be used to execute the image ranging method provided in any of the above embodiments, and has corresponding functions and beneficial effects.
[0104] Embodiment 6
[0105] Embodiment 6 of the present invention further provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the image ranging method in any of the above embodiments can be implemented. The method may specifically include:
[0106] Obtaining the imaging deviation of the midpoint of the pupils in the face image of the target user;
[0107] Determine the head deviation angle of the target user in the face image;
[0108] According to the imaging deviation and the head deviation angle, the distance measurement of the target user is compensated to obtain the actual distance from the midpoint of the target user's pupils to the camera.
[0109] Of course, the computer executable instructions of a storage medium including computer executable instructions provided by an embodiment of the present invention are not limited to the operations of the method described above, and can also execute related operations in the image ranging method provided by any embodiment of the present invention.
[0110] Through the above description of the implementation methods, the technicians in the relevant field can clearly understand that the present invention can be implemented by means of software and necessary general hardware, and of course it can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as a computer floppy disk, read-only memory (ROM), random access memory (RAM), flash memory (FLASH), hard disk or optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, server, or network device, etc.) to execute the methods described in each embodiment of the present invention.
[0111] It is worth noting that in the embodiment of the above-mentioned image ranging device, the various units and modules included are only divided according to functional logic, but are not limited to the above-mentioned division, as long as the corresponding functions can be realized; in addition, the specific names of the functional units are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of the present invention.
[0112] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. An image ranging method, characterized in that: include: Obtain the target user's facial image; Determine an imaging deviation of a midpoint of a double pupil in the face image; the imaging deviation is a distance from a midpoint of a double pupil in the face image to an imaging focus; Determine a head deviation angle of the target user relative to an imaging plane of the camera; the head deviation angle is a gaze deviation angle of the target user relative to the camera; Compensating the distance measurement of the target user according to the imaging deviation and the head deviation angle to obtain the actual distance from the midpoint of the target user's pupils to the camera; The method of compensating the distance measurement of the target user according to the imaging deviation and the head deviation angle to obtain the actual distance from the midpoint of the pupils of the target user to the camera includes: Determining the distance from the midpoint of the pupils in the face image to the camera according to the imaging deviation and the focal length of the camera; Determine a corresponding binocular pupil offset distance according to the head offset angle and a pre-input actual binocular pupil distance of the target user; The actual distance from the midpoint of the pupils of the target user to the camera is determined according to the first pupil imaging distance of the facial image, the distance from the midpoint of the pupils in the facial image to the camera, and the pupil offset distance; the first pupil imaging distance is the distance between the pupils in the facial image of the target user by a side-view camera.
2. The method according to claim 1, characterized in that: The determining the head deviation angle of the target user in the face image includes: Selecting a reference image of the target user from a pre-built image reference set according to the pupil imaging size of the face image; The head deviation angle of the target user is determined according to the first binocular imaging distance in the face image and the second binocular imaging distance in the reference image.
3. The method according to claim 2, characterized in that The reference image is an image taken when the target user is looking directly at the camera.
4. The method according to claim 1, characterized in that: The determining the head deviation angle of the target user in the face image includes: The face image is input into a pre-built deviation angle calculation model to obtain the head deviation angle of the target user.
5. The method according to claim 4, characterized in that The deviation angle calculation model is constructed by performing the following operations: Get historical face images and corresponding head offset angle labels; Inputting the historical face image into a preset neural network model to obtain a current head deviation angle of the historical face image; According to the head deviation angle label and the current head deviation angle, the corresponding classification loss is determined, the training parameters in the neural network model are corrected, and new historical face images are continuously acquired until the classification loss is lower than the preset loss threshold, and the current neural network model is used as the deviation angle calculation model.
6. An image ranging device, characterized in that: The device comprises: one or more processors; A storage device for storing one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the image ranging method as described in any one of claims 1 to 5.
7. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the image ranging method as described in any one of claims 1 to 5 is implemented.
