mv_machine_learning: add async API for face detection task group
[platform/core/api/mediavision.git] / mv_machine_learning / object_detection / src / face_detection_adapter.cpp
index 3484566..31bd39b 100644 (file)
@@ -35,7 +35,9 @@ template<typename T, typename V> FaceDetectionAdapter<T, V>::FaceDetectionAdapte
 }
 
 template<typename T, typename V> FaceDetectionAdapter<T, V>::~FaceDetectionAdapter()
-{}
+{
+       _object_detection->preDestroy();
+}
 
 template<typename T, typename V> void FaceDetectionAdapter<T, V>::create(int type)
 {
@@ -140,12 +142,21 @@ template<typename T, typename V> void FaceDetectionAdapter<T, V>::perform()
 
 template<typename T, typename V> void FaceDetectionAdapter<T, V>::performAsync(T &t)
 {
-       throw InvalidOperation("Not support yet.");
+       shared_ptr<MetaInfo> metaInfo = _object_detection->getInputMetaInfo();
+
+       if (metaInfo->dataType == MV_INFERENCE_DATA_UINT8) {
+               _object_detection->performAsync<unsigned char>(t, metaInfo);
+       } else if (metaInfo->dataType == MV_INFERENCE_DATA_FLOAT32) {
+               _object_detection->performAsync<float>(t, metaInfo);
+               // TODO
+       } else {
+               throw InvalidOperation("Invalid model data type.");
+       }
 }
 
 template<typename T, typename V> V &FaceDetectionAdapter<T, V>::getOutput()
 {
-       return _object_detection->result();
+       return _object_detection->getOutput<V>();
 }
 
 template class FaceDetectionAdapter<ObjectDetectionInput, ObjectDetectionResult>;