CN114973365A - Method, device and medium for correcting portrait deflection - Google Patents

Method, device and medium for correcting portrait deflection Download PDF

Info

Publication number
CN114973365A
CN114973365A CN202210587331.4A CN202210587331A CN114973365A CN 114973365 A CN114973365 A CN 114973365A CN 202210587331 A CN202210587331 A CN 202210587331A CN 114973365 A CN114973365 A CN 114973365A
Authority
CN
China
Prior art keywords
portrait
picture
coordinates
characteristic point
face characteristic
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.)
Pending
Application number
CN202210587331.4A
Other languages
Chinese (zh)
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.)
Wuhan Hongxin Technology Service Co Ltd
Original Assignee
Wuhan Hongxin Technology Service 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 Wuhan Hongxin Technology Service Co Ltd filed Critical Wuhan Hongxin Technology Service Co Ltd
Priority to CN202210587331.4A priority Critical patent/CN114973365A/en
Publication of CN114973365A publication Critical patent/CN114973365A/en
Pending legal-status Critical Current

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
    • G06V40/161Detection; Localisation; Normalisation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V20/00Scenes; Scene-specific elements
    • G06V20/40Scenes; Scene-specific elements in video content
    • G06V20/46Extracting features or characteristics from the video content, e.g. video fingerprints, representative shots or key frames
    • 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
    • G06V40/168Feature extraction; Face representation

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Multimedia (AREA)
  • Theoretical Computer Science (AREA)
  • Health & Medical Sciences (AREA)
  • Oral & Maxillofacial Surgery (AREA)
  • General Health & Medical Sciences (AREA)
  • Human Computer Interaction (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Image Processing (AREA)

Abstract

The invention discloses a method for correcting portrait deflection, which comprises the following steps: acquiring a video frame picture including a portrait, and intercepting the portrait picture from the video frame picture; acquiring coordinates of a first face characteristic point and coordinates of a second face characteristic point in the portrait picture based on the face characteristic point detection model; acquiring a horizontal deflection angle of the portrait picture based on the coordinates of the first face characteristic point and the coordinates of the second face characteristic point; and rotating the portrait picture according to the obtained horizontal deflection angle to realize portrait deflection correction. The method can enable the levelness of the obtained portrait to be more uniform in the process of portrait recognition preprocessing, thereby enabling the extraction of the portrait characteristic value to be more accurate and improving the comparison rate of the portrait to a certain extent.

Description

Method, device and medium for correcting portrait deflection
Technical Field
The present invention relates to the field of image recognition technology, and more particularly, to a method, an apparatus, and a medium for correcting portrait deflection.
Background
The application of portrait identification is more and more common in life, such as mobile payment, entrance and exit of a door, express delivery extraction and the like. These scenes often require human coordination to obtain the best portrait for comparison. And for some portrait captured by cameras distributed at the intersection, the deflection angles of the portrait are different, certain deviation exists when the portrait is subjected to feature extraction, retrieval and comparison, and even if the portrait is the same, the similarity during comparison sometimes has great difference due to different deflection angles.
Disclosure of Invention
In view of at least one of the defects or the improvement requirements of the prior art, the present invention provides a method for correcting the deflection angle of a portrait detected in a picture, so that the portrait is at the same level when the features are extracted, thereby achieving the goal of improving the portrait contrast ratio.
To achieve the above object, according to a first aspect of the present invention, there is provided a method for correcting a deflection of an image, comprising the steps of:
acquiring a video frame picture including a portrait, and intercepting the portrait picture from the video frame picture;
acquiring coordinates of a first face characteristic point and coordinates of a second face characteristic point in the portrait picture based on a face characteristic point detection model;
acquiring a horizontal deflection angle of the portrait picture based on the coordinates of the first face characteristic point and the coordinates of the second face characteristic point;
and rotating the portrait picture according to the obtained horizontal deflection angle to realize portrait deflection correction.
Further, the acquiring a video frame picture including a portrait, and the capturing the portrait picture from the video frame picture specifically includes:
after reading a video frame picture including a portrait and carrying out gray level processing, detecting the video frame picture by using a dlib portrait detection model to obtain a portrait rectangular frame, and intercepting a corresponding portrait picture from the video frame picture through the portrait rectangular frame.
Further, the human face feature point detection model is a dlib human face five-feature point detection model.
Further, the first face feature point is an external eye corner point of the left eye, and the second face feature point is an external eye corner point of the right eye.
Further, the horizontal deflection angle is specifically an included angle between a straight line formed by connecting the first face characteristic point and the second face characteristic point and a horizontal straight line; and acquiring the horizontal deflection angle of the portrait picture through an arctan function based on the coordinates of the first face characteristic point and the coordinates of the second face characteristic point.
Further, the rotating the portrait picture according to the obtained horizontal deflection angle to realize portrait deflection correction specifically comprises:
according to the horizontal deflection angle and the portrait picture, an affine transformation matrix is obtained by a getrientationmatrix 2D method in OpenCV, the obtained affine transformation matrix is used as a parameter and is transmitted into a warpAffine method to obtain a new portrait picture, and a new portrait after deflection correction is obtained.
According to a second aspect of the invention, there is also provided an apparatus for image deflection correction, comprising at least one processing unit, and at least one memory unit, wherein the memory unit stores a computer program which, when executed by the processing unit, causes the processing unit to carry out the steps of any of the methods described above.
According to a third aspect of the present invention, there is also provided a storage medium storing a computer program executable by an access authentication apparatus, the computer program causing the access authentication apparatus to perform the steps of any one of the methods described above when the computer program is run on the access authentication apparatus.
In general, compared with the prior art, the above technical solution contemplated by the present invention can achieve the following beneficial effects:
the method of the invention can make the acquired portrait levelness more uniform in the flow of portrait recognition preprocessing, thereby making the extraction of the portrait characteristic value more accurate and quicker and improving the portrait comparison rate to a certain extent.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed to be used in the embodiments will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art that other drawings can be obtained according to these drawings without creative efforts.
Fig. 1 is a schematic flow chart of a method for correcting an image deflection according to an embodiment of the present invention;
fig. 2 is a schematic distribution diagram of five feature points of a dlib face according to an embodiment of the present invention;
fig. 3 is a block diagram of an electronic device suitable for implementing the method described above according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and do not limit the invention. In addition, the technical features involved in the respective embodiments of the present invention described below may be combined with each other as long as they do not conflict with each other.
The terms "first," "second," or "third," etc. in the description, claims, or drawings of the present application are used for distinguishing between different elements and not necessarily for describing a particular sequential or chronological order. Furthermore, the terms "comprises" or "comprising," as well as any variations thereof, are intended to cover non-exclusive inclusions. For example, a process, method, system, article, or apparatus that comprises a list of steps or elements is not limited to only those steps or elements but may alternatively include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
As shown in FIG. 1, in one embodiment, a method for portrait deflection correction substantially includes the steps of S1-S4:
s1, obtaining a video frame picture including the portrait, and intercepting the portrait picture from the video frame picture.
More specifically, after reading a picture or a video frame including a portrait and performing gray scale processing, detecting the picture by using a dlib portrait detection model to obtain a portrait rectangular coordinate denoted as R i (i is 1, 2, 3 …), i represents the detected ith portrait rectangle, and corresponding portrait picture f is cut from the original picture or video frame through the portrait rectangles i (i=1,2,3…)。
And S2, acquiring the coordinates of the first face characteristic point and the coordinates of the second face characteristic point in the portrait picture based on the face characteristic point detection model.
And S3, acquiring the horizontal deflection angle of the portrait picture based on the coordinates of the first face characteristic point and the coordinates of the second face characteristic point.
The human face feature point detection model includes various detection models such as a dlib human face 5 feature point detection model and a dlib human face 68 feature point detection model, and in order to reduce the data amount and increase the execution rate, the present embodiment preferably employs the dlib human face 5 feature point detection model. As shown in fig. 2, the five positions of 5 human face feature points, namely the eye heads (i.e., points 3 and 1 in fig. 2) and the eye tails (i.e., points 2 and 0 in fig. 2) of both eyes and the nose head (i.e., point 4 in fig. 2) are shown.
The first and second facial feature points may actually be two corner points of the mouth, the nose, or the eyebrows. However, considering that two symmetrical points with a relatively long distance are selected as much as possible, and the point location is selected as much as possible as the most symmetrical portion of the face, this embodiment preferably uses the outer eye corner point of the left eye (i.e., point 0 in fig. 2) as the first face feature point, and the outer eye corner point of the right eye (i.e., point 2 in fig. 2) as the second face feature point.
The canthus is called the inner canthus (or inner canthus) and the outer canthus (or outer canthus) in medicine, and the inner canthus is the joint of the upper and lower eyelids, which is near the side of the nose and is called the inner canthus (inner canthus or inner canthus). The outer canthus is the junction between the upper and lower eyelids near the ear, and is called the outer canthus (outer canthus or angular point of the outer eye).
And analyzing the obtained portrait picture by using a 5-point detection model of dlib to obtain 5-point characteristics of each portrait, namely the inner and outer eye angular points of the left eye, the inner and outer eye angular points of the right eye and the lower point of the nose tip. Selecting the corner point of the left eye and marking as P 0 The corner point of the outer eye of the right eye is marked as P 2 Subscripts of x and y respectively represent an abscissa and an ordinate of the feature point with respect to an origin, and P is calculated 0 、P 2 The included angle between the straight line formed by the two points and the horizontal straight line is the portrait deflection angle which is marked as theta,
Figure BDA0003663037700000051
wherein theta is within-90 DEG<θ<90°。
And S4, rotating the portrait picture according to the obtained horizontal deflection angle, and realizing portrait deflection correction.
Specifically, the deflection angle theta of each portrait is obtained by processing the acquired portrait in sequence i (i 1, 2, 3 …), using getlotrationmatrix 2D method in OpenCV to center the portrait picture in the center
Figure BDA0003663037700000052
Centered, deflection angle θ i Obtaining an affine transformation matrix for the parameters, and introducing the obtained affine transformation matrix as the parameters into a warpAffine method to obtain a new portrait picture, namely the portrait F after deflection correction i (i=1、2、3…)。
The method for correcting the human image deflection detects the picture or the video frame by utilizing the dlib library, and determines the position of the human image in the picture and the coordinates of the two eyes in the human image. And calculating the horizontal deflection angle of the portrait according to the obtained left and right eye coordinates, and rotating the portrait by utilizing the affine transformation of OpenCV to realize the rapid correction of the portrait. The method is used in the portrait recognition preprocessing, so that the levelness of the obtained portrait is uniform, the extraction of the portrait characteristic value is more accurate and quicker, and the portrait comparison rate is improved to a certain extent in practice.
Fig. 3 schematically shows a block diagram of an electronic device adapted to implement the above described method according to an embodiment of the invention. The electronic device shown in fig. 3 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present invention.
As shown in fig. 3, the electronic device 1000 described in this embodiment includes: a processor 1001 which can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM)1002 or a program loaded from a storage section 1008 into a Random Access Memory (RAM) 1003. Processor 1001 may include, for example, a general purpose microprocessor (e.g., a CPU), an instruction set processor and/or associated chipset, and/or a special purpose microprocessor (e.g., an Application Specific Integrated Circuit (ASIC)), among others. The processor 1001 may also include onboard memory for caching purposes. The processor 1001 may include a single processing unit or multiple processing units for performing different actions of a method flow according to embodiments of the present disclosure.
In the RAM 1003, various programs and data necessary for the operation of the system 1000 are stored. The processor 1001, ROM1002, and RAM 1003 are connected to each other by a bus 1004. The processor 1001 performs various operations of the method flow according to the embodiments of the present disclosure by executing programs in the ROM1002 and/or the RAM 1003. Note that the programs may also be stored in one or more memories other than the ROM1002 and the RAM 1003. The processor 1001 may also perform various operations of the method flows according to embodiments of the present disclosure by executing programs stored in the one or more memories.
Electronic device 1000 may also include an input/output (I/O) interface 1005, the input/output (I/O) interface 1005 also being connected to bus 1004, according to an embodiment of the present disclosure. The system 1000 may also include one or more of the following components connected to the I/O interface 1005: an input section 1006 including a keyboard, a mouse, and the like; an output section 1007 including a display such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage portion 1008 including a hard disk and the like; and a communication section 1009 including a network interface card such as a LAN card, a modem, or the like. The communication section 1009 performs communication processing via a network such as the internet. The driver 1010 is also connected to the I/O interface 1005 as necessary. A removable medium 1011 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 1010 as necessary, so that a computer program read out therefrom is mounted into the storage section 1008 as necessary.
Method flows according to embodiments of the present disclosure may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable storage medium, the computer program containing program code for performing the method illustrated by the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication part 1009 and/or installed from the removable medium 1011. The computer program performs the above-described functions defined in the system of the embodiment of the present disclosure when executed by the processor 1001. The above described systems, devices, apparatuses, modules, units, etc. may be implemented by computer program modules according to embodiments of the present disclosure.
Embodiments of the present invention also provide a computer-readable storage medium, which may be embodied in the apparatus/device/system described in the above embodiments; or may exist separately and not be assembled into the device/apparatus/system. The computer-readable storage medium carries one or more programs which, when executed, implement the method according to an embodiment of the disclosure.
According to embodiments of the present disclosure, the computer-readable storage medium may be a non-volatile computer-readable storage medium, which may include, for example but is not limited to: a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In embodiments of the disclosure, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. For example, a computer-readable storage medium may include one or more memories other than ROM1002 and/or RAM 1003 described above in accordance with embodiments of the present disclosure.
It should be noted that each functional module in each embodiment of the present invention may be integrated into one processing module, or each module may exist alone physically, or two or more modules are integrated into one module. The integrated module can be realized in a hardware mode, and can also be realized in a software functional module mode. The integrated module, if implemented in the form of a software functional module and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention may be substantially or partially embodied in the form of a software product, or all or part of the technical solution that contributes to the prior art.
The flowchart or block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems that perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
It will be appreciated by those skilled in the art that various combinations and/or combinations of the features recited in the various embodiments of the disclosure and/or the claims may be made even if such combinations or combinations are not explicitly recited in the disclosure. In particular, various combinations and/or combinations of the features recited in the various embodiments and/or claims of the present disclosure may be made without departing from the spirit or teaching of the present disclosure, and all such combinations and/or combinations are within the scope of the present disclosure.
While the disclosure has been shown and described with reference to certain exemplary embodiments thereof, it will be understood by those skilled in the art that various changes in form and details may be made therein without departing from the spirit and scope of the disclosure as defined by the appended claims and their equivalents. Accordingly, the scope of the present disclosure should not be limited to the above-described embodiments, but should be defined not only by the appended claims, but also by equivalents thereof.

