visageSDK
Instance Methods | List of all members
VisageFeaturesDetector Class Reference

Objective-C wrapper of the VisageSDK::VisageFeaturesDetector class. More...

#import <objc_VisageFeaturesDetector.h>

Inherits NSObject.

Instance Methods

(VisageFeaturesDetector *) - init:
 Constructor. More...
 
(int) - detectFaces:withRect:withMaxFaces:withMinFaceScale:withMaxFaceScale:withRefinementStep:
 Performs face detection in a still image. More...
 
(int) - detectFacialFeatures:withFaceData:withMaxFaces:withMinFaceScale:withMaxFaceScale:withOutputOnly2DFeatures:
 Performs faces and facial features detection in a still image. More...
 

Detailed Description

Objective-C wrapper of the VisageSDK::VisageFeaturesDetector class.

Definition at line 23 of file objc_VisageFeaturesDetector.h.

Method Documentation

◆ detectFaces:withRect:withMaxFaces:withMinFaceScale:withMaxFaceScale:withRefinementStep:()

- (int) detectFaces: (VisageImage *)  frame
withRect: (NSMutableArray *)  faces
withMaxFaces: (int)  maxFaces
withMinFaceScale: (float)  minFaceScale
withMaxFaceScale: (float)  maxFaceScale
withRefinementStep: (bool)  useRefinementStep 

Performs face detection in a still image.

The algorithm detects one or more faces. For each detected face a square facial bounding box is returned.

The results are returned in form of CgRect objects. An NSMutableArray of CgRect objects passed to this method as output parameter should be allocated to maxFaces size. For example:

let detector = VisageFeaturesDetector("Face Detector.cfg")
let maxFaces = Int32(4)
let minFaceScale = Float(0.05)
let maxFaceScale = Float(0.95)
let faceRects = NSMutableArray(capacity: Int(maxFaces))
let n = detector?.detectFaces(image, withRect: faceRects, withMaxFaces: maxFaces, withMinFaceScale: minFaceScale, withMaxFaceScale: maxFaceScale, withRefinementStep: true)

After this call, n contains the number of detected faces. The first n members of the faces array are filled with resulting bounding boxes for each detected face. If maxFaces is smaller than the number of faces actually detected in the image, the function will return only first maxFaces detected faces.

VisageFeaturesDetector expects input image to be in the RGB, RGBA or grayscale color space with bit depth set to 8 and with origin in the top left pixel of the image.

Note that the input image is internally converted to grayscale.

Parameters
framethe input image.
facespointer to an array of CgRect objects in which the results will be returned.
maxFacesmaximum number of faces to be detected
minFaceScalescale of smallest face to be searched for, defined as decimal fraction [0.0 - 1.0] of input image size (min(width, height))
maxFaceScalescale of largest face to be searched for, defined as decimal fraction [0.0 - 1.0] of input image size (min(width, height))
useRefinementStepif set to true, additional refinement algorithm will be used resulting with more precise facial bounding boxes and lower FPR, but higher detection time
Returns
number of detected faces (0 or more)

◆ detectFacialFeatures:withFaceData:withMaxFaces:withMinFaceScale:withMaxFaceScale:withOutputOnly2DFeatures:()

- (int) detectFacialFeatures: (VisageImage *)  frame
withFaceData: (FaceDataCollection *)  output
withMaxFaces: (int)  maxFaces
withMinFaceScale: (float)  minFaceScale
withMaxFaceScale: (float)  maxFaceScale
withOutputOnly2DFeatures: (bool)  outputOnly2DFeatures 

Performs faces and facial features detection in a still image.

The algorithm detects one or more faces and their features. The results are, for each detected face, the 3D head pose, gaze direction, eye closure, the coordinates of facial feature points (e.g. chin tip, nose tip, lip corners etc.) and 3D face model fitted to the face. If outputOnly2DFeatures is set, only the 2D feature points will be returned.

The results are returned in form of FaceData objects. A FaceDataCollection passed to this method as output parameter should be allocated to maxFaces size. For example:

let detector = VisageFeaturesDetector("Face Detector.cfg")
let maxFaces = Int32(4)
let faceData = FaceDataCollection(maxFaces: maxFaces)
let minFaceScale = Float(0.05)
let maxFaceScale = Float(0.95)
let n = detector?.detectFacialFeatures(image, withFaceData: faceData, withMaxFaces: maxFaces, withMinFaceScale: minFaceScale, withMaxFaceScale: maxFaceScale, withOutputOnly2DFeatures: false)

After this call, n contains the number of faces actually detected. The first n members of the data array are filled with resulting data for each detected face. Please refer to the FaceData documentation for detailed description of returned parameters. If maxFaces is smaller than the number of faces actually present in the image, the function will return only first maxFaces detected faces.

VisageFeaturesDetector expects input image to be in the RGB, RGBA or grayscale color space with bit depth set to 8 and with origin in the top left pixel of the image.

Note that the input image is internally converted to grayscale.

Parameters
framethe input image.
outputpointer to a FaceDataCollection object in which the results will be returned.
maxFacesmaximum number of faces to be detected
minFaceScalescale of smallest face to be searched for, defined as decimal fraction [0.0 - 1.0] of input image size (min(width, height))
maxFaceScalescale of largest face to be searched for, defined as decimal fraction [0.0 - 1.0] of input image size (min(width, height))
outputOnly2DFeaturesif set, detection time will be reduced and only FeaturePoints2D will be returned
Returns
number of detected faces (0 or more)
See also
FaceData

◆ init:()

- (VisageFeaturesDetector *) init: (NSString *)  detectorConfigFile

Constructor.

Initialises the features detector.

Several data files are needed for facial features detection. In the current distribution these files are contained within the Samples/data folder.

To successfully initialize VisageFeaturesDetector, provide path to the configuration file that is located in folder with the following folder structure and data files:

  • vft folder (configuration parameter vft_data_path)
    • Required folders and algorithm data files:
      • ff/ *
      • fa/ *
        • NOTE: If landmarks refinement (configuration parameter refine_landmarks [0]) is disabled, d2.tflite is not needed.
      • fm/ containing .fdp and .wfm file corresponding to the 3D model (configuration parameters *_fitting_model, *_fitting_fdp)
Parameters
detectorConfigFilethe name of the detector configuration file (.cfg) relative to the current working directory, e.g. "Face Detector.cfg", assuming it's located in the current working directory.
Returns
true if successful

The documentation for this class was generated from the following file: