Face Detection Algorithm
Face Detection Algorithm
Face Detection Algorithm
http://www.luxand.com
Developer’s Guide
Requirements
The FaceSDK library supports the following platforms:
Windows 2000/XP/2003/Vista/2008/Seven
Linux (RHEL 5+, CentOS 5+ and other)
Mac OS X 10.4+ x86_64
Intel processor is recommended for better performance.
Minimum system requirements:
1.6 GHz processor
256 MB RAM
150 MB free disk space
Recommended system requirements:
2.4 GHz Intel multi-core processor
2 GB RAM
DirectShow-compatible webcam
Note that web camera functions are available only for Windows 32/64 platforms.
Technical Specifications
The FaceSDK library has the following technical specifications:
Face Detection
Robust frontal face detection
Detection of multiple faces in a photo
Head rotation support: –30..30 degrees of in-plane rotation and –30..30 degrees out-
of-plane rotation
Determines in-plane face rotation angle
Detection speed: as fast as 370 frames per second*, depending on resolution
o Realtime detection: 0.0027 sec (370 FPS)* , webcam resolution, –15..15
degrees of in-plane head rotation
Face Matching
Matching of two faces at given FAR (False Acceptance Rate) and FRR (False
Rejection Rate)
Enrollment time: 0.117 seconds (8.5 FPS)* (at webcam resoluton)
Template Size: 16 kb
Matching speed: 30,000 faces per second*
Returned information: facial similarity level
Library Size
The size of the redistributables does not exceed 10MB for each platform.
*
Measured on Intel 2.4 Ghz Processor
Installation
Windows
To install Luxand FaceSDK, run the installation file:
Luxand_FaceSDK_Setup.exe
and follow the instructions.
Directory Structure
The FaceSDK directory contains the following directories and files:
Sample Applications
FaceSDK is distributed with the following sample applications (they can be found in the
samples\ directory of FaceSDK):
1. LiveRecognition
This application memorizes a person from a camera and recognizes her when she
looks into a webcam. Source code is available on Microsoft C# 2005/2008, Borland
Delphi 6.0/7.0, Microsoft Visual C++ 2005/2008, Microsoft Visual Basic .NET
2005/2008 and Visual Basic 6.0.
2. FaceTracking
This application receives a picture from a webcam and highlights all detected faces
with rectangles. Source code is available on Microsoft C# 2005/2008, Borland Delphi
6.0/7.0, Microsoft Visual C++ 2005/2008, Microsoft Visual Basic .NET 2005/2008
and Visual Basic 6.0.
3. Lookalikes
This application allows the user to create a database of faces and run a search for best
matches (the most alike face from a database is shown). Source code is available on
C++, Microsoft C# 2005/2008, Borland Delphi 6.0/7.0.
4. FacialFeatures
This application opens a photograph, detects a face in a photo (only one face, the one
that can be detected best), detects face features and draws a frame around the detected
Redistributables
The following files may be redistributed with your application:
Library Activation
FaceSDK is a copy-protected library, and must be activated with a license key before its use.
You need to pass the license key received from Luxand, Inc. to the FSDK_ActivateLibrary
function before initializing Luxand FaceSDK. Almost all FaceSDK functions will return the
FSDKE_NOT_ACTIVATED error code in case the library is not activated. To retrieve your
license information, call FSDK_GetLicenseInfo. This function returns the name the library is
licensed to. You may need to use the FSDK_GetHardware_ID function to obtain your
hardware ID if your license is restricted to one machine only. Additionally, you can find out
hardware ID by running the hardwareid program (ShowHardwareID.exe for Windows), which
is located in the bin directory.
To get a temporary evaluation key from Luxand, Inc., run License Key Wizard from the Start
– Luxand – FaceSDK menu. You may also request this key at
http://luxand.com/facesdk/requestkey/.
FSDK_GetHardware_ID Function
Generates a Hardware ID code.
C++ Syntax:
int FSDK_GetHardware_ID(char* HardwareID);
Delphi Syntax:
function FSDK_GetHardware_ID(HardwareID: PChar): integer;
C# Syntax:
int FSDK.GetHardwareID(out string HardwareID);
VB Syntax:
Function FSDKVB_GetHardwareID(ByRef HardwareID As Byte) As
Long
Parameters:
HardwareID – address of the null-terminated string for receiving the Hardware ID code.
Return Value:
Returns FSDKE_OK if successful.
FSDK_GetLicenseInfo Function
Retrieves license information.
C++ Syntax:
int FSDK_GetLicenseInfo(char* LicenseInfo);
Delphi Syntax:
function FSDK_GetLicenseInfo(LicenseInfo: PChar): integer;
C# Syntax:
int FSDK.GetLicenseInfo(out string LicenseInfo);
VB Syntax:
Function FSDKVB_GetLicenseInfo(ByRef LicenseInfo As Byte) As
Long
Parameters:
LicenseInfo – address of the null-terminated string for receiving the license
information. This variable should be allocated no less than 256 bytes of memory.
Return Value:
Returns FSDKE_OK if successful.
FSDK_Finalize Function
Finalizes the FaceSDK library. Should be called when the application is exited.
C++ Syntax:
int FSDK_Finalize();
Delphi Syntax:
function FSDK_Finalize: integer;
C# Syntax:
int FSDK.Finalize();
VB Syntax:
Function FSDKVB_Finalize() As Long
Return Value:
Returns FSDKE_OK if successful.
FaceSDK provides a number of functions to load images to the internal representation from
files, buffers or HBITMAP handles and to save images from the internal representation to
files, buffers and HBITMAP handles. Each FSDK_LoadImageFromXXXX function creates a
new HImage handle, which can be deleted using the FSDK_FreeImage function.
FSDK_LoadImageFromFile Function
Loads the image from a file and provides the internal handle of this image.
C++ Syntax:
int FSDK_LoadImageFromFile(HImage* Image, char* FileName);
Delphi Syntax:
function FSDK_LoadImageFromFile(Image: PHImage; FileName:
PChar): integer;
C# Syntax:
int FSDK.LoadImageFromFile(ref UInt32 Image, string FileName)
VB Syntax:
Function FSDKVB_LoadImageFromFile(ByRef Image As Long, ByVal
FileName As String) As Long
Parameters:
Image – pointer to HImage for receiving the loaded image handle.
FileName – filename of the image to be loaded. FaceSDK supports the JPG, PNG and BMP
file formats.
Return Value:
Returns FSDKE_OK if successful.
FSDK_SaveImageToFile Function
Saves an image to a file. When saving to .jpg files, you can set the quality of JPEG
compression using the FSDK_SetJpegCompressionQuality function.
C++ Syntax:
int FSDK_SaveImageToFile(HImage Image, char* FileName);
Example
int img1;
FSDK_Initialize("");
FSDK_LoadImageFromFile(&img1, "test.bmp"); // load .bmp file
FSDK_SaveImageToFile(img1, "test.jpg"); // save as .jpg
FSDK_LoadImageFromBuffer Function
Loads an image from a buffer and provides the internal handle of this image. The function
suggests that the image data is organized in a top-to-bottom order, and the distance between
adjacent rows is ScanLine bytes (for example, in the 24-bit image, the ScanLine value might
be 3*Width bytes if there is no spacing between adjacent rows). The following image modes
are supported:
FSDK_GetImageBufferSize Function
Returns the size of the buffer required to store an image.
C++ Syntax:
int FSDK_GetImageBufferSize(HImage Image, int * BufSize,
FSDK_IMAGEMODE ImageMode);
Delphi Syntax:
function FSDK_GetImageBufferSize(Image: HImage; BufSize:
PInteger; ImageMode: FSDK_IMAGEMODE): integer;
VB Syntax:
Function FSDKVB_GetImageBufferSize(ByVal Image As Long, ByRef
BufSize As Long, ByVal ImageMode As FSDK_IMAGEMODE) As Long
The function is not available in .NET.
Parameters:
Image – internal handle of an image.
BufSize – pointer to an integer variable to store the calculated buffer size.
ImageMode – desired image mode of a buffer.
Return Value:
Returns FSDKE_OK if successful.
FSDK_LoadImageFromHBitmap Function
Loads the image from an HBITMAP handle and provides the internal handle of this image.
C++ Syntax:
int FSDK_LoadImageFromHBitmap(HImage* Image, HBITMAP*
BitmapHandle);
Delphi Syntax:
function FSDK_LoadImageFromHBitmap(Image: PHImage;
BitmapHandle: HBitmap): integer;
C# Syntax:
int FSDK.LoadImageFromHBitmap(ref UInt32 Image, IntPtr
BitmapHandle);
VB Syntax:
Function FSDKVB_LoadImageFromHBitmap(ByRef Image As Long,
ByVal BitmapHandle As Integer) As Long
Parameters:
Image – pointer to HImage for receiving the loaded image handle.
BitmapHandle – handle of the image to be loaded.
FSDK_SaveImageToHBitmap Function
Creates an HBITMAP handle containing the image.
C++ Syntax:
int FSDK_SaveImageToHBitmap(HImage Image, HBITMAP*
BitmapHandle);
Delphi Syntax:
function FSDK_SaveImageToHBitmap(Image: HImage; BitmapHandle:
PHBitmap): integer;
C# Syntax:
int FSDK.SaveImageToHBitmap(UInt32 Image, ref IntPtr
BitmapHandle);
VB Syntax:
Function FSDKVB_SaveImageToHBitmap(ByVal Image As Long, ByRef
BitmapHandle As Integer) As Long
Parameters:
Image – internal handle of the image to be saved to HBITMAP.
BitmapHandle – pointer to HBITMAP the created HBITMAP handle will be saved to.
Return Value:
Returns FSDKE_OK if successful.
FSDK_SetJpegCompressionQuality
Sets the quality of the JPEG compression to use in the FSDK_SaveImageToFile function.
C++ Syntax:
int FSDK_SetJpegCompressionQuality(int Quality);
Delphi Syntax:
function FSDK_SetJpegCompressionQuality(Quality: integer):
integer;
C# Syntax:
int FSDK.SetJpegCompressionQuality(int Quality);
VB Syntax:
Function FSDKVB_SetJpegCompressionQuality(ByVal Quality As
Long) As Long
Parameters:
Quality – quality of JPEG compression. Varies from 0 to 100.
FSDK_GetImageWidth Function
Returns the width of an image.
C++ Syntax:
int FSDK_GetImageWidth(HImage SourceImage, int* Width);
Delphi Syntax:
function FSDK_GetImageWidth(SourceImage: HImage; Width:
PInteger): integer;
C# Syntax:
int FSDK.GetImageWidth(UInt32 SourceImage, ref int Width);
VB Syntax:
Function FSDKVB_GetImageWidth(ByVal SourceImage As Long, ByRef
Width As Long) As Long
Parameters:
SourceImage – internal handle of an image.
Width – pointer to an integer variable to store the width of an image.
Return Value:
Returns FSDKE_OK if successful.
FSDK_GetImageHeight Function
Returns the height of an image.
C++ Syntax:
int FSDK_GetImageHeight(HImage SourceImage, int* Height);
Delphi Syntax:
function FSDK_GetImageHeight(SourceImage: HImage; Height:
PInteger): integer;
C# Syntax:
int FSDK.GetImageHeight(UInt32 SourceImage, ref int Height);
VB Syntax:
Function FSDKVB_GetImageHeight(ByVal SourceImage As Long,
ByRef Height As Long) As Long
Parameters:
SourceImage – internal handle of an image.
Height – pointer to an integer variable to store the height of an image.
FSDK_MirrorImage Function
Mirrors an image. The function can mirror horizontally and vertically.
C++ Syntax:
int FSDK_MirrorImage(HImage Image, bool
UseVerticalMirroringInsteadOfHorizontal);
Delphi Syntax:
function FSDK_MirrorImage(Image: HImage;
UseVerticalMirroringInsteadOfHorizontal: boolean): integer;
C# Syntax:
int FSDK.MirrorImage(UInt32 Image, bool
UseVerticalMirroringInsteadOfHorizontal);
VB Syntax:
Function FSDKVB_MirrorImage(ByVal Image As Long, ByVal
UseVerticalMirroringInsteadOfHorizontal As Boolean) As Long
Parameters:
Image – handle of the image to be mirrored.
UseVerticalMirroringInsteadOfHorizontal – sets the mirror direction.
TRUE: left-to-right swap;
FALSE: top-to-bottom swap;
Return Value:
Returns FSDKE_OK if successful.
FSDK_FreeImage Function
Frees the internal representation of an image.
C++ Syntax:
int FSDK_FreeImage(HImage Image);
Delphi Syntax:
function FSDK_FreeImage(Image: HImage): integer;
C# Syntax:
int FSDK.FreeImage(UInt32 Image);
VB Syntax:
Function FSDKVB_FreeImage(ByVal Image As Long) As Long
Face Detection
You can use the FSDK_DetectFace function to detect a frontal face in an image. The function
returns the position of the face in the image. The performance and reliability of face detection
is controlled by the FSDK_SetFaceDetectionParameters and
FSDK_SetFaceDetectionThreshold functions.
Typical parameters for face detection are:
To detect faces from a webcam in real time, call:
FSDK_SetFaceDetectionParameters(false, false, 100);
To reliably detect faces in digital camera photos, call
FSDK_SetFaceDetectionParameters(false, false, 500);
Data types
Luxand FaceSDK introduces the TFacePosition data type that stores the information about the
position of the face. The xc and yc fields specifies the X and Y coordinates of the center of
the face, w specifies the width of the face, and angle specifies the in-plane rotation angle of
the face in degrees.
C++ Declaration:
typedef struct {
int xc, yc, w;
double angle;
} TFacePosition;
C# Declaration:
public struct TFacePosition {
public int xc, yc, w;
public double angle;
}
Delphi Declaration:
TFacePosition = record
xc, yc, w: integer;
angle: double;
end;
PFacePosition = ^TFacePosition;
FSDK_DetectFace Function
Detects a frontal face in an image and stores information about the face position into the
TFacePosition structure.
C++ Syntax:
int FSDK_DetectFace(HImage Image, TFacePosition*
FacePosition);
Delphi Syntax:
function FSDK_DetectFace(Image: HImage; FacePosition:
PFacePosition): integer;
C# Syntax:
int FSDK.DetectFace(UInt32 Image, ref FSDK.TFacePosition
FacePosition);
VB Syntax:
Function FSDKVB_DetectFace(ByVal Image As Long, ByRef
FacePosition As TFacePosition) As Long
Parameters:
Image – handle of the image to detect the face in.
FacePosition – pointer to the TFacePosition structure to store information about the face
position.
Return Value:
Returns FSDKE_OK if successful. If a face is not found, the function returns the
FSDKE_FACE_NOT_FOUND code. If the input image is too small (less than 20x20 pixels),
the functions returns FSDKE_IMAGE_TOO_SMALL.
Example
int img1;
TFacePosition FacePosition;
FSDK_Initialize("");
FSDK_LoadImageFromFile(&img1, "test.jpg");
FSDK_DetectFace(img1, &FacePosition);
FSDK_Initialize("");
FSDK_LoadImageFromFile(&img1, "test.jpg");
FSDK_DetectMultipleFaces(img1, &DetectedCount , FaceArray,
sizeof(FaceArray));
FSDK_SetFaceDetectionThreshold Function
Sets a threshold value for face detection. The default value is 5.
The function allows adjusting the sensitivity of the detection. If the threshold value is set to a
higher value, the detector will only recognize faces with sharp, clearly defined details, thus
reducing the number of false positive detections. Setting the threshold lower allows detecting
more faces with less clearly defined features at the expense of increased number of false
positives.
C++ Syntax:
int FSDK_SetFaceDetectionThreshold(int Threshold);
Delphi Syntax:
function FSDK_SetFaceDetectionThreshold(Threshold: integer):
integer;
C# Syntax:
int FSDK.SetFaceDetectionThreshold(int Threshold);
VB Syntax:
Function FSDKVB_SetFaceDetectionThreshold(ByVal Threshold As
Long) As Long
Parameters:
Threshold – Threshold value.
C# Declaration:
public struct TPoint {
public int x, y;
}
Delphi Declaration:
TPoint = record
x, y: integer;
end;
FSDK_Features = array[0..FSDK_FACIAL_FEATURE_COUNT - 1] of
TPoint;
PFSDK_Features = ^FSDK_Features;
VB Declaration:
Type TPoint
x As Long
y As Long
End Type
FSDK_DetectFacialFeatures Function
Detects a frontal face in an image and detects its facial features.
Example
int img1;
FSDK_Features Features;
FSDK_Initialize("");
FSDK_LoadImageFromFile(&img1, "test.jpg");
FSDK_DetectFacialFeatures(img1, Features);
FSDK_DetectFacialFeaturesInRegion Function
Detects facial features in an image region returned by FSDK_DetectFace or
FSDK_DetectMultipleFaces. This function can be useful if an approximate face size is
known, or to detect facial features of a specific face returned by FSDK_DetectMultipleFaces.
C++ Syntax:
int FSDK_DetectFacialFeaturesInRegion(HImage Image,
TFacePosition* FacePosition, FSDK_Features* FacialFeatures);
Example
int i, DetectedCount, img1;
FSDK_Features Features;
TFacePosition FaceArray[50];
FSDK_Initialize("");
FSDK_LoadImageFromFile(&img1, "test.jpg");
FSDK_DetectEyes Function
Detects a frontal face in an image and detects its eye centers.
FSDK_DetectEyesInRegion Function
Detects eye centers in an image region returned by FSDK_DetectFace or
FSDK_DetectMultipleFaces.
C++ Syntax:
int FSDK_DetectEyesInRegion(HImage Image, TFacePosition*
FacePosition, FSDK_Features* FacialFeatures);
Delphi Syntax:
function FSDK_DetectEyesInRegion(Image: HImage; FacePosition:
PFacePosition; FacialFeatures: PFSDK_Features): integer;
C# Syntax:
int FSDK.DetectEyesInRegion(UInt32 Image, ref
FSDK.TFacePosition FacePosition, FSDK.TPoint[]
FacialFeatures);
VB Syntax:
Function FSDKVB_DetectEyesInRegion(ByVal Image As Long, ByRef
FacePosition As TFacePosition, ByRef FacialFeatures As TPoint)
As Long
Parameters:
Image – handle of the image eye centers should be detected in.
FacePosition – pointer to the face position structure.
Face Matching
Luxand FaceSDK provides the API to extract face templates and match them. A template
extracted from a face can be stored in a database and can then be used to match faces using
the FSDK_MatchFaces function.
The FSDK_MatchFaces function returns the facial similarity level. You may consider
similarity to be equal to the probability that templates belong to one and same person.
More precisely: if the access control system provides access to a person when similarity is
higher of threshold х, the possibility of providing erroneous access to another person is 1-х.
For example, if the decision to provide access to a person is based on the code
if (similarity > 0.99)
AllowAccess();
the possibility of erroneous access to another person is 0.01, or 1%.
A facial template is non-reversible, i.e. there is no way to create the original face image using
a template. To determine if the matched templates belong to the same person (with a specified
error possibility), you can compare the facial similarity value with a threshold calculated by
the FSDK_GetMatchingThresholdAtFAR or FSDK_GetMatchingThresholdAtFRR functions.
Please note: it is also recommended to retain the original face images and their templates in
the database. This is because future versions of Luxand FaceSDK may offer an improved
template extraction algorithm, together with changes to the template format.
A face template is stored in the FSDK_FaceTemplate data structure.
In .NET, there is no specific data type for a template. Instead, it is stored in an array of bytes
of FSDK.TemplateSize length. Below is an example of retrieving facial template in C#.
C# Example:
templateData = new byte[FSDK.TemplateSize];
FSDK.GetFaceTemplate(imageHandle, out templateData);
C++ Declaration:
typedef struct {
char ftemplate [16384];
} FSDK_FaceTemplate;
Delphi Declaration:
FSDK_FaceTemplate = record
Template: array[0.. 16384-1] of byte;
end;
PFSDK_FaceTemplate = ^FSDK_FaceTemplate;
FSDK_GetFaceTemplateInRegion
Extracts a template for a face located in a specific region returned by FSDK_DetectFace or
FSDK_DetectMultipleFaces.
The function detects eye centers in a specific region and extracts a template. The face
detection stage is not performed. This function can be useful if an approximate face size and
position is known, or to process a specific face returned by FSDK_DetectMultipleFaces. The
function produces no error if the face is not clearly visible. This is because it assumes that if
face detection functions return a detected face position, the face is of sufficient quality.
If facial features or eye centers are known, it is more efficient to use
FSDK_GetFaceTemplateUsingEyes function.
FSDK_GetFaceTemplateUsingEyes
Extracts a face template using the detected eye centers.
The function receives eye centers coordinates detected by the FSDK_DetectFacialFeatures,
FSDK_DetectFacialFeaturesInRegion, FSDK_DetectEyes or FSDK_DetectEyesInRegion
functions and extracts a face template. Face detection, facial feature detection, or eye centers
detection stage is not performed. This function can be useful when facial features or eye
centers for a specific face are already detected. The function produces no error if the face is
not clearly visible, since it assumes that if the face and its facial features or eye centers are
already detected, the face is of sufficient quality.
C++ Syntax:
int FSDK_GetFaceTemplateUsingEyes(HImage Image, FSDK_Features*
eyeCoords, FSDK_FaceTemplate* FaceTemplate);
Delphi Syntax:
function FSDK_ GetFaceTemplateUsingEyes(Image: HImage;
eyeCoords: PFSDK_Features; FaceTemplate: PFSDK_FaceTemplate):
integer;
FSDK_MatchFaces
Match two face templates. The returned value determines the similarity of the faces.
C++ Syntax:
int FSDK_MatchFaces(FSDK_FaceTemplate* FaceTemplate1,
FSDK_FaceTemplate* FaceTemplate2, float* Similarity);
Delphi Syntax:
function FSDK_MatchFaces(FaceTemplate1, FaceTemplate2:
PFSDK_FaceTemplate; Similarity: PSingle): integer;
C# Syntax:
int FSDK.MatchFaces(byte[] FaceTemplate1, byte[]
FaceTemplate2, ref float Similarity);
VB Syntax:
Function FSDKVB_MatchFaces(ByRef FaceTemplate1 As Byte, ByRef
FaceTemplate2 As Byte, ByRef Similarity As Single) As Long
Parameters:
FaceTemplate1 – pointer to the FSDK_FaceTemplate structure, using the first template
for comparison.
FaceTemplate2 – pointer to the FSDK_FaceTemplate structure, using the second
template for comparison.
Similarity – pointer to an integer value, used to receive the similarity of the face
templates.
Return Value:
Returns FSDKE_OK if successful.
Example
FSDK_FaceTemplate template1, template2;
FSDK_GetFaceTemplate(img1, &template1);
FSDK_GetFaceTemplate(img2, &template2);
FSDK_MatchFaces(&template1, &template2, &Similarity);
if (Similarity > MatchingThreshold)
printf("Same Person\n");
else
printf("Different Person\n");
FSDK_GetMatchingThresholdAtFRR
This function returns the threshold value for similarity to determine if two matched templates
belong to the same person at a given FRR (False Rejection Rate) value. The FRR determines
Data Types
There are data types to store the information about video formats. Note that the names of
video cameras are stored in wide char format (each char occupies two bytes).
C++ Declaration:
typedef struct {
int Width;
int Height;
int BPP;
} FSDK_VideoFormatInfo;
VB Declaration:
Type FSDK_VideoFormatInfo
Width As Long
Height As Long
BPP As Long
End Type
FSDK_InitializeCapturing Function
The function initializes the capturing process (but it does not open any cameras). It should be
called in a single thread that works with cameras. Note that it initializes COM in the thread.
C++ Syntax:
int FSDK_InitializeCapturing(void);
Delphi Syntax:
function FSDK_InitializeCapturing: integer;
C# Syntax:
int FSDKcam.InitializeCapturing();
VB Syntax:
Function FSDKVB_InitializeCapturing() As Long
Return Value:
Returns FSDKE_OK if successful.
FSDK_FinalizeCapturing Function
The function finalizes (also finalizing COM) the capturing process, initialized by the
FSDK_InitializeCapturing function.
C++ Syntax:
int FSDK_FinalizeCapturing(void);
FSDK_SetCameraNaming Function
Sets the retrieval format for the FSDK_GetCameraList function. Depending on the value of
the argument, either camera names (by default), or their unique IDs (Device Path) are
returned. The use of Device Path may be necessary if the system has several cameras of the
same manufacturer that have the same name.
C++ Syntax:
int FSDK_SetCameraNaming(bool UseDevicePathAsName);
Delphi Syntax:
function FSDK_SetCameraNaming(UseDevicePathAsName: boolean):
integer;
C# Syntax:
int FSDKcam.SetCameraNaming(bool UseDevicePathAsName)
VB Syntax:
Function FSDKVB_SetCameraNaming(ByVal UseDevicePathAsName As
Boolean) As Long
Parameters:
UseDevicePathAsName – sets a retrieval format for the FSDK_GetCameraList function.
FALSE: FSDK_GetCameraList returns the list of names for cameras installed in the system;
TRUE: FSDK_GetCameraList returns the list of unique device paths of these cameras.
Return Value:
Returns FSDKE_OK if successful.
FSDK_GetCameraList Function
The function retrieves the list of cameras available in the system. The name of each camera is
stored in wide char format (each character occupies two bytes).
C++ Syntax:
int FSDK_GetCameraList(wchar_t*** CameraList, int*
CameraCount);
Example
wchar_t** CameraList;
int CameraCount;
FSDK_InitializeCapturing();
if (FSDK_GetCameraList(&CameraList, &CameraCount)!=FSDKE_OK)
for (int i=0; i<CameraCount; i++)
wprintf(L"camera: %s\n", CameraList[i]);
printf("%d camera(s) found.\n", CameraCount);
FSDK_FinalizeCapturing();
FSDK_GetVideoFormatList Function
The function returns the list of video formats supported by a given camera.
C++ Syntax:
int FSDK_GetVideoFormatList(wchar_t* CameraName,
FSDK_VideoFormatInfo** VideoFormatList, int*
VideoFormatCount);
Delphi Syntax:
function FSDK_GetVideoFormatList(CameraName: PWideChar;
VideoFormatList: PFSDK_VideoFormatInfo; var VideoFormatCount:
integer): integer;
C# Syntax:
int FSDKcam.GetVideoFormatList(string CameraName, out
FSDKcam.VideoFormatInfo[] VideoFormatList, out int
VideoFormatCount)
FSDK_SetVideoFormat Function
The function sets the format of camera output.
C++ Syntax:
int FSDK_SetVideoFormat(wchar_t* CameraName,
FSDK_VideoFormatInfo VideoFormat);
Delphi Syntax:
function FSDK_SetVideoFormat(CameraName: PWideChar;
VideoFormat: FSDK_VideoFormatInfo): integer;
C# Syntax:
int FSDKcam.SetVideoFormat(string CameraName,
FSDKcam.VideoFormatInfo VideoFormat);
VB Syntax:
Function FSDKVB_SetVideoFormat(ByVal CameraName As String,
ByRef VideoFormat As FSDK_VideoFormatInfo) As Long
Parameters:
CameraName – pointer to name of desired video camera.
VideoFormat – desired video format.
Return Value:
Returns FSDKE_OK if successful.
Example
wchar_t** CameraList;
int CameraCount;
FSDK_VideoFormatInfo* VideoFormatList;
int VideoFormatCount;
FSDK_GetCameraList(&CameraList, &CameraCount);
FSDK_OpenVideoCamera Function
The function opens the camera of a given name and returns its handle.
C++ Syntax:
int FSDK_OpenVideoCamera(wchar_t* CameraName, int*
CameraHandle);
Delphi Syntax:
function FSDK_OpenVideoCamera(CameraName: PWideChar; var
CameraHandle: integer): integer;
C# Syntax:
int FSDKcam.OpenVideoCamera(string CameraName, ref int
CameraHandle);
VB Syntax:
Function FSDKVB_OpenVideoCamera(ByVal CameraName As String,
ByRef CameraHandle As Long) As Long
Parameters:
CameraName – pointer to name of video camera to open.
CameraHandle – pointer to integer variable to store the opened camera handle.
Return Value:
Returns FSDKE_OK if successful.
FSDK_GrabFrame Function
Retrieves the current frame from a video camera and stores it in the created HImage handle. If
a camera returns an image, mirrored horizontally (it depends on camera settings), then you
can mirror it by using FSDK_MirrorImage.
C++ Syntax:
int FSDK_GrabFrame(int CameraHandle, HImage* Image);
Delphi Syntax:
function FSDK_GrabFrame(CameraHandle: integer; var Image:
PHImage): integer;
C# Syntax:
int FSDKcam.GrabFrame(int CameraHandle, ref UInt32 Image);
VB Syntax:
Function FSDKVB_GrabFrame(ByVal CameraHandle As Long, ByRef
Image As Long) As Long
FSDK_CloseVideoCamera Function
The function closes the camera, opened by the FSDK_OpenVideoCamera function.
C++ Syntax:
int FSDK_CloseVideoCamera(int CameraHandle);
Delphi Syntax:
function FSDK_CloseVideoCamera(CameraHandle: integer):
integer;
C# Syntax:
int FSDKcam.CloseVideoCamera(int CameraHandle);
VB Syntax:
Function FSDKVB_CloseVideoCamera(ByVal CameraHandle As Long)
As Long
Parameters:
CameraHandle – handle of opened video camera to close.
Return Value:
Returns FSDKE_OK if successful.
Thread Safety
This chapter describes the use of FaceSDK in applications, processing multiple threads. If
your program is executed in a single thread (by default it happens in almost all environments),
you can skip this chapter.
Most of FaceSDK functions are safe for multithreaded operations except webcam-related
functions. It is strongly recommended to use these functions only within one thread. The
functions not guaranteed to be thread-safe are:
FSDK_Initialize,
FSDK_Finalize,
FSDK_ActivateLibrary,
FSDK_GetLicenseInfo,
FSDK_GetHardware_ID,
FSDK_InitializeCapturing,
FSDK_FinalizeCapturing,
FSDK_SetCameraNaming,
FSDK_SetFaceDetectionParameters,
FSDK_SetFaceDetectionThreshold,
FSDK_SetJpegCompressionQuality.
Note that HImage is safe only for multiple simultaneous reads or single write. Do not read
from (e.g. with FSDK_DetectFace) and write to (e.g. with FSDK_FreeImage) the same
HImage handle at one time.
Deprecated Functions
The following functions are deprecated and will not be supported in the future Luxand
FaceSDK versions:
FSDK_GetFaceTemplateUsingFeatures
Error Codes
The FaceSDK library defines the following error codes: