Luxand FaceSDK – Multi-Core Support

The following FaceSDK functions use multiple CPU cores, thus speeding up the calculations:

FSDK_DetectEyes,
FSDK_DetectEyesInRegion,
FSDK_DetectFace,
FSDK_DetectMultipleFaces,
FSDK_DetectFacialFeatures,
FSDK_DetectFacialFeaturesInRegion,
FSDK_GetFaceTemplate,
FSDK_GetFaceTemplateInRegion,
FSDK_GetFaceTemplateUsingFeatures,
FSDK_GetFaceTemplateUsingEyes,
FSDK_FeedFrame.

By default, these functions use all available processor cores. To get the number of processor cores used, call the FSDK_GetNumThreads function. To limit the number of processor cores used, call the FSDK_SetNumThreads function. Calling FSDK_SetNumThreads(1) will disable multi-core support.

Note that each of these functions forks into a number of threads on each call. It is not recommended to use nested parallelism when calling these functions; if you need nested parallelism, you may limit the number of threads with the FSDK_SetNumThreads functions. For example, if your application runs in several threads, and each thread executes FSDK_DetectFace (which uses all available cores), this is acceptable; however, if each thread forks into several threads, each executing FSDK_DetectFace, this could potentially reach the limit of resources available.

It is safe to use extensions for parallel computation (like OpenMP) with the above FaceSDK functions, if they are executed from a single thread. For example, the following C++ sample code is acceptable:

#pragma omp parallel for
for (int i = 0; i < 100; i++)
FSDK_DetectFace(...);

However, if your application forks into multiple threads, it is not recommended to execute the above FaceSDK functions within OpenMP statements in such threads. If you must, consider limiting the number of cores used by FaceSDK with the FSDK_SetNumThreads function.

  FSDK_GetNumThreads Function

Retrieves the number of processor cores used by FaceSDK.

C++ Syntax:

int FSDK_GetNumThreads(int * Num);

Delphi Syntax:

function FSDK_GetNumThreads(Num: PInteger): integer;

C# Syntax:

int FSDK.GetNumThreads(ref int Num);

VB Syntax:

Function FSDKVB_GetNumThreads(ByRef Num As Long) As Long

Java Syntax:

int FSDK.GetNumThreads(int Num[]);

Parameters:

Num – pointer to an integer value to receive the number of threads used by FaceSDK.

Return Value:

Returns FSDKE_OK if successful.

  FSDK_SetNumThreads Function

Sets the number of processor cores to be used by FaceSDK. If you set the number of cores to 1, support for multiple cores will be disabled, and the SDK will use only a single processor core.

C++ Syntax:

int FSDK_SetNumThreads(int Num);

Delphi Syntax:

function FSDK_SetNumThreads(Num: integer): integer;

C# Syntax:

int FSDK.SetNumThreads(int Num);

VB Syntax:

Function FSDKVB_SetNumThreads(ByVal Num As Long) As Long

Java Syntax:

int FSDK.SetNumThreads(int Num);

Parameters:

Num – the number of cores to be used by FaceSDK.

Return Value:

Returns FSDKE_OK if successful.

 

Next chapterThread Safety

Contents

Get in touch

Luxand, Inc.
815 N. Royal St. Suite 202
Alexandria, VA
22314
USA
Freephone:
+1 800 471 5636

Join our newsletter

And always stay informed of the latest company news and events!

Sign up >>

DMCA.com Protection Status