Betaface Face Detection and Recognition SDK
Betaface Face Detection and Recognition SDK
Betaface Face Detection and Recognition SDK
Recognition SDK
version 2.0
Page 1 of 41
Introduction
Betaface Face Detection and Recognition SDK is a Windows DLL library containing set of the
algorithms trained and tuned to detect human face pattern and some of the facial features on static images
and in video streams. SDK detects frontal faces (with some tolerance to the head rotation) under any
angle on the image and returns coordinates of faces found and all detected face features. SDK can be
accessed from different environments, as long as you can make a call to DLL, COM object or .Net
assembly.
- Detect multiple faces on images (all SDK editions) or in video streams (SDK Xtreme).
- Crop faces from the images based on detection information.
- Compare faces (similarity score, identification, and verification).
- Morph, warp or generate average face images.
- Detect face landmarks coordinates (22 points in SDK Standard, 22+86=108 points in SDK
Pro and Xtreme).
- Classification, such as gender, age, ethnicity estimation; smile, glasses, mustache and beard
detection (SDK Pro and Xtreme).
- Additional face measurements such as face and face features shape description; hairstyle
shape estimation; skin, hair, clothes color (SDK Pro and Xtreme).
Most of the algorithms do not require color information and work on grayscale pixel values
internally. Extended measurements that require color information (for example hairstyle detection) will
return empty result for grayscale images.
Technical details:
SDK core is a Windows native DLL with additional COM and .Net interface wrappers. SDK
package includes all necessary runtime files, this documentation and precompiled samples of usage with
source code in C++ and C#. SDK includes software license protection system. Our typical licensing option
is a hardware-locked license key file, which allow you to execute SDK runtime on a specific PC hardware.
Images can be loaded either from file system location (in various supported formats) or directly
from memory (raw pixel data). SDK Xtreme also allows video input for face tracking (VFW compatible
source, external video capture with raw video frames or, with additional sample project, from DirectShow
compatible sources).
Contents
Introduction............................................................................................................................................................. 1
SDK functions ......................................................................................................................................................... 5
SDK initialization and return values ................................................................................................................... 5
Betaface_Init ................................................................................................................................................... 5
Betaface_Deinit ............................................................................................................................................... 5
Loading, saving, copying, displaying and releasing images ............................................................................... 6
Betaface_LoadImage....................................................................................................................................... 6
Betaface_SaveImage ....................................................................................................................................... 6
Betaface_LoadMemoryImage ......................................................................................................................... 7
Betaface_SaveMemoryImage .......................................................................................................................... 7
Betaface_CopyImage ...................................................................................................................................... 8
Betaface_ReleaseImage .................................................................................................................................. 8
Betaface_ReleaseMemoryImage ..................................................................................................................... 8
Betaface_GetImageSize................................................................................................................................... 9
Betaface_DisplayImage .................................................................................................................................. 9
Face detection ................................................................................................................................................... 10
Betaface_DetectFaces ................................................................................................................................... 10
Betaface_ReleaseDetectionResult ................................................................................................................. 11
Processing detection result, retrieving faces information ................................................................................. 12
Betaface_GetFacesCount .............................................................................................................................. 12
Betaface_GetFaceInfo................................................................................................................................... 12
Betaface_CreateFaceInfo ............................................................................................................................. 12
Betaface_CopyFaceInfo ................................................................................................................................ 13
Betaface_ReleaseFaceInfo ............................................................................................................................ 13
Getting and setting face information property values ....................................................................................... 14
Betaface_GetFaceInfoBoolParam ................................................................................................................ 14
Betaface_GetFaceInfoDoubleParam ............................................................................................................ 14
Betaface_SetFaceInfoBoolParam ................................................................................................................. 15
Betaface_SetFaceInfoDoubleParam ............................................................................................................. 15
Predefined parameters .................................................................................................................................. 16
Features of the Face type .............................................................................................................................. 16
Features of the Point type ............................................................................................................................. 16
Features of the Measurement type ................................................................................................................ 19
Face recognition ............................................................................................................................................... 20
Betaface_GenerateFaceKey .......................................................................................................................... 20
Betaface_CompareFaceKeys ........................................................................................................................ 20
Betaface_CompareFaceKeysEx .................................................................................................................... 21
Betaface_ReleaseFaceKey ............................................................................................................................ 21
Betaface_JoinFaceKeys ................................................................................................................................ 22
Betaface_ReconstructFace ............................................................................................................................ 22
Betaface_ReconstructFaceAvi ...................................................................................................................... 23
Classifying faces (Gender, Age, Ethnicity, Smile, Glasses or facial hair detection) ......................................... 24
Betaface_AnalyseFace .................................................................................................................................. 24
Cropping and drawing faces ............................................................................................................................. 25
Betaface_CropFaceImage............................................................................................................................. 25
Betaface_CropImageAspect .......................................................................................................................... 26
Betaface_DrawFaceInfo ............................................................................................................................... 27
Face effects - morphing, warping, transporting to another image ................................................................... 28
Betaface_MorphFaces .................................................................................................................................. 28
Betaface_TransportFace ............................................................................................................................... 28
Betaface_TransformFaceInfo........................................................................................................................ 29
Average faces – functions to create face composites ........................................................................................ 30
Betaface_GetStoredAverageFaceInfo ........................................................................................................... 30
Betaface_UpdateAverageImage .................................................................................................................... 30
Betaface_UpdateAverageFaceInfo ............................................................................................................... 31
Video Processing (SDK Xtreme) ....................................................................................................................... 32
Introduction................................................................................................................................................... 32
Initialize video capturing from uncompressed video file or VFW source ..................................................... 33
Betaface_LoadVideo ..................................................................................................................................... 33
Betaface_CaptureVideo ................................................................................................................................ 33
Initialize video capturing from custom external video source ...................................................................... 34
Betaface_CaptureVideoCb ............................................................................................................................ 34
Callback CB_GrabNextFrame ...................................................................................................................... 34
De-initializing capturing and releasing allocated resources ........................................................................ 35
Betaface_ReleaseVideo ................................................................................................................................. 35
Set capturing process callbacks .................................................................................................................... 35
Betaface_SetFrameGrabbedCallback ........................................................................................................... 35
Callback CB_OnFrameGrabbed................................................................................................................... 35
Betaface_SetFrameReleasedCallback........................................................................................................... 36
Callback CB_OnFrameReleased .................................................................................................................. 36
Set tracking process callbacks ...................................................................................................................... 37
Betaface_SetFaceInfoUpdatedCallback ....................................................................................................... 37
Callback CB_OnFaceInfoUpdated ............................................................................................................... 37
Starting/stopping both capturing and tracking processes ............................................................................. 39
Betaface_StartDetectFaces ........................................................................................................................... 39
Betaface_StopDetectFaces ............................................................................................................................ 39
Betaface_WaitDetectFaces ........................................................................................................................... 40
Monitoring tracking progress and display debug information ..................................................................... 41
Betaface_GetCurrentDetectionState ............................................................................................................. 41
Betaface_DrawVideoFrame .......................................................................................................................... 41
SDK functions
Each SDK function returns integer value - 0 for no error and negative values for various error conditions.
Following values are predefined for all functions:
BETAFACE_BAD_STATE NULL
BETAFACE_OK 0
BETAFACE_ERROR_INTERNAL -1
BETAFACE_ERROR_INVALIDPARAM -2
BETAFACE_ERROR_LOADINGIMAGE -3
BETAFACE_ERROR_NOTSUPPORTED -4
SDK instance should be initialized prior to calling various SDK functions. Initialization function will return
internal state reference value which should be passed back with each SDK function call. It is
recommended to initialize separate instance for each execution thread. After initialization different images
or video feeds can be repeatedly processed. At the application exit, or to save RAM allocated for instance
de-initialization function should be called.
Call this function to initialize the library and retrieve internal state value.
Parameters:
pState Pointer to BetafaceInternalState variable, by this address internal state reference value
will be returned. Value BETAFACE_BAD_STATE is returned if the function fails.
Return value:
Call this function to release internal library state and all associated resources.
Parameters:
pState Pointer to BetafaceInternalState variable, by this address should be stored valid internal
state reference value.
Return value:
This function loads the static image from the HDD to the memory and converts it to internal Betaface image
representation format.
Parameters:
State Betaface library internal state value, obtained from Betaface_Init function.
strImageFilename full pathname to the static image on the HDD. Accepted file formats are: JPEG files
(*.jpeg;*.jpg;*.jpe), Windows bitmap (*.bmp;*.dib), Portable Network Graphics files
(*.png), Portable image format (*.pbm;*.pgm;*.ppm), Sun raster files (*.sr;*.ras) and
TIFF Files (*.tiff;*.tif).
pImg pointer to BetafaceImage variable, by this address image in internal Betaface
format will be returned.
Return value:
State Betaface library internal state value, obtained from Betaface_Init function.
strImageFilename Full pathname to the static image on the HDD. Accepted file formats are: JPEG
files (*.jpeg;*.jpg;*.jpe), Windows bitmap (*.bmp;*.dib), Portable Network
Graphics files (*.png), Portable image format (*.pbm;*.pgm;*.ppm), Sun raster
files (*.sr;*.ras) and TIFF Files (*.tiff;*.tif).
Img Betaface internal representation image in BetafaceImage type variable
flags Optional combination of image saving parameter flags.
Following flags are currently supported:
BETAFACE_SAVEIMAGE_GRAYSCALE = 0x1 – convert image to grayscale.
BETAFACE_SAVEIMAGE_FLIP_HORISONTAL = 0x2 – mirrors image.
strText Reserved for future use
Return value:
State Betaface library internal state value, obtained from Betaface_Init function.
pImageBytes Pointer to a memory buffer where uncompressed image pixel data is located
according to supplied image size and format parameters.
iWidth Image width in pixels
iHeight Image height in pixels
dPixelAspect Real x/y pixel aspect of the image pixels. For regular images stored as pixel buffers
this value is 1.0. For uncompressed video frames in some specific formats like
MPEG2 this value can differ from 1.0, i.e. pixels are not squares. SDK functions need
square pixels as an input and this function can reshape them.
nFormat Format of the image pixel data in supplied memory buffer. Accepted format values
are:
BETAFACE_MEMORYIMAGE_GG = 0x1 (8 bit grayscale)
BETAFACE_MEMORYIMAGE_RRGGBB = 0x2 (24 bit RGB)
BETAFACE_MEMORYIMAGE_BBGGRR = 0x3 (24 bit BGR)
BETAFACE_MEMORYIMAGE_RRGGBBAA = 0x4 (32 bit RGB)
BETAFACE_MEMORYIMAGE_BBGGRRAA = 0x5 (32 bit BGR)
bFlipVertical If this parameter is true, image buffer will be flipped vertically during conversion. SDK
assumes origin of the image is in top left corner.
pImg Pointer to BetafaceImage variable, by this address image in internal Betaface format
will be returned.
Return value:
State Betaface library internal state value, obtained from Betaface_Init function.
Img Betaface internal representation image in BetafaceImage type variable
nFormat Format of the image pixel data that exported memory image should have.
Accepted format values are:
BETAFACE_MEMORYIMAGE_GG = 0x1 (8 bit grayscale)
BETAFACE_MEMORYIMAGE_RRGGBB = 0x2 (24 bit RGB)
BETAFACE_MEMORYIMAGE_BBGGRR = 0x3 (24 bit BGR)
BETAFACE_MEMORYIMAGE_RRGGBBAA = 0x4 (32 bit RGB)
Parameters:
State Betaface library internal state value, obtained from Betaface_Init function.
Img Betaface internal representation image in BetafaceImage variable to be copied.
pImg Pointer to BetafaceImage variable, by this address a copy of Img image in internal
Betaface format will be returned.
Return value:
Parameters:
State Betaface library internal state value, obtained from Betaface_Init function
pImg Betaface internal representation image in BetafaceImage variable
Return value:
Parameters:
State Betaface library internal state value, obtained from Betaface_Init function
ppImageBytes Pointer to a variable containing memory buffer allocated and returned by
Betaface_SaveMemoryImage function
Return value:
Parameters:
State Betaface library internal state value, obtained from Betaface_Init function
Img Image in internal Betaface format
piWidth By this address width of the image in pixels will be returned
piHeight By this address height of the image in pixels will be returned
Return value:
This function returns display of the image in a separate window for debugging purposes
Parameters:
State Betaface library internal state value, obtained from Betaface_Init function
Img Image in internal Betaface format
strWindowName Window caption name for display
Return value:
Face detection
This functions searches for the face pattern on the given images in all locations and under any angles.
Parameters:
State Betaface library internal state value, obtained from Betaface_Init function
Img Source image in internal Betaface representation
dSettings .Flags Combination of detection flags. Currently following flags are supported:
BETAFACE_DETECTFACES_BASIC = 0x0 or
BETAFACE_DETECTFACES_PRO = 0x1 – specify one of those flags to
indicate which feature points you need to detect – Basic (22 points) or
Basic + Pro (22 + 86 facial points).
BETAFACE_DETECTFACES_BASIC_PROFILE = 0x4 – detect also
profile faces (profile faces will have lower accuracy of recognition and Pro
points detection)
BETAFACE_DETECTFACES_BESTFACEONLY = 0x100 – If this flag is
specified, only single face with highest detection score is processed and
returned.
BETAFACE_DETECTFACES_PROCALC_CALC_ALL = 0xFC03 – If this
flag is supported by your SDK edition you can enable generation of
‘extended measurements’ which describe geometrical face properties,
approximate hairstyle shape, detecting skin, hair, clothes colors and other
measurements. Enabling this flag will slow down face detection function
significantly. Extended measurements will be calculated only for the face
with highest detection score.
dSettings Limits of the source image resolution. First number of pixels is calculated
.iMaxImageWidthPix as nPixels = iMaxImageWidthPix * iMaxImageHeightPix, then if actual
dSettings source image resolution exceeds this number, image is downscaled before
.iMaxImageHeightPix processing. Influences speed and quality of features detection.
Recommended values are 640 or 320 for iMaxImageWidthPix and 480 or
240 for iMaxImageHeightPix. If one or both values are 0 no downscaling
is performed, however this option is not recommended.
dSettings Limits the minimum face size on the image as the fraction to the whole
.dMinFaceSizeOnImage image. Used to increase the speed of detection. 0.3 means that faces that
are 30% size of the whole picture or bigger will be detected. Value should
be adjusted depending on your application. Value can be set to 0.
dSettings Limits the minimum face size as the number of pixels on the shortest face
.iMinFaceSizePix rectangle size. Used to limit minimum face resolution. Recommended
value is 50. Value can be set to 0.
Parameters:
State Betaface library internal state value, obtained from Betaface_Init function
pDetectionResult Pointer to the BetafaceDetectionResult variable where valid detection data in
internal Betaface representation is stored.
Return value:
Detection result is essentially a collection of metadata associated with each face detected. This collection
of metadata is stored in a separate internal collection object for each face. You can query how many faces
were detected, retrieve specific face metadata and later get/set individual parameters values in it.
Parameters:
State Betaface library internal state value, obtained from Betaface_Init function
DetectionResult BetafaceDetectionResult variable where valid detection data in internal Betaface
representation is stored
piFacesCount Pointer to integer variable where number of faces detected will be returned
Return value:
State Betaface library internal state value, obtained from Betaface_Init function
DetectionResult BetafaceDetectionResult variable, where valid detection data in internal
Betaface representation is stored
iFaceIndex Index of the face, starting from 0
pFaceInfo Pointer to the BetafaceFaceInfo variable where the face information data in
internal Betaface representation will be returned.
Return value:
This function creates empty face information structure, which can be further filled in with points and
metadata. It is used when you need to create face information structure manually, for example to crop or
further process face defined by serialized points information stored in external database.
Parameters:
State Betaface library internal state value, obtained from Betaface_Init function
pFaceInfo Pointer to the BetafaceFaceInfo variable where empty face information data in
internal Betaface representation will be returned.
Return value:
Parameters:
State Betaface library internal state value, obtained from Betaface_Init function.
FaceInfo BetafaceFaceInfo variable containing face information data to be copied.
pFaceInfoCopy Pointer to the BetafaceFaceInfo variable where complete copy of FaceInfo face
information data in internal Betaface representation will be returned.
Return value:
Call this function to release face information data and all resources associated with it.
Parameters:
State Betaface library internal state value, obtained from Betaface_Init function.
pFaceInfo Pointer to the BetafaceFaceInfo variable where valid face information data in
internal Betaface representation is stored.
Return value:
Face information is represented by collection of named property values. Each property value is referenced
by combination (bitwise OR) of two integer constants – one of them defining specific Feature and another
defining specific parameter of this feature. Each feature can be one of three types (Face, Point and
Measurement) and have different parameters associated with it. For example: single Face type feature
called “Face” represents rectangular area, where face is found on the image and has X,Y coordinates of
its center as well as width/height of the face rectangle and detection score as parameters.
Features of Point type do not have detection scores or width/height information but only have X,Y
coordinates. Measurements have single value parameter as well as min/max parameters defining a value
within given range. Each parameter value can be either Boolean or Double, depends on the parameter,
and corresponding function should be used to get/set it.
Parameters:
State Betaface library internal state value, obtained from Betaface_Init function
FaceInfo BetafaceFaceInfo variable with stored valid face information data in internal Betaface
representation
param Parameter ID (a combination of face feature flag and parameter flag), for example:
parameter BETAFACE_PARAM_EXISTS | BETAFACE_FEATURE_EYE_L value will be
set to true if left eye was detected on this face and coordinate information is available.
pValue Pointer to bool variable where the requested parameter value will be returned
Return value:
Parameters:
State Betaface library internal state value, obtained from Betaface_Init function
FaceInfo BetafaceFaceInfo variable with stored valid face information data in internal Betaface
representation
param Parameter ID (a combination of face feature flag and parameter flag), for example
parameter BETAFACE_PARAM_X | BETAFACE_FEATURE_EYE_L value will contain X
Parameters:
State Betaface library internal state value, obtained from Betaface_Init function
FaceInfo BetafaceFaceInfo variable where stored valid face information data in internal Betaface
representation
param Parameter ID (a combination of face feature flag and parameter flag)
Value bool parameter value to be set
Return value:
Parameters:
State Betaface library internal state value, obtained from Betaface_Init function
FaceInfo BetafaceFaceInfo variable with stored valid face information data in internal Betaface
representation
param Parameter ID (a combination of face feature flag and parameter flag)
Value double parameter value to be set
Return value:
Predefined parameters:
BETAFACE_FEATURE_FACE 0x00000100
BETAFACE_FEATURE_PRO_CHIN_EARCONN_L 0x00010000
BETAFACE_FEATURE_PRO_CHIN_P1_L 0x00020000
BETAFACE_FEATURE_PRO_CHIN_P2_L 0x00030000
BETAFACE_FEATURE_PRO_CHIN_P3_L 0x00040000
BETAFACE_FEATURE_PRO_CHIN_P4_L 0x00050000
BETAFACE_FEATURE_PRO_CHIN_P5_L 0x00060000
BETAFACE_FEATURE_PRO_CHIN_B 0x00070000
BETAFACE_FEATURE_PRO_CHIN_P5_R 0x00080000
BETAFACE_FEATURE_PRO_CHIN_P4_R 0x00090000
BETAFACE_FEATURE_PRO_CHIN_P3_R 0x000A0000
BETAFACE_FEATURE_PRO_CHIN_P2_R 0x000B0000
BETAFACE_FEATURE_PRO_CHIN_P1_R 0x000C0000
BETAFACE_FEATURE_PRO_CHIN_EARCONN_R 0x000D0000
BETAFACE_FEATURE_PRO_TEMPLE_P4_R 0x000E0000
BETAFACE_FEATURE_PRO_TEMPLE_P3_R 0x000F0000
BETAFACE_FEATURE_PRO_TEMPLE_P2_R 0x00100000
BETAFACE_FEATURE_PRO_TEMPLE_P1_R 0x00110000
BETAFACE_FEATURE_PRO_TEMPLE_R 0x00120000
BETAFACE_FEATURE_PRO_FOREHEAD_R 0x00130000
BETAFACE_FEATURE_PRO_FOREHEAD_P4 0x00140000
BETAFACE_FEATURE_PRO_FOREHEAD_P3 0x00150000
BETAFACE_FEATURE_PRO_FOREHEAD_M 0x00160000
BETAFACE_FEATURE_PRO_FOREHEAD_P2 0x00170000
BETAFACE_FEATURE_PRO_FOREHEAD_P1 0x00180000
BETAFACE_FEATURE_PRO_FOREHEAD_L 0x00190000
BETAFACE_FEATURE_PRO_TEMPLE_L 0x001A0000
BETAFACE_FEATURE_PRO_TEMPLE_P1_L 0x001B0000
BETAFACE_FEATURE_PRO_TEMPLE_P2_L 0x001C0000
BETAFACE_FEATURE_PRO_TEMPLE_P3_L 0x001D0000
BETAFACE_FEATURE_PRO_TEMPLE_P4_L 0x001E0000
BETAFACE_FEATURE_PRO_EYE_O_R 0x001F0000
BETAFACE_FEATURE_PRO_EYE_BO_R 0x00200000
BETAFACE_FEATURE_PRO_EYE_B_R 0x00210000
BETAFACE_FEATURE_PRO_EYE_BI_R 0x00220000
BETAFACE_FEATURE_PRO_EYE_I_R 0x00230000
BETAFACE_FEATURE_PRO_EYE_TI_R 0x00240000
BETAFACE_FEATURE_PRO_EYE_T_R 0x00250000
BETAFACE_FEATURE_PRO_EYE_TO_R 0x00260000
BETAFACE_FEATURE_PRO_EYE_O_L 0x00270000
BETAFACE_FEATURE_PRO_EYE_TO_L 0x00280000
BETAFACE_FEATURE_PRO_EYE_T_L 0x00290000
BETAFACE_FEATURE_PRO_EYE_TI_L 0x002A0000
BETAFACE_FEATURE_PRO_EYE_I_L 0x002B0000
BETAFACE_FEATURE_PRO_EYE_BI_L 0x002C0000
BETAFACE_FEATURE_PRO_EYE_B_L 0x002D0000
BETAFACE_FEATURE_PRO_EYE_BO_L 0x002E0000
BETAFACE_FEATURE_PRO_EYEBROW_I_R 0x002F0000
BETAFACE_FEATURE_PRO_EYEBROW_TI_R 0x00300000
BETAFACE_FEATURE_PRO_EYEBROW_T_R 0x00310000
BETAFACE_FEATURE_PRO_EYEBROW_TO_R 0x00320000
BETAFACE_FEATURE_PRO_EYEBROW_O_R 0x00330000
BETAFACE_FEATURE_PRO_EYEBROW_BO_R 0x00340000
BETAFACE_FEATURE_PRO_EYEBROW_B_R 0x00350000
BETAFACE_FEATURE_PRO_EYEBROW_BI_R 0x00360000
BETAFACE_FEATURE_PRO_EYEBROW_I_L 0x00370000
BETAFACE_FEATURE_PRO_EYEBROW_TI_L 0x00380000
BETAFACE_FEATURE_PRO_EYEBROW_T_L 0x00390000
BETAFACE_FEATURE_PRO_EYEBROW_TO_L 0x003A0000
BETAFACE_FEATURE_PRO_EYEBROW_O_L 0x003B0000
BETAFACE_FEATURE_PRO_EYEBROW_BO_L 0x003C0000
BETAFACE_FEATURE_PRO_EYEBROW_B_L 0x003D0000
BETAFACE_FEATURE_PRO_EYEBROW_BI_L 0x003E0000
BETAFACE_FEATURE_PRO_MOUTH_L 0x003F0000
BETAFACE_FEATURE_PRO_MOUTH_TL 0x00400000
BETAFACE_FEATURE_PRO_MOUTH_T 0x00410000
BETAFACE_FEATURE_PRO_MOUTH_TR 0x00420000
BETAFACE_FEATURE_PRO_MOUTH_R 0x00430000
BETAFACE_FEATURE_PRO_MOUTH_BR 0x00440000
BETAFACE_FEATURE_PRO_MOUTH_B 0x00450000
BETAFACE_FEATURE_PRO_MOUTH_BL 0x00460000
BETAFACE_FEATURE_PRO_NOSE_T_L 0x00470000
BETAFACE_FEATURE_PRO_NOSE_TI_NOSTRIL_L 0x00480000
BETAFACE_FEATURE_PRO_NOSE_TO_NOSTRIL_L 0x00490000
BETAFACE_FEATURE_PRO_NOSE_BO_NOSTRIL_L 0x004A0000
BETAFACE_FEATURE_PRO_NOSE_B_NOSTRIL_L 0x004B0000
BETAFACE_FEATURE_PRO_NOSE_B 0x004C0000
BETAFACE_FEATURE_PRO_NOSE_B_NOSTRIL_R 0x004D0000
BETAFACE_FEATURE_PRO_NOSE_BO_NOSTRIL_R 0x004E0000
BETAFACE_FEATURE_PRO_NOSE_TO_NOSTRIL_R 0x004F0000
BETAFACE_FEATURE_PRO_NOSE_TI_NOSTRIL_R 0x00500000
BETAFACE_FEATURE_PRO_NOSE_T_R 0x00510000
BETAFACE_FEATURE_PRO_EYE_IRIS_R 0x00520000
BETAFACE_FEATURE_PRO_EYE_IRIS_L 0x00530000
BETAFACE_FEATURE_PRO_NOSE_TIP 0x00540000
BETAFACE_FEATURE_PRO_CHEEKBONE_L 0x00550000
BETAFACE_FEATURE_PRO_CHEEKBONE_R 0x00560000
BETAFACE_FEATURE_PROPARAM_CALC_FIRST 0x25000000
and
BETAFACE_FEATURE_PROPARAM_CALC_LAST 0x28FF0000
with a step of
BETAFACE_FEATURE_PROPARAM_MULT 0x00010000
For complete list of Measurement features supported in your version of SDK please contact Betaface
support.
Face recognition
Face recognition process involves converting face information and corresponding image into independent
recognition binary ‘key’ which usually have a size of few kilobytes or less and can be stored in the
database or any other storage like file system. Recognition key is essentially face and facial features
description in compact binary form. Recognition keys can be compared in pairs giving similarity value.
Similarity value can be used either directly to sort results of multiple faces comparison in the order of
similarity or, with a conversion for specific False Alarm (FA) rate and rank, they give normalized
confidence value - how likely two faces belong to the same person, in the range 0-100% as well as
decision whether it is the same person or not. Accuracy of such identification/verification tasks strongly
depends on the data used, size of the problem, particular algorithm and comparison strategy.
State Betaface library internal state value, obtained from Betaface_Init function
Img Image containing face to crop and to which FaceInfo corresponds
FaceInfo BetafaceFaceInfo variable where valid face information data in internal Betaface
representation is stored
flags Flag defining which key to generate, depending on SDK edition can be one of:
BETAFACE_RECKEY_DEFAULT = 0xFF – best available key type
BETAFACE_RECKEY_BASIC = 0x1
BETAFACE_RECKEY_PRO = 0x2
ppFaceKeyData Pointer to the variable where the address of the key binary data will be returned
piFaceKeyLen Pointer to the integer variable where length of the key data in bytes will be
returned
Return value:
Parameters:
State Betaface library internal state value, obtained from Betaface_Init function
pFaceKeyData1 Address of first face “key” binary data
pFaceKeyData2 Address of second face “key” binary data
State Betaface library internal state value, obtained from Betaface_Init function
pFaceKeyData1 Address of first face “key” binary data
pFaceKeyData2 Address of second face “key” binary data
FaceKeysLen Length of the keys data in bytes
iRank Target recognition rank (currently only 0 rank is supported)
dFalseAlarmRate Target false alarm rate, default 0.02
pbIsSamePerson Returned identification decision – true if those two faces belong to the same
person.
pdNormalizedConfidence Returned abstract confidence value that those two faces belong to the
same person, normalized in the range 0-100%
Return value:
This function release face “key” binary data and all associated resources
Parameters:
State Betaface library internal state value, obtained from Betaface_Init function
ppFaceKeyData Pointer to variable containing address of face “key” binary data to be released
Return value:
State Betaface library internal state value, obtained from Betaface_Init function
pFaceKeyData1 First recognition key for join operation
pFaceKeyData2 Second recognition key for join operation
FaceKeysLen Length of the keys data in bytes
bAppend Type of operation, when true then key1 and key2 are joined, when false key2 is
subtracted from key1
ppFaceKeyData Pointer to the variable where the address of the resulting strong key binary data
will be returned
piFaceKeyLen Pointer to the integer variable where length of the key data in bytes will be
returned
Return value:
State Betaface library internal state value, obtained from Betaface_Init function
pFaceKeyData Address of face “key” binary data
iFaceKeyLen Length of the key data in bytes
iWidth Output image width
iHeight Output image height
dEyesDistance Equivalent to the same parameter in Betaface_CropFaceImage function
dEyeLineHeightK Equivalent to the same parameter in Betaface_CropFaceImage function
pImg Resulting image with synthetic reconstructed face
Return value:
State Betaface library internal state value, obtained from Betaface_Init function
pFaceKeyData Address of face “key” binary data
iFaceKeyLen Length of the key data in bytes
iWidth Output image width
iHeight Output image height
dEyesDistance Equivalent to the same parameter in Betaface_CropFaceImage function
dEyeLineHeightK Equivalent to the same parameter in Betaface_CropFaceImage function
strFilename Resulting avi filename and path with synthetic reconstructed face
Return value:
Classifying faces (Gender, Age, Ethnicity, Smile, Glasses or facial hair detection)
State Betaface library internal state value, obtained from Betaface_Init function
Img Image containing face to analyze and to which FaceInfo corresponds
FaceInfo BetafaceFaceInfo variable where valid face information data in internal Betaface
representation is stored
flags Flag defining which classifiers to run, depending on SDK edition can be one of:
BETAFACE_CLASSIFIER_ALL = 0xFFFFFFFF
BETAFACE_CLASSIFIER_GENDER = 0x60010000
BETAFACE_CLASSIFIER_AGE = 0x60020000
BETAFACE_CLASSIFIER_ETHNICITY = 0x60040000
BETAFACE_CLASSIFIER_EXPRESSION = 0x60080000
BETAFACE_CLASSIFIER_GLASSES = 0x60100000
BETAFACE_CLASSIFIER_MUSTACHE = 0x60200000
BETAFACE_CLASSIFIER_BEARD = 0x60400000
Return value:
State Betaface library internal state value, obtained from Betaface_Init function
Img Image containing face to crop and to which FaceInfo corresponds
FaceInfo BetafaceFaceInfo variable where valid face information data in internal
Betaface representation is stored
dEyesDistance The distance between the eyes on the output face rectangle, as a fraction of the
whole out image width, for example 0.3 means that the distance between the
eyes on the output face rectangle will be 30% of the cropped image width
dEyeLineHeight The distance between the top of the output face rectangle and the line between
the eyes, as a fraction of the whole out image height, for example 0.4 means that
the distance between the top of the output face rectangle and the line between
the eyes will be 40% of the cropped image height
bDeRotate Specify true if you want to de-rotate face into strict vertical portrait position and fit
it into the output image dimensions. If this parameter is set to false face will be
cropped under the angle it appears on the source image. It is usually set to true
iCropWidth Output image width in pixels
iCropHeight Output image height in pixels
dAreaScale Additional scale coefficient applied to the face rectangle before the area to crop is
determined. If this coefficient is >1.0 then the cropped rectangle is scaled by this
factor or until the borders of the whole image are reached; if the face rectangle
was already out of the image borders then this coefficient will be fixed to 1.0. If the
specified coefficient is <1.0 then no checks are performed and scaling factor is
applied directly.
colorBackground Background color to fill in cropped image areas that fall outside of original image
borders. Color value is in RGB format, represented as integer 0x00RRGGBB
Commonly used color values:
BETAFACE_COLOR_BLACK = 0x00000000
BETAFACE_COLOR_WHITE = 0x00FFFFFF
BETAFACE_COLOR_RED = 0x00FF0000
BETAFACE_COLOR_GREEN = 0x0000FF00
BETAFACE_COLOR_BLUE = 0x000000FF
pCroppedFaceImg Pointer to the BetafaceImage variable where the cropped image in internal
Betaface representation will be returned
pCroppedFaceInfo Pointer to the BetafaceFaceInfo variable where the face information data,
converted to the cropped image coordinate system will be returned
Return value:
State Betaface library internal state value, obtained from Betaface_Init function
Img Image containing face to crop and to which FaceInfo corresponds
FaceInfo BetafaceFaceInfo variable where valid face information data in internal Betaface
representation is stored.
dEyesDistance The distance between the eyes on the face rectangle, as a fraction of the whole
face rectangle width, for example 0.3 mean that the distance between the eyes
on the output face rectangle will be 30% of the whole face rectangle width
dEyeLineHeight The distance between the top of the output face rectangle and the line between
the eyes, as a fraction of the whole face rectangle height, for example 0.4 mean
that the distance between the top of the output face rectangle and the line
between the eyes will be 40% of the whole face rectangle height
dFaceAspectHW Aspect ratio of the face rectangle
dImageAspectHW Aspect ratio of the final image area to cut
colorBackground Background color to fill in cropped image areas that fall outside of original image
borders. Color value is in RGB format, represented as integer 0x00RRGGBB.
Commonly used color values:
BETAFACE_COLOR_BLACK = 0x00000000
BETAFACE_COLOR_WHITE = 0x00FFFFFF
BETAFACE_COLOR_RED = 0x00FF0000
BETAFACE_COLOR_GREEN = 0x0000FF00
BETAFACE_COLOR_BLUE = 0x000000FF
pCroppedFaceImg Pointer to the BetafaceImage variable where the cropped image in internal
Betaface representation will be returned
pCroppedFaceInfo Pointer to the BetafaceFaceInfo variable where the face information data,
converted to the cropped image coordinate system will be returned
Return value:
State Betaface library internal state value, obtained from Betaface_Init function
Img Image containing face to crop and to which FaceInfo corresponds
FaceInfo BetafaceFaceInfo variable where valid face information data in internal Betaface
representation is stored
flags Flags that can be combined using bitwise OR operation, specifying what (rectangles,
points) to draw:
BETAFACE_DRAWFACE_FACERECT = 0x00000001
BETAFACE_DRAWFACE_EYECROSSES = 0x00000002
BETAFACE_DRAWFACE_FEATURES = 0x00000004
BETAFACE_DRAWFACE_FEATURES_PRO = 0x00010000
BETAFACE_DRAWFACE_CONTOURS_PRO = 0x00020000
BETAFACE_DRAWFACE_ALL_BASIC = 0x0000FFFF
BETAFACE_DRAWFACE_ALL_PRO = 0xFFFF0000
BETAFACE_DRAWFACE_ALL = 0xFFFFFFFF
Return value:
State Betaface library internal state value, obtained from Betaface_Init function
SrcFaceImg Image containing source face and to which SrcFaceInfo corresponds
SrcFaceInfo BetafaceFaceInfo variable where valid face information of the source face data in
internal Betaface representation is stored
DstFaceImg Image containing destination face and to which DstFaceInfo corresponds. This
parameter can be NULL, in which case function performs a face Warp, using
DstFaceInfo as a target face shape for geometrical distortion
DstFaceInfo BetafaceFaceInfo variable where valid face information of the destination face data
in internal Betaface representation is stored
dTransitionKoeff Transition coefficient ranges from 0.0 (100% source face) to 0.5 (50% of each face)
to 1.0 (100% destination face) to determine morphing stage
pMorphedImg Pointer to the BetafaceImage variable where the resulting morphed image ininternal
Betaface representation will be returned
Return value:
State Betaface library internal state value, obtained from Betaface_Init function
Parameters:
State Betaface library internal state value, obtained from Betaface_Init function
Img Image containing source face to which SrcFaceInfo corresponds
FaceInfo BetafaceFaceInfo variable where valid face information of the source face data in
internal Betaface representation is stored
iTransform Transformation type index
dValue Transformation strength
pFaceInfo Pointer to the BetafaceFaceInfo variable where modified face information will be
returned
Return value:
You can create ‘averaged’ face image from the group of input face images. This is done by warping each
face image into average face shape, accumulate those warped images as well as original face shapes
and then warping accumulated face image into accumulated face shape. Following functions and
Betaface_MorphFaces function is all you need for this task.
State Betaface library internal state value, obtained from Betaface_Init function
dEyesDistance The distance between the eyes on the output face rectangle, as a fraction of the
whole out image width, for example 0.3 means that the distance between the
eyes on the output face rectangle will be 30% of the cropped image width
dEyeLineHeight The distance between the top of the output face rectangle and the line between
the eyes, as a fraction of the whole out image height, for example 0.4 means that
the distance between the top of the output face rectangle and the line between
the eyes will be 40% of the cropped image height
iImageWidth Destination image width
iImageHeight Destination image height
pAverageFaceInfo Pointer to the BetafaceFaceInfo variable where the global average face
information data, converted to the cropped image coordinate system will be
returned
Return value:
State Betaface library internal state value, obtained from Betaface_Init function
OldAvgImg Image containing accumulated average face texture, warped to a global face
average shape obtained in Betaface_GetStoredAverageFaceInfo function
OldAvgCount Number of faces accumulated in average face texture image OldAvgImg
bAppend Type of update operation, set it to true to add texture image into accumulated
image or false to subtract from it
Img Image containing new single face texture to append into accumulated averageface
texture
AvgCount Number of faces already accumulated in image Img. If Img is not accumulated
texture image i.e. contain only one face, set this parameter to 1
pAverageImg Pointer to the BetafaceImage variable where the accumulated average face texture
image in internal Betaface representation will be returned
Return value:
State Betaface library internal state value, obtained from Betaface_Init function
OldAvgFaceInfo BetafaceFaceInfo variable where accumulated average face shape information,
in internal Betaface representation is stored
OldAvgCount Number of face shapes accumulated in average face shape information
OldAvgFaceInfo
bAppend Type of update operation, set it to true to add face shape information into
accumulated face shape information or false to subtract from it
FaceInfo BetafaceFaceInfo variable containing new single face shape information to
append into accumulated average face shape information
AvgCount Number of face shapes already accumulated in face shape information
FaceInfo. If FaceInfo is not accumulated face shape i.e. contain only one face,
set this parameter to 1
pAverageFaceInfo Pointer to the BetafaceFaceInfo variable where the accumulated average face
shape information in internal Betaface representation will be returned
Return value:
Introduction
Betaface SDK video processing engine can analyze video files or video streams from cameras
via VFW interface and support custom capturing via callbacks. Video processing chain split can be divided
into two logical parts:
– capturing process, which retrieves video frames from the camera or video file, stores them in runtime
buffer for processing and releases them, when they are no longer required.
- analyzing or tracking process, which analyzes captured data, detects and tracks faces + facial features
and recognizes persons.
Betaface SDK does capturing and tracking threads synchronization internally. Your application
should be aware that whole video processing chain is a multithreaded process, i.e callbacks can be called
at any time from different threads.
When integrating into your application, typical sequence is first to initialize Betaface SDK
(Betaface_Init), initialize capturing, and connect callback functions and then start/stop capturing and
tracking processes using StartDetectFaces/StopDetectFaces functions. When exiting application first de-
initialize video subsystem by calling Betaface_ReleaseVideo, and then de-initialize Betaface SDK by
calling Betaface_Deinit function.
General and very important rule of integration is that no callback at any time can be delayed on
your side in order not to disrupt tracking/capturing process. Do not call IO functions, wait for window
messages, access GUI or use any kind of synchronized calls anywhere in handler function. Do not release
data supplied to you in callback (video frames, parameters) or store any pointers. Maximum you can do
inside your callback handler is to copy, using corresponding copy functions, the data (video frame,
parameters) you are interested in somewhere in your local storage and immediately return. Don’t forget
callback can be called at once from multiple threads; therefore make sure you use locks to synchronize
writing operations in your local storage. Make sure that your local storage can’t be locked for significant
time from other place. Refer to or use as a starting point supplied sample application(s).
Betaface .Net interface assembly and advanced sample video project FDCamStream offers
extended capturing interface based on DirectShow.
This function initializes offline capturing from video file and returns internal Betaface video capturing runtime
state
Parameters:
State Betaface library internal state value, obtained from Betaface_Init function
strVideoFilename Full pathname to the video file on the HDD. Video will be decoded using standard
Windows VFW interfaces, meaning only few video codecs and uncompressed
frame formats are supported
pVideo Pointer to BetafaceVideo variable, by this address video capturing runtime state
in internal Betaface format will be returned
Return value:
Betaface_CaptureVideo (BetafaceInternalState State, int iCameraIdx, int iWidth, int iHeight, BetafaceVideo*
pVideo)
This function initializes live capturing from camera and return internal Betaface video capturing runtime state
Parameters:
State Betaface library internal state value, obtained from Betaface_Init function
iCameraIdx Index of the camera to select from VFW interface
iWidth X size of the video frame (should be supported by the camera)
iHeight Y size of the video frame (should be supported by the camera)
pVideo Pointer to BetafaceVideo variable, by this address video capturing runtime state in
internal Betaface format will be returned
Return value:
State Betaface library internal state value, obtained from Betaface_Init function
grabFunc Pointer to frame grabbing callback handler function
pArguments Pointer that will be passed back to you in every callback call
bOnline TRUE when it is a live camera stream, FALSE when it is offline capture from video file.
This parameter will affect tracking procedure and whether a tracker will or will not drop
frames it cannot process in time.
pVideo Pointer to BetafaceVideo variable, by this address video capturing runtime state in
internal Betaface format will be returned
Return value:
Video BetafaceVideo variable containing video capturing runtime state in internal Betaface
format
iFrameIdx Frame counter, starting from 0. Will increase with each callback call.
pFrame Pointer where to write BetafaceImage with frame data
pdFrameTime Pointer where to write frame relative time in seconds
pArguments Your pointer supplied in Betaface_CaptureVideoCb function
Return value:
This function stops capturing process and release all internal resources related to it
Parameters:
State Betaface library internal state value, obtained from Betaface_Init function
pVideo Pointer to variable containing video capturing runtime state in internal Betaface format
Return value:
Parameters:
State Betaface library internal state value, obtained from Betaface_Init function
Video Video capturing runtime state in internal Betaface format
callbackFunc Pointer to frame grabbed callback handler function
pArguments Pointer that is passed back to you in every callback call
Return value:
Video BetafaceVideo variable containing video capturing runtime state in internal Betaface
format
Frame BetafaceImage variable containing frame pixel data in internal Betaface format
iFrameIdx Captured frame relative index
dFrameTime Captured frame relative time in seconds
pArguments Your pointer supplied in Betaface_SetFrameGrabbedCallback function
Return value:
Return BETAFACE_OK
Parameters:
State Betaface library internal state value, obtained from Betaface_Init function
Video Video capturing runtime state in internal Betaface format
callbackFunc Pointer to frame released callback handler function
pArguments Pointer that is passed back to you in every callback call
Return value:
Return BETAFACE_OK
Parameters:
State Betaface library internal state value, obtained from Betaface_Init function
Video Video capturing runtime state in internal Betaface format
callbackFunc Pointer to tracking information callback handler function
pArguments Pointer that is passed back to you in every callback call
Return value:
Parameters:
Frame Current frame, when provided can be used together with FaceInfo to
generate recognition keys, analyze faces. Only provided for Initial and
Lenupdate updates and non-tracking updates (i.e. full scans).
FaceInfo Face info corresponding to the current frame
Face Cropped face image of this appearance (currently NULL)
pArguments Your pointer supplied in Betaface_SetFaceInfoUpdatedCallback function
Return value:
Return BETAFACE_OK
State Betaface library internal state value, obtained from Betaface_Init function
Video BetafaceVideo variable containing video capturing runtime state in
internal Betaface format
tSettings. Detection tick time in seconds, how often stream will be scanned for the
dDetectionTickSeconds new faces
tSettings. Minimum amount of seconds face should be tracked not to be rejected as
dMinExposureSeconds too short appearance
dSettings Face detection settings. Please refer to Betaface_DetectFaces function
documentation for description of those parameters. Two additional face
detections flags can be set here:
BETAFACE_DETECTFACES_TRACK_BASIC = 0x0
BETAFACE_DETECTFACES_TRACK_PRO=0x9
This suggests tracker which points to use to track faces – 86 Pro or only
8 basic.
Return value:
Parameters:
Parameters:
Parameters:
State Betaface library internal state value, obtained from Betaface_Init function
Video Video capturing runtime state in internal Betaface format
piFacesCount Pointer where number of faces detected is returned
pDetectionResult Pointer where snapshot of detection result should be written
Return value:
State Betaface library internal state value, obtained from Betaface_Init function
Img Video frame in internal Betaface format
iFrameIdx Index of video frame for which to draw available information
iFaceID Index of the face for which to draw available information
flags Flags, specifying what to draw – faces, points, IDs, in white or black and should tracker
additional info be displayed:
BETAFACE_DRAWVIDEOFRAME_FACE = 0x1
BETAFACE_DRAWVIDEOFRAME_POINTS = 0x2
BETAFACE_DRAWVIDEOFRAME_IDENTITY = 0x4
BETAFACE_DRAWVIDEOFRAME_CENTER = 0x8
BETAFACE_DRAWVIDEOFRAME_ALL = 0x0000FFFF
BETAFACE_DRAWVIDEOFRAME_INWHITE =0x00010000
BETAFACE_DRAWVIDEOFRAME_FILTER_SINGLES=0x00100000
BETAFACE_DRAWVIDEOFRAME_FILTER_TAILS=0x00200000
Return value: