A method and device for judging distance and face validity based on face pupil distance
The geometric algorithm of face double pupil spacing and camera shooting angle and resolution calculation of face and camera distance, and through effectiveness judgment, the problems of high complexity and waste of resources in the existing technology are solved, and the face recognition system is improved efficiency and resource utilization.
Patent Information
- Application Number
- CN202011001456.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-09-22
- Publication Date
- 2024-11-22
- Estimated Expiration
- 2040-09-22
AI Technical Summary
In the existing face recognition technology, the method of measuring distance through cameras is complex and requires a large number of face distance mapping libraries to collect, and the face quality cannot be effectively judged, resulting in wasted system resources.
The geometric algorithm is used to calculate the distance between the face and the camera by the geometric algorithm related to the camera's shooting angle and resolution, and judge the face's effectiveness through the preset maximum effective distance, and quickly filter out images that meet the distance requirements for subsequent operations. .
It realizes the simple and fast judgment of the distance between the face and the camera, improves the efficiency and resource utilization of the system, reduces the calculation amount and recognition times, and reduces the recognition cost.
Smart Images

Figure CN112257507B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of face distance recognition, and in particular to a method and device for judging distance and face validity based on face pupil distance. Background Art
[0002] Face recognition is a biometric identification technology that authenticates people based on their facial features. The biggest feature of the technology is that it can avoid personal information leakage and use a non-contact method for identification. With the progress and development of society, people's lifestyles have gradually changed. Nowadays, our lives are increasingly inseparable from smart electronic devices. With the popularization of smart electronic devices, this convenient and secure identity authentication method has also been widely used.
[0003] At present, the method of measuring distance through the camera generally uses deep learning neural network and depth of field layered measurement fusion technology to process face recognition and distance measurement. There is also a method of using the original mapping relationship between the pupil distance of the human eye and the face distance to perform a table lookup method to test the distance between the face and the camera. Among these existing methods, the neural network analysis and processing technology is relatively complex to implement, and the method using the face mapping relationship table requires a large amount of face distance mapping library collection, which is difficult to implement. In addition, the pictures commonly used for face recognition are generally directly based on pictures obtained after liveness detection or directly based on pictures obtained by the camera. The size of the face in the obtained picture (or the distance between the face and the camera) is not judged in advance for effectiveness, and pictures with low face quality are recognized, resulting in a waste of system resources. Summary of the invention
[0004] The technical problem to be solved by the present invention is to provide a method and device for judging the distance and face validity based on the interpupillary distance of the face, which can simply and quickly judge the distance between the face and the camera, and then perform subsequent steps by judging the validity of the face, making the system more efficient and practical.
[0005] In a first aspect, the present invention provides a method for judging distance and face validity based on face pupil distance, comprising:
[0006] Step 10: Get the camera's shooting angle D cam and supported resolution parameters, a resolution parameter is selected from the supported resolution parameters and set as the shooting resolution, the shooting resolution includes a width W px and height H px ;
[0007] Step 20, obtaining an image captured by a camera, and determining whether there is a face in the image, if there is a face, proceeding to step 30, if there is no face, proceeding to step 50;
[0008] Step 30, displaying the vertical center line of the image, obtaining and displaying the midpoint of both eyes of the face, when the midpoint of both eyes is located on the vertical center line of the image, proceeding to step 40, when the midpoint of both eyes is not on the vertical center line of the image, displaying a prompt message for adjusting the position of the face;
[0009] Step 40: Obtain binocular image distance E px , and then according to the binocular image distance E px Compared with the preset interpupillary standard distance E rel The corresponding relationship between the camera angle D cam And the shooting resolution width W px , calculate the distance R between the face and the camera through geometric algorithm rel ;
[0010] Step 50: preset a maximum effective distance, determine whether there is a face, and compare the distance R between the face and the camera. rel When there is no face, or the distance between the face and the camera is R rel If the distance is greater than the maximum effective distance, the face is judged to be invalid, a prompt message for adjusting the distance is displayed, and the process returns to step 20; if there is a face, and the distance R between the face and the camera is rel When the distance is less than or equal to the maximum effective distance, the face is judged to be valid and subsequent face operations are authorized.
[0011] Furthermore, in step 40, the distance R between the face and the camera is calculated. rel , the specific formula is as follows:
[0012]
[0013] Among them, E rel is the preset standard inter-pupillary distance, W px is the shooting resolution width, E px is the inter-pupil image distance, D cam The shooting angle of the camera.
[0014] Furthermore, the preset standard inter-pupillary distance E rel It is a set value selected in the range of 55-75mm based on the application scenario.
[0015] In a second aspect, the present invention provides a device for judging distance and face validity based on face pupil distance, comprising: a camera adaptation module, a face judgment module, a center matching module, a distance calculation module and a validity judgment module;
[0016] The camera adapter module is used to obtain the shooting angle D of the camera. camand supported resolution parameters, a resolution parameter is selected from the supported resolution parameters and set as the shooting resolution, the shooting resolution includes a width W px and height H px ;
[0017] The face judgment module is used to obtain the image captured by the camera and judge whether there is a face in the image. If there is a face, it enters the center matching module; if there is no face, it enters the effective judgment module;
[0018] The center matching module is used to display the vertical center line of the image, obtain and display the midpoint of the eyes of the face, and when the midpoint of the eyes is located on the vertical center line of the image, enter the distance calculation module, and when the midpoint of the eyes is not on the vertical center line of the image, display the prompt information of adjusting the face position;
[0019] The distance calculation module is used to obtain the binocular image distance E px , and then according to the binocular image distance E px Compared with the preset interpupillary standard distance E rel The corresponding relationship between the camera angle D cam And the shooting resolution width W px , calculate the distance R between the face and the camera through geometric algorithm rel ;
[0020] The effective judgment module is used to preset a maximum effective distance, judge whether there is a face and compare the distance R between the face and the camera. rel When there is no face, or the distance between the face and the camera is R rel When the distance is greater than the maximum effective distance, the face is judged to be invalid, a prompt message for adjusting the face position is displayed, and the face judgment module is returned; when there is a face and the distance between the face and the camera is R rel When the distance is less than or equal to the maximum effective distance, the face is judged to be valid and subsequent face operations are authorized.
[0021] Furthermore, in the distance calculation module, the distance R between the face and the camera is calculated. rel , the specific formula is as follows:
[0022]
[0023] Among them, E rel is the preset standard inter-pupillary distance, W px is the shooting resolution width, E px is the inter-pupil image distance, D cam The shooting angle of the camera.
[0024] Furthermore, the preset standard inter-pupillary distance Erel It is a set value selected in the range of 55-75mm based on the application scenario.
[0025] One or more technical solutions provided in the embodiments of the present invention have at least the following technical effects or advantages:
[0026] 1. The distance is calculated by using the pixel size of the inter-pupillary distance of the face in the camera image, the camera shooting angle, and the camera resolution-related algorithm. By obtaining the shooting angle resolution parameter of the camera, when the midpoint of the two eyes is located on the vertical center line of the image, the inter-pupillary image distance is obtained, and then the distance between the face and the camera is quickly and efficiently determined based on the preset inter-pupillary standard distance, the camera shooting angle, and the shooting resolution width;
[0027] 2. When authorizing system interaction, detect in advance whether a face exists, and calculate the distance between the face and the camera. When there is a face within the preset allowed face distance range, perform actual face search, making the system face interaction operation more efficient and practical.
[0028] The above description is only an overview of the technical solution of the present invention. In order to more clearly understand the technical means of the present invention, it can be implemented according to the contents of the specification. In order to make the above and other purposes, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] The present invention will be further described below in conjunction with embodiments with reference to the accompanying drawings.
[0030] Figure 1 is a flow chart of the method in Embodiment 1 of the present invention;
[0031] Figure 2 It is a structural schematic diagram of the device in the second embodiment of the present invention;
[0032] Figure 3 This is a system block diagram of Embodiment 3 of the present invention;
[0033] Figure 4 A schematic diagram of a geometric figure for calculating face distance in Embodiment 3 of the present invention;
[0034] Figure 5 Schematic diagram of the face validity judgment process in Embodiment 3 of the present invention. DETAILED DESCRIPTION
[0035] The technical solution in the embodiment of the present application has the following general idea:
[0036] In view of the current situation, the present invention uses the pixel size of the interpupillary distance of the face in the camera image and the camera shooting angle and camera resolution related algorithm to calculate the distance between the face and the camera. This algorithm is relatively simple to implement and can be implemented only through a linear algorithm. In addition, in view of the fact that the face and the camera are close in the self-service interactive device, this method can be used to first determine the validity of the face. If the face does not meet the distance requirement, the subsequent face search / matching authorization operation can be directly rejected. This processing can not only reduce the amount of equipment calculation and speed up the speed, but also reduce the cost expenditure of face recognition services such as face++ that charge according to the number of face recognitions, making the system more efficient and practical.
[0037] Embodiment 1
[0038] This embodiment provides a method for judging distance and face validity based on face pupil distance. Figure 1 As shown, including;
[0039] Step 10: Get the camera's shooting angle D cam and supported resolution parameters, a resolution parameter is selected from the supported resolution parameters and set as the shooting resolution, the shooting resolution includes a width W px and height H px ;
[0040] Step 20, obtaining an image captured by a camera, and determining whether there is a face in the image, if there is a face, proceeding to step 30, if there is no face, proceeding to step 50;
[0041] Step 30, display the vertical center line of the image, obtain and display the midpoint of both eyes of the face (for example, obtained by the face algorithm of the Android system SDK), when the midpoint of both eyes is located on the vertical center line of the image, enter step 40, when the midpoint of both eyes is not on the vertical center line of the image, display the prompt information of adjusting the face position;
[0042] Step 40: Obtain binocular image distance E px (For example, through the Android system's SDK face algorithm or OpenCV algorithm), and then according to the binocular image distance E px Compared with the preset interpupillary standard distance E rel The corresponding relationship between the camera angle D cam And the shooting resolution width W px , calculate the distance R between the face and the camera through geometric algorithm rel , the formula is as follows:
[0043]
[0044] Among them, E relis the preset standard inter-pupillary distance, W px is the shooting resolution width, E px is the inter-pupil image distance, D cam is the shooting angle of the camera;
[0045] In a possible implementation manner, the preset interpupillary standard distance E rel It is a set value selected in the range of 55-75mm based on the application scenario. For example, in the scenario of face recognition in a primary school, 55mm is selected as the preset standard inter-pupillary distance, so as to reduce the error between the distance calculation result and the actual distance and make the distance judgment result more accurate.
[0046] The distance is calculated using an algorithm related to the pixel size of the face interpupillary distance in the camera image, the camera shooting angle, and the camera resolution. By obtaining the camera shooting angle resolution parameter, when the midpoint of the two eyes is located on the vertical center line of the image, the interpupillary image distance is obtained. Then, based on the preset interpupillary standard distance, the camera shooting angle, and the shooting resolution width, the distance between the face and the camera can be quickly and efficiently determined.
[0047] Step 50: preset a maximum effective distance (e.g., 1 meter), determine whether there is a face, and compare the distance R between the face and the camera. rel When there is no face, or the distance between the face and the camera is R rel If the distance is greater than the maximum effective distance, the face is judged to be invalid, a prompt message for adjusting the distance is displayed, and the process returns to step 20; if there is a face, and the distance R between the face and the camera is rel When the distance is less than or equal to the maximum effective distance, the face is judged to be valid and subsequent face operations are authorized.
[0048] When the system interacts with the authorization, it detects in advance whether a face exists, calculates the distance between the face and the camera, and performs an actual face search when there is a face within the preset allowed face distance range, making the system face interaction operation more efficient and practical.
[0049] Based on the same inventive concept, the present application also provides a device corresponding to the method in Example 1, see Example 2 for details.
[0050] Embodiment 2
[0051] In this embodiment, a device for judging distance and face validity based on face pupil distance is provided. Figure 2 As shown, it includes: a camera adaptation module, a face recognition module, a center matching module, a distance calculation module and a valid judgment module;
[0052] The camera adapter module is used to obtain the shooting angle D of the camera.cam and supported resolution parameters, a resolution parameter is selected from the supported resolution parameters and set as the shooting resolution, the shooting resolution includes a width W px and height H px ;
[0053] The face judgment module is used to obtain the image captured by the camera and judge whether there is a face in the image. If there is a face, it enters the center matching module; if there is no face, it enters the effective judgment module;
[0054] The center matching module is used to display the vertical center line of the image, obtain and display the midpoint of the eyes of the face, and when the midpoint of the eyes is located on the vertical center line of the image, enter the distance calculation module, and when the midpoint of the eyes is not on the vertical center line of the image, display the prompt information of adjusting the face position;
[0055] The distance calculation module is used to obtain the binocular image distance E px , and then according to the binocular image distance E px Compared with the preset interpupillary standard distance E rel The corresponding relationship between the camera angle D cam And the shooting resolution width W px , calculate the distance R between the face and the camera through geometric algorithm rel ;
[0056] The effective judgment module is used to preset a maximum effective distance, judge whether there is a face and compare the distance R between the face and the camera. rel When there is no face, or the distance between the face and the camera is R rel When the distance is greater than the maximum effective distance, the face is judged to be invalid, a prompt message for adjusting the face position is displayed, and the face judgment module is returned; when there is a face and the distance between the face and the camera is R rel When the distance is less than or equal to the maximum effective distance, the face is judged to be valid and subsequent face operations are authorized.
[0057] In the distance calculation module, the distance R between the face and the camera is calculated. rel , the specific formula is as follows:
[0058]
[0059] Among them, E rel is the preset standard inter-pupillary distance, W px is the shooting resolution width, E px is the inter-pupil image distance, D cam The shooting angle of the camera.
[0060] The preset inter-pupillary standard distance Erel It is a set value selected in the range of 55-75mm based on the application scenario.
[0061] Since the device introduced in the second embodiment of the present invention is a device used to implement the method of the first embodiment of the present invention, those skilled in the art can understand the specific structure and deformation of the device based on the method introduced in the first embodiment of the present invention, so it is not described here in detail. All devices used in the method of the first embodiment of the present invention belong to the scope of protection of the present invention.
[0062] Embodiment 3
[0063] In a specific implementation mode of the present invention, the system framework is as follows Figure 3 :
[0064] Step 1: According to the actual shooting angle of the camera (hardware parameters), preset the shooting angle calculated by the system (D cam ) (such as: 30 degrees, 45 degrees, 90 degrees, 100 degrees, 120 degrees, etc.);
[0065] Step 2: The system obtains the resolution (width W) supported by the camera px , high H px ) (such as: 1920x1080, 1280x720, 640x480, 320x240, etc.), select the calculation resolution, and set the camera image to the selected resolution (width W px , high H px );
[0066] Step 3: Get a face image and use the interface prompt to make the midpoint of the face's eyes be located on the center line of the camera image (the center line of the camera image passes through W px The midpoint line of the face is obtained, and the center of the two eyes of the face can be obtained through the face algorithm of the Android SDK), and the pixel distance between the pupils of the face (E) is obtained through the face algorithm of the Android system SDK (or OpenCV). px );
[0067] Step 4: The standard distance between the pupils of a face is between 55-75mm: women are between 55mm and 65mm, men are between 65mm and 75mm, and children are around 55mm. Preset a standard distance E between the pupils according to the specific application scenario. rel ;
[0068] Step 5: According to the basic geometric algorithm, the camera shooting angle (D cam ), camera / full image resolution width (W px ), image inter-pupillary distance (E px ), the preset standard interpupillary distance (E rel), calculate the actual distance between the face and the camera (R rel );
[0069] Step 6: When performing interactive face recognition on the device, first preset the maximum distance allowed between the face and the camera (R pref ); then compare with R obtained in step 5 rel By contrast, if there is a face and (Rrel≦Rpref), the distance requirement is met and the subsequent actual face search / matching authorization operation can be continued. Otherwise, it is directly regarded as an unsuccessful face operation and the user is asked to retry. This processing can not only reduce the amount of equipment calculation and speed up the process, but also reduce the cost of face recognition services such as face++ that charge by the number of face recognitions, making the system more efficient and practical.
[0070] Calculation method for calculating the distance between the face and the camera:
[0071] The interface prompts the midpoint of the eyes of the face to be located on the center line of the camera image (the center line of the camera image passes through W px The midpoint line of the face is obtained, and the center of the two eyes of the face can be obtained through the face algorithm of the Android SDK), and the pixel distance between the pupils of the face (E) is obtained through the face algorithm of the Android system SDK (or OpenCV). px );
[0072] like Figure 4 As shown in the figure, when the midpoint of the human face's eyes is on the center line of the camera, (W px , E px , E rel ) can be mapped to the base of an isosceles triangle, and (R px , R rel ) can be regarded as the height of an isosceles triangle, thus converting it into a basic algorithm of an isosceles triangle, which can conveniently calculate the distance between the face and the camera.
[0073] Figure 4 Middle, D cam is the camera shooting angle, W px is the resolution width of the camera / image in pixels, E px is the inter-pupil pixel spacing in the camera image, R px is the pixel distance calculated between the face and the camera, D face is the angle between the human face pupil and the camera, E rel The standard distance between the pupils of a human face is between 55 and 75 mm. rel The distance calculation result is actually required.
[0074] The calculation process is as follows:
[0075] According to the basic algorithm of isosceles triangle, we know that:
[0076]
[0077]
[0078] This solves the system of equations:
[0079]
[0080]
[0081] Substituting formula (1) into formula (2) yields:
[0082]
[0083] The actual usage scenarios are as follows:
[0084] Shooting angle: The standard lens has a viewing angle of about 30 degrees, and the wide-angle camera has a viewing angle of more than 90 degrees. Taking a 720p ordinary camera as an example, the following data can be obtained:
[0085] Camera shooting angle D cam The camera / image resolution is 30 degrees, (1280x720), that is, the shooting resolution width W px =1280, the standard distance between the pupils of a human face is Erel, which is 55-75mm.
[0086] Substituting the parameters into the formula we get:
[0087]
[0088] E rel When taking 55mm, 65mm and 75mm respectively, we can get:
[0089]
[0090]
[0091]
[0092]
[0093] Therefore, as long as the device obtains the inter-pupil distance in the image (i.e., the inter-pupil image distance E px ), we can calculate the actual distance R between the face and the camera rel .
[0094] Assume that the acquired inter-pupil image distance E pxis 300 pixels. Substituting into the above formula, we can know R rel The range is:
[0095] R rel-min =131340 / E px =131340 / 300=437.8mm
[0096] R rel-mid =155220 / E px =155220 / 300=517.4mm
[0097] R rel-max =179100 / E px =179100 / 300=597mm
[0098] The error is: (R rel-max -R rel-mid ) or (R rel-mid -R rel-min ), is 79.6mm, and the error rate is: 79.6mm / 517.4mm=within 15%. This error comes from the difference in the interpupillary distance of the face (similar to the patented method using a mapping relationship, there is an error between the actual face and the standard face), and this difference can be used to set a suitable standard distance between the interpupillary distance of the face according to the applicable population, further reducing the error, which has met the requirements in general face error recognition limited range usage scenarios.
[0099] Methods for judging the validity of faces based on distance, such as Figure 5 As shown in the figure: When performing device interaction face authorization, first preset the maximum effective distance allowed between the face and the camera (R pref ); then compare with the calculated actual distance R rel In contrast, if there is a human face and R rel ≦R pref , it means the face is valid and meets the requirements, and the subsequent actual search / matching authorization operation can continue; otherwise, the face is invalid and it is directly regarded as an unsuccessful face operation, prompting the user to try again. This processing can not only reduce the amount of equipment calculation and speed up the speed, but also reduce the cost of face recognition services such as face++ that charge by the number of face recognitions, making the system more efficient and practical.
[0100] The embodiment of the present invention uses an algorithm related to the pixel size of the inter-pupillary distance of the face in the camera image and the camera shooting angle and camera resolution to calculate the distance. By obtaining the shooting angle resolution parameter of the camera, when the midpoint of the two eyes is located on the vertical center line of the image, the inter-pupillary image distance is obtained, and then the distance between the face and the camera is judged quickly and efficiently according to the preset inter-pupillary standard distance, the camera shooting angle and the shooting resolution width. When the system interaction is authorized, it is detected in advance whether the face exists, and by calculating the distance between the face and the camera, an actual face search is performed when there is a face within the preset allowed face distance range, so that the system face interaction operation is more efficient and practical.
[0101] Although the specific implementation modes of the present invention are described above, those skilled in the art should understand that the specific implementation modes described are only illustrative and are not intended to limit the scope of the present invention. Equivalent modifications and changes made by those skilled in the art in accordance with the spirit of the present invention should be included in the scope of protection of the claims of the present invention.
Claims
1. A method for judging distance and face validity based on face pupil distance, characterized by: include: Step 10: Get the camera's shooting angle D cam and supported resolution parameters, a resolution parameter is selected from the supported resolution parameters and set as the shooting resolution, the shooting resolution includes a width W px and height H px ; Step 20, obtaining an image captured by a camera, and determining whether there is a face in the image, if there is a face, proceeding to step 30, if there is no face, proceeding to step 50; Step 30, display the vertical center line of the image, obtain and display the midpoint of the eyes of the face, when the midpoint of the eyes is located on the vertical center line of the image, enter step 40, when the midpoint of the eyes is not on the vertical center line of the image, display the prompt information of adjusting the face position, and return to step 20; Step 40: Obtain binocular image distance E px , and then according to the binocular image distance E px Compared with the preset interpupillary standard distance E rel The corresponding relationship between the camera angle D cam And the shooting resolution width W px , calculate the distance R between the face and the camera through geometric algorithm rel ; Step 50: preset a maximum effective distance, determine whether there is a face, and compare the distance R between the face and the camera. rel The size of the maximum effective distance; When there is no face, or the distance between the face and the camera is R rel If the distance is greater than the maximum effective distance, the face is judged to be invalid, a prompt message for adjusting the distance is displayed, and the process returns to step 20; if there is a face, and the distance R between the face and the camera is rel When the distance is less than or equal to the maximum effective distance, the face is judged to be valid and subsequent face operations are authorized.
2. The method according to claim 1, characterized in that: In step 40, the distance R between the face and the camera is calculated by a geometric algorithm. rel , the specific formula is as follows: Among them, E rel is the preset standard inter-pupillary distance, W px is the shooting resolution width, E px is the inter-pupil image distance, D cam The shooting angle of the camera.
3. The method according to claim 1 or 2, characterized in that: The preset inter-pupillary standard distance E rel It is a set value selected in the range of 55-75mm based on the application scenario.
4. A device for judging distance and face validity based on interpupillary distance of a face, characterized in that: include: Camera adaptation module, face recognition module, center matching module, distance calculation module and effective judgment module; The camera adapter module is used to obtain the shooting angle D of the camera. cam and supported resolution parameters, a resolution parameter is selected from the supported resolution parameters and set as the shooting resolution, the shooting resolution includes a width W px and height H px ; The face judgment module is used to obtain the image captured by the camera and judge whether there is a face in the image. If there is a face, it enters the center matching module; if there is no face, it enters the effective judgment module; The center matching module is used to display the vertical center line of the image, obtain and display the midpoint of the eyes of the face, and when the midpoint of the eyes is located on the vertical center line of the image, enter the distance calculation module, and when the midpoint of the eyes is not on the vertical center line of the image, display the prompt information of adjusting the face position; The distance calculation module is used to obtain the binocular image distance E px , and then according to the binocular image distance E px Compared with the preset interpupillary standard distance E rel The corresponding relationship between the camera angle D cam And the shooting resolution width W px , calculate the distance R between the face and the camera through geometric algorithm rel ; The effective judgment module is used to preset a maximum effective distance, judge whether there is a face and compare the distance R between the face and the camera. rel The size of the maximum effective distance; When there is no face, or the distance between the face and the camera is R rel When the distance is greater than the maximum effective distance, the face is judged to be invalid, a prompt message for adjusting the face position is displayed, and the face judgment module is returned; when there is a face and the distance between the face and the camera is R rel When the distance is less than or equal to the maximum effective distance, the face is judged to be valid and subsequent face operations are authorized.
5. The device according to claim 4, characterized in that: In the distance calculation module, the distance R between the face and the camera is calculated by a geometric algorithm. rel , the specific formula is as follows: Among them, E rel is the preset standard inter-pupillary distance, W px is the shooting resolution width, E px is the inter-pupil image distance, D cam The shooting angle of the camera.
6. The device according to claim 4 or 5, characterized in that: The preset inter-pupillary standard distance E rel It is a set value selected in the range of 55-75mm based on the application scenario.
