High level api¶
Face detection and attributes estimation¶
High level api is represented VLFaceDetection and VLFaceDetector classes.
VLFaceDetection is container for a face detection. It has properties which are corresponding face estimations. Every property is a singleton which estimates corresponding attribute once and remembers it for next calling.
VLFaceDetector is a wraper on FaceDetector which convert FaceDetection to VLFaceDetection. Class contains a face estimator collection as a class attribute for a detections attributes estimation. If you want specify an unique VLFaceEngine for the instance of VLFaceDetector you should set the FaceEngine in the init of the class.
Example¶
>>> from lunavl.sdk.luna_faces import VLFaceDetector
>>> from lunavl.sdk.luna_faces import VLImage
>>> detector = VLFaceDetector()
>>> image = VLImage.load(
... url='https://cdn1.savepice.ru/uploads/2019/4/15/aa970957128d9892f297cdfa5b3fda88-full.jpg')
>>> detection = detector.detectOne(image)
>>> detection.basicAttributes.age
16.0
>>> detection.emotions.predominateEmotion.name
'Happiness'
Module realize hight level api for estimate face attributes
High level detection object. .. attribute:: estimatorCollection
collection of estimators
- type
FaceEstimatorsCollection
lazy load emotions estimations
- Type
Optional[Emotions]
lazy load eye estimations
- Type
Optional[EyesEstimation]
lazy load mouth state estimation
- Type
Optional[MouthStates]
lazy load basic attribute estimation
- Type
Optional[BasicAttributes]
lazy load gaze direction estimation
- Type
Optional[GazeEstimation]
lazy load warp quality estimation
- Type
Optional[Quality]
lazy load head pose estimation
- Type
Optional[HeadPose]
lazy load ags estimation
- Type
Optional[float]
lazy load transformed landmarks68
- Type
Optional[Landmarks68]
Get ags of the detection.
- Returns
emotions
- Return type
float
Convert to dict.
- Returns
All estimated attributes will be added to dict
- Return type
Dict
[str
,Union
[dict
,list
,float
]]
Get all basic attributes of the detection.
- Returns
basic attributes (age, gender, ethnicity)
- Return type
Get a face descriptor from warp
- Returns
mouth state
- Return type
Get emotions of the detection.
- Returns
emotions
- Return type
Get eyes estimation of the detection.
- Returns
eyes estimation
- Return type
Get gaze direction.
- Returns
gaze direction
- Return type
Get a head pose of the detection. Estimation bases on 68 landmarks
- Returns
head pose
- Return type
Get a mouth state of the detection
- Returns
mouth state
- Return type
Get warp from detection.
- Returns
warp
- Return type
Get quality of warped image which corresponding the detection :returns: quality
- Return type
High level face detector. Return VLFaceDetection instead simple FaceDetection.
face estimator collections for new detections.
face detector
- Type
face engine for detector and estimators, default FACE_ENGINE.
- Type
Batch detect faces on images.
- Parameters
images – input images list. Format must be R8G8B8
limit – max number of detections per input image
- Returns
return list of lists detection, order of detection lists is corresponding to order input images
- Return type
List
[List
[VLFaceDetection
]]
Detect just one best detection on the image.
- Parameters
image – image. Format must be R8G8B8 (todo check)
detectArea – rectangle area which contains face to detect. If not set will be set image.rect
- Returns
face detection if face is found otherwise None
- Return type
Union
[None
,VLFaceDetection
]
estimators collection of class for usual creating detectors
-
faceEngine
= <lunavl.sdk.faceengine.engine.VLFaceEngine object> a global instance of FaceEngine for usual creating detectors
High level sample object.
lazy load emotions estimations
- Type
Optional[Emotions]
lazy load mouth state estimation
- Type
Optional[MouthStates]
lazy load basic attribute estimation
- Type
Optional[BasicAttributes]
lazy load warp quality estimation
- Type
Optional[Quality]
Convert to dict.
- Returns
All estimated attributes will be added to dict
- Return type
Dict
[str
,Union
[dict
,list
,float
]]
Get all basic attributes of the detection.
- Returns
basic attributes (age, gender, ethnicity)
- Return type
Get a face descriptor from warp
- Returns
mouth state
- Return type
Get emotions of the detection.
- Returns
emotions
- Return type
estimators collection of class for usual creating detectors
Get a mouth state of the detection
- Returns
mouth state
- Return type
Support VLFaceDetection interface.
- Returns
self
- Return type
Get quality of warped image which corresponding the detection :returns: quality
- Return type