Luxand FaceSDK – Face Detection

You can use the FSDK_LocateFace function to find a frontal face in an image. The function returns the position of the face in the image. FSDK_LocateFace can extract the located face from the source image (if needed) for further use. Please note that the extracted face area is slightly wider than the one specified by the returned coordinates. The FSDK_LocateFace function also returns the approximate locations of the eyes and the face contour. To retrieve more exact values of facial feature locations, please use the FSDK_LocateFacialFeatures function.

FSDK_LocateFace Function

Searches an image for a frontal face.

C++ Syntax:

int _FSDKIMPORT_ FSDK_LocateFace(HImage Image, int* x1, int* y1, int* x2, int* y2, int* LeftEyeX, int* LeftEyeY, int* RightEyeX, int* RightEyeY, int ExtractFaceImage, int Width, int Height, HImage* ExtractedFaceImage, int* ExtractedLeftEyeX, int* ExtractedLeftEyeY, int* ExtractedRightEyeX, int* ExtractedRightEyeY);

Delphi Syntax:

function FSDK_LocateFace(Image: HImage; x1, y1, x2, y2: PInteger; LeftEyeX, LeftEyeY, RightEyeX, RightEyeY: PInteger; ExtractFaceImage: integer; Width: integer; Height: integer; ExtractedFaceImage: PHImage; ExtractedLeftEyeX, ExtractedLeftEyeY, ExtractedRightEyeX, ExtractedRightEyeY: PInteger): integer; cdecl; external 'FaceSDK.dll';

Parameters:

Image – the handle of the image to be searched for a face.
x1 – the pointer to the integer variable for receiving the X coordinate of the top left corner of the located face.
y1 – the pointer to the integer variable for receiving the Y coordinate of the top left corner of the located face.
x2 – the pointer to the integer variable for receiving the X coordinate of the bottom right corner of the located face.
y2 – the pointer to the integer variable for receiving the Y coordinate of the bottom right corner of the located face.

LeftEyeX – the pointer to the integer variable for receiving the X coordinate of the left eye.
LeftEyeY – the pointer to the integer variable for receiving the Y coordinate of the left eye.
RightEyeX – the pointer to the integer variable for receiving the X coordinate of the right eye.
RightEyeY – the pointer to the integer variable for receiving the Y coordinate of the right eye.

ExtractFaceImage – defines whether it is necessary to extract the located face image. If ExtractFaceImage = 1, the face will be extracted.

Width – the width of the extracted face image (used only if ExtractFaceImage = 1).
Height – the height of the extracted face image (used only if ExtractFaceImage = 1).

ExtractedFaceImage – the pointer to the HImage variable the extracted face will be stored in (used only if ExtractFaceImage = 1).

ExtractedLeftEyeX – the X coordinate of the left eye in the extracted image (used only if ExtractFaceImage = 1).
ExtractedLeftEyeY – the Y coordinate of the left eye in the extracted image (used only if ExtractFaceImage = 1).
ExtractedRightEyeX – the X coordinate of the right eye in the extracted image (used only if ExtractFaceImage = 1).
ExtractedRightEyeY – the Y coordinate of the right eye in the extracted image (used only if ExtractFaceImage = 1).

Return Value:

The function returns FSDK_OK if successful.

Example

int img2, img2_extracted;
int x1, y1, x2, y2, LeftEyeX, LeftEyeY, RightEyeX, RightEyeY;
int ExtractedLeftEyeX, ExtractedLeftEyeY, ExtractedRightEyeX, ExtractedRightEyeY;

FSDK_Initialize("");
FSDK_LoadImageFromFile(&img2, "test.jpg");

FSDK_LocateFace(img2, &x1, &y1, &x2, &y2, &LeftEyeX, &LeftEyeY, &RightEyeX, &RightEyeY, 1, 256, 256, &img2_extracted, &ExtractedLeftEyeX, &ExtractedLeftEyeY, &ExtractedRightEyeX, &ExtractedRightEyeY);

printf("Location of the face: (%d, %d) - (%d, %d)\n", x1, y1, x2, y2);
printf("Left eye estimation: (%d, %d); Right eye estimation: (%d, %d)\n", LeftEyeX, LeftEyeY, RightEyeX, RightEyeY);

FSDK_SaveImageToFile(img2_extracted, "extracted_face.bmp");

printf("Left eye in extracted_face.bmp: (%d, %d)\nRight eye in extracted_face.bmp: (%d, %d)\n", ExtractedLeftEyeX, ExtractedLeftEyeY, ExtractedRightEyeX, ExtractedRightEyeY);

Search

Solutions   |   Products   |   Download   |   Support   |   Development   |   Press   |   About Luxand © 2005-2008 Luxand Development