[go: up one dir, main page]

CN108154090B - Face recognition method and device - Google Patents

Face recognition method and device Download PDF

Info

Publication number
CN108154090B
CN108154090B CN201711310840.8A CN201711310840A CN108154090B CN 108154090 B CN108154090 B CN 108154090B CN 201711310840 A CN201711310840 A CN 201711310840A CN 108154090 B CN108154090 B CN 108154090B
Authority
CN
China
Prior art keywords
flow velocity
optical flow
histogram
face area
interval
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201711310840.8A
Other languages
Chinese (zh)
Other versions
CN108154090A (en
Inventor
万韶华
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Xiaomi Mobile Software Co Ltd
Original Assignee
Beijing Xiaomi Mobile Software Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Xiaomi Mobile Software Co Ltd filed Critical Beijing Xiaomi Mobile Software Co Ltd
Priority to CN201711310840.8A priority Critical patent/CN108154090B/en
Publication of CN108154090A publication Critical patent/CN108154090A/en
Application granted granted Critical
Publication of CN108154090B publication Critical patent/CN108154090B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V40/00Recognition of biometric, human-related or animal-related patterns in image or video data
    • G06V40/10Human or animal bodies, e.g. vehicle occupants or pedestrians; Body parts, e.g. hands
    • G06V40/16Human faces, e.g. facial parts, sketches or expressions
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/70Arrangements for image or video recognition or understanding using pattern recognition or machine learning
    • G06V10/74Image or video pattern matching; Proximity measures in feature spaces
    • G06V10/75Organisation of the matching processes, e.g. simultaneous or sequential comparisons of image or video features; Coarse-fine approaches, e.g. multi-scale approaches; using context analysis; Selection of dictionaries
    • G06V10/758Involving statistics of pixels or of feature values, e.g. histogram matching
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V40/00Recognition of biometric, human-related or animal-related patterns in image or video data
    • G06V40/40Spoof detection, e.g. liveness detection
    • G06V40/45Detection of the body part being alive

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Multimedia (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Human Computer Interaction (AREA)
  • Health & Medical Sciences (AREA)
  • General Health & Medical Sciences (AREA)
  • Oral & Maxillofacial Surgery (AREA)
  • Artificial Intelligence (AREA)
  • Computing Systems (AREA)
  • Databases & Information Systems (AREA)
  • Evolutionary Computation (AREA)
  • Medical Informatics (AREA)
  • Software Systems (AREA)
  • Image Analysis (AREA)

Abstract

The disclosure relates to a face recognition method and device. The method comprises the following steps: acquiring at least two frames of images containing a face to be detected, and acquiring a dense optical flow graph comprising optical flow velocity values of each pixel of any one frame of image in the two frames of images according to the at least two frames of images; determining N face area optical flow velocity histograms and N non-face area optical flow velocity histograms according to the optical flow velocity value of each pixel; acquiring the average distance between the face area optical flow velocity histogram and the non-face area optical flow velocity histogram according to the N face area optical flow velocity histograms, the N non-face area optical flow velocity histograms and the preset weight corresponding to each histogram interval; and when the detected average distance is smaller than the preset distance threshold value, determining the face to be detected as the false face. The calculated average distance value can be more accurate, and the accuracy of face recognition is improved.

Description

Face recognition method and device
Technical Field
The present disclosure relates to the field of image recognition technologies, and in particular, to a face recognition method and apparatus.
Background
With the development of science and technology, information security has become an increasingly concerned problem, and compared with biological characteristics such as fingerprints and irises, because face images are very easy to obtain, face recognition is increasingly applied to identity authentication.
At present, face recognition mainly includes acquiring a video to be detected by various devices and systems, such as a notebook computer, a mobile terminal, an access control system, and the like, and completing identity authentication by detecting a face in the video to be detected. However, in the mechanism for completing identity recognition through the face in the video to be detected, because the face image is very easy to obtain (for example, mobile phone photographing is performed under the condition that a target person is unknown), face prosthesis attack often occurs, that is, a printed face picture of a target user is used as an attack tool, the printed face picture is aligned to a shooting lens, and at this time, the video to be detected acquired by the shooting lens will include the face image of the target user, so that identity recognition is completed through face recognition. Thus, the accuracy of face recognition is reduced, and the safety of user information is low.
Disclosure of Invention
In order to overcome the problems in the related art, the embodiments of the present disclosure provide a face recognition method and apparatus. The technical scheme is as follows:
according to a first aspect of the embodiments of the present disclosure, there is provided a face recognition method, including:
acquiring at least two frames of images containing a face to be detected;
acquiring a dense optical flow graph according to the at least two frames of images, wherein the dense optical flow graph comprises optical flow velocity values of each pixel of any one frame of image in the two frames of images;
determining N face area optical flow velocity histograms and N non-face area optical flow velocity histograms according to the optical flow velocity value of each pixel; the histogram intervals of the optical flow velocity histograms of the face areas are different, and the histogram intervals of the optical flow velocity histograms of the non-face areas are different; n is an integer greater than or equal to 2;
acquiring the average distance between the face area optical flow velocity histogram and the non-face area optical flow velocity histogram according to the N face area optical flow velocity histograms, the N non-face area optical flow velocity histograms and the preset weight value corresponding to each histogram interval;
and when the average distance is smaller than a preset distance threshold value, determining that the face to be detected is a false face.
The technical scheme provided by the embodiment of the disclosure can have the following beneficial effects: acquiring at least two frames of images containing a face to be detected, and acquiring a dense optical flow graph according to the at least two frames of images, wherein the dense optical flow graph comprises optical flow velocity values of each pixel of any one frame of image in the two frames of images; determining N face area optical flow velocity histograms and N non-face area optical flow velocity histograms according to the optical flow velocity value of each pixel; the histogram intervals of the optical flow velocity histograms of the face areas are different, and the histogram intervals of the optical flow velocity histograms of the non-face areas are different; n is an integer greater than or equal to 2; acquiring the average distance between the face area optical flow velocity histogram and the non-face area optical flow velocity histogram according to the N face area optical flow velocity histograms, the N non-face area optical flow velocity histograms and the preset weight corresponding to each histogram interval; and when the detected average distance is smaller than the preset distance threshold value, determining the face to be detected as the false face. By the method, the calculated distance value can be more accurate, and the accuracy of face recognition is improved.
In one embodiment, the determining N histograms of optical flow velocities for face regions and N histograms of optical flow velocities for non-face regions based on optical flow velocity values for respective pixels includes:
acquiring a minimum optical flow velocity value in optical flow velocity values of each pixel;
determining the minimum optical flow velocity value as a first histogram interval of a1 st personal area optical flow velocity histogram;
determining a first histogram interval of each face area optical flow velocity histogram according to a preset multiple of the first histogram interval of the latter face area optical flow velocity histogram as the first histogram interval of the adjacent former face area optical flow velocity histogram;
determining each first optical flow velocity value interval in an nth personal face area optical flow velocity histogram according to a first histogram interval corresponding to the nth personal face area optical flow velocity histogram, wherein N is 1 and 2 … N in sequence;
for each first optical flow velocity value interval, acquiring the first pixel number contained in the first optical flow velocity value interval in the optical flow velocity values of the pixels in the face area;
determining the optical flow velocity histograms of the N human face areas according to each first optical flow velocity value interval and the first pixel number corresponding to each first optical flow velocity value interval;
determining that the minimum optical flow velocity value is a second histogram interval of a1 st non-human face area optical flow velocity histogram;
determining a second histogram interval of each non-face area optical flow velocity histogram according to the preset multiple that a second histogram interval of a latter non-face area optical flow velocity histogram is a second histogram interval of an adjacent former non-face area optical flow velocity histogram;
determining each second optical flow velocity value interval in the nth non-human face area optical flow velocity histogram according to a second histogram interval corresponding to the nth non-human face area optical flow velocity histogram, wherein N is 1 and 2 … N in sequence;
for each second optical flow velocity value interval, acquiring the number of second pixels contained in the second optical flow velocity value interval in the optical flow velocity values of the pixels in the non-human face area;
and determining the N non-human face area optical flow velocity histograms according to each second optical flow velocity value interval and the second pixel number corresponding to each second optical flow velocity value interval.
In one embodiment, the obtaining an average distance between the face area optical flow velocity histogram and the non-face area optical flow velocity histogram according to the N face area optical flow velocity histograms and the N non-face area optical flow velocity histograms and a preset weight corresponding to each histogram interval includes:
acquiring the number of new matched pixels in the ith optical flow velocity histogram, wherein i is 1 and 2 … N in sequence; the ith optical flow velocity histogram comprises a face area optical flow velocity histogram and a non-face area optical flow velocity histogram, and a first histogram space corresponding to the face area optical flow velocity histogram is the same as a second histogram space corresponding to the non-face area optical flow velocity histogram;
and acquiring the average distance between the human face area optical flow velocity histogram and the non-human face area optical flow velocity histogram according to the preset weight corresponding to the histogram interval of each pair of optical flow velocity histograms and the number of new matched pixels in each pair of optical flow velocity histograms.
In one embodiment, the obtaining the number of new matched pixels in the ith light flow velocity histogram includes:
acquiring the number of matched pixels in the ith-1 pair light flow velocity histogram and the number of matched pixels in the ith pair light flow velocity histogram;
and determining the difference value of the number of matched pixels in the ith light flow velocity histogram and the number of matched pixels in the ith-1 light flow velocity histogram as the new number of matched pixels in the ith light flow velocity histogram.
In one embodiment, the obtaining the number of matched pixels in the ith light flow velocity histogram includes:
acquiring a third pixel value corresponding to the interval distance of a jth first optical flow velocity value in a face area optical flow velocity histogram in the ith optical flow velocity histogram;
acquiring a fourth pixel value corresponding to the interval distance of a jth second optical flow velocity value in a non-human face area optical flow velocity histogram in the ith optical flow velocity histogram, wherein j is 1 and 2 … M in sequence; the M is the number of interval spaces of first optical flow velocity values in a human face area optical flow velocity histogram in the ith optical flow velocity histogram, or the M is the number of interval spaces of second optical flow velocity values in a non-human face area optical flow velocity histogram in the ith optical flow velocity histogram, and the M is an integer greater than or equal to 1;
determining the minimum value of a third pixel value corresponding to the interval pitch of the jth first optical flow velocity value interval and a fourth pixel value of the interval pitch of the jth second optical flow velocity value interval;
and determining the sum of the minimum values corresponding to the interval spacing of each optical flow velocity value in the ith optical flow velocity histogram as the number of matched pixels in the ith optical flow velocity histogram.
In one embodiment, the preset weight of the ith-1 th histogram of light flow velocity is greater than the preset weight of the ith histogram of light flow velocity.
The at least two frame images of the face to be detected are as follows: and two adjacent frames of images of the face to be detected.
The method further comprises the following steps:
and when the average distance is detected to be larger than or equal to the preset distance threshold, determining that the face to be detected is a living face.
According to a second aspect of the embodiments of the present disclosure, there is provided a face recognition apparatus including:
the first acquisition module is used for acquiring at least two frames of images containing a face to be detected;
a second obtaining module, configured to obtain a dense optical flow map according to the at least two frames of images obtained by the first obtaining module, where the dense optical flow map includes optical flow velocity values of pixels of any one of the two frames of images;
a first determining module, configured to determine N face area optical flow velocity histograms and N non-face area optical flow velocity histograms according to the optical flow velocity values of the pixels acquired by the second acquiring module; the histogram intervals of the optical flow velocity histograms of the face areas are different, and the histogram intervals of the optical flow velocity histograms of the non-face areas are different; n is an integer greater than or equal to 2;
a third obtaining module, configured to obtain an average distance between the face area optical flow velocity histogram and the non-face area optical flow velocity histogram according to the N face area optical flow velocity histograms and the N non-face area optical flow velocity histograms determined by the first determining module and a preset weight corresponding to each histogram interval;
the detection module is used for detecting whether the average distance between the face area optical flow velocity histogram and the non-face area optical flow velocity histogram acquired by the third acquisition module is smaller than a preset distance threshold value or not;
and the second determining module is used for determining that the face to be detected is a false face when the detecting module detects that the average distance is smaller than the preset distance threshold.
In one embodiment, the first determining module comprises: the first obtaining submodule, the first determining submodule, the second determining submodule, the third determining submodule, the second obtaining submodule, the fourth determining submodule, the fifth determining submodule, the sixth determining submodule, the seventh determining submodule, the third obtaining submodule and the eighth determining submodule;
the first acquisition submodule is used for acquiring the minimum optical flow velocity value in the optical flow velocity values of the pixels acquired by the second acquisition module;
the first determining submodule is configured to determine that the minimum optical flow velocity value acquired by the first acquiring submodule is a first histogram interval of a1 st personal-face-area optical flow velocity histogram;
the second determining submodule is used for determining the first histogram interval of each face area optical flow velocity histogram according to the fact that the first histogram interval of the next face area optical flow velocity histogram is a preset multiple of the first histogram interval of the adjacent previous face area optical flow velocity histogram;
the third determining submodule is configured to determine each first optical flow velocity value interval in the nth personal face area optical flow velocity histogram according to a first histogram interval corresponding to the nth personal face area optical flow velocity histogram, where N is 1 and 2 … N in sequence;
the second obtaining sub-module is configured to obtain, for each of the first optical flow velocity value intervals determined by the third determining sub-module, a first number of pixels included in the first optical flow velocity value interval in the optical flow velocity values of each pixel in the face area;
the fourth determining submodule is configured to determine the N face area optical flow velocity histograms according to each of the first optical flow velocity value intervals and the first number of pixels corresponding to each of the first optical flow velocity value intervals;
the fifth determining submodule is configured to determine that the minimum optical flow velocity value acquired by the first acquiring submodule is a second histogram interval of a1 st non-human-face area optical flow velocity histogram;
the sixth determining submodule is configured to determine a second histogram interval of each non-face area optical flow velocity histogram according to the preset multiple that a second histogram interval of a subsequent non-face area optical flow velocity histogram is a second histogram interval of an adjacent previous non-face area optical flow velocity histogram;
the seventh determining submodule is configured to determine each second optical flow velocity value interval in the nth non-human face region optical flow velocity histogram according to a second histogram pitch corresponding to the nth non-human face region optical flow velocity histogram, where N is 1 and 2 … N in sequence;
the third obtaining sub-module is configured to obtain, for each second optical flow velocity value interval determined by the seventh determining sub-module, a second number of pixels included in the second optical flow velocity value interval in the optical flow velocity values of the pixels in the non-face area;
the eighth determining submodule is configured to determine the N non-human-face area optical flow velocity histograms according to each of the second optical flow velocity value intervals and a second number of pixels corresponding to each of the second optical flow velocity value intervals.
In one embodiment, the third obtaining module comprises: a fourth obtaining submodule and a fifth obtaining submodule;
the fourth obtaining submodule is used for obtaining the number of new matched pixels in the ith optical flow velocity histogram, wherein i is 1 and 2 … N in sequence; the ith optical flow velocity histogram comprises a face area optical flow velocity histogram and a non-face area optical flow velocity histogram, and a first histogram space corresponding to the face area optical flow velocity histogram is the same as a second histogram space corresponding to the non-face area optical flow velocity histogram;
the fifth obtaining submodule is used for obtaining the average distance between the optical flow velocity histogram of the face area and the optical flow velocity histogram of the non-face area according to the preset weight corresponding to the histogram interval of each pair of optical flow velocity histograms and the number of new matched pixels in each pair of optical flow velocity histograms obtained by the fourth obtaining submodule.
In one embodiment, the fourth obtaining sub-module includes: a sixth obtaining sub-module and a ninth determining sub-module;
the sixth obtaining submodule is used for obtaining the number of matched pixels in the ith-1 pair of light flow velocity histogram and the number of matched pixels in the ith pair of light flow velocity histogram;
the ninth determining sub-module is configured to determine that a difference between the number of matched pixels in the ith light flow velocity histogram and the number of matched pixels in the ith-1 light flow velocity histogram, which is obtained by the sixth obtaining sub-module, is a new number of matched pixels in the ith light flow velocity histogram.
In one embodiment, the sixth obtaining sub-module includes: a seventh obtaining sub-module, an eighth obtaining sub-module, a tenth determining sub-module and an eleventh determining sub-module;
the seventh obtaining submodule is used for obtaining a third pixel value corresponding to the interval distance of a jth first optical flow velocity value in a face area optical flow velocity histogram in the ith optical flow velocity histogram;
the eighth obtaining submodule is configured to obtain a fourth pixel value corresponding to an interval pitch of a jth second optical flow velocity value in a non-human face area optical flow velocity histogram in the ith optical flow velocity histogram, where j is 1 and 2 … M in sequence; the M is the number of interval spaces of first optical flow velocity values in a human face area optical flow velocity histogram in the ith optical flow velocity histogram, or the M is the number of interval spaces of second optical flow velocity values in a non-human face area optical flow velocity histogram in the ith optical flow velocity histogram, and the M is an integer greater than or equal to 1;
the tenth determining submodule is configured to determine a minimum value of a third pixel value corresponding to the interval pitch of the jth first optical flow velocity value and a fourth pixel value of the interval pitch of the jth second optical flow velocity value;
and the eleventh determining submodule is used for determining that the sum of the minimum values corresponding to the interval spacing of each optical flow velocity value in the ith optical flow velocity histogram is the number of matched pixels in the ith optical flow velocity histogram.
In one embodiment, the preset weight of the ith-1 th histogram of light flow velocity is greater than the preset weight of the ith histogram of light flow velocity.
In one embodiment, the at least two frames of images of the face to be detected are: and two adjacent frames of images of the face to be detected.
In one embodiment, the apparatus further comprises: a third determination module;
the third determining module is configured to determine that the face to be detected is a living face when the detecting module detects that the average distance is greater than or equal to the preset distance threshold.
According to a third aspect of the embodiments of the present disclosure, there is provided a face recognition apparatus including:
a processor;
a memory for storing processor-executable instructions;
wherein the processor is configured to:
acquiring at least two frames of images containing a face to be detected;
acquiring a dense optical flow graph according to the at least two frames of images, wherein the dense optical flow graph comprises optical flow velocity values of each pixel of any one frame of image in the two frames of images;
determining N face area optical flow velocity histograms and N non-face area optical flow velocity histograms according to the optical flow velocity value of each pixel; the histogram intervals of the optical flow velocity histograms of the face areas are different, and the histogram intervals of the optical flow velocity histograms of the non-face areas are different; n is an integer greater than or equal to 2;
acquiring the average distance between the face area optical flow velocity histogram and the non-face area optical flow velocity histogram according to the N face area optical flow velocity histograms, the N non-face area optical flow velocity histograms and the preset weight value corresponding to each histogram interval;
and when the average distance is smaller than a preset distance threshold value, determining that the face to be detected is a false face.
According to a fourth aspect of embodiments of the present disclosure, there is provided a computer readable storage medium having stored thereon computer instructions which, when executed by a processor, implement the method steps of any one of the first aspect.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and together with the description, serve to explain the principles of the disclosure.
FIG. 1 is a flow diagram illustrating a face recognition method according to an example embodiment.
Fig. 2 is a histogram diagram shown in accordance with an example embodiment.
Fig. 3 is a flowchart illustrating a face recognition method according to an exemplary embodiment.
FIG. 4 is a block diagram illustrating a face recognition apparatus according to an example embodiment.
Fig. 5 is a block diagram illustrating the first determination module 12 in a face recognition apparatus according to an exemplary embodiment.
Fig. 6 is a block diagram illustrating the second obtaining module 13 in the face recognition apparatus according to an exemplary embodiment.
Fig. 7 is a block diagram illustrating a fourth obtaining sub-module 131 in the face recognition apparatus according to an exemplary embodiment.
Fig. 8 is a block diagram illustrating a sixth obtaining sub-module 1311 in a face recognition apparatus according to an example embodiment.
Fig. 9 is a block diagram illustrating a face recognition apparatus according to an exemplary embodiment.
Fig. 10 is a block diagram illustrating a face recognition apparatus 80 according to an exemplary embodiment.
Fig. 11 is a block diagram illustrating an apparatus 90 for face recognition according to an example embodiment.
Detailed Description
Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the exemplary embodiments below are not intended to represent all implementations consistent with the present disclosure. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present disclosure, as detailed in the appended claims.
In the mechanism for completing identity recognition through the face in the video to be detected, if a living face appears in the video shot by the shooting lens, the speed of the optical flow of the pixels in the face area is different from the speed of the optical flow of the pixels in the non-face (background) area. The optical flow velocity is generally high for human face areas and low for non-human face areas. However, in the case of a prosthetic face, the optical flow velocities are generally the same for both face and non-face regions. Therefore, false body attack can be identified by comparing the statistical information of the optical flow velocity of the human face area and the non-human face area.
It is noted that the face recognition method provided by the embodiment of the present disclosure may be applied to a terminal device or a server. Wherein, the terminal device includes but is not limited to: the mobile phone, the tablet computer, the intelligent wearable device and the like. The server includes, but is not limited to, a device providing a computing service provided and used by a face recognition service operator, and may also provide a device providing a computing service used by a face recognition service operator for a network operator. In order to more clearly explain the scheme of the present disclosure, the following embodiments are described with a terminal device as an execution subject.
Fig. 1 is a flowchart illustrating a face recognition method according to an exemplary embodiment, as shown in fig. 1, the method includes the following steps S101 to S105:
in step S101, at least two frames of images including a face to be detected are acquired.
Illustratively, the at least two frames of images of the face to be detected are two adjacent frames of images of the face to be detected.
In step S102, a dense optical flow map is acquired from at least two frames of images, the dense optical flow map including optical flow velocity values of respective pixels of any one of the two frames of images.
The at least two frames of images of the face to be detected may be read from a video stored in the terminal device in advance, or may be captured by a capturing device on the terminal device, or may be transmitted by receiving other devices or systems.
The optical flow velocity value of a pixel is used for indicating the moving distance of the pixel from the previous frame image to the next frame image in two adjacent frame images.
According to the previous frame image and the current frame image in the two frames of images, a dense optical flow graph can be calculated, and the dense optical flow graph represents the magnitude and the direction of the movement speed of each pixel in one image. Only the magnitude of the motion velocity of the pixel (optical flow velocity value) is used in the present disclosure, and the direction information is not considered. The optical flow velocity value for each pixel can be obtained from the dense optical flow map.
In step S103, N face area optical flow velocity histograms and N non-face area optical flow velocity histograms are determined from the optical flow velocity values of the respective pixels; the histogram intervals of the optical flow velocity histograms of the face areas are different, and the histogram intervals of the optical flow velocity histograms of the non-face areas are different; n is an integer of 2 or more.
For example, the face recognition may be performed on the image of the current frame according to the AdaBoost algorithm, so as to detect a face region in the image of the current frame, where the face region is represented by a rectangular frame. And then after obtaining the optical flow velocity value of each pixel, determining the optical flow velocity value of each pixel in the face area by combining the recognized face area, further determining N optical flow velocity histograms of the face area according to the optical flow velocity value of each pixel in the face area, simultaneously determining the optical flow velocity value of each pixel in the non-face area by combining the recognized face area, further determining N optical flow velocity histograms of the non-face area according to the optical flow velocity value of each pixel in the non-face area, wherein the determined optical flow velocity histograms of the face area and the non-face area have the same number.
By setting different histogram intervals, the distribution of the luminous flux velocity values can be reflected more comprehensively.
In step S104, an average distance between the face area optical flow velocity histogram and the non-face area optical flow velocity histogram is obtained according to the N face area optical flow velocity histograms and the N non-face area optical flow velocity histograms and the preset weight corresponding to each histogram interval.
In step S105, when the detected average distance is smaller than the preset distance threshold, it is determined that the face to be detected is a prosthetic face.
In one embodiment, the method further comprises: and when the detected average distance is larger than or equal to the preset distance threshold value, determining that the face in the face video to be detected is a living body face.
It should be noted that the above-mentioned living human face may be understood as the human face to be detected is obtained by photographing a human face of a live human being, and is not obtained by photographing a photograph or an image including the human face, which may be understood as a false human face.
The preset distance threshold may be stored in the terminal device in advance, or may be obtained by the terminal device from other apparatuses or systems, which is not limited in this disclosure.
In the disclosure, a human face area optical flow velocity histogram and a non-human face area optical flow velocity histogram are constructed by setting different histogram pitches, the constructed histogram of the optical flow velocity of the face area can comprehensively reflect the distribution of the optical flow velocity values of the face area, the constructed histogram of the optical flow velocity of the non-face area can also comprehensively reflect the distribution of the optical flow velocity values of the non-face area, and when calculating the average distance between the histogram of the optical flow velocity of the face area and the histogram of the optical flow velocity of the non-face area, setting a preset weight for each histogram interval, thereby embodying the proportion of the distance between the human face area optical flow velocity histogram and the non-human face area optical flow velocity histogram corresponding to different histogram pitches in the finally calculated average distance value, therefore, the calculated average distance value can be more accurate, and the accuracy of face recognition is improved.
The technical scheme provided by the embodiment of the disclosure can have the following beneficial effects: acquiring at least two frames of images containing a face to be detected, and acquiring a dense optical flow graph according to the at least two frames of images, wherein the dense optical flow graph comprises optical flow velocity values of each pixel of any one frame of image in the two frames of images; determining N face area optical flow velocity histograms and N non-face area optical flow velocity histograms according to the optical flow velocity value of each pixel; the histogram intervals of the optical flow velocity histograms of the face areas are different, and the histogram intervals of the optical flow velocity histograms of the non-face areas are different; n is an integer greater than or equal to 2; acquiring the average distance between the face area optical flow velocity histogram and the non-face area optical flow velocity histogram according to the N face area optical flow velocity histograms, the N non-face area optical flow velocity histograms and the preset weight corresponding to each histogram interval; and when the detected average distance is smaller than the preset distance threshold value, determining the face to be detected as the false face. By the method, the calculated distance value can be more accurate, and the accuracy of face recognition is improved.
In one embodiment, the determination of the N face area optical flow velocity histograms from the optical flow velocity values of the respective pixels in the above step S102 may be implemented as the following steps a1-a 6:
in a1, the minimum optical-flow velocity value among the optical-flow velocity values of the respective pixels is acquired.
In a2, the minimum optical flow velocity value is determined to be the first histogram interval of the 1 st face region optical flow velocity histogram.
At a3, a first histogram spacing of each face region optical flow velocity histogram is determined according to a preset multiple of the first histogram spacing of the subsequent face region optical flow velocity histogram to the first histogram spacing of the adjacent previous face region optical flow velocity histogram.
In a4, each first optical-flow velocity value section in the N-th personal-face-region optical-flow velocity histogram is determined from the first histogram pitch corresponding to the N-th personal-face-region optical-flow velocity histogram, and N sequentially takes 1 and 2 … N.
The initial values of the first optical flow velocity value intervals in the optical flow velocity histograms of the face areas may be different or the same, and the disclosure does not limit the initial values.
In a5, the first number of pixels included in the first optical-flow velocity value section among the optical-flow velocity values of the respective pixels in the face area is acquired for each first optical-flow velocity value section.
In a6, N face region optical flow velocity histograms are determined from each first optical flow velocity value interval and the first number of pixels corresponding to each first optical flow velocity value interval.
As shown in fig. 2, after obtaining the optical flow velocity values of the pixels, assuming that the minimum optical flow value among the optical flow velocity values is 1, assuming that the preset multiple is 2, and constructing a 3-person face area optical flow velocity histogram, after obtaining the minimum optical flow value 1, taking 1 as the first histogram interval of the 1 st person face area optical flow velocity histogram, since the preset multiple is 2, the first histogram interval of the 2 nd person face area optical flow velocity histogram is 2 times the first histogram interval of the 1 st person face area optical flow velocity histogram, at this time, the first histogram interval of the 2 nd person face area optical flow velocity histogram is 2; the first histogram interval of the 3 rd face area optical flow velocity histogram is 2 times of the first histogram interval of the 2 nd face area optical flow velocity histogram, and at this time, the first histogram interval of the 3 rd face area optical flow velocity histogram is 4; assuming that the first optical flow velocity value interval of the 1 st personal face area optical flow velocity histogram is 0 as the initial value of optical flow velocity, the first optical flow velocity value intervals in the 1 st personal face area optical flow velocity histogram are (0, 1), (1, 2), (2, 3), (3, 4), (4, 5), respectively; after obtaining each first optical flow velocity value interval, a first pixel quantity value included in (0, 1) is determined from the optical flow velocity values of each pixel in the face area, for example: 0.5, 0.6; similarly, the first pixel number value contained in (1, 2), the first pixel number value contained in (2, 3), the first pixel number value contained in (3, 4) and the first pixel number value contained in (4, 5) are determined from the optical flow velocity values of the pixels in the human face area, and after the first pixel number values are obtained, the optical flow velocity histogram of the 1 st human face area is created by taking (0, 1), (1, 2), (2, 3), (3, 4), (4, 5) as the horizontal axis and the contained pixel number values as the vertical axis; correspondingly, the intervals of the first optical flow velocity values in the 2 nd personal face area optical flow velocity histogram are respectively (0, 2), (2, 4), (4, 6), (6, 8) and (8, 10) based on the initial value of the optical flow velocity in the 1 st personal face area optical flow velocity histogram and the first histogram pitch 2 of the 2 nd personal face area optical flow velocity histogram; similarly, a first pixel number value contained in (0, 2), a first pixel number value contained in (2, 4), a first pixel number value contained in (4, 6), a first pixel number value contained in (6, 8) and a first pixel number value contained in (8, 10) are determined from the optical flow velocity values of the pixels in the face area, and after the first pixel number values are obtained, a2 nd optical flow velocity histogram of the face area is created by taking the first pixel number values as horizontal axes and the contained pixel number values as vertical axes; accordingly, the 3 rd face region optical flow velocity histogram is created in accordance with the above method, by obtaining the intervals of the first optical flow velocity values in the 3 rd face region optical flow velocity histogram as (0, 4), (4, 8), (8, 12), (12, 16), (16, 20) based on the initial value of the optical flow velocity in the 1 st face region optical flow velocity histogram and the first histogram pitch 4 of the 3 rd face region optical flow velocity histogram.
The technical scheme provided by the embodiment of the disclosure can have the following beneficial effects: according to the method and the device, the face area optical flow velocity histogram is determined based on the minimum optical flow velocity value in the optical flow velocity values of the pixels, and the distribution of the optical flow velocity values of the pixels can be comprehensively embodied based on the minimum optical flow value and different histogram pitches are set, so that the constructed face area optical flow velocity histogram is more accurate.
In one embodiment, the determination of the N non-human face area optical flow velocity histograms from the optical flow velocity values of the respective pixels in the above step S102 may be implemented as the following steps B1-B6:
in B1, the minimum optical-flow velocity value among the optical-flow velocity values of the respective pixels is acquired.
In B2, the minimum optical flow velocity value is determined to be the second histogram pitch of the 1 st non-face region optical flow velocity histogram.
In B3, the second histogram spacing of each non-face area optical flow velocity histogram is determined according to the second histogram spacing of the latter non-face area optical flow velocity histogram being a preset multiple of the second histogram spacing of the adjacent former non-face area optical flow velocity histogram.
In B4, each of the second optical flow velocity value intervals in the nth non-human face region optical flow velocity histogram is determined according to the second histogram pitch corresponding to the nth non-human face region optical flow velocity histogram, and N is 1N and 2 … N in this order.
In B5, the second number of pixels included in the second optical-flow velocity value section among the optical-flow velocity values of the respective pixels in the non-human-face area is acquired for each second optical-flow velocity value section.
In B6, N non-face area optical flow velocity histograms are determined from each second optical flow velocity value interval and the second number of pixels corresponding to each second optical flow velocity value interval.
The method for constructing the optical flow velocity histogram of the non-face area in this embodiment is the same as the method for constructing the optical flow velocity histogram of the face area in the above embodiment, and details are not repeated here.
The technical scheme provided by the embodiment of the disclosure can have the following beneficial effects: according to the method and the device, the non-human face area optical flow velocity histogram is determined based on the minimum optical flow value in the optical flow values of all the pixels, and the optical flow value distribution of all the pixels can be comprehensively embodied by setting different interval intervals based on the minimum optical flow value, so that the constructed non-human face area optical flow velocity histogram is more accurate.
Because in the related art, when the distance between two histograms is determined, a user needs to define a histogram interval by himself/herself, if the interval between the histograms is selected improperly, the situation that optical flow value distribution is reflected in each interval of the histograms is not comprehensive enough, and the result of face recognition is not accurate enough.
In one embodiment, the above step S103 may be implemented as the following steps C1-C2:
in C1, acquiring the number of new matched pixels in the ith optical flow velocity histogram, wherein i is 1 and 2 … N in sequence; the ith optical flow velocity histogram comprises a face area optical flow velocity histogram and a non-face area optical flow velocity histogram, and the first histogram space corresponding to the face area optical flow velocity histogram is the same as the second histogram space corresponding to the non-face area optical flow velocity histogram.
If the number of matched pixels in the ith optical flow velocity histogram is used as a parameter for acquiring the distance between the N face area optical flow velocity histograms and the N non-face area optical flow velocity histograms, then, since the number of matched pixels in the ith optical flow velocity histogram and the number of matched pixels in the ith-1 optical flow velocity histogram are overlapped, the number of partial pixels in the acquired distance is repeatedly calculated, and the calculated distance is not accurate enough, in the present disclosure, the new number of matched pixels in each pair of optical flow velocity histograms is used as a parameter for acquiring the distance between the N face area optical flow velocity histograms and the N non-face area optical flow velocity histograms, so that repeated calculation can be avoided, and the accuracy of the calculation result is effectively improved.
In C2, the average distance between the histogram of optical flow velocities of the face region and the histogram of optical flow velocities of the non-face region is obtained according to the preset weight corresponding to the histogram interval of each pair of histograms of optical flow velocities and the number of new matched pixels in each pair of histograms of optical flow velocities.
Illustratively, according to the above embodiments, the constructed N face area optical flow velocity histograms are:
Figure BDA0001502954010000161
wherein H1(y) is the 1 st face region optical flow velocity histogram, H2(y) 2 nd Individual face area optical flowVelocity histogram, HN(y) is the nth face area optical flow velocity histogram; the constructed N non-face area optical flow velocity histograms are as follows:
Figure BDA0001502954010000171
H1(z) is the 1 st histogram of optical flow velocities of non-face regions, H2(z) is the 2 nd histogram of optical flow velocities for non-face regions, HN(z) is the nth non-face area optical flow velocity histogram; according to
Figure BDA0001502954010000172
Acquiring the average distance between the optical flow velocity histogram of the face area and the optical flow velocity histogram of the non-face area; wherein N isiFor the ith number of new matched pixels in the histogram of light flow velocity, wiAnd presetting a weight corresponding to the histogram space of the ith optical flow velocity histogram.
The technical scheme provided by the embodiment of the disclosure can have the following beneficial effects: and setting corresponding preset weights for the histogram space of each pair of optical flow velocity histograms, so that the obtained average distance is more accurate.
The above-described obtaining of the number of new matched pixels in the ith histogram of light flow velocity may be implemented as the following steps D1-D2:
in D1, the number of matched pixels in the ith-1 th light flow velocity histogram and the number of matched pixels in the ith light flow velocity histogram are obtained.
In D2, the difference between the number of matched pixels in the ith light flow velocity histogram and the number of matched pixels in the ith-1 light flow velocity histogram is determined as the new number of matched pixels in the ith light flow velocity histogram.
Illustratively, according to Ni=I[Hi(y),Hi(z)]-I[Hi-1(y),Hi-1(z)]Determining the number of new matched pixels in the ith histogram of light flow velocity, where I [ H ]i(y),Hi(z)]For the ith number of matched pixels in the histogram of light flow velocity, I [ H ]i-1(y),Hi-1(z)]For the matching image in the i-1 th light flow velocity histogramThe number of elements.
In one embodiment, obtaining the number of matched pixels in the ith light flow velocity histogram includes the following steps E1-E4:
in E1, a third pixel value corresponding to the interval pitch of the j-th first optical flow velocity value in the optical flow velocity histogram of the face area in the optical flow velocity histogram of the i-th optical flow velocity histogram is acquired.
In E2, acquiring a fourth pixel value corresponding to the interval pitch of a jth second optical flow velocity value in a non-human face area optical flow velocity histogram in an ith optical flow velocity histogram, wherein j is 1 and 2 … M in sequence; m is the number of interval pitches of first optical flow velocity values in a human face area optical flow velocity histogram in an ith optical flow velocity histogram, or M is the number of interval pitches of second optical flow velocity values in a non-human face area optical flow velocity histogram in the ith optical flow velocity histogram, and M is an integer greater than or equal to 1.
At E3, the minimum value of the third pixel value corresponding to the interval pitch of the jth first optical-flow velocity value interval and the fourth pixel value of the interval pitch of the jth second optical-flow velocity value interval is determined.
In E4, the sum of the minimum values corresponding to the interval spacing of each optical flow velocity value in the ith optical flow velocity histogram is determined as the number of matched pixels in the ith optical flow velocity histogram.
By way of example, according to
Figure BDA0001502954010000181
Determining the number of matched pixels in the ith light flow velocity histogram, where Hi(y)jThe value is a third pixel value corresponding to the interval space of the jth first optical flow velocity value in the optical flow velocity histogram of the face area in the ith optical flow velocity histogram, (H)i(y)j,Hi(z)j) And the fourth pixel value is corresponding to the interval space of the jth second optical flow velocity value in the non-human face area optical flow velocity histogram in the ith optical flow velocity histogram.
In one embodiment, the preset weight of the ith-1 to the histogram of light flow velocities is greater than the preset weight of the ith to the histogram of light flow velocities.
In one implementation, the preset weight of the ith histogram of light flow velocity can be taken as
Figure BDA0001502954010000182
Wherein β is a predetermined multiple in the above embodiment. Assuming β is 2, then
Figure BDA0001502954010000183
Because the histogram interval in the ith-1-th optical flow velocity histogram is smaller than the histogram interval in the ith optical flow velocity histogram, the distribution relation of optical flow values of each pixel can be more comprehensively reflected by the ith-1-th optical flow velocity histogram, so that the weight occupied by the distance between the ith-1-th optical flow velocity histogram and the finally acquired distance between the N face area optical flow velocity histograms and the N non-face area optical flow velocity histograms is larger, and the preset weight of the ith-1-th optical flow velocity histogram is set to be larger than the preset weight of the ith optical flow velocity histogram, so that the accuracy of the distance between the acquired N face area optical flow velocity histograms and the acquired N non-face area optical flow velocity histograms is improved.
The implementation is described in detail below by way of several embodiments.
Fig. 3 is a flowchart illustrating a face recognition method according to an exemplary embodiment, as shown in fig. 3, including the following steps:
in step S201, at least two frames of images including a face to be detected are acquired.
In step S202, a dense optical flow map is acquired from at least two frames of images, the dense optical flow map including optical flow velocity values of respective pixels of any one of the two frames of images.
For example, the position of a face in a current image frame may be detected according to an AdaBoost algorithm, where the position of the face is represented by a rectangular frame, and if the face is detected, the current image frame is saved and a next image frame is continuously detected, and if the face is not detected, the current image frame is determined not to be a face video to be detected, and the current image frame is discarded and the next image frame is detected.
According to the two frames of images of the previous frame image and the current frame image containing the face image, a dense light flow graph can be calculated, and the light flow velocity value of each pixel can be acquired according to the dense light flow graph.
In step S203, the minimum optical-flow velocity value among the optical-flow velocity values of the respective pixels is determined.
In step S204, N face region optical flow velocity histograms are determined from the optical flow velocity values of the respective pixels
Figure BDA0001502954010000191
Wherein H1(y) is the 1 st face region optical flow velocity histogram, H2(y) is the 2 nd histogram of optical flow velocities for the face region, HN(y) is the nth face region optical flow velocity histogram.
Determining the minimum optical flow velocity value as the 1 st individual face area optical flow velocity histogram H1(y) first histogram spacing a1
According to ai=2ai-1Determining a first histogram interval of the optical flow velocity histogram of each face region, wherein aiFor the ith personal face region, the optical flow velocity histogram Hi(y) first histogram spacing ai;ai-1For the i-1 st face area, the optical flow velocity histogram Hi-1(y) first histogram spacing ai-1. And i takes 2 and 3 … N in sequence.
According to aiDetermining each first optical-flow velocity value interval in the ith personal-face-area optical-flow velocity histogram.
And acquiring the first pixel number contained in the first optical flow velocity value section in the optical flow velocity values of the pixels in the human face area for each first optical flow velocity value section.
And determining N face area optical flow velocity histograms according to each first optical flow velocity value interval and the first pixel number corresponding to each first optical flow velocity value interval.
In step S205, N non-human face area optical flow velocity histograms are determined according to the optical flow velocity value of each pixelDrawing (A)
Figure BDA0001502954010000201
H1(z) is the 1 st histogram of optical flow velocities of non-face regions, H2(z) is the 2 nd histogram of optical flow velocities for non-face regions, HN(z) is the Nth non-face area optical flow velocity histogram.
Determining the minimum optical flow velocity value as the 1 st non-face area optical flow velocity histogram H1(z) second histogram interval b1
According to bi=2bi-1Determining a second histogram interval of the optical flow velocity histogram of each non-face region, wherein biIs the ith non-face area optical flow velocity histogram Hi(z) second histogram interval bi;bi-1Is the i-1 st non-face area optical flow velocity histogram Hi-1(z) second histogram interval bi-1. And i takes 2 and 3 … N in sequence.
According to biAnd determining each second optical flow velocity value interval in the ith non-human face area optical flow velocity histogram.
For each second optical flow velocity value interval, acquiring the number of second pixels contained in the second optical flow velocity value interval in the optical flow velocity values of all pixels in the non-human face area;
and determining N non-human face area optical flow velocity histograms according to each second optical flow velocity value interval and the second pixel number corresponding to each second optical flow velocity value interval.
In step S206, according to
Figure BDA0001502954010000202
Determining the number of matched pixels in the ith light flow velocity histogram, where Hi(y)jThe value is a third pixel value corresponding to the interval space of the jth first optical flow velocity value in the optical flow velocity histogram of the face area in the ith optical flow velocity histogram, (H)i(y)j,Hi(z)j) For the ith second optical flow velocity value in the non-human face area optical flow velocity histogram in the optical flow velocity histogramAnd fourth pixel values corresponding to the interval pitches.
In step S207, according to Ni=I[Hi(y),Hi(z)]-I[Hi-1(y),Hi-1(z)]Determining the number of new matched pixels in the ith histogram of light flow velocity, where I [ H ]i(y),Hi(z)]For the ith number of matched pixels in the histogram of light flow velocity, I [ H ]i-1(y),Hi-1(z)]Is the number of matched pixels in the i-1 th histogram of light flow velocity.
In step S208, according to
Figure BDA0001502954010000211
Acquiring the average distance between the optical flow velocity histogram of the face area and the optical flow velocity histogram of the non-face area; wherein N isiFor the ith number of new matched pixels in the histogram of light flow velocity, wiAnd presetting a weight corresponding to the histogram space of the ith optical flow velocity histogram.
In step S209, when detecting
Figure BDA0001502954010000212
When the distance is larger than or equal to a preset distance threshold value, determining that the face in the face video to be detected is a living body face;
when detecting that
Figure BDA0001502954010000213
And when the distance is smaller than the preset distance threshold, determining the face in the face video to be detected as a false face.
The following are embodiments of the disclosed apparatus that may be used to perform embodiments of the disclosed methods.
Fig. 4 is a block diagram illustrating a face recognition apparatus according to an example embodiment. As shown in fig. 4, the face recognition apparatus includes:
the first obtaining module 11 is configured to obtain at least two frames of images including a face to be detected.
A second obtaining module 12, configured to obtain a dense optical flow map according to the at least two frames of images obtained by the first obtaining module 11, where the dense optical flow map includes optical flow velocity values of each pixel of any one of the two frames of images;
a first determining module 13, configured to determine N histograms of optical flow velocities of human face areas and N histograms of optical flow velocities of non-human face areas according to the optical flow velocity values of the pixels acquired by the second acquiring module 12; the histogram intervals of the optical flow velocity histograms of the face areas are different, and the histogram intervals of the optical flow velocity histograms of the non-face areas are different; n is an integer greater than or equal to 2;
a third obtaining module 14, configured to obtain an average distance between the face area optical flow velocity histogram and the non-face area optical flow velocity histogram according to the N face area optical flow velocity histograms and the N non-face area optical flow velocity histograms determined by the first determining module 13 and a preset weight corresponding to each histogram interval;
a detection module 15, configured to detect whether an average distance between the face area optical flow velocity histogram and the non-face area optical flow velocity histogram acquired by the third acquisition module 14 is smaller than a preset distance threshold;
a second determining module 16, configured to determine that the face to be detected is a prosthetic face when the detecting module 15 detects that the average distance is smaller than the preset distance threshold.
In one embodiment, as shown in fig. 5, the first determining module 13 includes: a first acquisition sub-module 131, a first determination sub-module 132, a second determination sub-module 133, a third determination sub-module 134, a second acquisition sub-module 135, a fourth determination sub-module 136, a fifth determination sub-module 137, a sixth determination sub-module 138, a seventh determination sub-module 139, a third acquisition sub-module 1310, and an eighth determination sub-module 1311;
the first obtaining sub-module 131 is configured to obtain a minimum optical flow velocity value among the optical flow velocity values of the pixels obtained by the second obtaining module 12;
the first determining submodule 132 is configured to determine that the minimum optical flow velocity value acquired by the first acquiring submodule 131 is a first histogram interval of a1 st face area optical flow velocity histogram;
the second determining submodule 133 is configured to determine a first histogram interval of each face area optical flow velocity histogram according to that the first histogram interval of the subsequent face area optical flow velocity histogram is a preset multiple of the first histogram interval of the adjacent previous face area optical flow velocity histogram;
the third determining submodule 134 is configured to determine, according to a first histogram interval corresponding to an nth personal-face-region optical flow velocity histogram, each first optical flow velocity value interval in the nth personal-face-region optical flow velocity histogram, where N is 1 and 2 … N in sequence;
the second obtaining sub-module 135 is configured to obtain, for each of the first optical flow velocity value intervals determined by the third determining sub-module 134, a first number of pixels included in the first optical flow velocity value interval in the optical flow velocity values of the pixels in the face area;
the fourth determining submodule 136 is configured to determine the N face area optical flow velocity histograms according to each of the first optical flow velocity value intervals and the first number of pixels corresponding to each of the first optical flow velocity value intervals;
the fifth determining submodule 137 is configured to determine that the minimum optical flow velocity value acquired by the second acquiring submodule 12 is a second histogram pitch of a1 st non-human face area optical flow velocity histogram;
the sixth determining submodule 138 is configured to determine a second histogram interval of each non-face area optical flow velocity histogram according to that the second histogram interval of the subsequent non-face area optical flow velocity histogram is the preset multiple of the second histogram interval of the adjacent previous non-face area optical flow velocity histogram;
the seventh determining submodule 139 is configured to determine each second optical flow velocity value interval in the nth non-human face region optical flow velocity histogram according to a second histogram interval corresponding to the nth non-human face region optical flow velocity histogram, where N is 1 and 2 … N in sequence;
the third obtaining sub-module 1310 is configured to obtain, for each of the second optical flow velocity value intervals determined by the seventh determining sub-module 139, a second number of pixels included in the second optical flow velocity value interval in the optical flow velocity values of the pixels in the non-human face area;
the eighth determining submodule 1311 is configured to determine the N non-human-face area optical flow velocity histograms according to each of the second optical flow velocity value intervals and the second number of pixels corresponding to each of the second optical flow velocity value intervals.
In one embodiment, as shown in fig. 6, the third obtaining module 14 includes: a fourth acquisition submodule 141 and a fifth acquisition submodule 142;
the fourth obtaining submodule 141 is configured to obtain the number of new matched pixels in the ith optical flow velocity histogram, where i is 1 and 2 … N in sequence; the ith optical flow velocity histogram comprises a face area optical flow velocity histogram and a non-face area optical flow velocity histogram, and a first histogram space corresponding to the face area optical flow velocity histogram is the same as a second histogram space corresponding to the non-face area optical flow velocity histogram;
the fifth obtaining sub-module 142 is configured to obtain distances between the N face area optical flow velocity histograms and the N non-face area optical flow velocity histograms according to a preset weight corresponding to a histogram interval of each pair of optical flow velocity histograms and the number of new matched pixels in each pair of optical flow velocity histograms obtained by the fourth obtaining sub-module 141.
In one embodiment, as shown in fig. 7, the fourth obtaining submodule 141 includes: a sixth obtaining sub-module 1411 and a ninth determining sub-module 1412;
the sixth obtaining sub-module 1411 is configured to obtain the number of matched pixels in the ith-1 pair light flow velocity histogram and the number of matched pixels in the ith pair light flow velocity histogram;
the ninth determining sub-module 1412 is configured to determine that the difference between the number of matched pixels in the ith light flow velocity histogram and the number of matched pixels in the ith-1 light flow velocity histogram acquired by the sixth acquiring sub-module 1411 is the new number of matched pixels in the ith light flow velocity histogram.
In one embodiment, as shown in fig. 8, the sixth obtaining sub-module 1411 includes: a seventh acquisition submodule a1, an eighth acquisition submodule a2, a tenth determination submodule a3 and an eleventh determination submodule a 4;
the seventh obtaining submodule a1 is configured to obtain a third pixel value corresponding to an interval pitch of a jth first optical flow velocity value in a face area optical flow velocity histogram in the ith optical flow velocity histogram;
the eighth obtaining submodule a2 is configured to obtain a fourth pixel value corresponding to an interval pitch of a jth second optical flow velocity value in a non-human face area optical flow velocity histogram in the ith optical flow velocity histogram, where j sequentially takes 1 and 2 … M; the M is the number of interval spaces of first optical flow velocity values in a human face area optical flow velocity histogram in the ith optical flow velocity histogram, or the M is the number of interval spaces of second optical flow velocity values in a non-human face area optical flow velocity histogram in the ith optical flow velocity histogram, and the M is an integer greater than or equal to 1;
the tenth determining submodule a3 is configured to determine a minimum value of a third pixel value corresponding to the interval pitch of the jth first optical flow velocity value and a fourth pixel value of the interval pitch of the jth second optical flow velocity value;
the eleventh determining submodule a4 is configured to determine that the sum of minimum values corresponding to the interval spacing of each optical flow velocity value in the ith optical flow velocity histogram is the number of matched pixels in the ith optical flow velocity histogram.
In one embodiment, the preset weight of the ith-1 th histogram of light flow velocity is greater than the preset weight of the ith histogram of light flow velocity.
In one embodiment, the at least two frames of images of the face to be detected are: and two adjacent frames of images of the face to be detected.
In one embodiment, as shown in fig. 9, the apparatus further comprises: a third determination module 17;
the third determining module 17 is configured to determine that the face to be detected is a living face when the detecting module 15 detects that the average distance is greater than or equal to the preset distance threshold.
According to a third aspect of the embodiments of the present disclosure, there is provided a face recognition apparatus including:
a processor;
a memory for storing processor-executable instructions;
wherein the processor is configured to:
acquiring at least two frames of images containing a face to be detected;
acquiring a dense optical flow graph according to the at least two frames of images, wherein the dense optical flow graph comprises optical flow velocity values of each pixel of any one frame of image in the two frames of images;
determining N face area optical flow velocity histograms and N non-face area optical flow velocity histograms according to the optical flow velocity value of each pixel; the histogram intervals of the optical flow velocity histograms of the face areas are different, and the histogram intervals of the optical flow velocity histograms of the non-face areas are different; n is an integer greater than or equal to 2;
acquiring the average distance between the face area optical flow velocity histogram and the non-face area optical flow velocity histogram according to the N face area optical flow velocity histograms, the N non-face area optical flow velocity histograms and the preset weight value corresponding to each histogram interval;
and when the average distance is smaller than a preset distance threshold value, determining that the face to be detected is a false face.
The processor may be further configured to:
the method for determining N face area optical flow velocity histograms and N non-face area optical flow velocity histograms according to the optical flow velocity value of each pixel comprises the following steps:
acquiring a minimum optical flow velocity value in optical flow velocity values of each pixel;
determining the minimum optical flow velocity value as a first histogram interval of a1 st personal area optical flow velocity histogram;
determining a first histogram interval of each face area optical flow velocity histogram according to a preset multiple of the first histogram interval of the latter face area optical flow velocity histogram as the first histogram interval of the adjacent former face area optical flow velocity histogram;
determining each first optical flow velocity value interval in an nth personal face area optical flow velocity histogram according to a first histogram interval corresponding to the nth personal face area optical flow velocity histogram, wherein N is 1 and 2 … N in sequence;
for each first optical flow velocity value interval, acquiring the first pixel number contained in the first optical flow velocity value interval in the optical flow velocity values of the pixels in the face area;
determining the optical flow velocity histograms of the N human face areas according to each first optical flow velocity value interval and the first pixel number corresponding to each first optical flow velocity value interval;
determining that the minimum optical flow velocity value is a second histogram interval of a1 st non-human face area optical flow velocity histogram;
determining a second histogram interval of each non-face area optical flow velocity histogram according to the preset multiple that a second histogram interval of a latter non-face area optical flow velocity histogram is a second histogram interval of an adjacent former non-face area optical flow velocity histogram;
determining each second optical flow velocity value interval in the nth non-human face area optical flow velocity histogram according to a second histogram interval corresponding to the nth non-human face area optical flow velocity histogram, wherein N is 1 and 2 … N in sequence;
for each second optical flow velocity value interval, acquiring the number of second pixels contained in the second optical flow velocity value interval in the optical flow velocity values of the pixels in the non-human face area;
and determining the N non-human face area optical flow velocity histograms according to each second optical flow velocity value interval and the second pixel number corresponding to each second optical flow velocity value interval.
The obtaining of the average distance between the face area optical flow velocity histogram and the non-face area optical flow velocity histogram according to the N face area optical flow velocity histograms, the N non-face area optical flow velocity histograms, and the preset weight corresponding to each histogram interval includes:
acquiring the number of new matched pixels in the ith optical flow velocity histogram, wherein i is 1 and 2 … N in sequence; the ith optical flow velocity histogram comprises a face area optical flow velocity histogram and a non-face area optical flow velocity histogram, and a first histogram space corresponding to the face area optical flow velocity histogram is the same as a second histogram space corresponding to the non-face area optical flow velocity histogram;
and acquiring the average distance between the human face area optical flow velocity histogram and the non-human face area optical flow velocity histogram according to the preset weight corresponding to the histogram interval of each pair of optical flow velocity histograms and the number of new matched pixels in each pair of optical flow velocity histograms.
The obtaining of the number of new matched pixels in the ith light flow velocity histogram includes:
acquiring the number of matched pixels in the ith-1 pair light flow velocity histogram and the number of matched pixels in the ith pair light flow velocity histogram;
and determining the difference value of the number of matched pixels in the ith light flow velocity histogram and the number of matched pixels in the ith-1 light flow velocity histogram as the new number of matched pixels in the ith light flow velocity histogram.
The obtaining the number of matched pixels in the ith light flow velocity histogram comprises the following steps:
acquiring a third pixel value corresponding to the interval distance of a jth first optical flow velocity value in a face area optical flow velocity histogram in the ith optical flow velocity histogram;
acquiring a fourth pixel value corresponding to the interval distance of a jth second optical flow velocity value in a non-human face area optical flow velocity histogram in the ith optical flow velocity histogram, wherein j is 1 and 2 … M in sequence; the M is the number of interval spaces of first optical flow velocity values in a human face area optical flow velocity histogram in the ith optical flow velocity histogram, or the M is the number of interval spaces of second optical flow velocity values in a non-human face area optical flow velocity histogram in the ith optical flow velocity histogram, and the M is an integer greater than or equal to 1;
determining the minimum value of a third pixel value corresponding to the interval pitch of the jth first optical flow velocity value interval and a fourth pixel value of the interval pitch of the jth second optical flow velocity value interval;
and determining the sum of the minimum values corresponding to the interval spacing of each optical flow velocity value in the ith optical flow velocity histogram as the number of matched pixels in the ith optical flow velocity histogram.
The preset weight value of the ith-1 to the light flow velocity histogram is larger than the preset weight value of the ith to the light flow velocity histogram.
The at least two frame images of the face to be detected are as follows: and two adjacent frames of images of the face to be detected.
The method further comprises the following steps:
and when the average distance is detected to be larger than or equal to the preset distance threshold, determining that the face to be detected is a living face.
With regard to the apparatus in the above-described embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment related to the method, and will not be elaborated here.
Fig. 10 is a block diagram illustrating a face recognition apparatus 80, which is suitable for a terminal device, according to an exemplary embodiment. For example, the apparatus 80 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, an exercise device, a personal digital assistant, and the like.
The apparatus 80 may include one or more of the following components: processing component 802, memory 804, power component 806, multimedia component 808, audio component 810, input/output (I/O) interface 812, sensor component 814, and communication component 816.
The processing component 802 generally controls overall operation of the device 80, such as operations associated with display, telephone calls, data communications, camera operations, and recording operations. The processing components 802 may include one or more processors 820 to execute instructions to perform all or a portion of the steps of the methods described above. Further, the processing component 802 can include one or more modules that facilitate interaction between the processing component 802 and other components. For example, the processing component 802 can include a multimedia module to facilitate interaction between the multimedia component 808 and the processing component 802.
The memory 804 is configured to store various types of data to support operations at the apparatus 80. Examples of such data include instructions for any application or method operating on the device 80, contact data, phonebook data, messages, pictures, videos, and so forth. The memory 804 may be implemented by any type or combination of volatile or non-volatile memory devices such as Static Random Access Memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic or optical disks.
The power supply component 806 provides power to the various components of the device 80. The power components 806 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for the device 80.
The multimedia component 808 includes a screen that provides an output interface between the device 80 and the user. In some embodiments, the screen may include a Liquid Crystal Display (LCD) and a Touch Panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive an input signal from a user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundary of a touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 808 includes a front facing camera and/or a rear facing camera. The front camera and/or the rear camera may receive external multimedia data when the device 80 is in an operating mode, such as a shooting mode or a video mode. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
The audio component 810 is configured to output and/or input audio signals. For example, the audio component 810 includes a Microphone (MIC) configured to receive external audio signals when the apparatus 80 is in an operating mode, such as a call mode, a recording mode, and a voice recognition mode. The received audio signals may further be stored in the memory 804 or transmitted via the communication component 816. In some embodiments, audio component 810 also includes a speaker for outputting audio signals.
The I/O interface 812 provides an interface between the processing component 802 and peripheral interface modules, which may be keyboards, click wheels, buttons, etc. These buttons may include, but are not limited to: a home button, a volume button, a start button, and a lock button.
The sensor assembly 814 includes one or more sensors for providing various aspects of state assessment for the device 80. For example, the sensor assembly 814 may detect the open/closed status of the device 80, the relative positioning of the components, such as a display and keypad of the device 80, the change in position of the device 80 or a component of the device 80, the presence or absence of user contact with the device 80, the orientation or acceleration/deceleration of the device 80, and the change in temperature of the device 80. Sensor assembly 814 may include a proximity sensor configured to detect the presence of a nearby object without any physical contact. The sensor assembly 814 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 814 may also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
The communication component 816 is configured to facilitate wired or wireless communication between the apparatus 80 and other devices. The device 80 may access a wireless network based on a communication standard, such as WiFi, 2G or 3G, or a combination thereof. In an exemplary embodiment, the communication component 816 receives a broadcast signal or broadcast related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 816 further includes a Near Field Communication (NFC) module to facilitate short-range communications. For example, the NFC module may be implemented based on Radio Frequency Identification (RFID) technology, infrared data association (IrDA) technology, Ultra Wideband (UWB) technology, Bluetooth (BT) technology, and other technologies.
In an exemplary embodiment, the apparatus 80 may be implemented by one or more Application Specific Integrated Circuits (ASICs), Digital Signal Processors (DSPs), Digital Signal Processing Devices (DSPDs), Programmable Logic Devices (PLDs), Field Programmable Gate Arrays (FPGAs), controllers, micro-controllers, microprocessors or other electronic components for performing the above-described methods.
In an exemplary embodiment, a non-transitory computer-readable storage medium comprising instructions, such as the memory 804 comprising instructions, executable by the processor 820 of the apparatus 80 to perform the above-described method is also provided. For example, the non-transitory computer readable storage medium may be a ROM, a Random Access Memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, and the like.
A non-transitory computer readable storage medium, wherein instructions, when executed by a processor of an apparatus 80, enable the apparatus 80 to perform the above-described face recognition method, the method comprising:
acquiring at least two frames of images containing a face to be detected;
acquiring a dense optical flow graph according to the at least two frames of images, wherein the dense optical flow graph comprises optical flow velocity values of each pixel of any one frame of image in the two frames of images;
determining N face area optical flow velocity histograms and N non-face area optical flow velocity histograms according to the optical flow velocity value of each pixel; the histogram intervals of the optical flow velocity histograms of the face areas are different, and the histogram intervals of the optical flow velocity histograms of the non-face areas are different; n is an integer greater than or equal to 2;
acquiring the average distance between the face area optical flow velocity histogram and the non-face area optical flow velocity histogram according to the N face area optical flow velocity histograms, the N non-face area optical flow velocity histograms and the preset weight value corresponding to each histogram interval;
and when the average distance is smaller than a preset distance threshold value, determining that the face to be detected is a false face.
The method for determining N face area optical flow velocity histograms and N non-face area optical flow velocity histograms according to the optical flow velocity value of each pixel comprises the following steps:
acquiring a minimum optical flow velocity value in optical flow velocity values of each pixel;
determining the minimum optical flow velocity value as a first histogram interval of a1 st personal area optical flow velocity histogram;
determining a first histogram interval of each face area optical flow velocity histogram according to a preset multiple of the first histogram interval of the latter face area optical flow velocity histogram as the first histogram interval of the adjacent former face area optical flow velocity histogram;
determining each first optical flow velocity value interval in an nth personal face area optical flow velocity histogram according to a first histogram interval corresponding to the nth personal face area optical flow velocity histogram, wherein N is 1 and 2 … N in sequence;
for each first optical flow velocity value interval, acquiring the first pixel number contained in the first optical flow velocity value interval in the optical flow velocity values of the pixels in the face area;
determining the optical flow velocity histograms of the N human face areas according to each first optical flow velocity value interval and the first pixel number corresponding to each first optical flow velocity value interval;
determining that the minimum optical flow velocity value is a second histogram interval of a1 st non-human face area optical flow velocity histogram;
determining a second histogram interval of each non-face area optical flow velocity histogram according to the preset multiple that a second histogram interval of a latter non-face area optical flow velocity histogram is a second histogram interval of an adjacent former non-face area optical flow velocity histogram;
determining each second optical flow velocity value interval in the nth non-human face area optical flow velocity histogram according to a second histogram interval corresponding to the nth non-human face area optical flow velocity histogram, wherein N is 1 and 2 … N in sequence;
for each second optical flow velocity value interval, acquiring the number of second pixels contained in the second optical flow velocity value interval in the optical flow velocity values of the pixels in the non-human face area;
and determining the N non-human face area optical flow velocity histograms according to each second optical flow velocity value interval and the second pixel number corresponding to each second optical flow velocity value interval.
The obtaining of the average distance between the face area optical flow velocity histogram and the non-face area optical flow velocity histogram according to the N face area optical flow velocity histograms, the N non-face area optical flow velocity histograms, and the preset weight corresponding to each histogram interval includes:
acquiring the number of new matched pixels in the ith optical flow velocity histogram, wherein i is 1 and 2 … N in sequence; the ith optical flow velocity histogram comprises a face area optical flow velocity histogram and a non-face area optical flow velocity histogram, and a first histogram space corresponding to the face area optical flow velocity histogram is the same as a second histogram space corresponding to the non-face area optical flow velocity histogram;
and acquiring the average distance between the human face area optical flow velocity histogram and the non-human face area optical flow velocity histogram according to the preset weight corresponding to the histogram interval of each pair of optical flow velocity histograms and the number of new matched pixels in each pair of optical flow velocity histograms.
The obtaining of the number of new matched pixels in the ith light flow velocity histogram includes:
acquiring the number of matched pixels in the ith-1 pair light flow velocity histogram and the number of matched pixels in the ith pair light flow velocity histogram;
and determining the difference value of the number of matched pixels in the ith light flow velocity histogram and the number of matched pixels in the ith-1 light flow velocity histogram as the new number of matched pixels in the ith light flow velocity histogram.
The obtaining the number of matched pixels in the ith light flow velocity histogram comprises the following steps:
acquiring a third pixel value corresponding to the interval distance of a jth first optical flow velocity value in a face area optical flow velocity histogram in the ith optical flow velocity histogram;
acquiring a fourth pixel value corresponding to the interval distance of a jth second optical flow velocity value in a non-human face area optical flow velocity histogram in the ith optical flow velocity histogram, wherein j is 1 and 2 … M in sequence; the M is the number of interval spaces of first optical flow velocity values in a human face area optical flow velocity histogram in the ith optical flow velocity histogram, or the M is the number of interval spaces of second optical flow velocity values in a non-human face area optical flow velocity histogram in the ith optical flow velocity histogram, and the M is an integer greater than or equal to 1;
determining the minimum value of a third pixel value corresponding to the interval pitch of the jth first optical flow velocity value interval and a fourth pixel value of the interval pitch of the jth second optical flow velocity value interval;
and determining the sum of the minimum values corresponding to the interval spacing of each optical flow velocity value in the ith optical flow velocity histogram as the number of matched pixels in the ith optical flow velocity histogram.
The preset weight value of the ith-1 to the light flow velocity histogram is larger than the preset weight value of the ith to the light flow velocity histogram.
The at least two frame images of the face to be detected are as follows: and two adjacent frames of images of the face to be detected.
The method further comprises the following steps:
and when the average distance is detected to be larger than or equal to the preset distance threshold, determining that the face to be detected is a living face.
Fig. 11 is a block diagram illustrating an apparatus 90 for face recognition according to an example embodiment. For example, the apparatus 90 may be provided as a server. The apparatus 90 comprises a processing component 902 further comprising one or more processors, and memory resources, represented by memory 903, for storing instructions, e.g., applications, executable by the processing component 902. The application programs stored in memory 903 may include one or more modules that each correspond to a set of instructions. Further, the processing component 902 is configured to execute instructions to perform the above-described methods.
The apparatus 90 may also include a power component 906 configured to perform power management of the apparatus 90, a wired or wireless network interface 905 configured to connect the apparatus 90 to a network, and an input/output (I/O) interface 908. The apparatus 90 may operate based on an operating system stored in the memory 903, such as Windows Server, Mac OS XTM, UnixTM, LinuxTM, FreeBSDTM, or the like.
A non-transitory computer readable storage medium in which instructions, when executed by a processor of an apparatus 90, enable the apparatus 90 to perform the above-described face recognition method, the method comprising:
acquiring at least two frames of images containing a face to be detected;
acquiring a dense optical flow graph according to the at least two frames of images, wherein the dense optical flow graph comprises optical flow velocity values of each pixel of any one frame of image in the two frames of images;
determining N face area optical flow velocity histograms and N non-face area optical flow velocity histograms according to the optical flow velocity value of each pixel; the histogram intervals of the optical flow velocity histograms of the face areas are different, and the histogram intervals of the optical flow velocity histograms of the non-face areas are different; n is an integer greater than or equal to 2;
acquiring the average distance between the face area optical flow velocity histogram and the non-face area optical flow velocity histogram according to the N face area optical flow velocity histograms, the N non-face area optical flow velocity histograms and the preset weight value corresponding to each histogram interval;
and when the average distance is smaller than a preset distance threshold value, determining that the face to be detected is a false face.
The method for determining N face area optical flow velocity histograms and N non-face area optical flow velocity histograms according to the optical flow velocity value of each pixel comprises the following steps:
acquiring a minimum optical flow velocity value in optical flow velocity values of each pixel;
determining the minimum optical flow velocity value as a first histogram interval of a1 st personal area optical flow velocity histogram;
determining a first histogram interval of each face area optical flow velocity histogram according to a preset multiple of the first histogram interval of the latter face area optical flow velocity histogram as the first histogram interval of the adjacent former face area optical flow velocity histogram;
determining each first optical flow velocity value interval in an nth personal face area optical flow velocity histogram according to a first histogram interval corresponding to the nth personal face area optical flow velocity histogram, wherein N is 1 and 2 … N in sequence;
for each first optical flow velocity value interval, acquiring the first pixel number contained in the first optical flow velocity value interval in the optical flow velocity values of the pixels in the face area;
determining the optical flow velocity histograms of the N human face areas according to each first optical flow velocity value interval and the first pixel number corresponding to each first optical flow velocity value interval;
determining that the minimum optical flow velocity value is a second histogram interval of a1 st non-human face area optical flow velocity histogram;
determining a second histogram interval of each non-face area optical flow velocity histogram according to the preset multiple that a second histogram interval of a latter non-face area optical flow velocity histogram is a second histogram interval of an adjacent former non-face area optical flow velocity histogram;
determining each second optical flow velocity value interval in the nth non-human face area optical flow velocity histogram according to a second histogram interval corresponding to the nth non-human face area optical flow velocity histogram, wherein N is 1 and 2 … N in sequence;
for each second optical flow velocity value interval, acquiring the number of second pixels contained in the second optical flow velocity value interval in the optical flow velocity values of the pixels in the non-human face area;
and determining the N non-human face area optical flow velocity histograms according to each second optical flow velocity value interval and the second pixel number corresponding to each second optical flow velocity value interval.
The obtaining of the average distance between the face area optical flow velocity histogram and the non-face area optical flow velocity histogram according to the N face area optical flow velocity histograms, the N non-face area optical flow velocity histograms, and the preset weight corresponding to each histogram interval includes:
acquiring the number of new matched pixels in the ith optical flow velocity histogram, wherein i is 1 and 2 … N in sequence; the ith optical flow velocity histogram comprises a face area optical flow velocity histogram and a non-face area optical flow velocity histogram, and a first histogram space corresponding to the face area optical flow velocity histogram is the same as a second histogram space corresponding to the non-face area optical flow velocity histogram;
and acquiring the average distance between the human face area optical flow velocity histogram and the non-human face area optical flow velocity histogram according to the preset weight corresponding to the histogram interval of each pair of optical flow velocity histograms and the number of new matched pixels in each pair of optical flow velocity histograms.
The obtaining of the number of new matched pixels in the ith light flow velocity histogram includes:
acquiring the number of matched pixels in the ith-1 pair light flow velocity histogram and the number of matched pixels in the ith pair light flow velocity histogram;
and determining the difference value of the number of matched pixels in the ith light flow velocity histogram and the number of matched pixels in the ith-1 light flow velocity histogram as the new number of matched pixels in the ith light flow velocity histogram.
The obtaining the number of matched pixels in the ith light flow velocity histogram comprises the following steps:
acquiring a third pixel value corresponding to the interval distance of a jth first optical flow velocity value in a face area optical flow velocity histogram in the ith optical flow velocity histogram;
acquiring a fourth pixel value corresponding to the interval distance of a jth second optical flow velocity value in a non-human face area optical flow velocity histogram in the ith optical flow velocity histogram, wherein j is 1 and 2 … M in sequence; the M is the number of interval spaces of first optical flow velocity values in a human face area optical flow velocity histogram in the ith optical flow velocity histogram, or the M is the number of interval spaces of second optical flow velocity values in a non-human face area optical flow velocity histogram in the ith optical flow velocity histogram, and the M is an integer greater than or equal to 1;
determining the minimum value of a third pixel value corresponding to the interval pitch of the jth first optical flow velocity value interval and a fourth pixel value of the interval pitch of the jth second optical flow velocity value interval;
and determining the sum of the minimum values corresponding to the interval spacing of each optical flow velocity value in the ith optical flow velocity histogram as the number of matched pixels in the ith optical flow velocity histogram.
The preset weight value of the ith-1 to the light flow velocity histogram is larger than the preset weight value of the ith to the light flow velocity histogram.
The at least two frame images of the face to be detected are as follows: and two adjacent frames of images of the face to be detected.
The method further comprises the following steps:
and when the average distance is detected to be larger than or equal to the preset distance threshold, determining that the face to be detected is a living face.
Other embodiments of the disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the disclosure disclosed herein. This application is intended to cover any variations, uses, or adaptations of the disclosure following, in general, the principles of the disclosure and including such departures from the present disclosure as come within known or customary practice within the art to which the disclosure pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the disclosure being indicated by the following claims.
It will be understood that the present disclosure is not limited to the precise arrangements described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.