Claims (8)

1. A method of portrait deflection correction, comprising the steps of:
acquiring a video frame picture including a portrait, and intercepting the portrait picture from the video frame picture;
acquiring coordinates of a first face characteristic point and coordinates of a second face characteristic point in the portrait picture based on a face characteristic point detection model;
acquiring a horizontal deflection angle of the portrait picture based on the coordinates of the first face characteristic point and the coordinates of the second face characteristic point;
and rotating the portrait picture according to the obtained horizontal deflection angle to realize portrait deflection correction.
2. The method for correcting human image deflection according to claim 1, wherein the acquiring a video frame picture including a human image, and the capturing a human image picture from the video frame picture specifically comprises:
after reading a video frame picture including a portrait and carrying out gray level processing, detecting the video frame picture by using a dlib portrait detection model to obtain a portrait rectangular frame, and intercepting a corresponding portrait picture from the video frame picture through the portrait rectangular frame.
3. The method for correcting human image deflection according to claim 1, wherein the human face feature point detection model is dlib human face five feature point detection model.
4. The method for rectifying human image deflection according to claim 3, wherein said first face feature point is an external eye corner point of a left eye, and said second face feature point is an external eye corner point of a right eye.
5. The method for correcting human image deflection according to claim 1, wherein the horizontal deflection angle is an angle between a horizontal line and a line connecting the first human face feature point and the second human face feature point; and acquiring the horizontal deflection angle of the portrait picture through an arctan function based on the coordinates of the first face characteristic point and the coordinates of the second face characteristic point.
6. The method for rectifying human image deflection according to claim 1, wherein said rotating the human image picture according to the obtained horizontal deflection angle, to realize human image deflection correction specifically comprises:
according to the horizontal deflection angle and the portrait picture, an affine transformation matrix is obtained by a getrotontionmatrix 2D method in OpenCV, the obtained affine transformation matrix is used as a parameter and is transmitted into a warpAffine method to obtain a new portrait picture, and a new portrait after deflection correction is obtained.
7. An apparatus for image deflection correction, comprising at least one processing unit and at least one memory unit, wherein the memory unit stores a computer program which, when executed by the processing unit, causes the processing unit to carry out the steps of the method according to any one of claims 1 to 6.
8. A storage medium storing a computer program executable by an access authentication device, the computer program causing the access authentication device to perform the steps of the method of any one of claims 1 to 6 when run on the access authentication device.
CN202210587331.4A 2022-05-26 2022-05-26 Method, device and medium for correcting portrait deflection Pending CN114973365A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210587331.4A CN114973365A (en) 2022-05-26 2022-05-26 Method, device and medium for correcting portrait deflection

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210587331.4A CN114973365A (en) 2022-05-26 2022-05-26 Method, device and medium for correcting portrait deflection

