CN108509916A - Method and apparatus for generating image - Google Patents

Method and apparatus for generating image Download PDF

Info

Publication number
CN108509916A
CN108509916A CN201810290271.3A CN201810290271A CN108509916A CN 108509916 A CN108509916 A CN 108509916A CN 201810290271 A CN201810290271 A CN 201810290271A CN 108509916 A CN108509916 A CN 108509916A
Authority
CN
China
Prior art keywords
transformation
machine learning
learning model
face region
image
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
CN201810290271.3A
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.)
Baidu Online Network Technology Beijing Co Ltd
Beijing Baidu Netcom Science and Technology Co Ltd
Original Assignee
Beijing Baidu Netcom Science and Technology 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 Baidu Netcom Science and Technology Co Ltd filed Critical Beijing Baidu Netcom Science and Technology Co Ltd
Priority to CN201810290271.3A priority Critical patent/CN108509916A/en
Publication of CN108509916A publication Critical patent/CN108509916A/en
Pending legal-status Critical Current

Links

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
    • 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
    • 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)
  • Health & Medical Sciences (AREA)
  • Oral & Maxillofacial Surgery (AREA)
  • Human Computer Interaction (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Multimedia (AREA)
  • Theoretical Computer Science (AREA)
  • General Health & Medical Sciences (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Image Analysis (AREA)
  • Image Processing (AREA)

Abstract

The embodiment of the present application discloses the method and apparatus for generating image.One specific implementation mode of this method includes:Human face region is extracted from the facial image of acquisition;Spatial alternation is carried out to the human face region extracted, generates human face region after transformation;Human face region after the transformation is added in default background image, target image is generated;The training sample that machine learning model is added using the target image as negative sample is concentrated, wherein the machine learning model is used to determine whether the reference object indicated by facial image is face live body based on input facial image therein.The embodiment of the present application can increase the training samples number of the machine learning model for determining face live body, improve the accuracy of detection face live body.

Description

Method and apparatus for generating image
Technical field
The invention relates to field of computer technology, and in particular to the method and apparatus for generating image.
Background technology
Face recognition technology is a computer application investigative technique, belongs to one kind of biometrics identification technology.
Can not only distinguish bion by the biological characteristic of organism, additionally it is possible to the physical condition of bion into Row judges.For example, it may determine that whether biology is live body, whether is in fatigue state by organism image;Organism Image is also used as the Rule of judgment of unlock, prevents live body from attacking, to increase the safety of equipment.
Invention content
The embodiment of the present application proposes the method and apparatus for generating image, and the method for detecting face live body And device.
In a first aspect, the embodiment of the present application provides a kind of method for generating image, including:From the face figure of acquisition Human face region is extracted as in;Spatial alternation is carried out to the human face region extracted, generates human face region after transformation;Descendant will be converted Face region is added in default background image, generates target image;Machine learning model is added using target image as negative sample Training sample concentrate, wherein machine learning model is used to determine indicated by facial image based on input facial image therein Reference object whether be face live body.
In some embodiments, default background image includes face;Spatial alternation is carried out to the human face region extracted, it is raw At human face region after transformation, including:The characteristic point for presetting the face in background image is obtained, extracted human face region is obtained Characteristic point;The characteristic point of characteristic point and human face region based on acquired face determines and becomes used by carrying out spatial alternation Change matrix;Using transformation matrix, spatial alternation is carried out to human face region, generates human face region after transformation;Face figure after converting As being added in default background image, generation target image, including:After converting in face region overlay to default background image Face in so that transformation after the position of the characteristic point of human face region and the characteristic point in the face of background image correspond.
In some embodiments, transformation angle used by spatial alternation includes one of a variety of transformation angles obtained in advance Or the transformation angle generated at random.
Second aspect, the embodiment of the present application provide a kind of method for detecting face live body, and method includes:Obtain mesh Mark facial image;By in target facial image input machine learning model trained in advance, testing result is obtained, training in advance Machine learning model is used to determine whether the reference object indicated by facial image is face based on input facial image therein Live body;Wherein, the training sample that machine learning model trained in advance is obtained using the method based on such as first aspect any one This training is got.
In some embodiments, training obtains machine learning model trained in advance as follows:Obtain initial machine Device learning model;Obtain training sample set;In the training sample input initial machine learning model that training sample is concentrated, utilize Machine learning method is trained initial machine learning model based on the markup information of training sample, obtains machine learning mould Type.
The third aspect, the embodiment of the present application provide a kind of device for generating image, including:Extraction unit, configuration For extracting human face region from the facial image of acquisition;Converter unit is configured to carry out the human face region extracted empty Between convert, generate transformation after human face region;Adding device is configured to human face region after converting and is added to default background image In, generate target image;Unit is added, is configured to that the training sample of machine learning model is added using target image as negative sample This concentration, wherein machine learning model is used to determine the shooting pair indicated by facial image based on input facial image therein As if no is face live body.
In some embodiments, default background image includes face;Converter unit, including:Acquisition module is configured to obtain The characteristic point of the face in default background image is taken, the characteristic point of extracted human face region is obtained;Determining module is configured to The characteristic point of characteristic point and human face region based on acquired face determines transformation matrix used by carrying out spatial alternation; Generation module, is configured to use transformation matrix, carries out spatial alternation to human face region, generates human face region after transformation;And Adding device is further configured to:By in face region overlay to the face in default background image after transformation, so that transformation The position of the characteristic point of human face region and the characteristic point in the face of background image corresponds afterwards.
In some embodiments, transformation angle used by spatial alternation includes one of a variety of transformation angles obtained in advance Or the transformation angle generated at random.
Fourth aspect, the embodiment of the present application provide a kind of device for detecting face live body, which includes:It obtains Unit is configured to obtain target facial image;Detection unit is configured to target facial image input machine trained in advance In device learning model, testing result is obtained, trained machine learning model is used for true based on facial image therein is inputted in advance Determine whether the reference object indicated by facial image is face live body;Wherein, machine learning model trained in advance, which uses, is based on Training sample set as the device of third aspect any one obtains trains to obtain.
In some embodiments, training obtains machine learning model trained in advance as follows:Obtain initial machine Device learning model;Obtain training sample set;In the training sample input initial machine learning model that training sample is concentrated, utilize Machine learning method is trained initial machine learning model based on the markup information of training sample, obtains machine learning mould Type.
5th aspect, the embodiment of the present application provide a kind of electronic equipment, including:One or more processors;Storage dress It sets, for storing one or more programs, when one or more programs are executed by one or more processors so that one or more A processor realizes the method such as any embodiment in the method for generating image.
6th aspect, the embodiment of the present application provide a kind of computer readable storage medium, are stored thereon with computer journey Sequence realizes the method such as any embodiment in the method for generating image when the program is executed by processor.
7th aspect, the embodiment of the present application provide a kind of electronic equipment, including:One or more processors;Storage dress It sets, for storing one or more programs, when one or more programs are executed by one or more processors so that one or more A processor realizes the method such as any embodiment in the method for detecting face live body.
Eighth aspect, the embodiment of the present application provide a kind of computer readable storage medium, are stored thereon with computer journey Sequence realizes the method such as any embodiment in the method for detecting face live body when the program is executed by processor.
Method and apparatus provided by the embodiments of the present application for generating image are carried from the facial image of acquisition first Take human face region.Spatial alternation then is carried out to the human face region extracted, generates human face region after transformation.Later, it will convert Human face region is added in default background image afterwards, generates target image.Then, machine is added using target image as negative sample The training sample of learning model is concentrated, wherein machine learning model is used to determine face figure based on input facial image therein As whether indicated reference object is face live body.The embodiment of the present application can increase the engineering for determining face live body The training samples number of model is practised, the accuracy for determining face live body is improved.
Description of the drawings
By reading a detailed description of non-restrictive embodiments in the light of the attached drawings below, the application's is other Feature, objects and advantages will become more apparent upon:
Fig. 1 is that this application can be applied to exemplary system architecture figures therein;
Fig. 2 is the flow chart according to one embodiment of the method for generating image of the application;
Fig. 3 is the schematic diagram according to an application scenarios of the method for generating image of the application;
Fig. 4 is the flow chart according to another embodiment of the method for generating image of the application;
Fig. 5 is the flow chart according to another embodiment of the method for detecting face live body of the application;
Fig. 6 is the structural schematic diagram according to one embodiment of the device for generating image of the application;
Fig. 7 is the structural schematic diagram according to another embodiment of the device for detecting face live body of the application;
Fig. 8 is adapted for the structural schematic diagram of the computer system of the electronic equipment for realizing the embodiment of the present application.
Specific implementation mode
The application is described in further detail with reference to the accompanying drawings and examples.It is understood that this place is retouched The specific embodiment stated is used only for explaining related invention, rather than the restriction to the invention.It also should be noted that in order to Convenient for description, is illustrated only in attached drawing and invent relevant part with related.
It should be noted that in the absence of conflict, the features in the embodiments and the embodiments of the present application can phase Mutually combination.The application is described in detail below with reference to the accompanying drawings and in conjunction with the embodiments.
Fig. 1 shows the implementation of the method for generating image or the device for generating image that can apply the application The exemplary system architecture 100 of example.
As shown in Figure 1, system architecture 100 may include terminal device 101,102,103, network 104 and server 105. Network 104 between terminal device 101,102,103 and server 105 provide communication link medium.Network 104 can be with Including various connection types, such as wired, wireless communication link or fiber optic cables etc..
User can be interacted by network 104 with server 105 with using terminal equipment 101,102,103, to receive or send out Send message etc..Various telecommunication customer end applications can be installed, such as web browser is answered on terminal device 101,102,103 With, shopping class application, searching class application, instant messaging tools, mailbox client, social platform software etc..
Terminal device 101,102,103 can be hardware, can also be software.When terminal device 101,102,103 is hard Can be the various electronic equipments with display screen, including but not limited to smart mobile phone, tablet computer, e-book reading when part Device, pocket computer on knee and desktop computer etc..When terminal device 101,102,103 is software, may be mounted at In above-mentioned cited electronic equipment.Multiple softwares or software module may be implemented into (such as providing Distributed Services in it Multiple softwares or software module), single software or software module can also be implemented as.It is not specifically limited herein.Terminal is set Standby 101,102,103 can carry out spatial alternation to the human face region of extraction, and human face region after transformation is added to the default back of the body In scape image, target image is generated.The training sample that machine learning model is added using target image as negative sample later is concentrated.
Server 105 can be to provide the server of various services, such as to being shown on terminal device 101,102,103 Target image provides the background server supported.Background server the data such as the facial image that receives such as can analyze Processing, and target image is fed back into terminal device.
It should be noted that the embodiment of the present application provided for generate image method can by terminal device 101, 102,103 or server 105 execute, correspondingly, the device for generating image can be set to terminal device 101,102,103 Or in server 105.
It should be understood that the number of the terminal device, network and server in Fig. 1 is only schematical.According to realization need It wants, can have any number of terminal device, network and server.
With continued reference to Fig. 2, the flow of one embodiment of the method for generating image according to the application is shown 200.The method for being used to generate image, includes the following steps:
Step 201, human face region is extracted from the facial image of acquisition.
In the present embodiment, the method for generating image runs electronic equipment (such as service shown in FIG. 1 thereon Device or terminal device) human face region can be extracted from the advance facial image for obtaining or obtaining in real time.Human face region is behaved The region of complete face is presented in face image.The shape in the region can be the shape of face outer profile, can also be specified Arbitrary shape, such as rectangle.Herein, the quantity of the human face region of extraction can be more than one or two.
Specifically, Face datection can be carried out to facial image, determines the region where face, then obtains face area Domain.
Step 202, spatial alternation is carried out to the human face region extracted, generates human face region after transformation.
In the present embodiment, above-mentioned electronic equipment can carry out spatial alternation to the human face region extracted.By space Human face region after transformation is human face region after transformation.
In practice, above-mentioned electronic equipment may be used various ways and carry out spatial alternation, become for example, projection may be used It changes.
In some optional realization methods of the present embodiment, spatial alternation can be affine transformation.
When in the present embodiment, using affine transformation, above-mentioned electronic equipment can translate human face region, scale, At least one of overturning and rotation transformation.
In some optional realization methods of the present embodiment, transformation angle used by spatial alternation includes obtaining in advance One of a variety of transformation angles or the transformation angle that generates at random.
It may include rotation angle and/or mis-cut angle to convert angle.Based on transformation angle, above-mentioned electronic equipment can be adopted Affine transformation is carried out to human face region with various ways.For example, above-mentioned electronic equipment can be based on human face region before transformation Characteristic point coordinate, rotation angle and the fixation point coordinates of preset rotation, carry out spatial alternation.
In order to obtain more rich sample, a variety of rotation angles and/or angle of chamfer may be used in above-mentioned electronic equipment Degree converts human face region, obtains human face region after multiple transformation of various angles.
Step 203, human face region after transformation is added in default background image, generates target image.
In the present embodiment, above-mentioned electronic equipment can by after the transformation that spatial alternation obtains human face region be added to In default background image, target image is generated.It is mutually tied with default background image in this way, obtained target image is exactly human face region Close obtained image.
In practice, default background image can be the image for showing various patterns, can also be a pattern-free Image.Above-mentioned electronic equipment may be used various ways and human face region after transformation be added in default background image.Citing comes It says, above-mentioned electronic equipment can be by face region overlay to default background image after transformation, or the default Background that is added to As in.
In the case where human face region is more than two, default background image may include a predeterminable area, pre- at this If more than two human face regions can be added in region.In addition, default background image can also include more than two default Region, these predeterminable areas up for adding human face region respectively wherein.
Step 204, the training sample for machine learning model being added using target image as negative sample is concentrated, wherein machine Learning model is used to determine whether the reference object indicated by facial image is face live body based on input facial image therein.
In the present embodiment, the training sample of machine learning model is added using target image as negative sample for above-mentioned electronic equipment This concentration.Camera shoots reference object, obtains facial image.Here reference object can be face live body, Face live body is can not be, for example presents the picture of face or the statue of face etc..Negative sample is indicated shooting Object is not the facial image of face live body.Can be judged by information such as depth of view information facial image reference object whether be Face live body.
Training sample set is added using the target image generated based on 201~step 204 of above-mentioned steps as negative sample, it can Increase the sample size that training sample is concentrated, so that machine learning model after being trained using target image, increases mould Type determine reference object whether be face live body accuracy.
Above-mentioned machine learning model can be the model that neural network model etc. can be continued to optimize by machine learning.Machine Device learning model can be by support vector machines (Support Vector Machine, SVM), model-naive Bayesian (Naive Bayesian Model, NBM) graders (Classifier) training such as model obtains.In addition, machine learning model can also It is based on made of certain classification functions (such as softmax functions etc.) in advance training.
It is a signal according to the application scenarios of the method for generating image of the present embodiment with continued reference to Fig. 3, Fig. 3 Figure.In the application scenarios of Fig. 3, electronic equipment 301 obtains facial image 302 from local or other electronic equipments, and from obtaining Human face region 303 is extracted in the facial image taken;Spatial alternation is carried out to the human face region 303 extracted, generates transformation descendant Face region 304;Human face region after transformation is added in default background image, target image 305 is generated;By target image 305 The training sample that machine learning model is added as negative sample is concentrated, wherein machine learning model is used for therein based on inputting Facial image determines whether the reference object indicated by facial image is face live body.
Method the embodiment of the present application that above-described embodiment of the application provides can increase the machine for determining face live body The training samples number of device learning model improves the accuracy for determining face live body.More negative samples are obtained by the present embodiment, The probability that negative sample is determined as face live body by machine learning model can be reduced.
With further reference to Fig. 4, it illustrates the flows 400 of another embodiment of the method for generating image.The use In the flow 400 for the method for generating image, include the following steps:
Step 401, human face region is extracted from the facial image of acquisition.
In the present embodiment, the method for generating image runs electronic equipment (such as service shown in FIG. 1 thereon Device or terminal device) human face region can be extracted from the advance facial image for obtaining or obtaining in real time.Human face region is behaved The region of complete face is presented in face image.The shape in the region can be the shape of face outer profile, can also be specified Arbitrary shape, such as rectangle.Herein, the quantity of the human face region of extraction can be more than one or two.
Specifically, Face datection can be carried out to facial image, determines the region where face, then obtains face area Domain.
Step 402, spatial alternation is carried out to the human face region extracted, generates human face region after transformation.
In the present embodiment, above-mentioned electronic equipment can carry out spatial alternation to the human face region extracted.By space Human face region after transformation is human face region after transformation.
In practice, above-mentioned electronic equipment may be used various ways and carry out spatial alternation, for example, affine change may be used It changes, projective transformation can also be used.When using affine transformation, above-mentioned electronic equipment can translate human face region, be contracted At least one of put, overturn and rotate transformation.
Step 403, the characteristic point for presetting the face in background image is obtained, the feature of extracted human face region is obtained Point.
In the present embodiment, above-mentioned electronic equipment can be obtained from local or other electronic equipments and be preset in background image Face characteristic point, and the characteristic point of human face region extracted.Can obtain the people formerly extracted from local obtain The characteristic point of face can also be extract real-time characteristic point.Characteristic point is behaved can embody the site of facial feature on the face, such as Nose, canthus, upper lip etc..Default background image in the present embodiment includes face.
Step 404, the characteristic point of characteristic point and human face region based on acquired face determines and carries out spatial alternation institute The transformation matrix of use.
In the present embodiment, if necessary to carry out spatial alternation, transformation matrix can first be obtained.Above-mentioned electronic equipment can be with The characteristic point of characteristic point and above-mentioned human face region based on acquired face determines and converts square used by carrying out spatial alternation Battle array.
In practice, above-mentioned electronic equipment can determine the coordinate of each characteristic point.Characteristic point in human face region Characteristic point with the face in default background image be correspond it is identical, for example, upper lip in human face region with it is default The upper lip of face in background image is identical.Above-mentioned electronic equipment can be according to opposite in human face region and default background image The coordinate for the characteristic point answered, determines transformation matrix.
Step 405, using transformation matrix, spatial alternation is carried out to human face region, generates human face region after transformation.
In the present embodiment, above-mentioned electronic equipment uses transformation matrix, carries out spatial alternation to human face region, is converted Human face region afterwards.
In practice, above-mentioned electronic equipment can be by the coordinate of the characteristic point in above-mentioned human face region and default background image In face characteristic point coordinate respectively as the coordinate before transformation and the coordinate after transformation.Above-mentioned electronic equipment can use Coordinate after coordinate and transformation, carries out spatial alternation, with face area after being converted to human face region before transformation matrix, and transformation Domain.
Step 406, by face region overlay to the face in default background image after transformation, so that the transformation descendant The characteristic point in face region and the position of the characteristic point in the face of the background image correspond.
In the present embodiment, above-mentioned electronic equipment is by face region overlay after transformation to the face in default background image In, so that the characteristic point of human face region and the position one of the characteristic point in the face of the background image are a pair of after the transformation It answers.Each characteristic point after transformation in human face region is covered in the corresponding characteristic point in default background image.
Step 407, the training sample for machine learning model being added using target image as negative sample is concentrated.
In the present embodiment, the training sample of machine learning model is added using target image as negative sample for above-mentioned electronic equipment This concentration.Wherein, machine learning model is used to determine the shooting pair indicated by facial image based on input facial image therein As if no is face live body.
The spatial alternation of the present embodiment and covering can be accurate allow characteristic point in human face region and default background image It corresponds, generates accurate target image.
With further reference to Fig. 5, it illustrates the flows 500 of one embodiment of the method for detecting face live body.It should Flow 500 for the method for detecting face live body, includes the following steps:
Step 501, target facial image is obtained.
In the present embodiment, it is (such as shown in FIG. 1 to run electronic equipment thereon for the method for detecting face live body Server or terminal device) target facial image can be obtained from local or other electronic equipments.Target facial image be in The image of existing face.
Step 502, by target facial image input machine learning model trained in advance, testing result is obtained, wherein Trained machine learning model can be used for determining the shooting indicated by facial image based on input facial image therein in advance Whether object is face live body.
In the present embodiment, above-mentioned electronic equipment inputs above-mentioned target image in machine learning model trained in advance, Obtain testing result.Also, trained machine learning model may be used based on embodiment or Fig. 4 institute as shown in Figure 2 in advance The training sample set that the method for generating image for the embodiment shown obtains trains to obtain.
Specifically, testing result may indicate that whether reference object indicated by facial image is face live body.For example, detection As a result can be the mark for indicating " reference object is face live body " or " reference object is not face live body ".In addition, detection knot Fruit can also be the probability that reference object is face live body.For example, if probability is more than a certain predetermined threshold value, can indicate to detect As a result it is face live body for reference object.
In some optional realization methods of the present embodiment, trained machine learning model is instructed as follows in advance It gets:
Obtain initial machine learning model;
Obtain training sample set;
In the training sample input initial machine learning model that training sample is concentrated, using machine learning method, it is based on The markup information of training sample is trained initial machine learning model, obtains machine learning model.
In the present embodiment, markup information be indicate facial image indicated by reference object whether be face live body letter Breath, and in advance to the information of facial image mark before training.For example, standard information can be mark, and can indicate The reference object of facial image whether be face live body probability.When training, the facial image that can concentrate training sample is made For input, initial machine learning model is trained using the markup information of the facial image in facial image as output, is obtained To machine learning model.
Initial machine learning model can be the machine learning model up for being trained using above-mentioned training step.It lifts For example, initial machine learning model can be support vector machines (Support Vector Machine, SVM), simple pattra leaves Graders (Classifier) such as this model (Naive Bayesian Model, NBM) model etc..In addition, machine learning model Can also be certain classification functions (such as softmax functions etc.).
Target image is added training sample set by the present embodiment, keeps training sample more abundant.Further, using adding The shooting pair of image can more accurately be determined by having entered the machine learning model that the training sample set of target image is trained As if no is face live body.
With further reference to Fig. 6, as the realization to method shown in above-mentioned each figure, this application provides one kind for generating figure One embodiment of the device of picture, the device embodiment is corresponding with embodiment of the method shown in Fig. 2, which can specifically answer For in various electronic equipments.
As shown in fig. 6, the device 600 for generating image of the present embodiment includes:Extraction unit 601, converter unit 602, adding device 603 and addition unit 604.Wherein, extraction unit 601 are configured to extract from the facial image of acquisition Human face region;Converter unit 602 is configured to carry out spatial alternation to the human face region extracted, generates face area after transformation Domain;Adding device 603 is configured to human face region after converting and is added in default background image, generates target image;It is added Unit 604, the training sample for being configured to be added machine learning model using target image as negative sample are concentrated, wherein machine Learning model is used to determine whether the reference object indicated by facial image is face live body based on input facial image therein.
In the present embodiment, extraction unit 601 can extract people from the advance facial image for obtaining or obtaining in real time Face region.Human face region is the region that complete face is presented in facial image.The shape in the region can be face outer profile Shape can also be specified arbitrary shape, such as rectangle.Herein, the quantity of the human face region of extraction can be one or Person is more than two.
In the present embodiment, converter unit 602 can carry out spatial alternation to the human face region extracted.Become by space Human face region after changing is human face region after transformation.In practice, converter unit 602 may be used various ways and carry out space change It changes, for example, projective transformation may be used.
In the present embodiment, adding device 603 can by after the transformation that spatial alternation obtains human face region be added to In default background image, target image is generated.It is mutually tied with default background image in this way, obtained target image is exactly human face region Close obtained region.In practice, default background image can be the image for showing various patterns, can also be a nothing The image of pattern.Adding device 603 may be used various ways and human face region after transformation be added in default background image.It lifts For example, adding device 603 can be by face region overlay to default background image after transformation, or the default background that is added to In image.
In the present embodiment, the training sample that machine learning model is added using target image as negative sample for unit 604 is added This concentration.Wherein, machine learning model is used to determine the shooting pair indicated by facial image based on input facial image therein As if no is face live body.Camera shoots reference object, obtains facial image.
In some optional realization methods of the present embodiment, default background image includes face;To the face extracted Region carries out spatial alternation, generates human face region after transformation, including:The characteristic point for presetting the face in background image is obtained, is obtained Take the characteristic point of extracted human face region;The characteristic point of characteristic point and human face region based on acquired face, determine into Transformation matrix used by row spatial alternation;Using transformation matrix, spatial alternation is carried out to human face region, generates face after transformation Region;Facial image after transformation is added in default background image, target image is generated, including:Human face region after converting It covers in the face in default background image, so that the spy after transformation in the characteristic point of human face region and the face of background image The position of sign point corresponds.
In some optional realization methods of the present embodiment, transformation angle used by spatial alternation includes obtaining in advance One of a variety of transformation angles or the transformation angle that generates at random.
With further reference to Fig. 7, as the realization to method shown in above-mentioned each figure, this application provides one kind for detecting people One embodiment of the device of face live body, the device embodiment is corresponding with embodiment of the method shown in fig. 5, which specifically may be used To be applied in various electronic equipments.
As shown in fig. 7, the device 700 for detecting face live body of the present embodiment includes:Acquiring unit 701 and detection are single Member 702.Wherein, acquiring unit 701 are configured to obtain target facial image;Detection unit 702 is configured to target person In face image input machine learning model trained in advance, testing result is obtained, trained machine learning model is used for base in advance Determine whether the reference object indicated by facial image is face live body in inputting facial image therein;Trained machine in advance Learning model trains to obtain using the training sample set that the device based on such as Fig. 6 any one obtains.
In some optional realization methods of the present embodiment, trained machine learning model is instructed as follows in advance It gets:Obtain initial machine learning model;Obtain training sample set;The training sample that training sample is concentrated inputs initial machine In device learning model, using machine learning method, initial machine learning model is instructed based on the markup information of training sample Practice, obtains machine learning model.
Below with reference to Fig. 8, it illustrates the computer systems 800 suitable for the electronic equipment for realizing the embodiment of the present application Structural schematic diagram.Electronic equipment shown in Fig. 8 is only an example, to the function of the embodiment of the present application and should not use model Shroud carrys out any restrictions.
As shown in figure 8, computer system 800 includes central processing unit (CPU) 801, it can be read-only according to being stored in Program in memory (ROM) 802 or be loaded into the program in random access storage device (RAM) 803 from storage section 808 and Execute various actions appropriate and processing.In RAM 803, also it is stored with system 800 and operates required various programs and data. CPU 801, ROM 802 and RAM 803 are connected with each other by bus 804.Input/output (I/O) interface 805 is also connected to always Line 804.
It is connected to I/O interfaces 805 with lower component:Importation 806 including keyboard, mouse etc.;It is penetrated including such as cathode The output par, c 807 of spool (CRT), liquid crystal display (LCD) etc. and loud speaker etc.;Storage section 808 including hard disk etc.; And the communications portion 809 of the network interface card including LAN card, modem etc..Communications portion 809 via such as because The network of spy's net executes communication process.Driver 810 is also according to needing to be connected to I/O interfaces 805.Detachable media 811, such as Disk, CD, magneto-optic disk, semiconductor memory etc. are mounted on driver 810, as needed in order to be read from thereon Computer program be mounted into storage section 808 as needed.
Particularly, in accordance with an embodiment of the present disclosure, it may be implemented as computer above with reference to the process of flow chart description Software program.For example, embodiment of the disclosure includes a kind of computer program product comprising be carried on computer-readable medium On computer program, which includes the program code for method shown in execution flow chart.In such reality It applies in example, which can be downloaded and installed by communications portion 809 from network, and/or from detachable media 811 are mounted.When the computer program is executed by central processing unit (CPU) 801, limited in execution the present processes Above-mentioned function.It should be noted that the computer-readable medium of the application can be computer-readable signal media or calculating Machine readable storage medium storing program for executing either the two arbitrarily combines.Computer readable storage medium for example can be --- but it is unlimited In --- electricity, system, device or the device of magnetic, optical, electromagnetic, infrared ray or semiconductor, or the arbitrary above combination.It calculates The more specific example of machine readable storage medium storing program for executing can include but is not limited to:Being electrically connected, be portable with one or more conducting wires Formula computer disk, hard disk, random access storage device (RAM), read-only memory (ROM), erasable programmable read only memory (EPROM or flash memory), optical fiber, portable compact disc read-only memory (CD-ROM), light storage device, magnetic memory device or The above-mentioned any appropriate combination of person.In this application, can be any include computer readable storage medium or storage program Tangible medium, the program can be commanded execution system, device either device use or it is in connection.And in this Shen Please in, computer-readable signal media may include in a base band or as the data-signal that a carrier wave part is propagated, In carry computer-readable program code.Diversified forms may be used in the data-signal of this propagation, including but not limited to Electromagnetic signal, optical signal or above-mentioned any appropriate combination.Computer-readable signal media can also be computer-readable Any computer-readable medium other than storage medium, the computer-readable medium can send, propagate or transmit for by Instruction execution system, device either device use or program in connection.The journey for including on computer-readable medium Sequence code can transmit with any suitable medium, including but not limited to:Wirelessly, electric wire, optical cable, RF etc. or above-mentioned Any appropriate combination.
Flow chart in attached drawing and block diagram, it is illustrated that according to the system of the various embodiments of the application, method and computer journey The architecture, function and operation in the cards of sequence product.In this regard, each box in flowchart or block diagram can generation A part for a part for one module, program segment, or code of table, the module, program segment, or code includes one or more uses The executable instruction of the logic function as defined in realization.It should also be noted that in some implementations as replacements, being marked in box The function of note can also occur in a different order than that indicated in the drawings.For example, two boxes succeedingly indicated are actually It can be basically executed in parallel, they can also be executed in the opposite order sometimes, this is depended on the functions involved.Also it to note Meaning, the combination of each box in block diagram and or flow chart and the box in block diagram and or flow chart can be with holding The dedicated hardware based system of functions or operations as defined in row is realized, or can use specialized hardware and computer instruction Combination realize.
Being described in unit involved in the embodiment of the present application can be realized by way of software, can also be by hard The mode of part is realized.Described unit can also be arranged in the processor, for example, can be described as:A kind of processor packet It includes extraction unit, converter unit, adding device and unit is added.Wherein, the title of these units not structure under certain conditions The restriction of the pairs of unit itself, for example, extraction unit is also described as " extracting face area from the facial image of acquisition The unit in domain ".
As on the other hand, present invention also provides a kind of computer-readable medium, which can be Included in device described in above-described embodiment;Can also be individualism, and without be incorporated the device in.Above-mentioned calculating Machine readable medium carries one or more program, when said one or multiple programs are executed by the device so that should Device:Human face region is extracted from the facial image of acquisition;Spatial alternation is carried out to the human face region extracted, after generating transformation Human face region;Human face region after transformation is added in default background image, target image is generated;Using target image as negative sample The training sample of this addition machine learning model is concentrated, wherein machine learning model is used for based on input facial image therein Determine whether the reference object indicated by facial image is face live body.
Above description is only the preferred embodiment of the application and the explanation to institute's application technology principle.People in the art Member should be appreciated that invention scope involved in the application, however it is not limited to technology made of the specific combination of above-mentioned technical characteristic Scheme, while should also cover in the case where not departing from foregoing invention design, it is carried out by above-mentioned technical characteristic or its equivalent feature Other technical solutions of arbitrary combination and formation.Such as features described above has similar work(with (but not limited to) disclosed herein Can technical characteristic replaced mutually and the technical solution that is formed.

Claims (14)

1. a kind of method for generating image, including:
Human face region is extracted from the facial image of acquisition;
Spatial alternation is carried out to the human face region extracted, generates human face region after transformation;
Human face region after the transformation is added in default background image, target image is generated;
The training sample that machine learning model is added using the target image as negative sample is concentrated, wherein the machine learning Model is used to determine whether the reference object indicated by facial image is face live body based on input facial image therein.
2. the method according to claim 1, wherein default background image includes face;
It is described that spatial alternation is carried out to the human face region extracted, human face region after transformation is generated, including:
The characteristic point of the face in the default background image is obtained, the characteristic point of extracted human face region is obtained;
The characteristic point of characteristic point and the human face region based on acquired face determines and becomes used by carrying out spatial alternation Change matrix;
Using the transformation matrix, spatial alternation is carried out to the human face region, generates human face region after transformation;
It is described that facial image after the transformation is added in the default background image, target image is generated, including:
By in face region overlay after the transformation to the face in the default background image, so that face area after the transformation The characteristic point in domain and the position of the characteristic point in the face of the background image correspond.
3. the method according to claim 1, wherein transformation angle includes a variety of transformation obtained in advance used by spatial alternation One of angle or the transformation angle generated at random.
4. a kind of method for detecting face live body, method include:
Obtain target facial image;
By in target facial image input machine learning model trained in advance, testing result is obtained, in advance trained machine Device learning model is used to determine whether the reference object indicated by facial image is that face is lived based on input facial image therein Body;
Wherein, the instruction that machine learning model trained in advance is obtained using the method based on any one of such as claim 1-3 Practice sample set to train to obtain.
5. method according to claim 4, wherein training obtains trained machine learning model as follows in advance:
Obtain initial machine learning model;
Obtain training sample set;
In the training sample input initial machine learning model that the training sample is concentrated, using machine learning method, it is based on The markup information of training sample is trained the initial machine learning model, obtains machine learning model.
6. a kind of device for generating image, including:
Extraction unit is configured to extract human face region from the facial image of acquisition;
Converter unit is configured to carry out spatial alternation to the human face region extracted, generates human face region after transformation;
Adding device is configured to human face region after the transformation being added in default background image, generates target image;
Unit is added, the training sample for being configured to be added machine learning model using the target image as negative sample is concentrated, Wherein, the machine learning model is used to determine that the reference object indicated by facial image is based on input facial image therein No is face live body.
7. device according to claim 6, wherein default background image includes face;
The converter unit, including:
Acquisition module is configured to obtain the characteristic point of the face in the default background image, obtains extracted face area The characteristic point in domain;
Determining module is configured to the characteristic point of characteristic point and the human face region based on acquired face, determines and carries out Transformation matrix used by spatial alternation;
Generation module, is configured to use the transformation matrix, and spatial alternation is carried out to the human face region, generates transformation descendant Face region;And
The adding device is further configured to:
By in face region overlay to the face in default background image after the transformation, so that human face region after the transformation The position of characteristic point and the characteristic point in the face of the background image corresponds.
8. device according to claim 7, wherein transformation angle includes a variety of transformation obtained in advance used by spatial alternation One of angle or the transformation angle generated at random.
9. a kind of device for detecting face live body, device include:
Acquiring unit is configured to obtain target facial image;
Detection unit is configured to, by target facial image input machine learning model trained in advance, be detected As a result, trained machine learning model is used to determine the shooting indicated by facial image based on input facial image therein in advance Whether object is face live body;
Wherein, the instruction that machine learning model trained in advance is obtained using the device based on any one of such as claim 6-8 Practice sample set to train to obtain.
10. device according to claim 9, wherein training obtains trained machine learning model as follows in advance:
Obtain initial machine learning model;
Obtain training sample set;
In the training sample input initial machine learning model that the training sample is concentrated, using machine learning method, it is based on The markup information of training sample is trained the initial machine learning model, obtains machine learning model.
11. a kind of electronic equipment, including:
One or more processors;
Storage device, for storing one or more programs,
When one or more programs are executed by one or more processors so that one or more processors realize such as claim Any method in 1-3.
12. a kind of computer readable storage medium, is stored thereon with computer program, wherein when the program is executed by processor It realizes such as method any in claim 1-3.
13. a kind of electronic equipment, including:
One or more processors;
Storage device, for storing one or more programs,
When one or more programs are executed by one or more processors so that one or more processors realize such as claim Any method in 4-5.
14. a kind of computer readable storage medium, is stored thereon with computer program, wherein when the program is executed by processor It realizes such as method any in claim 4-5.
CN201810290271.3A 2018-03-30 2018-03-30 Method and apparatus for generating image Pending CN108509916A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810290271.3A CN108509916A (en) 2018-03-30 2018-03-30 Method and apparatus for generating image

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810290271.3A CN108509916A (en) 2018-03-30 2018-03-30 Method and apparatus for generating image

Publications (1)

Publication Number Publication Date
CN108509916A true CN108509916A (en) 2018-09-07

Family

ID=63380008

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810290271.3A Pending CN108509916A (en) 2018-03-30 2018-03-30 Method and apparatus for generating image

Country Status (1)

Country Link
CN (1) CN108509916A (en)

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109345460A (en) * 2018-09-28 2019-02-15 百度在线网络技术(北京)有限公司 Method and apparatus for correcting image
CN109934191A (en) * 2019-03-20 2019-06-25 北京字节跳动网络技术有限公司 Information processing method and device
CN110796089A (en) * 2019-10-30 2020-02-14 上海掌门科技有限公司 Method and apparatus for training face-changing model
CN111680675A (en) * 2020-08-14 2020-09-18 腾讯科技(深圳)有限公司 Face living body detection method, system, device, computer equipment and storage medium
CN111860079A (en) * 2019-04-30 2020-10-30 北京嘀嘀无限科技发展有限公司 Living body image detection method and device and electronic equipment
CN112070137A (en) * 2020-08-27 2020-12-11 腾讯科技(深圳)有限公司 Training data set generation method, target object detection method and related equipment
CN112488137A (en) * 2019-09-11 2021-03-12 广州虎牙科技有限公司 Sample acquisition method and device, electronic equipment and machine-readable storage medium
CN112767239A (en) * 2021-01-12 2021-05-07 云南电网有限责任公司电力科学研究院 Automatic sample generation method, system, equipment and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103886301A (en) * 2014-03-28 2014-06-25 中国科学院自动化研究所 Human face living detection method
US20160366129A1 (en) * 2015-06-10 2016-12-15 Alibaba Group Holding Limited Liveness detection method and device, and identity authentication method and device
CN106778525A (en) * 2016-11-25 2017-05-31 北京旷视科技有限公司 Identity identifying method and device
CN107609494A (en) * 2017-08-31 2018-01-19 北京飞搜科技有限公司 A kind of human face in-vivo detection method and system based on silent formula

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103886301A (en) * 2014-03-28 2014-06-25 中国科学院自动化研究所 Human face living detection method
US20160366129A1 (en) * 2015-06-10 2016-12-15 Alibaba Group Holding Limited Liveness detection method and device, and identity authentication method and device
CN106778525A (en) * 2016-11-25 2017-05-31 北京旷视科技有限公司 Identity identifying method and device
CN107609494A (en) * 2017-08-31 2018-01-19 北京飞搜科技有限公司 A kind of human face in-vivo detection method and system based on silent formula

Cited By (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109345460A (en) * 2018-09-28 2019-02-15 百度在线网络技术(北京)有限公司 Method and apparatus for correcting image
CN109934191A (en) * 2019-03-20 2019-06-25 北京字节跳动网络技术有限公司 Information processing method and device
CN111860079A (en) * 2019-04-30 2020-10-30 北京嘀嘀无限科技发展有限公司 Living body image detection method and device and electronic equipment
CN111860079B (en) * 2019-04-30 2024-05-14 北京嘀嘀无限科技发展有限公司 Living body image detection method and device and electronic equipment
CN112488137A (en) * 2019-09-11 2021-03-12 广州虎牙科技有限公司 Sample acquisition method and device, electronic equipment and machine-readable storage medium
CN110796089A (en) * 2019-10-30 2020-02-14 上海掌门科技有限公司 Method and apparatus for training face-changing model
CN110796089B (en) * 2019-10-30 2023-12-12 上海掌门科技有限公司 Method and apparatus for training face model
CN111680675A (en) * 2020-08-14 2020-09-18 腾讯科技(深圳)有限公司 Face living body detection method, system, device, computer equipment and storage medium
WO2022033219A1 (en) * 2020-08-14 2022-02-17 腾讯科技(深圳)有限公司 Face liveness detection method, system and apparatus, computer device, and storage medium
CN112070137A (en) * 2020-08-27 2020-12-11 腾讯科技(深圳)有限公司 Training data set generation method, target object detection method and related equipment
CN112070137B (en) * 2020-08-27 2024-06-28 腾讯科技(深圳)有限公司 Training data set generation method, target object detection method and related equipment
CN112767239A (en) * 2021-01-12 2021-05-07 云南电网有限责任公司电力科学研究院 Automatic sample generation method, system, equipment and storage medium

Similar Documents

Publication Publication Date Title
CN108509916A (en) Method and apparatus for generating image
CN108038469B (en) Method and apparatus for detecting human body
CN108898186B (en) Method and device for extracting image
CN109902659B (en) Method and apparatus for processing human body image
CN108898185A (en) Method and apparatus for generating image recognition model
CN108509915A (en) The generation method and device of human face recognition model
CN109508681A (en) The method and apparatus for generating human body critical point detection model
CN107909065A (en) The method and device blocked for detecting face
CN107609536A (en) Information generating method and device
CN108304835A (en) character detecting method and device
CN107578017A (en) Method and apparatus for generating image
CN108182412A (en) For the method and device of detection image type
CN108830235A (en) Method and apparatus for generating information
CN109191514A (en) Method and apparatus for generating depth detection model
CN107590807A (en) Method and apparatus for detection image quality
CN107578034A (en) information generating method and device
CN108073910A (en) For generating the method and apparatus of face characteristic
CN109255767A (en) Image processing method and device
CN108416326A (en) Face identification method and device
CN109242801A (en) Image processing method and device
CN108509921A (en) Method and apparatus for generating information
CN110009059A (en) Method and apparatus for generating model
CN108491823A (en) Method and apparatus for generating eye recognition model
CN109255337A (en) Face critical point detection method and apparatus
CN108427941A (en) Method, method for detecting human face and device for generating Face datection model

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