Claims (18)

1. A face recognition method, comprising:
acquiring at least two frames of images containing a face to be detected;
acquiring a dense optical flow graph according to the at least two frames of images, wherein the dense optical flow graph comprises optical flow velocity values of each pixel of any one frame of image in the two frames of images;
determining N face area optical flow velocity histograms and N non-face area optical flow velocity histograms according to the optical flow velocity value of each pixel; the histogram intervals of the optical flow velocity histograms of the face areas are different, and the histogram intervals of the optical flow velocity histograms of the non-face areas are different; n is an integer greater than or equal to 2;
acquiring the average distance between the face area optical flow velocity histogram and the non-face area optical flow velocity histogram according to the N face area optical flow velocity histograms, the N non-face area optical flow velocity histograms and the preset weight value corresponding to each histogram interval;
and when the average distance is smaller than a preset distance threshold value, determining that the face to be detected is a false face.
2. The method according to claim 1, wherein said determining N histograms of optical flow velocities for face regions and N histograms of optical flow velocities for non-face regions from optical flow velocity values for respective pixels comprises:
acquiring a minimum optical flow velocity value in optical flow velocity values of each pixel;
determining the minimum optical flow velocity value as a first histogram interval of a1 st personal area optical flow velocity histogram;
determining a first histogram interval of each face area optical flow velocity histogram according to a preset multiple of the first histogram interval of the latter face area optical flow velocity histogram as the first histogram interval of the adjacent former face area optical flow velocity histogram;
determining each first optical flow velocity value interval in an nth personal face area optical flow velocity histogram according to a first histogram interval corresponding to the nth personal face area optical flow velocity histogram, wherein N is 1 and 2 … N in sequence;
for each first optical flow velocity value interval, acquiring the first pixel number contained in the first optical flow velocity value interval in the optical flow velocity values of the pixels in the face area;
determining the optical flow velocity histograms of the N human face areas according to each first optical flow velocity value interval and the first pixel number corresponding to each first optical flow velocity value interval;
determining that the minimum optical flow velocity value is a second histogram interval of a1 st non-human face area optical flow velocity histogram;
determining a second histogram interval of each non-face area optical flow velocity histogram according to the preset multiple that a second histogram interval of a latter non-face area optical flow velocity histogram is a second histogram interval of an adjacent former non-face area optical flow velocity histogram;
determining each second optical flow velocity value interval in the nth non-human face area optical flow velocity histogram according to a second histogram interval corresponding to the nth non-human face area optical flow velocity histogram, wherein N is 1 and 2 … N in sequence;
for each second optical flow velocity value interval, acquiring the number of second pixels contained in the second optical flow velocity value interval in the optical flow velocity values of the pixels in the non-human face area;
and determining the N non-human face area optical flow velocity histograms according to each second optical flow velocity value interval and the second pixel number corresponding to each second optical flow velocity value interval.
3. The method according to claim 1, wherein the obtaining the average distance between the face area optical flow velocity histogram and the non-face area optical flow velocity histogram according to the N face area optical flow velocity histograms and the N non-face area optical flow velocity histograms and the preset weight corresponding to each histogram interval comprises:
acquiring the number of new matched pixels in the ith optical flow velocity histogram, wherein i is 1 and 2 … N in sequence; the ith optical flow velocity histogram comprises a face area optical flow velocity histogram and a non-face area optical flow velocity histogram, and a first histogram space corresponding to the face area optical flow velocity histogram is the same as a second histogram space corresponding to the non-face area optical flow velocity histogram;
and acquiring the average distance between the human face area optical flow velocity histogram and the non-human face area optical flow velocity histogram according to the preset weight corresponding to the histogram interval of each pair of optical flow velocity histograms and the number of new matched pixels in each pair of optical flow velocity histograms.
4. The method of claim 3, wherein obtaining the number of new matched pixels in the ith histogram of light flow velocity comprises:
acquiring the number of matched pixels in the ith-1 pair light flow velocity histogram and the number of matched pixels in the ith pair light flow velocity histogram;
and determining the difference value of the number of matched pixels in the ith light flow velocity histogram and the number of matched pixels in the ith-1 light flow velocity histogram as the new number of matched pixels in the ith light flow velocity histogram.
5. The method of claim 4, wherein obtaining the number of matched pixels in the ith histogram of light flow velocity comprises:
acquiring a third pixel value corresponding to the interval distance of a jth first optical flow velocity value in a face area optical flow velocity histogram in the ith optical flow velocity histogram;
acquiring a fourth pixel value corresponding to the interval distance of a jth second optical flow velocity value in a non-human face area optical flow velocity histogram in the ith optical flow velocity histogram, wherein j is 1 and 2 … M in sequence; the M is the number of interval spaces of first optical flow velocity values in a human face area optical flow velocity histogram in the ith optical flow velocity histogram, or the M is the number of interval spaces of second optical flow velocity values in a non-human face area optical flow velocity histogram in the ith optical flow velocity histogram, and the M is an integer greater than or equal to 1;
determining the minimum value of a third pixel value corresponding to the interval pitch of the jth first optical flow velocity value interval and a fourth pixel value of the interval pitch of the jth second optical flow velocity value interval;
and determining the sum of the minimum values corresponding to the interval spacing of each optical flow velocity value in the ith optical flow velocity histogram as the number of matched pixels in the ith optical flow velocity histogram.
6. The method according to any of claims 3-5, wherein the preset weight of the ith-1 histogram of light flow velocities is greater than the preset weight of the ith histogram of light flow velocities.
7. The method according to claim 1, wherein the at least two images of the face to be detected are: and two adjacent frames of images of the face to be detected.
8. The method of claim 1, further comprising:
and when the average distance is detected to be larger than or equal to the preset distance threshold, determining that the face to be detected is a living face.
9. A face recognition apparatus, comprising:
the first acquisition module is used for acquiring at least two frames of images containing a face to be detected;
a second obtaining module, configured to obtain a dense optical flow map according to the at least two frames of images obtained by the first obtaining module, where the dense optical flow map includes optical flow velocity values of pixels of any one of the two frames of images;
a first determining module, configured to determine N face area optical flow velocity histograms and N non-face area optical flow velocity histograms according to the optical flow velocity values of the pixels acquired by the second acquiring module; the histogram intervals of the optical flow velocity histograms of the face areas are different, and the histogram intervals of the optical flow velocity histograms of the non-face areas are different; n is an integer greater than or equal to 2;
a third obtaining module, configured to obtain an average distance between the face area optical flow velocity histogram and the non-face area optical flow velocity histogram according to the N face area optical flow velocity histograms and the N non-face area optical flow velocity histograms determined by the first determining module and a preset weight corresponding to each histogram interval;
the detection module is used for detecting whether the average distance between the face area optical flow velocity histogram and the non-face area optical flow velocity histogram acquired by the third acquisition module is smaller than a preset distance threshold value or not;
and the second determining module is used for determining that the face to be detected is a false face when the detecting module detects that the average distance is smaller than the preset distance threshold.
10. The apparatus of claim 9, wherein the first determining module comprises: the first obtaining submodule, the first determining submodule, the second determining submodule, the third determining submodule, the second obtaining submodule, the fourth determining submodule, the fifth determining submodule, the sixth determining submodule, the seventh determining submodule, the third obtaining submodule and the eighth determining submodule;
the first acquisition submodule is used for acquiring the minimum optical flow velocity value in the optical flow velocity values of the pixels acquired by the second acquisition module;
the first determining submodule is configured to determine that the minimum optical flow velocity value acquired by the first acquiring submodule is a first histogram interval of a1 st personal-face-area optical flow velocity histogram;
the second determining submodule is used for determining the first histogram interval of each face area optical flow velocity histogram according to the fact that the first histogram interval of the next face area optical flow velocity histogram is a preset multiple of the first histogram interval of the adjacent previous face area optical flow velocity histogram;
the third determining submodule is configured to determine each first optical flow velocity value interval in the nth personal face area optical flow velocity histogram according to a first histogram interval corresponding to the nth personal face area optical flow velocity histogram, where N is 1 and 2 … N in sequence;
the second obtaining sub-module is configured to obtain, for each of the first optical flow velocity value intervals determined by the third determining sub-module, a first number of pixels included in the first optical flow velocity value interval in the optical flow velocity values of each pixel in the face area;
the fourth determining submodule is configured to determine the N face area optical flow velocity histograms according to each of the first optical flow velocity value intervals and the first number of pixels corresponding to each of the first optical flow velocity value intervals;
the fifth determining submodule is configured to determine that the minimum optical flow velocity value acquired by the first acquiring submodule is a second histogram interval of a1 st non-human-face area optical flow velocity histogram;
the sixth determining submodule is configured to determine a second histogram interval of each non-face area optical flow velocity histogram according to the preset multiple that a second histogram interval of a subsequent non-face area optical flow velocity histogram is a second histogram interval of an adjacent previous non-face area optical flow velocity histogram;
the seventh determining submodule is configured to determine each second optical flow velocity value interval in the nth non-human face region optical flow velocity histogram according to a second histogram pitch corresponding to the nth non-human face region optical flow velocity histogram, where N is 1 and 2 … N in sequence;
the third obtaining sub-module is configured to obtain, for each second optical flow velocity value interval determined by the seventh determining sub-module, a second number of pixels included in the second optical flow velocity value interval in the optical flow velocity values of the pixels in the non-face area;
the eighth determining submodule is configured to determine the N non-human-face area optical flow velocity histograms according to each of the second optical flow velocity value intervals and a second number of pixels corresponding to each of the second optical flow velocity value intervals.
11. The apparatus of claim 9, wherein the third obtaining module comprises: a fourth obtaining submodule and a fifth obtaining submodule;
the fourth obtaining submodule is used for obtaining the number of new matched pixels in the ith optical flow velocity histogram, wherein i is 1 and 2 … N in sequence; the ith optical flow velocity histogram comprises a face area optical flow velocity histogram and a non-face area optical flow velocity histogram, and a first histogram space corresponding to the face area optical flow velocity histogram is the same as a second histogram space corresponding to the non-face area optical flow velocity histogram;
the fifth obtaining submodule is used for obtaining the average distance between the optical flow velocity histogram of the face area and the optical flow velocity histogram of the non-face area according to the preset weight corresponding to the histogram interval of each pair of optical flow velocity histograms and the number of new matched pixels in each pair of optical flow velocity histograms obtained by the fourth obtaining submodule.
12. The apparatus of claim 11, wherein the fourth acquisition submodule comprises: a sixth obtaining sub-module and a ninth determining sub-module;
the sixth obtaining submodule is used for obtaining the number of matched pixels in the ith-1 pair of light flow velocity histogram and the number of matched pixels in the ith pair of light flow velocity histogram;
the ninth determining sub-module is configured to determine that a difference between the number of matched pixels in the ith light flow velocity histogram and the number of matched pixels in the ith-1 light flow velocity histogram, which is obtained by the sixth obtaining sub-module, is a new number of matched pixels in the ith light flow velocity histogram.
13. The apparatus of claim 12, wherein the sixth acquisition submodule comprises: a seventh obtaining sub-module, an eighth obtaining sub-module, a tenth determining sub-module and an eleventh determining sub-module;
the seventh obtaining submodule is used for obtaining a third pixel value corresponding to the interval distance of a jth first optical flow velocity value in a face area optical flow velocity histogram in the ith optical flow velocity histogram;
the eighth obtaining submodule is configured to obtain a fourth pixel value corresponding to an interval pitch of a jth second optical flow velocity value in a non-human face area optical flow velocity histogram in the ith optical flow velocity histogram, where j is 1 and 2 … M in sequence; the M is the number of interval spaces of first optical flow velocity values in a human face area optical flow velocity histogram in the ith optical flow velocity histogram, or the M is the number of interval spaces of second optical flow velocity values in a non-human face area optical flow velocity histogram in the ith optical flow velocity histogram, and the M is an integer greater than or equal to 1;
the tenth determining submodule is configured to determine a minimum value of a third pixel value corresponding to the interval pitch of the jth first optical flow velocity value and a fourth pixel value of the interval pitch of the jth second optical flow velocity value;
and the eleventh determining submodule is used for determining that the sum of the minimum values corresponding to the interval spacing of each optical flow velocity value in the ith optical flow velocity histogram is the number of matched pixels in the ith optical flow velocity histogram.
14. The apparatus according to any of claims 11-13, wherein the preset weight of the ith-1 histogram of light flow velocities is greater than the preset weight of the ith histogram of light flow velocities.
15. The apparatus according to claim 9, wherein the at least two images of the face to be detected are: and two adjacent frames of images of the face to be detected.
16. The apparatus of claim 9, further comprising: a third determination module;
the third determining module is configured to determine that the face to be detected is a living face when the detecting module detects that the average distance is greater than or equal to the preset distance threshold.
17. A face recognition apparatus, comprising:
a processor;
a memory for storing processor-executable instructions;
wherein the processor is configured to:
acquiring at least two frames of images containing a face to be detected;
acquiring a dense optical flow graph according to the at least two frames of images, wherein the dense optical flow graph comprises optical flow velocity values of each pixel of any one frame of image in the two frames of images;
determining N face area optical flow velocity histograms and N non-face area optical flow velocity histograms according to the optical flow velocity value of each pixel; the histogram intervals of the optical flow velocity histograms of the face areas are different, and the histogram intervals of the optical flow velocity histograms of the non-face areas are different; n is an integer greater than or equal to 2;
acquiring the average distance between the face area optical flow velocity histogram and the non-face area optical flow velocity histogram according to the N face area optical flow velocity histograms, the N non-face area optical flow velocity histograms and the preset weight value corresponding to each histogram interval;
and when the average distance is smaller than a preset distance threshold value, determining that the face to be detected is a false face.
18. A computer-readable storage medium having stored thereon computer instructions, characterized in that the instructions, when executed by a processor, carry out the method steps of any of claims 1-8.
CN201711310840.8A 2017-12-11 2017-12-11 Face recognition method and device Active CN108154090B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201711310840.8A CN108154090B (en) 2017-12-11 2017-12-11 Face recognition method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201711310840.8A CN108154090B (en) 2017-12-11 2017-12-11 Face recognition method and device

