Luxand FaceSDK – 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_SetNumThreads.

When working with cameras in multiple threads on Windows platforms, make sure that each thread calls the FSDK_InitializeCapturing function and the FSDK_FinalizeCapturing function when the thread is done. The following functions are thread safe (on all supported platforms) given that no different threads are simultaneously accessing the same camera handle:

FSDK_GetVideoFormatList,
FSDK_FreeVideoFormatList,
FSDK_SetVideoFormat,
FSDK_OpenVideoCamera,
FSDK_CloseVideoCamera,
FSDK_GrabFrame.

The following functions set global parameters that have effect on each thread:

FSDK_SetFaceDetectionParameters,
FSDK_SetFaceDetectionThreshold,
FSDK_SetJpegCompressionQuality,
FSDK_SetCameraNaming,
FSDK_SetHTTPProxy,
FSDK_SetNumThreads.

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.

For more information on thread safety of Tracker API, see the Thread Safety section in the Tracker API chapter.

 

Next chapterMigration from FaceSDK 5.0.1

Contents