Luxand FaceSDK – Working With Images

Images are represented as the HImage data type.

C++ Declaration:

typedef int HImage;

C# Declaration:

UInt32 Image

Delphi Declaration:

HImage = integer;
PHImage = ^HImage;

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);

Delphi Syntax:

function FSDK_SaveImageToFile(Image: HImage; FileName: PChar): integer;

C# Syntax:

int FSDK.SaveImageToFile(UInt32 Image, string FileName);

VB Syntax:

Function FSDKVB_SaveImageToFile(ByVal Image As Long, ByVal FileName As String) As Long

Parameters:

Image – internal handle of an image to be saved.

FileName – name of file the image will be saved to. FaceSDK saves images in the BMP, PNG or JPG file format. The format to use is recognized by the extension specified in the FileName parameter.

Return Value:

Returns FSDKE_OK if successful.

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:

Mode name

Meaning

FSDK_IMAGE_GRAYSCALE_8BIT

8-bit grayscale image

FSDK_IMAGE_COLOR_24BIT

24-bit color image (R, G, B order)

FSDK_IMAGE_COLOR_32BIT

32-bit color image with alpha channel (R, G, B, A order)

The function is not available in .NET. It is suggested to use FSDK_LoadImageFromHBitmap function instead.

C++ Syntax:

int FSDK_LoadImageFromBuffer(HImage* Image, unsigned char* Buffer, int Width, int Height, int ScanLine, FSDK_IMAGEMODE ImageMode);

Delphi Syntax:

function FSDK_LoadImageFromBuffer(Image: PHImage; var Buffer; Width, Height: integer; ScanLine: integer; ImageMode: FSDK_IMAGEMODE): integer;

VB Syntax:

Function FSDKVB_LoadImageFromBuffer(ByRef Image As Long, ByRef Buffer As Byte, ByVal Width As Long, ByVal Height As Long, ByVal ScanLine As Long, ByVal ImageMode As FSDK_IMAGEMODE) As Long

Parameters:

Image – pointer to HImage for receiving the loaded image handle.

Buffer – pointer to buffer containing image data.

Width – width of an image in pixels.

Height – height of an image in pixels.

ScanLine – distance between adjacent rows in bytes.

ImageMode – mode of an image.

Return Value:

Returns FSDKE_OK if successful.

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_SaveImageToBuffer Function

Saves an image to a buffer in the desired image mode. Refer to the FSDK_LoadImageFromBuffer function description to read more about image modes.

 C++ Syntax:

int FSDK_SaveImageToBuffer(HImage Image, unsigned char* Buffer, FSDK_IMAGEMODE ImageMode);

Delphi Syntax:

function FSDK_SaveImageToBuffer(Image: HImage; var Buffer; ImageMode: FSDK_IMAGEMODE): integer;

VB Syntax:

Function FSDKVB_SaveImageToBuffer(ByVal Image As Long, ByRef Buffer As Byte, ByVal ImageMode As FSDK_IMAGEMODE) As Long

The function is not available in .NET. It is suggested to use the FSDK_SaveImageToHBitmap function instead.

Parameters:

Image – internal handle of an image to be saved.

Buffer – pointer to the buffer containing the image data.

ImageMode – desired mode an image will be saved in.

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.

Return Value:

Returns FSDKE_OK if successful.

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.

Return Value:

Returns FSDKE_OK if successful.

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.

Return Value:

Returns FSDKE_OK if successful.

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

Parameters:

Image – handle of the image to be freed.

Return Value:

Returns FSDKE_OK if successful.

 

Next chapterFace Detection

Contents

Top Downloads

Glamourizer
Turn ordinary photos into glamour portraits, hundreds at a time
Blink!
Log into your PC by simply looking at it
Echo FX
Enhance your videos with stunning video FX for Adobe® After Effects
BabyMaker
Don't wait nine months to see your baby! All you need is two pictures

Latest News

22.07.2010 Blink! 2.1 Released!
Blink! 2.1 Released! Securely login to Windows Vista/7, for both the 32- and 64-bit editions!

25.03.2010 FaceSDK 3 Released!
FaceSDK 3 goes gold! The updated release of FaceSDK vastly improves face recognition speed and accuracy over the previous version.

10.02.2010 Blink! 2.0 Automates Windows Login and Boosts Recognition Rate
Luxand updates Blink!, an innovative face-based biometric login system, with better and faster face recognition algorithms.

Solutions  |  Products  |  Download  |  Support  |  Development  |  Press  |  About Luxand
© 2005-2010 Luxand, Inc.