int mv_face_detection_destroy(mv_face_detection_h handle)
{
- lock_guard<mutex> lock(g_face_detection_mutex);
+ // TODO. find proper solution later.
+ // For thread safety, lock is needed here but if async API is used then dead lock occurs
+ // because mv_face_detection_destroy_open function acquires a lock and,
+ // while waiting for the thread loop to finish, the same lock is also acquired
+ // within functions - mv_face_detection_get_result_open and mv_face_detection_get_label_open
+ // - called to obtain results from the thread loop.
MEDIA_VISION_SUPPORT_CHECK(_mv_inference_check_system_info_feature_supported());
MEDIA_VISION_INSTANCE_CHECK(handle);
return MEDIA_VISION_ERROR_NONE;
}
+int mv_face_detection_inference_async(mv_face_detection_h handle, mv_source_h source, mv_completion_cb completion_cb,
+ void *user_data)
+{
+ LOGD("ENTER");
+
+ lock_guard<mutex> lock(g_face_detection_mutex);
+
+ if (!handle) {
+ LOGE("Handle is NULL.");
+ return MEDIA_VISION_ERROR_INVALID_PARAMETER;
+ }
+
+ try {
+ auto context = static_cast<Context *>(handle);
+ auto task = static_cast<FaceDetectionTask *>(context->__tasks.at("face_detection"));
+
+ ObjectDetectionInput input = { handle, source, completion_cb, user_data };
+
+ task->performAsync(input);
+ } catch (const BaseException &e) {
+ LOGE("%s", e.what());
+ return e.getError();
+ }
+
+ LOGD("LEAVE");
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
int mv_face_detection_get_result(mv_face_detection_h handle, unsigned int *number_of_objects,
const unsigned int **indices, const float **confidences, const int **left,
const int **top, const int **right, const int **bottom)