Publications (1)

Publication Number Publication Date
CN114973365A true CN114973365A (en) 2022-08-30

Family

ID=82954924

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210587331.4A Pending CN114973365A (en) 2022-05-26 2022-05-26 Method, device and medium for correcting portrait deflection

Country Status (1)

Country Link
CN (1) CN114973365A (en)

Similar Documents

Publication Publication Date Title
US11182589B2 (en) Methods and apparatuses for determining face image quality, electronic devices, and computer storage media
WO2018028546A1 (en) Key point positioning method, terminal, and computer storage medium
WO2020062523A1 (en) Gaze point determination method and apparatus, and electronic device and computer storage medium
CN111598091A (en) Image recognition method and device, electronic equipment and computer readable storage medium
CN108229301B (en) Eyelid line detection method and device and electronic equipment
CN110852310B (en) Three-dimensional face recognition method and device, terminal equipment and computer readable medium
KR20200118076A (en) Biometric detection method and device, electronic device and storage medium
US11367310B2 (en) Method and apparatus for identity verification, electronic device, computer program, and storage medium
CN111553251B (en) Certificate four-corner defect detection method, device, equipment and storage medium
CN110062157B (en) Method and device for rendering image, electronic equipment and computer readable storage medium
CN110619656B (en) Face detection tracking method and device based on binocular camera and electronic equipment
CN108875556B (en) Method, apparatus, system and computer storage medium for testimony of a witness verification
CN112396050B (en) Image processing method, device and storage medium
WO2019085338A1 (en) Electronic apparatus, image-based age classification method and system, and storage medium
US20190130600A1 (en) Detection Method and Device Thereof
CN111680546A (en) Attention detection method, attention detection device, electronic equipment and storage medium
US11398052B2 (en) Camera positioning method, device and medium
CN112949418A (en) Method and device for determining speaking object, electronic equipment and storage medium
CN111259711A (en) Lip movement identification method and system
US20220207917A1 (en) Facial expression image processing method and apparatus, and electronic device
CN111784658A (en) Quality analysis method and system for face image
CN110909568A (en) Image detection method, apparatus, electronic device, and medium for face recognition
CN114049674A (en) Three-dimensional face reconstruction method, device and storage medium
CN111784660A (en) Method and system for analyzing face correcting degree of face image
CN114973365A (en) Method, device and medium for correcting portrait deflection

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