3DiVi Face SDK  3.24.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Groups
VideoWorker Class Reference

VideoWorker is an interface object for tracking, processing and matching faces on multiple video streams. We recommend you to use VideoWorker instead of Capturer for face tracking on video streams. When VideoWorker is created with matching_thread=0 and processing_thread=0, then the standard Capturer license is used. More...

#import <VideoWorker.h>

Instance Methods

(int) - addTrackingCallbackU::
 Add a handler for a Tracking event. Thread-safe. More...
 
(int) - addMatchFoundCallbackU::
 Add a handler for a MatchFound event. Thread-safe. More...
 
(void) - addHandlerCallback:
 Add an event handler. Thread-safe. More...
 
(int) - addVideoFrame::
 Add a new video frame for a specific video stream. Tracking and recognition results will be returned asynchronously via Tracking, MatchFound and TrackingLost callbacks. Thread-safe. More...
 
(void) - setDatabase:
 Set / replace the database (can be called at any time). Available only if matching_threads_count > 0. Thread-safe. More...
 
(void) - enableProcessingOnStream:
 Enable the creation of templates for a given stream. After that, the matching is resumed as well. Thread-safe. More...
 
(void) - disableProcessingOnStream:
 Disable the creation of templates for a given stream. After that, the matching stops as well. Thread-safe. More...
 
(void) - resetStream:
 Reset work state for the stream. It waits for the callbacks, which are currently being executed, therefore, do not synchronize the resetStream call with the code inside the callbacks, otherwise it can cause a deadlock. After resetStream is executed, no callbacks related to the previous frames or tracks will be called. It is necessary to release the memory allocated for all tracks with track_id less than the return value, since there will be no TrackingLost callback for the tracks removed during this reset. Thread-safe. More...
 

Detailed Description

VideoWorker is an interface object for tracking, processing and matching faces on multiple video streams. We recommend you to use VideoWorker instead of Capturer for face tracking on video streams. When VideoWorker is created with matching_thread=0 and processing_thread=0, then the standard Capturer license is used.

Method Documentation

- (void) addHandlerCallback: (CallbackHandler *_Nonnull)  handler

Add an event handler. Thread-safe.

Parameters
[in]handlerA pointer to a custom class inherited from CallbackHandler.
- (int) addMatchFoundCallbackU: (const void *_Nonnull)  callback
: (void *_Nonnull const)  userdata 

Add a handler for a MatchFound event. Thread-safe.

Parameters
[in]callbackCallback function.
[in]userdataAny pointer. It will be passed to the callback as a userdata argument.
Returns
Integer id for this callback. Use it for passing to VideoWorker::removeMatchFoundCallback to unsubscribe.
- (int) addTrackingCallbackU: (const void *_Nonnull)  callback
: (void *_Nonnull const)  userdata 

Add a handler for a Tracking event. Thread-safe.

Parameters
[in]callbackCallback function.
[in]userdataAny pointer. It will be passed to the callback as a userdata argument.
Returns
Integer id for this callback. Use it for passing to VideoWorker::removeTrackingCallback to unsubscribe.
- (int) addVideoFrame: (RawImage *_Nonnull)  image
: (int)  stream_id 

Add a new video frame for a specific video stream. Tracking and recognition results will be returned asynchronously via Tracking, MatchFound and TrackingLost callbacks. Thread-safe.

Parameters
[in]frameVideo frame. Only colored images are allowed (i.e. IRawImage::FORMAT_RGB, IRawImage::FORMAT_BGR, IRawImage::FORMAT_YUV_NV21 and IRawImage::FORMAT_YUV_NV12).
[in]stream_idInteger id of the video stream (0 <= stream_id < streams_count).
[in]timestamp_microsecTimestamp of the frame in microseconds
Returns
Integer id for this frame, unique for this video stream. This id will be used to identify this frame in the callbacks.
- (void) disableProcessingOnStream: (const int)  stream_id

Disable the creation of templates for a given stream. After that, the matching stops as well. Thread-safe.

Parameters
[in]stream_idInteger id of the video stream (0 <= stream_id < streams_count).
- (void) enableProcessingOnStream: (const int)  stream_id

Enable the creation of templates for a given stream. After that, the matching is resumed as well. Thread-safe.

Parameters
[in]stream_idInteger id of the video stream (0 <= stream_id < streams_count).
- (void) resetStream: (const int)  stream_id

Reset work state for the stream. It waits for the callbacks, which are currently being executed, therefore, do not synchronize the resetStream call with the code inside the callbacks, otherwise it can cause a deadlock. After resetStream is executed, no callbacks related to the previous frames or tracks will be called. It is necessary to release the memory allocated for all tracks with track_id less than the return value, since there will be no TrackingLost callback for the tracks removed during this reset. Thread-safe.

Parameters
[in]stream_idInteger id of the video stream (0 <= stream_id < streams_count).
Returns
Integer track_id_threshold, which means that all tracks that were removed during resetStream had track_id < track_id_threshold, and all new tracks will have track_id >= track_id_threshold.
- (void) setDatabase: (NSArray< DatabaseElement * > *_Nonnull)  elements

Set / replace the database (can be called at any time). Available only if matching_threads_count > 0. Thread-safe.

Parameters
[in]elementsVector of database elements.