Publications (2)

Publication Number Publication Date
CN108154090A CN108154090A (en) 2018-06-12
CN108154090B true CN108154090B (en) 2021-10-01

Family

ID=62466119

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201711310840.8A Active CN108154090B (en) 2017-12-11 2017-12-11 Face recognition method and device

Country Status (1)

Country Link
CN (1) CN108154090B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108875676B (en) * 2018-06-28 2021-08-10 北京旷视科技有限公司 Living body detection method, device and system
CN111047908B (en) * 2018-10-12 2021-11-02 富士通株式会社 Detection device, method and video monitoring device for cross-line vehicle
CN112651311A (en) * 2020-12-15 2021-04-13 展讯通信(天津)有限公司 Face recognition method and related equipment

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106204640A (en) * 2016-06-29 2016-12-07 长沙慧联智能科技有限公司 A kind of moving object detection system and method
CN106228129A (en) * 2016-07-18 2016-12-14 中山大学 A kind of human face in-vivo detection method based on MATV feature
CN107358206A (en) * 2017-07-13 2017-11-17 山东大学 Micro- expression detection method that a kind of Optical-flow Feature vector modulus value and angle based on area-of-interest combine

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106204640A (en) * 2016-06-29 2016-12-07 长沙慧联智能科技有限公司 A kind of moving object detection system and method
CN106228129A (en) * 2016-07-18 2016-12-14 中山大学 A kind of human face in-vivo detection method based on MATV feature
CN107358206A (en) * 2017-07-13 2017-11-17 山东大学 Micro- expression detection method that a kind of Optical-flow Feature vector modulus value and angle based on area-of-interest combine

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
A Face Anti-Spoofing Method Based on Optical Flow Field;Wenze Yin et al.;《2016 IEEE 13th International Conference on Signal Processing》;20170316;第1333-1337页 *
一种基于光流场的复杂背景下人脸定位方法;王凌等;《计算机工程与应用》;20040108;第68-70,73页 *
光流模值估计的微表情捕捉;姜波等;《浙江大学学报(工学版)》;20170414;第577-583,589页 *

Also Published As

Publication number Publication date
CN108154090A (en) 2018-06-12

Similar Documents

Publication Publication Date Title
CN106651955B (en) Method and device for positioning target object in picture
US9674395B2 (en) Methods and apparatuses for generating photograph
CN106572299B (en) Camera opening method and device
CN105430262B (en) Filming control method and device
US10452890B2 (en) Fingerprint template input method, device and medium
CN105095881B (en) Face recognition method, face recognition device and terminal
US10115019B2 (en) Video categorization method and apparatus, and storage medium
CN109145679B (en) Method, device and system for sending out early warning information
CN107944367B (en) Face key point detection method and device
CN105554389B (en) Shooting method and device
CN105631803B (en) The method and apparatus of filter processing
EP3113071B1 (en) Method and device for acquiring iris image
US10216976B2 (en) Method, device and medium for fingerprint identification
CN106557759B (en) Signpost information acquisition method and device
CN105260732A (en) Image processing method and device
CN107958223B (en) Face recognition method and device, mobile equipment and computer readable storage medium
CN106503682B (en) Method and device for positioning key points in video data
CN107480785B (en) Convolutional neural network training method and device
CN109034150B (en) Image processing method and device
CN108154090B (en) Face recognition method and device
EP3211564A1 (en) Method and device for verifying a fingerprint
CN109325141B (en) Image retrieval method and device, electronic equipment and storage medium
CN107239758B (en) Method and device for positioning key points of human face
CN108108668B (en) Age prediction method and device based on image
CN107122356B (en) Method and device for displaying face value and electronic equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant