*
* @remarks The @a infer should be released using mv_object_detection_3d_destroy().
*
- * @param[out] infer The handle to the inference to be created.
+ * @param[out] handle The handle to the inference to be created.
*
* @return @c 0 on success, otherwise a negative error value
* @retval #MEDIA_VISION_ERROR_NONE Successful
* @see mv_object_detection_3d_destroy()
* @see mv_object_detection_3d_prepare()
*/
-int mv_object_detection_3d_create(mv_object_detection_3d_h *infer);
+int mv_object_detection_3d_create(mv_object_detection_3d_h *handle);
/**
* @brief Destroys inference handle and releases all its resources.
*
* @since_tizen 7.0
*
- * @param[in] infer The handle to the inference to be destroyed.
+ * @param[in] handle The handle to the inference to be destroyed.
*
* @return @c 0 on success, otherwise a negative error value
* @retval #MEDIA_VISION_ERROR_NONE Successful
*
* @see mv_object_detection_3d_create()
*/
-int mv_object_detection_3d_destroy(mv_object_detection_3d_h infer);
+int mv_object_detection_3d_destroy(mv_object_detection_3d_h handle);
/**
* @brief Set user-given model information.
*
* @since_tizen 7.0
*
- * @param [in] infer The handle to the inference
+ * @param [in] handle The handle to the inference
*
* @return @c 0 on success, otherwise a negative error value
* @retval #MEDIA_VISION_ERROR_NONE Successful
* @retval #MEDIA_VISION_ERROR_INVALID_OPERATION Invalid operation
* @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported
*/
-int mv_object_detection_3d_configure(mv_object_detection_3d_h infer);
+int mv_object_detection_3d_configure(mv_object_detection_3d_h handle);
/**
* @brief Prepares the object detection inference
*
* @since_tizen 7.0
*
- * @param[in] infer The handle to the inference.
+ * @param[in] handle The handle to the inference.
*
* @return @c 0 on success, otherwise a negative error value
* @retval #MEDIA_VISION_ERROR_NONE Successful
* @retval #MEDIA_VISION_ERROR_INVALID_OPERATION Invalid operation
* @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED_FORMAT Not supported format
*/
-int mv_object_detection_3d_prepare(mv_object_detection_3d_h infer);
+int mv_object_detection_3d_prepare(mv_object_detection_3d_h handle);
/**
* @brief Performs the object detection 3d inference on the @a source.
* @since_tizen 7.0
* @remarks This function is synchronous and may take considerable time to run.
*
+ * @param[in] handle The handle to the inference
* @param[in] source The handle to the source of the media
- * @param[in] infer The handle to the inference
*
* @return @c 0 on success, otherwise a negative error value
* @retval #MEDIA_VISION_ERROR_NONE Successful
*
* @see mv_object_detect_result_s structure
*/
-int mv_object_detection_3d_inference(mv_object_detection_3d_h infer, mv_source_h source);
+int mv_object_detection_3d_inference(mv_object_detection_3d_h handle, mv_source_h source);
/**
* @brief Gets the probability value to the detected object.
+++ /dev/null
-/**
- * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __MEDIA_VISION_FACE_RECOGNITION_OPEN_H__
-#define __MEDIA_VISION_FACE_RECOGNITION_OPEN_H__
-
-#include <mv_common.h>
-#include <mv_private.h>
-#include <mv_face_recognition_type.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-/**
- * @brief Create face recognition object handle.
- * @details Use this function to create an face recognition object handle.
- * After creation the handle has to be prepared with
- * @ref mv_face_recognition_prepare_open() function to prepare
- * an face recognition object.
- *
- * @since_tizen 7.0
- *
- * @param[out] handle The handle to the face recognition object to be created
- *
- * @return @c 0 on success, otherwise a negative error value
- * @retval #MEDIA_VISION_ERROR_NONE Successful
- * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #MEDIA_VISION_ERROR_OUT_OF_MEMORY Out of memory
- *
- * @post Release @a handle by using
- * @ref mv_face_recognition_destroy_open() function when it is not needed
- * anymore
- *
- * @see mv_face_recognition_destroy_open()
- */
-int mv_face_recognition_create_open(mv_face_recognition_h *out_handle);
-
-/**
- * @brief Destroy face recognition handle and releases all its resources.
- *
- * @since_tizen 7.0
- *
- * @param[in] handle The handle to the face recognition object to be destroyed.
- *
- * @return @c 0 on success, otherwise a negative error value
- * @retval #MEDIA_VISION_ERROR_NONE Successful
- * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
- *
- * @pre Create an face recognition handle by using @ref mv_face_recognition_create_open()
- *
- * @see mv_face_recognition_create_open()
- */
-int mv_face_recognition_destroy_open(mv_face_recognition_h handle);
-
-/**
- * @brief Prepare face recognition.
- *
- * @since_tizen 7.0
- *
- * @param[in] handle The handle to the face recognition object to be prepared.
- *
- * @return @c 0 on success, otherwise a negative error value
- * @retval #MEDIA_VISION_ERROR_NONE Successful
- * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
- *
- * @pre Create an face recognition handle by using @ref mv_face_recognition_create_open()
- *
- * @see mv_face_recognition_create_open()
- */
-int mv_face_recognition_prepare_open(mv_face_recognition_h handle);
-
-/**
- * @brief Register a new face on the @a source
- * @details Use this function to register a new face.
- * Each time when this function is called, a new face on the media source
- * will be registered to internal database.
- *
- * @since_tizen 7.0
- *
- * @param[in] handle The handle to the face recognition object.
- * @param[in] source The handle to the source of the media.
- * @param[in] label The label to be registered. (the maximum length of the label array is 256 words)
- *
- * @return @c 0 on success, otherwise a negative error value
- * @retval #MEDIA_VISION_ERROR_NONE Successful
- * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED_FORMAT Source colorspace
- * isn't supported
- * @retval #MEDIA_VISION_ERROR_OUT_OF_MEMORY Out of memory
- *
- * @pre Create a source handle by calling @ref mv_create_source()
- * @pre Create an face recognition handle by calling @ref mv_face_recognition_create_open()
- * @pre Prepare an face recognition by calling @ref mv_face_recognition_prepare_open()
- */
-int mv_face_recognition_register_open(mv_face_recognition_h handle, mv_source_h source, const char *label);
-
-/**
- * @brief Unregister a new face on the @a source
- * @details Use this function to unregister a given label.
- * Each time when this function is called, all data related to the label
- * will be removed from internal database.
- *
- * @since_tizen 7.0
- *
- * @param[in] handle The handle to the face recognition object.
- * @param[in] label The label to be registered. (the maximum length of the label array is 256 words)
- *
- * @return @c 0 on success, otherwise a negative error value
- * @retval #MEDIA_VISION_ERROR_NONE Successful
- * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED_FORMAT Source colorspace
- * isn't supported
- * @retval #MEDIA_VISION_ERROR_OUT_OF_MEMORY Out of memory
- *
- * @pre Create an face recognition handle by calling @ref mv_face_recognition_create_open()
- * @pre Prepare an face recognition by calling @ref mv_face_recognition_prepare_open()
- */
-int mv_face_recognition_unregister_open(mv_face_recognition_h handle, const char *label);
-
-/**
- * @brief Inference with a given face on the @a source
- * @details Use this function to inference with a given source.
- *
- *
- * @since_tizen 7.0
- *
- * @param[in] handle The handle to the face recognition object.
- * @param[in] source The handle to the source of the media.
- *
- * @return @c 0 on success, otherwise a negative error value
- * @retval #MEDIA_VISION_ERROR_NONE Successful
- * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED_FORMAT Source colorspace
- * isn't supported
- * @retval #MEDIA_VISION_ERROR_OUT_OF_MEMORY Out of memory
- *
- * @pre Create a source handle by calling @ref mv_create_source()
- * @pre Create an face recognition handle by calling @ref mv_face_recognition_create_open()
- * @pre Prepare an face recognition by calling @ref mv_face_recognition_prepare_open()
- * @pre Register a new face by calling @ref mv_face_recognition_register_open()
- */
-int mv_face_recognition_inference_open(mv_face_recognition_h handle, mv_source_h source);
-
-/**
- * @brief Get a label name and store it to @a out_label.
- * @details Use this function to get a label name after calling mv_face_recognition_inference_open function.
- *
- * @since_tizen 7.0
- *
- * @param[in] handle The handle to the face recognition object.
- * @param[out] out_label The array pointer for the label name to be stored.
- *
- * @return @c 0 on success, otherwise a negative error value
- * @retval #MEDIA_VISION_ERROR_NONE Successful
- * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #MEDIA_VISION_ERROR_INVALID_OPERATION Invalid operation
- *
- * @pre Request a inference by calling @ref mv_face_recognition_inference_open()
- */
-int mv_face_recognition_get_label_open(mv_face_recognition_h handle, const char **out_label);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* __MEDIA_VISION_INFERENCE_OPEN_H__ */
+++ /dev/null
-/**
- * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "mv_private.h"
-#include "mv_face_recognition.h"
-#include "mv_face_recognition_open.h"
-
-int mv_face_recognition_create(mv_face_recognition_h *out_handle)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported());
-
- MEDIA_VISION_NULL_ARG_CHECK(out_handle);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = MEDIA_VISION_ERROR_NONE;
-
- ret = mv_face_recognition_create_open(out_handle);
-
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
-
-int mv_face_recognition_destroy(mv_face_recognition_h handle)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported());
-
- MEDIA_VISION_INSTANCE_CHECK(handle);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = MEDIA_VISION_ERROR_NONE;
-
- ret = mv_face_recognition_destroy_open(handle);
-
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
-
-int mv_face_recognition_prepare(mv_face_recognition_h handle)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported());
-
- MEDIA_VISION_INSTANCE_CHECK(handle);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = MEDIA_VISION_ERROR_NONE;
-
- ret = mv_face_recognition_prepare_open(handle);
-
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
-
-int mv_face_recognition_register(mv_face_recognition_h handle, mv_source_h source, const char *label)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported());
-
- MEDIA_VISION_INSTANCE_CHECK(handle);
- MEDIA_VISION_INSTANCE_CHECK(source);
- MEDIA_VISION_INSTANCE_CHECK(label);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = MEDIA_VISION_ERROR_NONE;
-
- ret = mv_face_recognition_register_open(handle, source, label);
-
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
-
-int mv_face_recognition_unregister(mv_face_recognition_h handle, const char *label)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported());
-
- MEDIA_VISION_INSTANCE_CHECK(handle);
- MEDIA_VISION_INSTANCE_CHECK(label);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = MEDIA_VISION_ERROR_NONE;
-
- ret = mv_face_recognition_unregister_open(handle, label);
-
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
-
-int mv_face_recognition_inference(mv_face_recognition_h handle, mv_source_h source)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported());
-
- MEDIA_VISION_INSTANCE_CHECK(handle);
- MEDIA_VISION_INSTANCE_CHECK(source);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = MEDIA_VISION_ERROR_NONE;
-
- ret = mv_face_recognition_inference_open(handle, source);
-
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
-
-int mv_face_recognition_get_label(mv_face_recognition_h handle, const char **out_label)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported());
-
- MEDIA_VISION_INSTANCE_CHECK(handle);
- MEDIA_VISION_INSTANCE_CHECK(out_label);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = MEDIA_VISION_ERROR_NONE;
-
- ret = mv_face_recognition_get_label_open(handle, out_label);
-
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
--- /dev/null
+/**
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <algorithm>
+#include <dlog.h>
+#include <memory>
+#include <mutex>
+
+#include "mv_private.h"
+#include "context.h"
+#include "machine_learning_exception.h"
+#include "face_recognition_adapter.h"
+#include "facenet_adapter.h"
+#include "mv_face_recognition.h"
+
+using namespace std;
+using namespace mediavision::common;
+using namespace mediavision::machine_learning;
+using namespace mediavision::machine_learning::face_recognition;
+using namespace mediavision::machine_learning::exception;
+using FaceRecognitionTask = ITask<FaceRecognitionInput, FaceRecognitionResult>;
+using FacenetTask = ITask<FacenetInput, FacenetOutput>;
+
+static mutex g_face_recognition_mutex;
+
+int mv_face_recognition_create(mv_face_recognition_h *out_handle)
+{
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported());
+
+ MEDIA_VISION_NULL_ARG_CHECK(out_handle);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ Context *context = new (nothrow) Context();
+ if (!context) {
+ LOGE("Fail to allocate a context.");
+ return MEDIA_VISION_ERROR_OUT_OF_MEMORY;
+ }
+
+ FaceRecognitionTask *face_recognition_task = new (nothrow)
+ FaceRecognitionAdapter<FaceRecognitionInput, FaceRecognitionResult>();
+ if (!face_recognition_task) {
+ delete context;
+ LOGE("Fail to allocate a task.");
+ return MEDIA_VISION_ERROR_OUT_OF_MEMORY;
+ }
+
+ FacenetTask *facenet_task = new (nothrow) FacenetAdapter<FacenetInput, FacenetOutput>();
+ if (!facenet_task) {
+ delete face_recognition_task;
+ delete context;
+ LOGE("Fail to allocate a task.");
+ return MEDIA_VISION_ERROR_OUT_OF_MEMORY;
+ }
+
+ pair<map<string, void *>::iterator, bool> result;
+
+ result = context->__tasks.insert(pair<string, void *>("face_recognition", face_recognition_task));
+ if (!result.second) {
+ delete facenet_task;
+ delete face_recognition_task;
+ delete context;
+ LOGE("Fail to register a new task. Same task already exists.");
+ return MEDIA_VISION_ERROR_INVALID_OPERATION;
+ }
+
+ result = context->__tasks.insert(pair<string, void *>("facenet", facenet_task));
+ if (!result.second) {
+ delete facenet_task;
+ delete face_recognition_task;
+ delete context;
+ LOGE("Fail to register a new task. Same task already exists.");
+ return MEDIA_VISION_ERROR_INVALID_OPERATION;
+ }
+
+ *out_handle = static_cast<mv_face_recognition_h>(context);
+
+ LOGD("face recognition handle [%p] has been created", *out_handle);
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_face_recognition_destroy(mv_face_recognition_h handle)
+{
+ lock_guard<mutex> lock(g_face_recognition_mutex);
+
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported());
+
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ Context *context = static_cast<Context *>(handle);
+ map<string, void *>::iterator iter;
+
+ for (iter = context->__tasks.begin(); iter != context->__tasks.end(); ++iter) {
+ if (iter->first.compare("face_recognition") == 0) {
+ auto face_recognition_task = static_cast<FaceRecognitionTask *>(iter->second);
+ delete face_recognition_task;
+ }
+
+ if (iter->first.compare("facenet") == 0) {
+ auto facenet_task = static_cast<FacenetTask *>(iter->second);
+ delete facenet_task;
+ }
+ }
+
+ delete context;
+
+ LOGD("Face recognition handle has been destroyed");
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_face_recognition_prepare(mv_face_recognition_h handle)
+{
+ lock_guard<mutex> lock(g_face_recognition_mutex);
+
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported());
+
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ try {
+ Context *context = static_cast<Context *>(handle);
+ auto face_recognition_task = static_cast<FaceRecognitionTask *>(context->__tasks["face_recognition"]);
+ auto facenet_task = static_cast<FacenetTask *>(context->__tasks["facenet"]);
+
+ face_recognition_task->configure();
+ facenet_task->configure();
+ face_recognition_task->prepare();
+ facenet_task->prepare();
+ } catch (const BaseException &e) {
+ LOGE("%s", e.what());
+ return e.getError();
+ }
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_face_recognition_register(mv_face_recognition_h handle, mv_source_h source, const char *label)
+{
+ lock_guard<mutex> lock(g_face_recognition_mutex);
+
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported());
+
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+ MEDIA_VISION_INSTANCE_CHECK(source);
+ MEDIA_VISION_INSTANCE_CHECK(label);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ try {
+ Context *context = static_cast<Context *>(handle);
+ auto face_recognition_task = static_cast<FaceRecognitionTask *>(context->__tasks["face_recognition"]);
+ auto facenet_task = static_cast<FacenetTask *>(context->__tasks["facenet"]);
+ FacenetInput facenet_input = { { source } };
+
+ facenet_task->setInput(facenet_input);
+ facenet_task->perform();
+
+ FacenetOutput &facenet_output = facenet_task->getOutput();
+ FaceRecognitionInput face_recognition_input = { .mode = mode::REGISTER };
+ FaceRecognitionRegisterInput facenet_to_face_reg_input = { facenet_output.outputs[0], string(label) };
+
+ face_recognition_input.register_src.clear();
+ face_recognition_input.register_src.push_back(facenet_to_face_reg_input);
+ face_recognition_task->setInput(face_recognition_input);
+ face_recognition_task->perform();
+ } catch (const BaseException &e) {
+ LOGE("%s", e.what());
+ return e.getError();
+ }
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_face_recognition_unregister(mv_face_recognition_h handle, const char *label)
+{
+ lock_guard<mutex> lock(g_face_recognition_mutex);
+
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported());
+
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+ MEDIA_VISION_INSTANCE_CHECK(label);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ try {
+ Context *context = static_cast<Context *>(handle);
+ auto face_recognition_task = static_cast<FaceRecognitionTask *>(context->__tasks["face_recognition"]);
+ FaceRecognitionInput input = { mode::DELETE };
+
+ input.labels.clear();
+ input.labels.push_back(string(label));
+ face_recognition_task->setInput(input);
+ face_recognition_task->perform();
+ } catch (const BaseException &e) {
+ LOGE("%s", e.what());
+ return e.getError();
+ }
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_face_recognition_inference(mv_face_recognition_h handle, mv_source_h source)
+{
+ lock_guard<mutex> lock(g_face_recognition_mutex);
+
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported());
+
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+ MEDIA_VISION_INSTANCE_CHECK(source);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ try {
+ Context *context = static_cast<Context *>(handle);
+ auto face_recognition_task = static_cast<FaceRecognitionTask *>(context->__tasks["face_recognition"]);
+ auto facenet_task = static_cast<FacenetTask *>(context->__tasks["facenet"]);
+ FacenetInput facenet_input = { { source } };
+
+ facenet_task->setInput(facenet_input);
+ facenet_task->perform();
+ FacenetOutput &facenet_output = facenet_task->getOutput();
+
+ FaceRecognitionInput face_recognition_input = { mode::INFERENCE };
+
+ face_recognition_input.inputs = facenet_output.outputs;
+ face_recognition_task->setInput(face_recognition_input);
+ face_recognition_task->perform();
+ } catch (const BaseException &e) {
+ LOGE("%s", e.what());
+ return e.getError();
+ }
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_face_recognition_get_label(mv_face_recognition_h handle, const char **out_label)
+{
+ lock_guard<mutex> lock(g_face_recognition_mutex);
+
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported());
+
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+ MEDIA_VISION_INSTANCE_CHECK(out_label);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ try {
+ Context *context = static_cast<Context *>(handle);
+ auto face_recognition_task = static_cast<FaceRecognitionTask *>(context->__tasks["face_recognition"]);
+
+ *out_label = face_recognition_task->getOutput().label.c_str();
+ } catch (const BaseException &e) {
+ LOGE("%s", e.what());
+ return e.getError();
+ }
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+++ /dev/null
-/**
- * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <algorithm>
-#include <dlog.h>
-#include <memory>
-#include <mutex>
-
-#include "face_recognition_adapter.h"
-#include "facenet_adapter.h"
-#include "mv_face_recognition_open.h"
-#include "machine_learning_exception.h"
-#include "context.h"
-
-using namespace std;
-using namespace mediavision::common;
-using namespace mediavision::machine_learning;
-using namespace mediavision::machine_learning::face_recognition;
-using namespace mediavision::machine_learning::exception;
-using FaceRecognitionTask = ITask<FaceRecognitionInput, FaceRecognitionResult>;
-using FacenetTask = ITask<FacenetInput, FacenetOutput>;
-
-static mutex g_face_recognition_mutex;
-
-int mv_face_recognition_create_open(mv_face_recognition_h *handle)
-{
- if (!handle) {
- LOGE("Handle can't be created because handle pointer is NULL");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- Context *context = new (nothrow) Context();
- if (!context) {
- LOGE("Fail to allocate a context.");
- return MEDIA_VISION_ERROR_OUT_OF_MEMORY;
- }
-
- FaceRecognitionTask *face_recognition_task = new (nothrow)
- FaceRecognitionAdapter<FaceRecognitionInput, FaceRecognitionResult>();
- if (!face_recognition_task) {
- delete context;
- LOGE("Fail to allocate a task.");
- return MEDIA_VISION_ERROR_OUT_OF_MEMORY;
- }
-
- FacenetTask *facenet_task = new (nothrow) FacenetAdapter<FacenetInput, FacenetOutput>();
- if (!facenet_task) {
- delete face_recognition_task;
- delete context;
- LOGE("Fail to allocate a task.");
- return MEDIA_VISION_ERROR_OUT_OF_MEMORY;
- }
-
- pair<map<string, void *>::iterator, bool> result;
-
- result = context->__tasks.insert(pair<string, void *>("face_recognition", face_recognition_task));
- if (!result.second) {
- delete facenet_task;
- delete face_recognition_task;
- delete context;
- LOGE("Fail to register a new task. Same task already exists.");
- return MEDIA_VISION_ERROR_INVALID_OPERATION;
- }
-
- result = context->__tasks.insert(pair<string, void *>("facenet", facenet_task));
- if (!result.second) {
- delete facenet_task;
- delete face_recognition_task;
- delete context;
- LOGE("Fail to register a new task. Same task already exists.");
- return MEDIA_VISION_ERROR_INVALID_OPERATION;
- }
-
- *handle = static_cast<mv_face_recognition_h>(context);
-
- LOGD("face recognition handle [%p] has been created", *handle);
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_face_recognition_destroy_open(mv_face_recognition_h handle)
-{
- lock_guard<mutex> lock(g_face_recognition_mutex);
-
- if (!handle) {
- LOGE("Handle is NULL.");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- Context *context = static_cast<Context *>(handle);
- map<string, void *>::iterator iter;
-
- for (iter = context->__tasks.begin(); iter != context->__tasks.end(); ++iter) {
- if (iter->first.compare("face_recognition") == 0) {
- auto face_recognition_task = static_cast<FaceRecognitionTask *>(iter->second);
- delete face_recognition_task;
- }
-
- if (iter->first.compare("facenet") == 0) {
- auto facenet_task = static_cast<FacenetTask *>(iter->second);
- delete facenet_task;
- }
- }
-
- delete context;
-
- LOGD("Face recognition handle has been destroyed");
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_face_recognition_prepare_open(mv_face_recognition_h handle)
-{
- LOGD("ENTER");
-
- lock_guard<mutex> lock(g_face_recognition_mutex);
-
- if (!handle) {
- LOGE("Handle is NULL.");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- try {
- Context *context = static_cast<Context *>(handle);
- auto face_recognition_task = static_cast<FaceRecognitionTask *>(context->__tasks["face_recognition"]);
- auto facenet_task = static_cast<FacenetTask *>(context->__tasks["facenet"]);
-
- face_recognition_task->configure();
- facenet_task->configure();
- face_recognition_task->prepare();
- facenet_task->prepare();
- } catch (const BaseException &e) {
- LOGE("%s", e.what());
- return e.getError();
- }
-
- LOGD("LEAVE");
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_face_recognition_register_open(mv_face_recognition_h handle, mv_source_h source, const char *label)
-{
- LOGD("ENTER");
-
- lock_guard<mutex> lock(g_face_recognition_mutex);
-
- if (!handle) {
- LOGE("Handle is NULL.");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- try {
- Context *context = static_cast<Context *>(handle);
- auto face_recognition_task = static_cast<FaceRecognitionTask *>(context->__tasks["face_recognition"]);
- auto facenet_task = static_cast<FacenetTask *>(context->__tasks["facenet"]);
- FacenetInput facenet_input = { { source } };
-
- facenet_task->setInput(facenet_input);
- facenet_task->perform();
-
- FacenetOutput &facenet_output = facenet_task->getOutput();
- FaceRecognitionInput face_recognition_input = { .mode = mode::REGISTER };
- FaceRecognitionRegisterInput facenet_to_face_reg_input = { facenet_output.outputs[0], string(label) };
-
- face_recognition_input.register_src.clear();
- face_recognition_input.register_src.push_back(facenet_to_face_reg_input);
- face_recognition_task->setInput(face_recognition_input);
- face_recognition_task->perform();
- } catch (const BaseException &e) {
- LOGE("%s", e.what());
- return e.getError();
- }
-
- LOGD("LEAVE");
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_face_recognition_unregister_open(mv_face_recognition_h handle, const char *label)
-{
- LOGD("ENTER");
-
- lock_guard<mutex> lock(g_face_recognition_mutex);
-
- if (!handle) {
- LOGE("Handle is NULL.");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- try {
- Context *context = static_cast<Context *>(handle);
- auto face_recognition_task = static_cast<FaceRecognitionTask *>(context->__tasks["face_recognition"]);
- FaceRecognitionInput input = { mode::DELETE };
-
- input.labels.clear();
- input.labels.push_back(string(label));
- face_recognition_task->setInput(input);
- face_recognition_task->perform();
- } catch (const BaseException &e) {
- LOGE("%s", e.what());
- return e.getError();
- }
-
- LOGD("LEAVE");
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_face_recognition_inference_open(mv_face_recognition_h handle, mv_source_h source)
-{
- LOGD("ENTER");
-
- lock_guard<mutex> lock(g_face_recognition_mutex);
-
- if (!handle) {
- LOGE("Handle is NULL.");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- try {
- Context *context = static_cast<Context *>(handle);
- auto face_recognition_task = static_cast<FaceRecognitionTask *>(context->__tasks["face_recognition"]);
- auto facenet_task = static_cast<FacenetTask *>(context->__tasks["facenet"]);
- FacenetInput facenet_input = { { source } };
-
- facenet_task->setInput(facenet_input);
- facenet_task->perform();
- FacenetOutput &facenet_output = facenet_task->getOutput();
-
- FaceRecognitionInput face_recognition_input = { mode::INFERENCE };
-
- face_recognition_input.inputs = facenet_output.outputs;
- face_recognition_task->setInput(face_recognition_input);
- face_recognition_task->perform();
- } catch (const BaseException &e) {
- LOGE("%s", e.what());
- return e.getError();
- }
-
- LOGD("LEAVE");
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_face_recognition_get_label_open(mv_face_recognition_h handle, const char **out_label)
-{
- LOGD("ENTER");
-
- lock_guard<mutex> lock(g_face_recognition_mutex);
-
- if (!handle) {
- LOGE("Handle is NULL.");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- try {
- Context *context = static_cast<Context *>(handle);
- auto face_recognition_task = static_cast<FaceRecognitionTask *>(context->__tasks["face_recognition"]);
-
- *out_label = face_recognition_task->getOutput().label.c_str();
- } catch (const BaseException &e) {
- LOGE("%s", e.what());
- return e.getError();
- }
-
- LOGD("LEAVE");
-
- return MEDIA_VISION_ERROR_NONE;
-}
\ No newline at end of file
+++ /dev/null
-/**
- * Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "mv_private.h"
-#include "mv_image_classification_internal.h"
-#include "mv_image_classification_open.h"
-
-/**
- * @file mv_image_classification.c
- * @brief This file contains Media Vision inference module.
- */
-
-int mv_image_classification_create(mv_image_classification_h *infer)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_inference_check_system_info_feature_supported());
- MEDIA_VISION_NULL_ARG_CHECK(infer);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv_image_classification_create_open(infer);
-
- MEDIA_VISION_FUNCTION_LEAVE();
- return ret;
-}
-
-int mv_image_classification_destroy(mv_image_classification_h infer)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_inference_check_system_info_feature_supported());
- MEDIA_VISION_INSTANCE_CHECK(infer);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv_image_classification_destroy_open(infer);
-
- MEDIA_VISION_FUNCTION_LEAVE();
- return ret;
-}
-
-int mv_image_classification_configure(mv_image_classification_h infer)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_inference_check_system_info_feature_supported());
- MEDIA_VISION_INSTANCE_CHECK(infer);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv_image_classification_configure_open(infer);
-
- MEDIA_VISION_FUNCTION_LEAVE();
- return ret;
-}
-
-int mv_image_classification_prepare(mv_image_classification_h infer)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_inference_check_system_info_feature_supported());
- MEDIA_VISION_INSTANCE_CHECK(infer);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv_image_classification_prepare_open(infer);
-
- MEDIA_VISION_FUNCTION_LEAVE();
- return ret;
-}
-
-int mv_image_classification_inference(mv_image_classification_h infer, mv_source_h source)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_inference_image_check_system_info_feature_supported());
- MEDIA_VISION_INSTANCE_CHECK(source);
- MEDIA_VISION_INSTANCE_CHECK(infer);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv_image_classification_inference_open(infer, source);
-
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
-
-int mv_image_classification_get_label(mv_image_classification_h handle, const char **out_label)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported());
-
- MEDIA_VISION_INSTANCE_CHECK(handle);
- MEDIA_VISION_NULL_ARG_CHECK(out_label);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv_image_classification_get_label_open(handle, out_label);
-
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
-
-int mv_image_classification_set_model(mv_image_classification_h handle, const char *model_file, const char *meta_file,
- const char *label_file)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported());
-
- MEDIA_VISION_INSTANCE_CHECK(handle);
- MEDIA_VISION_NULL_ARG_CHECK(model_file);
- MEDIA_VISION_NULL_ARG_CHECK(meta_file);
- MEDIA_VISION_NULL_ARG_CHECK(label_file);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv_image_classification_set_model_open(handle, model_file, meta_file, label_file);
-
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
-
-int mv_image_classification_set_engine(mv_image_classification_h handle, const char *backend_type,
- const char *device_type)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported());
-
- MEDIA_VISION_INSTANCE_CHECK(handle);
- MEDIA_VISION_NULL_ARG_CHECK(backend_type);
- MEDIA_VISION_NULL_ARG_CHECK(device_type);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv_image_classification_set_engine_open(handle, backend_type, device_type);
-
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
-
-int mv_image_classification_get_engine_count(mv_image_classification_h handle, unsigned int *engine_count)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported());
-
- MEDIA_VISION_INSTANCE_CHECK(handle);
- MEDIA_VISION_NULL_ARG_CHECK(engine_count);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv_image_classification_get_engine_count_open(handle, engine_count);
-
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
-
-int mv_image_classification_get_engine_type(mv_image_classification_h handle, const unsigned int engine_index,
- char **engine_type)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported());
-
- MEDIA_VISION_INSTANCE_CHECK(handle);
- MEDIA_VISION_NULL_ARG_CHECK(engine_type);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv_image_classification_get_engine_type_open(handle, engine_index, engine_type);
-
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
-
-int mv_image_classification_get_device_count(mv_image_classification_h handle, const char *engine_type,
- unsigned int *device_count)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported());
-
- MEDIA_VISION_INSTANCE_CHECK(handle);
- MEDIA_VISION_NULL_ARG_CHECK(device_count);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv_image_classification_get_device_count_open(handle, engine_type, device_count);
-
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
-
-int mv_image_classification_get_device_type(mv_image_classification_h handle, const char *engine_type,
- const unsigned int device_index, char **device_type)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported());
-
- MEDIA_VISION_INSTANCE_CHECK(handle);
- MEDIA_VISION_NULL_ARG_CHECK(engine_type);
- MEDIA_VISION_NULL_ARG_CHECK(device_type);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv_image_classification_get_device_type_open(handle, engine_type, device_index, device_type);
-
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
--- /dev/null
+/**
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "mv_private.h"
+#include "itask.h"
+#include "mv_image_classification_internal.h"
+#include "image_classification_adapter.h"
+#include "machine_learning_exception.h"
+#include "image_classification_type.h"
+#include "context.h"
+
+#include <new>
+#include <unistd.h>
+#include <string>
+#include <algorithm>
+
+using namespace std;
+using namespace mediavision::inference;
+using namespace mediavision::common;
+using namespace mediavision::machine_learning;
+using namespace MediaVision::Common;
+using namespace mediavision::machine_learning::exception;
+using ImageClassificationTask = ITask<ImageClassificationInput, ImageClassificationResult>;
+
+int mv_image_classification_create(mv_image_classification_h *out_handle)
+{
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_check_system_info_feature_supported());
+ MEDIA_VISION_NULL_ARG_CHECK(out_handle);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ Context *context = nullptr;
+ ImageClassificationTask *task = nullptr;
+
+ try {
+ context = new Context();
+ task = new ImageClassificationAdapter<ImageClassificationInput, ImageClassificationResult>();
+
+ context->__tasks.insert(make_pair("image_classification", task));
+ *out_handle = static_cast<mv_image_classification_h>(context);
+ } catch (const BaseException &e) {
+ LOGE("%s", e.what());
+ delete task;
+ delete context;
+ return e.getError();
+ }
+
+ LOGD("object detection 3d handle [%p] has been created", *out_handle);
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_image_classification_destroy(mv_image_classification_h handle)
+{
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_check_system_info_feature_supported());
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ auto context = static_cast<Context *>(handle);
+
+ for (auto &m : context->__tasks)
+ delete static_cast<ImageClassificationTask *>(m.second);
+
+ delete context;
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_image_classification_configure(mv_image_classification_h handle)
+{
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_check_system_info_feature_supported());
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ try {
+ auto context = static_cast<Context *>(handle);
+ auto task = static_cast<ImageClassificationTask *>(context->__tasks.at("image_classification"));
+ if (!task) {
+ return MEDIA_VISION_ERROR_INVALID_OPERATION;
+ }
+
+ task->configure();
+ } catch (const BaseException &e) {
+ LOGE("%s", e.what());
+ return e.getError();
+ }
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_image_classification_prepare(mv_image_classification_h handle)
+{
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_check_system_info_feature_supported());
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ try {
+ auto context = static_cast<Context *>(handle);
+ auto task = static_cast<ImageClassificationTask *>(context->__tasks.at("image_classification"));
+
+ task->prepare();
+ } catch (const BaseException &e) {
+ LOGE("%s", e.what());
+ return e.getError();
+ }
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_image_classification_inference(mv_image_classification_h handle, mv_source_h source)
+{
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_image_check_system_info_feature_supported());
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+ MEDIA_VISION_INSTANCE_CHECK(source);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ try {
+ auto context = static_cast<Context *>(handle);
+ auto task = static_cast<ImageClassificationTask *>(context->__tasks.at("image_classification"));
+
+ ImageClassificationInput input = { source };
+
+ task->setInput(input);
+ task->perform();
+ } catch (const BaseException &e) {
+ LOGE("%s", e.what());
+ return e.getError();
+ }
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_image_classification_get_label(mv_image_classification_h handle, const char **out_label)
+{
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported());
+
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+ MEDIA_VISION_NULL_ARG_CHECK(out_label);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ try {
+ auto context = static_cast<Context *>(handle);
+ auto task = static_cast<ImageClassificationTask *>(context->__tasks.at("image_classification"));
+
+ ImageClassificationResult &result = task->getOutput();
+
+ *out_label = result.label.c_str();
+ } catch (const BaseException &e) {
+ LOGE("%s", e.what());
+ return e.getError();
+ }
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_image_classification_set_model(mv_image_classification_h handle, const char *model_file, const char *meta_file,
+ const char *label_file)
+{
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported());
+
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+ MEDIA_VISION_NULL_ARG_CHECK(model_file);
+ MEDIA_VISION_NULL_ARG_CHECK(meta_file);
+ MEDIA_VISION_NULL_ARG_CHECK(label_file);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ try {
+ auto context = static_cast<Context *>(handle);
+ auto task = static_cast<ImageClassificationTask *>(context->__tasks.at("image_classification"));
+
+ task->setModelInfo(model_file, meta_file, label_file);
+ } catch (const BaseException &e) {
+ LOGE("%s", e.what());
+ return e.getError();
+ }
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_image_classification_set_engine(mv_image_classification_h handle, const char *backend_type,
+ const char *device_type)
+{
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported());
+
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+ MEDIA_VISION_NULL_ARG_CHECK(backend_type);
+ MEDIA_VISION_NULL_ARG_CHECK(device_type);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ try {
+ auto context = static_cast<Context *>(handle);
+ auto task = static_cast<ImageClassificationTask *>(context->__tasks.at("image_classification"));
+
+ task->setEngineInfo(backend_type, device_type);
+ } catch (const BaseException &e) {
+ LOGE("%s", e.what());
+ return e.getError();
+ }
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_image_classification_get_engine_count(mv_image_classification_h handle, unsigned int *engine_count)
+{
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported());
+
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+ MEDIA_VISION_NULL_ARG_CHECK(engine_count);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ try {
+ auto context = static_cast<Context *>(handle);
+ auto task = static_cast<ImageClassificationTask *>(context->__tasks.at("image_classification"));
+
+ task->getNumberOfEngines(engine_count);
+ // TODO.
+ } catch (const BaseException &e) {
+ LOGE("%s", e.what());
+ return e.getError();
+ }
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_image_classification_get_engine_type(mv_image_classification_h handle, const unsigned int engine_index,
+ char **engine_type)
+{
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported());
+
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+ MEDIA_VISION_NULL_ARG_CHECK(engine_type);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ try {
+ auto context = static_cast<Context *>(handle);
+ auto task = static_cast<ImageClassificationTask *>(context->__tasks.at("image_classification"));
+
+ task->getEngineType(engine_index, engine_type);
+ // TODO.
+ } catch (const BaseException &e) {
+ LOGE("%s", e.what());
+ return e.getError();
+ }
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_image_classification_get_device_count(mv_image_classification_h handle, const char *engine_type,
+ unsigned int *device_count)
+{
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported());
+
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+ MEDIA_VISION_NULL_ARG_CHECK(device_count);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ try {
+ auto context = static_cast<Context *>(handle);
+ auto task = static_cast<ImageClassificationTask *>(context->__tasks.at("image_classification"));
+
+ task->getNumberOfDevices(engine_type, device_count);
+ // TODO.
+ } catch (const BaseException &e) {
+ LOGE("%s", e.what());
+ return e.getError();
+ }
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_image_classification_get_device_type(mv_image_classification_h handle, const char *engine_type,
+ const unsigned int device_index, char **device_type)
+{
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported());
+
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+ MEDIA_VISION_NULL_ARG_CHECK(engine_type);
+ MEDIA_VISION_NULL_ARG_CHECK(device_type);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ try {
+ auto context = static_cast<Context *>(handle);
+ auto task = static_cast<ImageClassificationTask *>(context->__tasks.at("image_classification"));
+
+ task->getDeviceType(engine_type, device_index, device_type);
+ // TODO.
+ } catch (const BaseException &e) {
+ LOGE("%s", e.what());
+ return e.getError();
+ }
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+++ /dev/null
-/**
- * Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "mv_private.h"
-#include "itask.h"
-#include "mv_image_classification_open.h"
-#include "image_classification_adapter.h"
-#include "machine_learning_exception.h"
-#include "image_classification_type.h"
-#include "context.h"
-
-#include <new>
-#include <unistd.h>
-#include <string>
-#include <algorithm>
-
-using namespace std;
-using namespace mediavision::inference;
-using namespace mediavision::common;
-using namespace mediavision::machine_learning;
-using namespace MediaVision::Common;
-using namespace mediavision::machine_learning::exception;
-using ImageClassificationTask = ITask<ImageClassificationInput, ImageClassificationResult>;
-
-int mv_image_classification_set_model_open(mv_image_classification_h handle, const char *model_file,
- const char *meta_file, const char *label_file)
-{
- if (!handle) {
- LOGE("Handle is NULL.");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- try {
- auto context = static_cast<Context *>(handle);
- auto task = static_cast<ImageClassificationTask *>(context->__tasks.at("image_classification"));
-
- task->setModelInfo(model_file, meta_file, label_file);
- } catch (const BaseException &e) {
- LOGE("%s", e.what());
- return e.getError();
- }
-
- LOGD("LEAVE");
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_image_classification_set_engine_open(mv_image_classification_h handle, const char *backend_type,
- const char *device_type)
-{
- if (!handle) {
- LOGE("Handle is NULL.");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- try {
- auto context = static_cast<Context *>(handle);
- auto task = static_cast<ImageClassificationTask *>(context->__tasks.at("image_classification"));
-
- task->setEngineInfo(backend_type, device_type);
- } catch (const BaseException &e) {
- LOGE("%s", e.what());
- return e.getError();
- }
-
- LOGD("LEAVE");
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_image_classification_get_engine_count_open(mv_image_classification_h handle, unsigned int *engine_count)
-{
- if (!handle) {
- LOGE("Handle is NULL.");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- try {
- auto context = static_cast<Context *>(handle);
- auto task = static_cast<ImageClassificationTask *>(context->__tasks.at("image_classification"));
-
- task->getNumberOfEngines(engine_count);
- // TODO.
- } catch (const BaseException &e) {
- LOGE("%s", e.what());
- return e.getError();
- }
-
- LOGD("LEAVE");
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_image_classification_get_engine_type_open(mv_image_classification_h handle, const unsigned int engine_index,
- char **engine_type)
-{
- if (!handle) {
- LOGE("Handle is NULL.");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- try {
- auto context = static_cast<Context *>(handle);
- auto task = static_cast<ImageClassificationTask *>(context->__tasks.at("image_classification"));
-
- task->getEngineType(engine_index, engine_type);
- // TODO.
- } catch (const BaseException &e) {
- LOGE("%s", e.what());
- return e.getError();
- }
-
- LOGD("LEAVE");
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_image_classification_get_device_count_open(mv_image_classification_h handle, const char *engine_type,
- unsigned int *device_count)
-{
- if (!handle) {
- LOGE("Handle is NULL.");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- try {
- auto context = static_cast<Context *>(handle);
- auto task = static_cast<ImageClassificationTask *>(context->__tasks.at("image_classification"));
-
- task->getNumberOfDevices(engine_type, device_count);
- // TODO.
- } catch (const BaseException &e) {
- LOGE("%s", e.what());
- return e.getError();
- }
-
- LOGD("LEAVE");
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_image_classification_get_device_type_open(mv_image_classification_h handle, const char *engine_type,
- const unsigned int device_index, char **device_type)
-{
- if (!handle) {
- LOGE("Handle is NULL.");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- try {
- auto context = static_cast<Context *>(handle);
- auto task = static_cast<ImageClassificationTask *>(context->__tasks.at("image_classification"));
-
- task->getDeviceType(engine_type, device_index, device_type);
- // TODO.
- } catch (const BaseException &e) {
- LOGE("%s", e.what());
- return e.getError();
- }
-
- LOGD("LEAVE");
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_image_classification_create_open(mv_image_classification_h *out_handle)
-{
- if (!out_handle) {
- LOGE("Handle can't be created because handle pointer is NULL");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- Context *context = nullptr;
- ImageClassificationTask *task = nullptr;
-
- try {
- context = new Context();
- task = new ImageClassificationAdapter<ImageClassificationInput, ImageClassificationResult>();
-
- context->__tasks.insert(make_pair("image_classification", task));
- *out_handle = static_cast<mv_image_classification_h>(context);
- } catch (const BaseException &e) {
- LOGE("%s", e.what());
- delete task;
- delete context;
- return e.getError();
- }
-
- LOGD("object detection 3d handle [%p] has been created", *out_handle);
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_image_classification_destroy_open(mv_image_classification_h handle)
-{
- if (!handle) {
- LOGE("Handle is NULL.");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- auto context = static_cast<Context *>(handle);
-
- for (auto &m : context->__tasks)
- delete static_cast<ImageClassificationTask *>(m.second);
-
- delete context;
-
- LOGD("Object detection 3d handle has been destroyed.");
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_image_classification_configure_open(mv_image_classification_h handle)
-{
- LOGD("ENTER");
-
- if (!handle) {
- LOGE("Handle is NULL.");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- try {
- auto context = static_cast<Context *>(handle);
- auto task = static_cast<ImageClassificationTask *>(context->__tasks.at("image_classification"));
- if (!task) {
- return MEDIA_VISION_ERROR_INVALID_OPERATION;
- }
-
- task->configure();
- } catch (const BaseException &e) {
- LOGE("%s", e.what());
- return e.getError();
- }
-
- LOGD("LEAVE");
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_image_classification_prepare_open(mv_image_classification_h handle)
-{
- LOGD("ENTER");
-
- if (!handle) {
- LOGE("Handle is NULL.");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- try {
- auto context = static_cast<Context *>(handle);
- auto task = static_cast<ImageClassificationTask *>(context->__tasks.at("image_classification"));
-
- task->prepare();
- } catch (const BaseException &e) {
- LOGE("%s", e.what());
- return e.getError();
- }
-
- LOGD("LEAVE");
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_image_classification_inference_open(mv_image_classification_h handle, mv_source_h source)
-{
- LOGD("ENTER");
-
- if (!handle) {
- LOGE("Handle is NULL.");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- try {
- auto context = static_cast<Context *>(handle);
- auto task = static_cast<ImageClassificationTask *>(context->__tasks.at("image_classification"));
-
- ImageClassificationInput input = { source };
-
- task->setInput(input);
- task->perform();
- } catch (const BaseException &e) {
- LOGE("%s", e.what());
- return e.getError();
- }
-
- LOGD("LEAVE");
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_image_classification_get_label_open(mv_image_classification_h handle, const char **out_label)
-{
- LOGD("ENTER");
-
- if (!handle) {
- LOGE("Handle is NULL.");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- try {
- auto context = static_cast<Context *>(handle);
- auto task = static_cast<ImageClassificationTask *>(context->__tasks.at("image_classification"));
-
- ImageClassificationResult &result = task->getOutput();
-
- *out_label = result.label.c_str();
- } catch (const BaseException &e) {
- LOGE("%s", e.what());
- return e.getError();
- }
-
- LOGD("LEAVE");
-
- return MEDIA_VISION_ERROR_NONE;
-}
\ No newline at end of file
+++ /dev/null
-/**
- * Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __MEDIA_VISION_FACIAL_LANDMARK_OPEN_H__
-#define __MEDIA_VISION_FACIAL_LANDMARK_OPEN_H__
-
-#include <mv_common.h>
-#include <mv_private.h>
-#include <mv_facial_landmark_type.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-/**
- * @brief Create facial landmark object handle.
- * @details Use this function to create an facial landmark object handle.
- * After creation the handle has to be prepared with
- * @ref mv_facial_landmark_prepare_open() function to prepare
- * an facial landmark object.
- *
- * @since_tizen 7.5
- *
- * @param[out] out_handle The handle to the facial landmark object to be created
- *
- * @return @c 0 on success, otherwise a negative error value
- * @retval #MEDIA_VISION_ERROR_NONE Successful
- * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #MEDIA_VISION_ERROR_OUT_OF_MEMORY Out of memory
- *
- * @post Release @a handle by using
- * @ref mv_facial_landmark_destroy_open() function when it is not needed
- * anymore
- *
- * @see mv_facial_landmark_destroy_open()
- */
-int mv_facial_landmark_create_open(mv_facial_landmark_h *out_handle);
-
-/**
- * @brief Destroy facial landmark handle and releases all its resources.
- *
- * @since_tizen 7.5
- *
- * @param[in] handle The handle to the facial landmark object to be destroyed.
- *
- * @return @c 0 on success, otherwise a negative error value
- * @retval #MEDIA_VISION_ERROR_NONE Successful
- * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
- *
- * @pre Create an facial landmark handle by using @ref mv_facial_landmark_create_open()
- *
- * @see mv_facial_landmark_create_open()
- */
-int mv_facial_landmark_destroy_open(mv_facial_landmark_h handle);
-
-/**
- * @brief Set user-given model information.
- * @details Use this function to change the model information instead of default one after calling @ref mv_facial_landmark_create().
- *
- * @since_tizen 7.5
- *
- * @param[in] handle The handle to the facial landmark object.
- * @param[in] model_name Model name.
- * @param[in] model_file Model file name.
- * @param[in] meta_type Model meta file name.
- * @param[in] label_file Label file name.
- *
- * @return @c 0 on success, otherwise a negative error value
- * @retval #MEDIA_VISION_ERROR_NONE Successful
- * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #MEDIA_VISION_ERROR_INVALID_OPERATION Invalid operation
- *
- * @pre Create a facial landmark handle by calling @ref mv_facial_landmark_create()
- */
-int mv_facial_landmark_set_model_open(mv_facial_landmark_h handle, const char *model_name, const char *model_file,
- const char *meta_file, const char *label_file);
-
-/**
- * @brief Configure the backend to the inference handle
- *
- * @since_tizen 7.5
- *
- * @param [in] handle The handle to the inference
- *
- * @return @c 0 on success, otherwise a negative error value
- * @retval #MEDIA_VISION_ERROR_NONE Successful
- * @retval #MEDIA_VISION_ERROR_OUT_OF_MEMORY Out of memory
- * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported
- */
-int mv_facial_landmark_configure_open(mv_facial_landmark_h handle);
-
-/**
- * @brief Prepare inference.
- * @details Use this function to prepare inference based on
- * the configured network.
- *
- * @since_tizen 7.5
- *
- * @param [in] handle The handle to the inference
- *
- * @return @c 0 on success, otherwise a negative error value
- * @retval #MEDIA_VISION_ERROR_NONE Successful
- * @retval #MEDIA_VISION_ERROR_INVALID_DATA Invalid model data
- * @retval #MEDIA_VISION_ERROR_OUT_OF_MEMORY Out of memory
- */
-int mv_facial_landmark_prepare_open(mv_facial_landmark_h handle);
-
-/**
- *
- * @brief Inference with a given facial on the @a source
- * @details Use this function to inference with a given source.
- *
- *
- * @since_tizen 7.5
- *
- * @param[in] handle The handle to the facial landmark object.
- * @param[in] source The handle to the source of the media.
- *
- * @return @c 0 on success, otherwise a negative error value
- * @retval #MEDIA_VISION_ERROR_NONE Successful
- * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED_FORMAT Source colorspace
- * isn't supported
- * @retval #MEDIA_VISION_ERROR_OUT_OF_MEMORY Out of memory
- *
- * @pre Create a source handle by calling @ref mv_create_source()
- * @pre Create an facial landmark handle by calling @ref mv_facial_landmark_create_open()
- * @pre Prepare an inference by calling mv_object_detect_configure_open()
- * @pre Prepare an facial landmark by calling @ref mv_facial_landmark_prepare_open()
- */
-int mv_facial_landmark_inference_open(mv_facial_landmark_h handle, mv_source_h source);
-
-/**
- * @brief Gets the facial landmark positions on the @a source.
- *
- * @since_tizen 7.5
- *
- * @param[in] handle The handle to the inference
- * @param[out] number_of_landmarks A number of landmarks detected.
- * @param[out] pos_x An array containing x-coordinate values.
- * @param[out] pos_y An array containing y-coordinate values.
- *
- * @return @c 0 on success, otherwise a negative error value
- * @retval #MEDIA_VISION_ERROR_NONE Successful
- * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported
- * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #MEDIA_VISION_ERROR_INTERNAL Internal error
- *
- * @pre Create a source handle by calling mv_create_source()
- * @pre Create an inference handle by calling mv_facial_landmark_create()
- * @pre Prepare an inference by calling mv_facial_landmark_configure()
- * @pre Prepare an inference by calling mv_facial_landmark_prepare()
- * @pre Prepare an inference by calling mv_facial_landmark_inference()
- */
-int mv_facial_landmark_get_positions_open(mv_facial_landmark_h handle, unsigned int *number_of_landmarks,
- unsigned int **pos_x, unsigned int **pos_y);
-
-/**
- * @brief Set user-given backend and device types for inference.
- * @details Use this function to change the backend and device types for inference instead of default ones after calling @ref mv_facial_landmark_create_open().
- *
- * @since_tizen 7.5
- *
- * @param[in] handle The handle to the image classification object.
- * @param[in] backend_type A string of backend type.
- * @param[in] device_type A string of device type.
- *
- * @return @c 0 on success, otherwise a negative error value
- * @retval #MEDIA_VISION_ERROR_NONE Successful
- * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #MEDIA_VISION_ERROR_INVALID_OPERATION Invalid operation
- *
- * @pre Create a image classification handle by calling @ref mv_facial_landmark_create_open()
- */
-int mv_facial_landmark_set_engine_open(mv_facial_landmark_h handle, const char *backend_type, const char *device_type);
-
-/**
- * @brief Get a number of inference engines available for image classification task API.
- * @details Use this function to get how many inference engines are supported for image classification after calling @ref mv_facial_landmark_create_open().
- *
- * @since_tizen 7.5
- *
- * @param[in] handle The handle to the image classification object.
- * @param[out] engine_count A number of inference engines available for image classification API.
- *
- * @return @c 0 on success, otherwise a negative error value
- * @retval #MEDIA_VISION_ERROR_NONE Successful
- * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #MEDIA_VISION_ERROR_INVALID_OPERATION Invalid operation
- *
- * @pre Create a image classification handle by calling @ref mv_facial_landmark_create_open()
- */
-int mv_facial_landmark_get_engine_count_open(mv_facial_landmark_h handle, unsigned int *engine_count);
-
-/**
- * @brief Get engine type to a given inference engine index.
- * @details Use this function to get inference engine type with a given engine index after calling @ref mv_facial_landmark_get_engine_count().
- *
- * @since_tizen 7.5
- *
- * @param[in] handle The handle to the image classification object.
- * @param[in] engine_index A inference engine index for getting the inference engine type.
- * @param[out] engine_type A string to inference engine.
- *
- * @return @c 0 on success, otherwise a negative error value
- * @retval #MEDIA_VISION_ERROR_NONE Successful
- * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #MEDIA_VISION_ERROR_INVALID_OPERATION Invalid operation
- *
- * @pre Get a number of inference engines available for image classification task API by calling @ref mv_facial_landmark_get_engine_count()
- */
-int mv_facial_landmark_get_engine_type_open(mv_facial_landmark_h handle, const unsigned int engine_index,
- char **engine_type);
-
-/**
- * @brief Get a number of device types available to a given inference engine.
- * @details Use this function to get how many device types are supported for a given inference engine after calling @ref mv_facial_landmark_create_open().
- *
- * @since_tizen 7.5
- *
- * @param[in] handle The handle to the image classification object.
- * @param[in] engine_type A inference engine string.
- * @param[out] device_count A number of device types available for a given inference engine.
- *
- * @return @c 0 on success, otherwise a negative error value
- * @retval #MEDIA_VISION_ERROR_NONE Successful
- * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #MEDIA_VISION_ERROR_INVALID_OPERATION Invalid operation
- *
- * @pre Create a image classification handle by calling @ref mv_facial_landmark_create_open()
- */
-int mv_facial_landmark_get_device_count_open(mv_facial_landmark_h handle, const char *engine_type,
- unsigned int *device_count);
-
-/**
- * @brief Get device type list available.
- * @details Use this function to get what device types are supported for current inference engine type after calling @ref mv_facial_landmark_configure().
- *
- * @since_tizen 7.5
- *
- * @param[in] handle The handle to the image classification object.
- * @param[in] engine_type A inference engine string.
- * @param[in] device_index A device index for getting the device type.
- * @param[out] device_type A string to device type.
- *
- * @return @c 0 on success, otherwise a negative error value
- * @retval #MEDIA_VISION_ERROR_NONE Successful
- * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #MEDIA_VISION_ERROR_INVALID_OPERATION Invalid operation
- *
- * @pre Create a image classification handle by calling @ref mv_facial_landmark_create_open()
- * @pre Configure image classification task by calling @ref mv_facial_landmark_configure_open()
- */
-int mv_facial_landmark_get_device_type_open(mv_facial_landmark_h handle, const char *engine_type,
- const unsigned int device_index, char **device_type);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* __MEDIA_VISION_INFERENCE_OPEN_H__ */
+++ /dev/null
-/**
- * Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __MEDIA_VISION_POSE_LANDMARK_OPEN_H__
-#define __MEDIA_VISION_POSE_LANDMARK_OPEN_H__
-
-#include <mv_common.h>
-#include <mv_private.h>
-#include <mv_pose_landmark_type.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-/**
- * @brief Creates pose landmark object handle.
- * @details Use this function to create an pose landmark object handle.
- * After creation the handle has to be prepared with
- * @ref mv_pose_landmark_prepare_open() function to prepare
- * an pose landmark object.
- *
- * @since_tizen 7.5
- *
- * @param[out] out_handle The handle to the pose landmark object to be created
- *
- * @return @c 0 on success, otherwise a negative error value
- * @retval #MEDIA_VISION_ERROR_NONE Successful
- * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #MEDIA_VISION_ERROR_OUT_OF_MEMORY Out of memory
- *
- * @post Release @a handle by using
- * @ref mv_pose_landmark_destroy_open() function when it is not needed
- * anymore
- *
- * @see mv_pose_landmark_destroy_open()
- */
-int mv_pose_landmark_create_open(mv_pose_landmark_h *out_handle);
-
-/**
- * @brief Destroys pose landmark handle and releases all its resources.
- *
- * @since_tizen 7.5
- *
- * @param[in] handle The handle to the pose landmark object to be destroyed.
- *
- * @return @c 0 on success, otherwise a negative error value
- * @retval #MEDIA_VISION_ERROR_NONE Successful
- * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
- *
- * @pre Create an pose landmark handle by using @ref mv_pose_landmark_create_open()
- *
- * @see mv_pose_landmark_create_open()
- */
-int mv_pose_landmark_destroy_open(mv_pose_landmark_h handle);
-
-/**
- * @brief Set user-given model information.
- * @details Use this function to change the model information instead of default one after calling @ref mv_pose_landmark_create().
- *
- * @since_tizen 7.5
- *
- * @param[in] handle The handle to the pose landmark object.
- * @param[in] model_name Model name.
- * @param[in] model_file Model file name.
- * @param[in] meta_type Model meta file name.
- * @param[in] label_file Label file name.
- *
- * @return @c 0 on success, otherwise a negative error value
- * @retval #MEDIA_VISION_ERROR_NONE Successful
- * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #MEDIA_VISION_ERROR_INVALID_OPERATION Invalid operation
- *
- * @pre Create a pose landmark handle by calling @ref mv_pose_landmark_create()
- */
-int mv_pose_landmark_set_model_open(mv_pose_landmark_h handle, const char *model_name, const char *model_file,
- const char *meta_file, const char *label_file);
-
-/**
- * @brief Configures the backend to the inference handle
- *
- * @since_tizen 7.5
- *
- * @param [in] handle The handle to the inference
- *
- * @return @c 0 on success, otherwise a negative error value
- * @retval #MEDIA_VISION_ERROR_NONE Successful
- * @retval #MEDIA_VISION_ERROR_OUT_OF_MEMORY Out of memory
- * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported
- */
-int mv_pose_landmark_configure_open(mv_pose_landmark_h handle);
-
-/**
- * @brief Prepares inference.
- * @details Use this function to prepare inference based on
- * the configured network.
- *
- * @since_tizen 7.5
- *
- * @param [in] handle The handle to the inference
- *
- * @return @c 0 on success, otherwise a negative error value
- * @retval #MEDIA_VISION_ERROR_NONE Successful
- * @retval #MEDIA_VISION_ERROR_INVALID_DATA Invalid model data
- * @retval #MEDIA_VISION_ERROR_OUT_OF_MEMORY Out of memory
- */
-int mv_pose_landmark_prepare_open(mv_pose_landmark_h handle);
-
-/**
- *
- * @brief Inferences with a given raw image on the @a source
- * @details Use this function to inference with a given source.
- *
- *
- * @since_tizen 7.5
- *
- * @param[in] handle The handle to the pose landmark object.
- * @param[in] source The handle to the source of the media.
- *
- * @return @c 0 on success, otherwise a negative error value
- * @retval #MEDIA_VISION_ERROR_NONE Successful
- * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED_FORMAT Source colorspace
- * isn't supported
- * @retval #MEDIA_VISION_ERROR_OUT_OF_MEMORY Out of memory
- *
- * @pre Create a source handle by calling @ref mv_create_source()
- * @pre Create an pose landmark handle by calling @ref mv_pose_landmark_create_open()
- * @pre Prepare an inference by calling mv_object_detect_configure_open()
- * @pre Prepare an pose landmark by calling @ref mv_pose_landmark_prepare_open()
- */
-int mv_pose_landmark_inference_open(mv_pose_landmark_h handle, mv_source_h source);
-
-/**
- * @brief Gets the pose landmark positions on the @a source.
- *
- * @since_tizen 7.5
- * @remarks pos_x and pos_y arrays are allocated internally by the framework and will remain valid
- * until the handle is returned.
- * Please do not deallocate them directly, and if you want to use them after the handle is returned,
- * please copy them to user memory and use the copy.
- * @param[in] handle The handle to the inference
- * @param[out] number_of_landmarks A number of landmarks detected.
- * @param[out] pos_x An array containing x-coordinate values.
- * @param[out] pos_y An array containing y-coordinate values.
- *
- * @return @c 0 on success, otherwise a negative error value
- * @retval #MEDIA_VISION_ERROR_NONE Successful
- * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported
- * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #MEDIA_VISION_ERROR_INTERNAL Internal error
- *
- * @pre Create a source handle by calling mv_create_source()
- * @pre Create an inference handle by calling mv_pose_landmark_create()
- * @pre Prepare an inference by calling mv_pose_landmark_configure()
- * @pre Prepare an inference by calling mv_pose_landmark_prepare()
- * @pre Prepare an inference by calling mv_pose_landmark_inference()
- */
-int mv_pose_landmark_get_pos_open(mv_pose_landmark_h handle, unsigned int *number_of_landmarks, unsigned int **pos_x,
- unsigned int **pos_y);
-
-/**
- * @brief Set user-given backend and device types for inference.
- * @details Use this function to change the backend and device types for inference instead of default ones after calling @ref mv_pose_landmark_create_open().
- *
- * @since_tizen 7.5
- *
- * @param[in] handle The handle to the image classification object.
- * @param[in] backend_type A string of backend type.
- * @param[in] device_type A string of device type.
- *
- * @return @c 0 on success, otherwise a negative error value
- * @retval #MEDIA_VISION_ERROR_NONE Successful
- * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #MEDIA_VISION_ERROR_INVALID_OPERATION Invalid operation
- *
- * @pre Creates a image classification handle by calling @ref mv_pose_landmark_create_open()
- */
-int mv_pose_landmark_set_engine_open(mv_pose_landmark_h handle, const char *backend_type, const char *device_type);
-
-/**
- * @brief Get a number of inference engines available for image classification task API.
- * @details Use this function to get how many inference engines are supported for image classification after calling @ref mv_pose_landmark_create_open().
- *
- * @since_tizen 7.5
- *
- * @param[in] handle The handle to the image classification object.
- * @param[out] engine_count A number of inference engines available for image classification API.
- *
- * @return @c 0 on success, otherwise a negative error value
- * @retval #MEDIA_VISION_ERROR_NONE Successful
- * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #MEDIA_VISION_ERROR_INVALID_OPERATION Invalid operation
- *
- * @pre Create a image classification handle by calling @ref mv_pose_landmark_create_open()
- */
-int mv_pose_landmark_get_engine_count_open(mv_pose_landmark_h handle, unsigned int *engine_count);
-
-/**
- * @brief Gets engine type to a given inference engine index.
- * @details Use this function to get inference engine type with a given engine index after calling @ref mv_pose_landmark_get_engine_count().
- *
- * @since_tizen 7.5
- * @remarks engine_type array is allocated internally by the framework and will remain valid
- * until the handle is returned.
- * Please do not deallocate it directly, and if you want to use it after the handle is returned,
- * please copy it to user memory and use the copy.
- * @param[in] handle The handle to the image classification object.
- * @param[in] engine_index A inference engine index for getting the inference engine type.
- * @param[out] engine_type A string to inference engine.
- *
- * @return @c 0 on success, otherwise a negative error value
- * @retval #MEDIA_VISION_ERROR_NONE Successful
- * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #MEDIA_VISION_ERROR_INVALID_OPERATION Invalid operation
- *
- * @pre Get a number of inference engines available for image classification task API by calling @ref mv_pose_landmark_get_engine_count()
- */
-int mv_pose_landmark_get_engine_type_open(mv_pose_landmark_h handle, const unsigned int engine_index,
- char **engine_type);
-
-/**
- * @brief Gets a number of device types available to a given inference engine.
- * @details Use this function to get how many device types are supported for a given inference engine after calling @ref mv_pose_landmark_create_open().
- *
- * @since_tizen 7.5
- *
- * @param[in] handle The handle to the image classification object.
- * @param[in] engine_type A inference engine string.
- * @param[out] device_count A number of device types available for a given inference engine.
- *
- * @return @c 0 on success, otherwise a negative error value
- * @retval #MEDIA_VISION_ERROR_NONE Successful
- * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #MEDIA_VISION_ERROR_INVALID_OPERATION Invalid operation
- *
- * @pre Create a image classification handle by calling @ref mv_pose_landmark_create_open()
- */
-int mv_pose_landmark_get_device_count_open(mv_pose_landmark_h handle, const char *engine_type,
- unsigned int *device_count);
-
-/**
- * @brief Gets device type list available.
- * @details Use this function to get what device types are supported for current inference engine type after calling @ref mv_pose_landmark_configure().
- *
- * @since_tizen 7.5
- * @remarks device_type array is allocated internally by the framework and will remain valid
- * until the handle is returned.
- * Please do not deallocate it directly, and if you want to use it after the handle is returned,
- * please copy it to user memory and use the copy.
- * @param[in] handle The handle to the image classification object.
- * @param[in] engine_type A inference engine string.
- * @param[in] device_index A device index for getting the device type.
- * @param[out] device_type A string to device type.
- *
- * @return @c 0 on success, otherwise a negative error value
- * @retval #MEDIA_VISION_ERROR_NONE Successful
- * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #MEDIA_VISION_ERROR_INVALID_OPERATION Invalid operation
- *
- * @pre Creates a image classification handle by calling @ref mv_pose_landmark_create_open()
- * @pre Configure image classification task by calling @ref mv_pose_landmark_configure_open()
- */
-int mv_pose_landmark_get_device_type_open(mv_pose_landmark_h handle, const char *engine_type,
- const unsigned int device_index, char **device_type);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* __MEDIA_VISION_INFERENCE_OPEN_H__ */
+++ /dev/null
-/**
- * Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "mv_private.h"
-#include "mv_facial_landmark_internal.h"
-#include "mv_facial_landmark_open.h"
-
-/**
- * @file mv_facial_landmark.c
- * @brief This file contains Media Vision inference module.
- */
-
-int mv_facial_landmark_create(mv_facial_landmark_h *handle)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_inference_check_system_info_feature_supported());
- MEDIA_VISION_NULL_ARG_CHECK(handle);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv_facial_landmark_create_open(handle);
-
- MEDIA_VISION_FUNCTION_LEAVE();
- return ret;
-}
-
-int mv_facial_landmark_destroy(mv_facial_landmark_h handle)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_inference_check_system_info_feature_supported());
- MEDIA_VISION_INSTANCE_CHECK(handle);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv_facial_landmark_destroy_open(handle);
-
- MEDIA_VISION_FUNCTION_LEAVE();
- return ret;
-}
-
-int mv_facial_landmark_set_model(mv_facial_landmark_h handle, const char *model_name, const char *model_file,
- const char *meta_file, const char *label_file)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_inference_check_system_info_feature_supported());
-
- MEDIA_VISION_INSTANCE_CHECK(handle);
- MEDIA_VISION_INSTANCE_CHECK(model_name);
- MEDIA_VISION_NULL_ARG_CHECK(model_file);
- MEDIA_VISION_NULL_ARG_CHECK(meta_file);
- MEDIA_VISION_NULL_ARG_CHECK(label_file);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv_facial_landmark_set_model_open(handle, model_name, model_file, meta_file, label_file);
-
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
-
-int mv_facial_landmark_set_engine(mv_facial_landmark_h handle, const char *backend_type, const char *device_type)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_inference_check_system_info_feature_supported());
-
- MEDIA_VISION_INSTANCE_CHECK(handle);
- MEDIA_VISION_NULL_ARG_CHECK(backend_type);
- MEDIA_VISION_NULL_ARG_CHECK(device_type);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv_facial_landmark_set_engine_open(handle, backend_type, device_type);
-
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
-
-int mv_facial_landmark_get_engine_count(mv_facial_landmark_h handle, unsigned int *engine_count)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_inference_check_system_info_feature_supported());
-
- MEDIA_VISION_INSTANCE_CHECK(handle);
- MEDIA_VISION_NULL_ARG_CHECK(engine_count);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv_facial_landmark_get_engine_count_open(handle, engine_count);
-
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
-
-int mv_facial_landmark_get_engine_type(mv_facial_landmark_h handle, const unsigned int engine_index, char **engine_type)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_inference_check_system_info_feature_supported());
-
- MEDIA_VISION_INSTANCE_CHECK(handle);
- MEDIA_VISION_NULL_ARG_CHECK(engine_type);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv_facial_landmark_get_engine_type_open(handle, engine_index, engine_type);
-
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
-
-int mv_facial_landmark_get_device_count(mv_facial_landmark_h handle, const char *engine_type,
- unsigned int *device_count)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_inference_check_system_info_feature_supported());
-
- MEDIA_VISION_INSTANCE_CHECK(handle);
- MEDIA_VISION_NULL_ARG_CHECK(device_count);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv_facial_landmark_get_device_count_open(handle, engine_type, device_count);
-
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
-
-int mv_facial_landmark_get_device_type(mv_facial_landmark_h handle, const char *engine_type,
- const unsigned int device_index, char **device_type)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_inference_check_system_info_feature_supported());
-
- MEDIA_VISION_INSTANCE_CHECK(handle);
- MEDIA_VISION_NULL_ARG_CHECK(engine_type);
- MEDIA_VISION_NULL_ARG_CHECK(device_type);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv_facial_landmark_get_device_type_open(handle, engine_type, device_index, device_type);
-
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
-
-int mv_facial_landmark_configure(mv_facial_landmark_h handle)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_inference_check_system_info_feature_supported());
- MEDIA_VISION_INSTANCE_CHECK(handle);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv_facial_landmark_configure_open(handle);
-
- MEDIA_VISION_FUNCTION_LEAVE();
- return ret;
-}
-
-int mv_facial_landmark_prepare(mv_facial_landmark_h handle)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_inference_check_system_info_feature_supported());
- MEDIA_VISION_INSTANCE_CHECK(handle);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv_facial_landmark_prepare_open(handle);
-
- MEDIA_VISION_FUNCTION_LEAVE();
- return ret;
-}
-
-int mv_facial_landmark_inference(mv_facial_landmark_h handle, mv_source_h source)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_inference_image_check_system_info_feature_supported());
- MEDIA_VISION_INSTANCE_CHECK(handle);
- MEDIA_VISION_INSTANCE_CHECK(source);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv_facial_landmark_inference_open(handle, source);
-
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
-
-int mv_facial_landmark_get_positions(mv_facial_landmark_h handle, unsigned int *number_of_landmarks,
- unsigned int **pos_x, unsigned int **pos_y)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_inference_image_check_system_info_feature_supported());
- MEDIA_VISION_INSTANCE_CHECK(handle);
- MEDIA_VISION_INSTANCE_CHECK(number_of_landmarks);
- MEDIA_VISION_INSTANCE_CHECK(pos_x);
- MEDIA_VISION_INSTANCE_CHECK(pos_y);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv_facial_landmark_get_positions_open(handle, number_of_landmarks, pos_x, pos_y);
-
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
--- /dev/null
+/**
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "mv_private.h"
+#include "itask.h"
+#include "mv_facial_landmark_internal.h"
+#include "facial_landmark_adapter.h"
+#include "machine_learning_exception.h"
+#include "landmark_detection_type.h"
+#include "context.h"
+
+#include <new>
+#include <unistd.h>
+#include <string>
+#include <algorithm>
+#include <mutex>
+#include <iostream>
+
+using namespace std;
+using namespace mediavision::inference;
+using namespace mediavision::common;
+using namespace mediavision::machine_learning;
+using namespace MediaVision::Common;
+using namespace mediavision::machine_learning::exception;
+using LandmarkDetectionTask = ITask<LandmarkDetectionInput, LandmarkDetectionResult>;
+
+static mutex g_facial_landmark_mutex;
+
+int mv_facial_landmark_create(mv_facial_landmark_h *handle)
+{
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_check_system_info_feature_supported());
+ MEDIA_VISION_NULL_ARG_CHECK(handle);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ Context *context = nullptr;
+ LandmarkDetectionTask *task = nullptr;
+
+ try {
+ context = new Context();
+ task = new FacialLandmarkAdapter<LandmarkDetectionInput, LandmarkDetectionResult>();
+ context->__tasks.insert(make_pair("facial_landmark", task));
+ *handle = static_cast<mv_facial_landmark_h>(context);
+ } catch (const BaseException &e) {
+ delete task;
+ delete context;
+ return e.getError();
+ }
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_facial_landmark_destroy(mv_facial_landmark_h handle)
+{
+ lock_guard<mutex> lock(g_facial_landmark_mutex);
+
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_check_system_info_feature_supported());
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ auto context = static_cast<Context *>(handle);
+
+ for (auto &m : context->__tasks)
+ delete static_cast<LandmarkDetectionTask *>(m.second);
+
+ delete context;
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_facial_landmark_set_model(mv_facial_landmark_h handle, const char *model_name, const char *model_file,
+ const char *meta_file, const char *label_file)
+{
+ lock_guard<mutex> lock(g_facial_landmark_mutex);
+
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_check_system_info_feature_supported());
+
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+ MEDIA_VISION_INSTANCE_CHECK(model_name);
+ MEDIA_VISION_NULL_ARG_CHECK(model_file);
+ MEDIA_VISION_NULL_ARG_CHECK(meta_file);
+ MEDIA_VISION_NULL_ARG_CHECK(label_file);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ try {
+ auto context = static_cast<Context *>(handle);
+ auto task = static_cast<LandmarkDetectionTask *>(context->__tasks.at("facial_landmark"));
+
+ task->setModelInfo(model_file, meta_file, label_file, model_name);
+ } catch (const BaseException &e) {
+ LOGE("%s", e.what());
+ return e.getError();
+ }
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_facial_landmark_set_engine(mv_facial_landmark_h handle, const char *backend_type, const char *device_type)
+{
+ lock_guard<mutex> lock(g_facial_landmark_mutex);
+
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_check_system_info_feature_supported());
+
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+ MEDIA_VISION_NULL_ARG_CHECK(backend_type);
+ MEDIA_VISION_NULL_ARG_CHECK(device_type);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ try {
+ auto context = static_cast<Context *>(handle);
+ auto task = static_cast<LandmarkDetectionTask *>(context->__tasks.at("facial_landmark"));
+
+ task->setEngineInfo(backend_type, device_type);
+ } catch (const BaseException &e) {
+ LOGE("%s", e.what());
+ return e.getError();
+ }
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_facial_landmark_get_engine_count(mv_facial_landmark_h handle, unsigned int *engine_count)
+{
+ lock_guard<mutex> lock(g_facial_landmark_mutex);
+
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_check_system_info_feature_supported());
+
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+ MEDIA_VISION_NULL_ARG_CHECK(engine_count);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ try {
+ auto context = static_cast<Context *>(handle);
+ auto task = static_cast<LandmarkDetectionTask *>(context->__tasks.at("facial_landmark"));
+
+ task->getNumberOfEngines(engine_count);
+ // TODO.
+ } catch (const BaseException &e) {
+ LOGE("%s", e.what());
+ return e.getError();
+ }
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_facial_landmark_get_engine_type(mv_facial_landmark_h handle, const unsigned int engine_index, char **engine_type)
+{
+ lock_guard<mutex> lock(g_facial_landmark_mutex);
+
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_check_system_info_feature_supported());
+
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+ MEDIA_VISION_NULL_ARG_CHECK(engine_type);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ try {
+ auto context = static_cast<Context *>(handle);
+ auto task = static_cast<LandmarkDetectionTask *>(context->__tasks.at("facial_landmark"));
+
+ task->getEngineType(engine_index, engine_type);
+ // TODO.
+ } catch (const BaseException &e) {
+ LOGE("%s", e.what());
+ return e.getError();
+ }
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_facial_landmark_get_device_count(mv_facial_landmark_h handle, const char *engine_type,
+ unsigned int *device_count)
+{
+ lock_guard<mutex> lock(g_facial_landmark_mutex);
+
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_check_system_info_feature_supported());
+
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+ MEDIA_VISION_NULL_ARG_CHECK(device_count);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ try {
+ auto context = static_cast<Context *>(handle);
+ auto task = static_cast<LandmarkDetectionTask *>(context->__tasks.at("facial_landmark"));
+
+ task->getNumberOfDevices(engine_type, device_count);
+ // TODO.
+ } catch (const BaseException &e) {
+ LOGE("%s", e.what());
+ return e.getError();
+ }
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_facial_landmark_get_device_type(mv_facial_landmark_h handle, const char *engine_type,
+ const unsigned int device_index, char **device_type)
+{
+ lock_guard<mutex> lock(g_facial_landmark_mutex);
+
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_check_system_info_feature_supported());
+
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+ MEDIA_VISION_NULL_ARG_CHECK(engine_type);
+ MEDIA_VISION_NULL_ARG_CHECK(device_type);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ try {
+ auto context = static_cast<Context *>(handle);
+ auto task = static_cast<LandmarkDetectionTask *>(context->__tasks.at("facial_landmark"));
+
+ task->getDeviceType(engine_type, device_index, device_type);
+ // TODO.
+ } catch (const BaseException &e) {
+ LOGE("%s", e.what());
+ return e.getError();
+ }
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_facial_landmark_configure(mv_facial_landmark_h handle)
+{
+ lock_guard<mutex> lock(g_facial_landmark_mutex);
+
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_check_system_info_feature_supported());
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ try {
+ auto context = static_cast<Context *>(handle);
+ auto task = static_cast<LandmarkDetectionTask *>(context->__tasks.at("facial_landmark"));
+
+ task->configure();
+ } catch (const BaseException &e) {
+ LOGE("%s", e.what());
+ return e.getError();
+ }
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_facial_landmark_prepare(mv_facial_landmark_h handle)
+{
+ lock_guard<mutex> lock(g_facial_landmark_mutex);
+
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_check_system_info_feature_supported());
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ try {
+ auto context = static_cast<Context *>(handle);
+ auto task = static_cast<LandmarkDetectionTask *>(context->__tasks.at("facial_landmark"));
+
+ task->prepare();
+ } catch (const BaseException &e) {
+ LOGE("%s", e.what());
+ return e.getError();
+ }
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_facial_landmark_inference(mv_facial_landmark_h handle, mv_source_h source)
+{
+ lock_guard<mutex> lock(g_facial_landmark_mutex);
+
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_image_check_system_info_feature_supported());
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+ MEDIA_VISION_INSTANCE_CHECK(source);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ try {
+ auto context = static_cast<Context *>(handle);
+ auto task = static_cast<LandmarkDetectionTask *>(context->__tasks.at("facial_landmark"));
+
+ LandmarkDetectionInput input = { source };
+
+ task->setInput(input);
+ task->perform();
+ } catch (const BaseException &e) {
+ LOGE("%s", e.what());
+ return e.getError();
+ }
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_facial_landmark_get_positions(mv_facial_landmark_h handle, unsigned int *number_of_landmarks,
+ unsigned int **pos_x, unsigned int **pos_y)
+{
+ lock_guard<mutex> lock(g_facial_landmark_mutex);
+
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_image_check_system_info_feature_supported());
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+ MEDIA_VISION_INSTANCE_CHECK(number_of_landmarks);
+ MEDIA_VISION_INSTANCE_CHECK(pos_x);
+ MEDIA_VISION_INSTANCE_CHECK(pos_y);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ try {
+ auto context = static_cast<Context *>(handle);
+ auto task = static_cast<LandmarkDetectionTask *>(context->__tasks.at("facial_landmark"));
+
+ LandmarkDetectionResult &result = task->getOutput();
+ *number_of_landmarks = result.number_of_landmarks;
+ *pos_x = result.x_pos.data();
+ *pos_y = result.y_pos.data();
+ } catch (const BaseException &e) {
+ LOGE("%s", e.what());
+ return e.getError();
+ }
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+++ /dev/null
-/**
- * Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "mv_private.h"
-#include "itask.h"
-#include "mv_facial_landmark_open.h"
-#include "facial_landmark_adapter.h"
-#include "machine_learning_exception.h"
-#include "landmark_detection_type.h"
-#include "context.h"
-
-#include <new>
-#include <unistd.h>
-#include <string>
-#include <algorithm>
-#include <mutex>
-#include <iostream>
-
-using namespace std;
-using namespace mediavision::inference;
-using namespace mediavision::common;
-using namespace mediavision::machine_learning;
-using namespace MediaVision::Common;
-using namespace mediavision::machine_learning::exception;
-using LandmarkDetectionTask = ITask<LandmarkDetectionInput, LandmarkDetectionResult>;
-
-static mutex g_facial_landmark_mutex;
-
-int mv_facial_landmark_create_open(mv_facial_landmark_h *handle)
-{
- if (!handle) {
- LOGE("Handle can't be created because handle pointer is NULL");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- Context *context = nullptr;
- LandmarkDetectionTask *task = nullptr;
-
- try {
- context = new Context();
- task = new FacialLandmarkAdapter<LandmarkDetectionInput, LandmarkDetectionResult>();
- context->__tasks.insert(make_pair("facial_landmark", task));
- *handle = static_cast<mv_facial_landmark_h>(context);
- } catch (const BaseException &e) {
- delete task;
- delete context;
- return e.getError();
- }
-
- LOGD("facial landmark handle [%p] has been created", *handle);
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_facial_landmark_destroy_open(mv_facial_landmark_h handle)
-{
- lock_guard<mutex> lock(g_facial_landmark_mutex);
-
- if (!handle) {
- LOGE("Handle is NULL.");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- auto context = static_cast<Context *>(handle);
-
- for (auto &m : context->__tasks)
- delete static_cast<LandmarkDetectionTask *>(m.second);
-
- delete context;
-
- LOGD("facial landmark handle has been destroyed.");
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_facial_landmark_set_model_open(mv_facial_landmark_h handle, const char *model_name, const char *model_file,
- const char *meta_file, const char *label_file)
-{
- lock_guard<mutex> lock(g_facial_landmark_mutex);
-
- if (!handle) {
- LOGE("Handle is NULL.");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- try {
- auto context = static_cast<Context *>(handle);
- auto task = static_cast<LandmarkDetectionTask *>(context->__tasks.at("facial_landmark"));
-
- task->setModelInfo(model_file, meta_file, label_file, model_name);
- } catch (const BaseException &e) {
- LOGE("%s", e.what());
- return e.getError();
- }
-
- LOGD("LEAVE");
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_facial_landmark_set_engine_open(mv_facial_landmark_h handle, const char *backend_type, const char *device_type)
-{
- lock_guard<mutex> lock(g_facial_landmark_mutex);
-
- if (!handle) {
- LOGE("Handle is NULL.");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- try {
- auto context = static_cast<Context *>(handle);
- auto task = static_cast<LandmarkDetectionTask *>(context->__tasks.at("facial_landmark"));
-
- task->setEngineInfo(backend_type, device_type);
- } catch (const BaseException &e) {
- LOGE("%s", e.what());
- return e.getError();
- }
-
- LOGD("LEAVE");
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_facial_landmark_get_engine_count_open(mv_facial_landmark_h handle, unsigned int *engine_count)
-{
- lock_guard<mutex> lock(g_facial_landmark_mutex);
-
- if (!handle) {
- LOGE("Handle is NULL.");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- try {
- auto context = static_cast<Context *>(handle);
- auto task = static_cast<LandmarkDetectionTask *>(context->__tasks.at("facial_landmark"));
-
- task->getNumberOfEngines(engine_count);
- // TODO.
- } catch (const BaseException &e) {
- LOGE("%s", e.what());
- return e.getError();
- }
-
- LOGD("LEAVE");
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_facial_landmark_get_engine_type_open(mv_facial_landmark_h handle, const unsigned int engine_index,
- char **engine_type)
-{
- lock_guard<mutex> lock(g_facial_landmark_mutex);
-
- if (!handle) {
- LOGE("Handle is NULL.");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- try {
- auto context = static_cast<Context *>(handle);
- auto task = static_cast<LandmarkDetectionTask *>(context->__tasks.at("facial_landmark"));
-
- task->getEngineType(engine_index, engine_type);
- // TODO.
- } catch (const BaseException &e) {
- LOGE("%s", e.what());
- return e.getError();
- }
-
- LOGD("LEAVE");
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_facial_landmark_get_device_count_open(mv_facial_landmark_h handle, const char *engine_type,
- unsigned int *device_count)
-{
- lock_guard<mutex> lock(g_facial_landmark_mutex);
-
- if (!handle) {
- LOGE("Handle is NULL.");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- try {
- auto context = static_cast<Context *>(handle);
- auto task = static_cast<LandmarkDetectionTask *>(context->__tasks.at("facial_landmark"));
-
- task->getNumberOfDevices(engine_type, device_count);
- // TODO.
- } catch (const BaseException &e) {
- LOGE("%s", e.what());
- return e.getError();
- }
-
- LOGD("LEAVE");
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_facial_landmark_get_device_type_open(mv_facial_landmark_h handle, const char *engine_type,
- const unsigned int device_index, char **device_type)
-{
- lock_guard<mutex> lock(g_facial_landmark_mutex);
-
- if (!handle) {
- LOGE("Handle is NULL.");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- try {
- auto context = static_cast<Context *>(handle);
- auto task = static_cast<LandmarkDetectionTask *>(context->__tasks.at("facial_landmark"));
-
- task->getDeviceType(engine_type, device_index, device_type);
- // TODO.
- } catch (const BaseException &e) {
- LOGE("%s", e.what());
- return e.getError();
- }
-
- LOGD("LEAVE");
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_facial_landmark_configure_open(mv_facial_landmark_h handle)
-{
- LOGD("ENTER");
-
- lock_guard<mutex> lock(g_facial_landmark_mutex);
-
- if (!handle) {
- LOGE("Handle is NULL.");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- try {
- auto context = static_cast<Context *>(handle);
- auto task = static_cast<LandmarkDetectionTask *>(context->__tasks.at("facial_landmark"));
-
- task->configure();
- } catch (const BaseException &e) {
- LOGE("%s", e.what());
- return e.getError();
- }
-
- LOGD("LEAVE");
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_facial_landmark_prepare_open(mv_facial_landmark_h handle)
-{
- LOGD("ENTER");
-
- lock_guard<mutex> lock(g_facial_landmark_mutex);
-
- if (!handle) {
- LOGE("Handle is NULL.");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- try {
- auto context = static_cast<Context *>(handle);
- auto task = static_cast<LandmarkDetectionTask *>(context->__tasks.at("facial_landmark"));
-
- task->prepare();
- } catch (const BaseException &e) {
- LOGE("%s", e.what());
- return e.getError();
- }
-
- LOGD("LEAVE");
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_facial_landmark_inference_open(mv_facial_landmark_h handle, mv_source_h source)
-{
- LOGD("ENTER");
-
- lock_guard<mutex> lock(g_facial_landmark_mutex);
-
- if (!handle) {
- LOGE("Handle is NULL.");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- try {
- auto context = static_cast<Context *>(handle);
- auto task = static_cast<LandmarkDetectionTask *>(context->__tasks.at("facial_landmark"));
-
- LandmarkDetectionInput input = { source };
-
- task->setInput(input);
- task->perform();
- } catch (const BaseException &e) {
- LOGE("%s", e.what());
- return e.getError();
- }
-
- LOGD("LEAVE");
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_facial_landmark_get_positions_open(mv_facial_landmark_h handle, unsigned int *number_of_landmarks,
- unsigned int **pos_x, unsigned int **pos_y)
-{
- LOGD("ENTER");
-
- lock_guard<mutex> lock(g_facial_landmark_mutex);
-
- if (!handle) {
- LOGE("Handle is NULL.");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- try {
- auto context = static_cast<Context *>(handle);
- auto task = static_cast<LandmarkDetectionTask *>(context->__tasks.at("facial_landmark"));
-
- LandmarkDetectionResult &result = task->getOutput();
- *number_of_landmarks = result.number_of_landmarks;
- *pos_x = result.x_pos.data();
- *pos_y = result.y_pos.data();
- } catch (const BaseException &e) {
- LOGE("%s", e.what());
- return e.getError();
- }
-
- LOGD("LEAVE");
-
- return MEDIA_VISION_ERROR_NONE;
-}
+++ /dev/null
-/**
- * Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "mv_private.h"
-#include "mv_pose_landmark_internal.h"
-#include "mv_pose_landmark_open.h"
-
-/**
- * @file mv_pose_landmark.c
- * @brief This file contains Media Vision inference module.
- */
-
-int mv_pose_landmark_create(mv_pose_landmark_h *handle)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_inference_check_system_info_feature_supported());
- MEDIA_VISION_NULL_ARG_CHECK(handle);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv_pose_landmark_create_open(handle);
-
- MEDIA_VISION_FUNCTION_LEAVE();
- return ret;
-}
-
-int mv_pose_landmark_destroy(mv_pose_landmark_h handle)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_inference_check_system_info_feature_supported());
- MEDIA_VISION_INSTANCE_CHECK(handle);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv_pose_landmark_destroy_open(handle);
-
- MEDIA_VISION_FUNCTION_LEAVE();
- return ret;
-}
-
-int mv_pose_landmark_set_model(mv_pose_landmark_h handle, const char *model_name, const char *model_file,
- const char *meta_file, const char *label_file)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_inference_check_system_info_feature_supported());
-
- MEDIA_VISION_INSTANCE_CHECK(handle);
- MEDIA_VISION_INSTANCE_CHECK(model_name);
- MEDIA_VISION_NULL_ARG_CHECK(model_file);
- MEDIA_VISION_NULL_ARG_CHECK(meta_file);
- MEDIA_VISION_NULL_ARG_CHECK(label_file);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv_pose_landmark_set_model_open(handle, model_name, model_file, meta_file, label_file);
-
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
-
-int mv_pose_landmark_set_engine(mv_pose_landmark_h handle, const char *backend_type, const char *device_type)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_inference_check_system_info_feature_supported());
-
- MEDIA_VISION_INSTANCE_CHECK(handle);
- MEDIA_VISION_NULL_ARG_CHECK(backend_type);
- MEDIA_VISION_NULL_ARG_CHECK(device_type);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv_pose_landmark_set_engine_open(handle, backend_type, device_type);
-
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
-
-int mv_pose_landmark_get_engine_count(mv_pose_landmark_h handle, unsigned int *engine_count)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_inference_check_system_info_feature_supported());
-
- MEDIA_VISION_INSTANCE_CHECK(handle);
- MEDIA_VISION_NULL_ARG_CHECK(engine_count);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv_pose_landmark_get_engine_count_open(handle, engine_count);
-
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
-
-int mv_pose_landmark_get_engine_type(mv_pose_landmark_h handle, const unsigned int engine_index, char **engine_type)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_inference_check_system_info_feature_supported());
-
- MEDIA_VISION_INSTANCE_CHECK(handle);
- MEDIA_VISION_NULL_ARG_CHECK(engine_type);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv_pose_landmark_get_engine_type_open(handle, engine_index, engine_type);
-
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
-
-int mv_pose_landmark_get_device_count(mv_pose_landmark_h handle, const char *engine_type, unsigned int *device_count)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_inference_check_system_info_feature_supported());
-
- MEDIA_VISION_INSTANCE_CHECK(handle);
- MEDIA_VISION_NULL_ARG_CHECK(device_count);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv_pose_landmark_get_device_count_open(handle, engine_type, device_count);
-
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
-
-int mv_pose_landmark_get_device_type(mv_pose_landmark_h handle, const char *engine_type,
- const unsigned int device_index, char **device_type)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_inference_check_system_info_feature_supported());
-
- MEDIA_VISION_INSTANCE_CHECK(handle);
- MEDIA_VISION_NULL_ARG_CHECK(engine_type);
- MEDIA_VISION_NULL_ARG_CHECK(device_type);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv_pose_landmark_get_device_type_open(handle, engine_type, device_index, device_type);
-
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
-
-int mv_pose_landmark_configure(mv_pose_landmark_h handle)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_inference_check_system_info_feature_supported());
- MEDIA_VISION_INSTANCE_CHECK(handle);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv_pose_landmark_configure_open(handle);
-
- MEDIA_VISION_FUNCTION_LEAVE();
- return ret;
-}
-
-int mv_pose_landmark_prepare(mv_pose_landmark_h handle)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_inference_check_system_info_feature_supported());
- MEDIA_VISION_INSTANCE_CHECK(handle);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv_pose_landmark_prepare_open(handle);
-
- MEDIA_VISION_FUNCTION_LEAVE();
- return ret;
-}
-
-int mv_pose_landmark_inference(mv_pose_landmark_h handle, mv_source_h source)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_inference_image_check_system_info_feature_supported());
- MEDIA_VISION_INSTANCE_CHECK(handle);
- MEDIA_VISION_INSTANCE_CHECK(source);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv_pose_landmark_inference_open(handle, source);
-
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
-
-int mv_pose_landmark_get_pos(mv_pose_landmark_h handle, unsigned int *number_of_landmarks, unsigned int **pos_x,
- unsigned int **pos_y)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_inference_image_check_system_info_feature_supported());
- MEDIA_VISION_INSTANCE_CHECK(handle);
- MEDIA_VISION_INSTANCE_CHECK(number_of_landmarks);
- MEDIA_VISION_INSTANCE_CHECK(pos_x);
- MEDIA_VISION_INSTANCE_CHECK(pos_y);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv_pose_landmark_get_pos_open(handle, number_of_landmarks, pos_x, pos_y);
-
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
--- /dev/null
+/**
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "mv_private.h"
+#include "itask.h"
+#include "mv_pose_landmark_internal.h"
+#include "pose_landmark_adapter.h"
+#include "machine_learning_exception.h"
+#include "landmark_detection_type.h"
+#include "context.h"
+
+#include <new>
+#include <unistd.h>
+#include <string>
+#include <algorithm>
+#include <mutex>
+#include <iostream>
+
+using namespace std;
+using namespace mediavision::inference;
+using namespace mediavision::common;
+using namespace mediavision::machine_learning;
+using namespace MediaVision::Common;
+using namespace mediavision::machine_learning::exception;
+using LandmarkDetectionTask = ITask<LandmarkDetectionInput, LandmarkDetectionResult>;
+
+static mutex g_pose_landmark_mutex;
+
+int mv_pose_landmark_create(mv_pose_landmark_h *handle)
+{
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_check_system_info_feature_supported());
+ MEDIA_VISION_NULL_ARG_CHECK(handle);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ Context *context = nullptr;
+ LandmarkDetectionTask *task = nullptr;
+
+ try {
+ context = new Context();
+ task = new PoseLandmarkAdapter<LandmarkDetectionInput, LandmarkDetectionResult>();
+ context->__tasks.insert(make_pair("pose_landmark", task));
+ *handle = static_cast<mv_pose_landmark_h>(context);
+ } catch (const BaseException &e) {
+ delete task;
+ delete context;
+ return e.getError();
+ }
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_pose_landmark_destroy(mv_pose_landmark_h handle)
+{
+ lock_guard<mutex> lock(g_pose_landmark_mutex);
+
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_check_system_info_feature_supported());
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ auto context = static_cast<Context *>(handle);
+
+ for (auto &m : context->__tasks)
+ delete static_cast<LandmarkDetectionTask *>(m.second);
+
+ delete context;
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_pose_landmark_set_model(mv_pose_landmark_h handle, const char *model_name, const char *model_file,
+ const char *meta_file, const char *label_file)
+{
+ lock_guard<mutex> lock(g_pose_landmark_mutex);
+
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_check_system_info_feature_supported());
+
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+ MEDIA_VISION_INSTANCE_CHECK(model_name);
+ MEDIA_VISION_NULL_ARG_CHECK(model_file);
+ MEDIA_VISION_NULL_ARG_CHECK(meta_file);
+ MEDIA_VISION_NULL_ARG_CHECK(label_file);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ try {
+ auto context = static_cast<Context *>(handle);
+ auto task = static_cast<LandmarkDetectionTask *>(context->__tasks.at("pose_landmark"));
+
+ task->setModelInfo(model_file, meta_file, label_file, model_name);
+ } catch (const BaseException &e) {
+ LOGE("%s", e.what());
+ return e.getError();
+ }
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_pose_landmark_set_engine(mv_pose_landmark_h handle, const char *backend_type, const char *device_type)
+{
+ lock_guard<mutex> lock(g_pose_landmark_mutex);
+
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_check_system_info_feature_supported());
+
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+ MEDIA_VISION_NULL_ARG_CHECK(backend_type);
+ MEDIA_VISION_NULL_ARG_CHECK(device_type);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ try {
+ auto context = static_cast<Context *>(handle);
+ auto task = static_cast<LandmarkDetectionTask *>(context->__tasks.at("pose_landmark"));
+
+ task->setEngineInfo(backend_type, device_type);
+ } catch (const BaseException &e) {
+ LOGE("%s", e.what());
+ return e.getError();
+ }
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_pose_landmark_get_engine_count(mv_pose_landmark_h handle, unsigned int *engine_count)
+{
+ lock_guard<mutex> lock(g_pose_landmark_mutex);
+
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_check_system_info_feature_supported());
+
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+ MEDIA_VISION_NULL_ARG_CHECK(engine_count);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ try {
+ auto context = static_cast<Context *>(handle);
+ auto task = static_cast<LandmarkDetectionTask *>(context->__tasks.at("pose_landmark"));
+
+ task->getNumberOfEngines(engine_count);
+ // TODO.
+ } catch (const BaseException &e) {
+ LOGE("%s", e.what());
+ return e.getError();
+ }
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_pose_landmark_get_engine_type(mv_pose_landmark_h handle, const unsigned int engine_index, char **engine_type)
+{
+ lock_guard<mutex> lock(g_pose_landmark_mutex);
+
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_check_system_info_feature_supported());
+
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+ MEDIA_VISION_NULL_ARG_CHECK(engine_type);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ try {
+ auto context = static_cast<Context *>(handle);
+ auto task = static_cast<LandmarkDetectionTask *>(context->__tasks.at("pose_landmark"));
+
+ task->getEngineType(engine_index, engine_type);
+ // TODO.
+ } catch (const BaseException &e) {
+ LOGE("%s", e.what());
+ return e.getError();
+ }
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_pose_landmark_get_device_count(mv_pose_landmark_h handle, const char *engine_type, unsigned int *device_count)
+{
+ lock_guard<mutex> lock(g_pose_landmark_mutex);
+
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_check_system_info_feature_supported());
+
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+ MEDIA_VISION_NULL_ARG_CHECK(device_count);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ try {
+ auto context = static_cast<Context *>(handle);
+ auto task = static_cast<LandmarkDetectionTask *>(context->__tasks.at("pose_landmark"));
+
+ task->getNumberOfDevices(engine_type, device_count);
+ // TODO.
+ } catch (const BaseException &e) {
+ LOGE("%s", e.what());
+ return e.getError();
+ }
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_pose_landmark_get_device_type(mv_pose_landmark_h handle, const char *engine_type,
+ const unsigned int device_index, char **device_type)
+{
+ lock_guard<mutex> lock(g_pose_landmark_mutex);
+
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_check_system_info_feature_supported());
+
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+ MEDIA_VISION_NULL_ARG_CHECK(engine_type);
+ MEDIA_VISION_NULL_ARG_CHECK(device_type);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ try {
+ auto context = static_cast<Context *>(handle);
+ auto task = static_cast<LandmarkDetectionTask *>(context->__tasks.at("pose_landmark"));
+
+ task->getDeviceType(engine_type, device_index, device_type);
+ // TODO.
+ } catch (const BaseException &e) {
+ LOGE("%s", e.what());
+ return e.getError();
+ }
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_pose_landmark_configure(mv_pose_landmark_h handle)
+{
+ lock_guard<mutex> lock(g_pose_landmark_mutex);
+
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_check_system_info_feature_supported());
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ try {
+ auto context = static_cast<Context *>(handle);
+ auto task = static_cast<LandmarkDetectionTask *>(context->__tasks.at("pose_landmark"));
+
+ task->configure();
+ } catch (const BaseException &e) {
+ LOGE("%s", e.what());
+ return e.getError();
+ }
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_pose_landmark_prepare(mv_pose_landmark_h handle)
+{
+ lock_guard<mutex> lock(g_pose_landmark_mutex);
+
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_check_system_info_feature_supported());
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ try {
+ auto context = static_cast<Context *>(handle);
+ auto task = static_cast<LandmarkDetectionTask *>(context->__tasks.at("pose_landmark"));
+
+ task->prepare();
+ } catch (const BaseException &e) {
+ LOGE("%s", e.what());
+ return e.getError();
+ }
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_pose_landmark_inference(mv_pose_landmark_h handle, mv_source_h source)
+{
+ lock_guard<mutex> lock(g_pose_landmark_mutex);
+
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_image_check_system_info_feature_supported());
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+ MEDIA_VISION_INSTANCE_CHECK(source);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ try {
+ auto context = static_cast<Context *>(handle);
+ auto task = static_cast<LandmarkDetectionTask *>(context->__tasks.at("pose_landmark"));
+
+ LandmarkDetectionInput input = { source };
+
+ task->setInput(input);
+ task->perform();
+ } catch (const BaseException &e) {
+ LOGE("%s", e.what());
+ return e.getError();
+ }
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_pose_landmark_get_pos(mv_pose_landmark_h handle, unsigned int *number_of_landmarks, unsigned int **pos_x,
+ unsigned int **pos_y)
+{
+ lock_guard<mutex> lock(g_pose_landmark_mutex);
+
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_image_check_system_info_feature_supported());
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+ MEDIA_VISION_INSTANCE_CHECK(number_of_landmarks);
+ MEDIA_VISION_INSTANCE_CHECK(pos_x);
+ MEDIA_VISION_INSTANCE_CHECK(pos_y);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ try {
+ auto context = static_cast<Context *>(handle);
+ auto task = static_cast<LandmarkDetectionTask *>(context->__tasks.at("pose_landmark"));
+
+ LandmarkDetectionResult &result = task->getOutput();
+ *number_of_landmarks = result.number_of_landmarks;
+ *pos_x = result.x_pos.data();
+ *pos_y = result.y_pos.data();
+ } catch (const BaseException &e) {
+ LOGE("%s", e.what());
+ return e.getError();
+ }
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+++ /dev/null
-/**
- * Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "mv_private.h"
-#include "itask.h"
-#include "mv_pose_landmark_open.h"
-#include "pose_landmark_adapter.h"
-#include "machine_learning_exception.h"
-#include "landmark_detection_type.h"
-#include "context.h"
-
-#include <new>
-#include <unistd.h>
-#include <string>
-#include <algorithm>
-#include <mutex>
-#include <iostream>
-
-using namespace std;
-using namespace mediavision::inference;
-using namespace mediavision::common;
-using namespace mediavision::machine_learning;
-using namespace MediaVision::Common;
-using namespace mediavision::machine_learning::exception;
-using LandmarkDetectionTask = ITask<LandmarkDetectionInput, LandmarkDetectionResult>;
-
-static mutex g_pose_landmark_mutex;
-
-int mv_pose_landmark_create_open(mv_pose_landmark_h *handle)
-{
- if (!handle) {
- LOGE("Handle can't be created because handle pointer is NULL");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- Context *context = nullptr;
- LandmarkDetectionTask *task = nullptr;
-
- try {
- context = new Context();
- task = new PoseLandmarkAdapter<LandmarkDetectionInput, LandmarkDetectionResult>();
- context->__tasks.insert(make_pair("pose_landmark", task));
- *handle = static_cast<mv_pose_landmark_h>(context);
- } catch (const BaseException &e) {
- delete task;
- delete context;
- return e.getError();
- }
-
- LOGD("pose landmark handle [%p] has been created", *handle);
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_pose_landmark_destroy_open(mv_pose_landmark_h handle)
-{
- lock_guard<mutex> lock(g_pose_landmark_mutex);
-
- if (!handle) {
- LOGE("Handle is NULL.");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- auto context = static_cast<Context *>(handle);
-
- for (auto &m : context->__tasks)
- delete static_cast<LandmarkDetectionTask *>(m.second);
-
- delete context;
-
- LOGD("pose landmark handle has been destroyed.");
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_pose_landmark_set_model_open(mv_pose_landmark_h handle, const char *model_name, const char *model_file,
- const char *meta_file, const char *label_file)
-{
- lock_guard<mutex> lock(g_pose_landmark_mutex);
-
- if (!handle) {
- LOGE("Handle is NULL.");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- try {
- auto context = static_cast<Context *>(handle);
- auto task = static_cast<LandmarkDetectionTask *>(context->__tasks.at("pose_landmark"));
-
- task->setModelInfo(model_file, meta_file, label_file, model_name);
- } catch (const BaseException &e) {
- LOGE("%s", e.what());
- return e.getError();
- }
-
- LOGD("LEAVE");
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_pose_landmark_set_engine_open(mv_pose_landmark_h handle, const char *backend_type, const char *device_type)
-{
- lock_guard<mutex> lock(g_pose_landmark_mutex);
-
- if (!handle) {
- LOGE("Handle is NULL.");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- try {
- auto context = static_cast<Context *>(handle);
- auto task = static_cast<LandmarkDetectionTask *>(context->__tasks.at("pose_landmark"));
-
- task->setEngineInfo(backend_type, device_type);
- } catch (const BaseException &e) {
- LOGE("%s", e.what());
- return e.getError();
- }
-
- LOGD("LEAVE");
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_pose_landmark_get_engine_count_open(mv_pose_landmark_h handle, unsigned int *engine_count)
-{
- lock_guard<mutex> lock(g_pose_landmark_mutex);
-
- if (!handle) {
- LOGE("Handle is NULL.");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- try {
- auto context = static_cast<Context *>(handle);
- auto task = static_cast<LandmarkDetectionTask *>(context->__tasks.at("pose_landmark"));
-
- task->getNumberOfEngines(engine_count);
- // TODO.
- } catch (const BaseException &e) {
- LOGE("%s", e.what());
- return e.getError();
- }
-
- LOGD("LEAVE");
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_pose_landmark_get_engine_type_open(mv_pose_landmark_h handle, const unsigned int engine_index,
- char **engine_type)
-{
- lock_guard<mutex> lock(g_pose_landmark_mutex);
-
- if (!handle) {
- LOGE("Handle is NULL.");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- try {
- auto context = static_cast<Context *>(handle);
- auto task = static_cast<LandmarkDetectionTask *>(context->__tasks.at("pose_landmark"));
-
- task->getEngineType(engine_index, engine_type);
- // TODO.
- } catch (const BaseException &e) {
- LOGE("%s", e.what());
- return e.getError();
- }
-
- LOGD("LEAVE");
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_pose_landmark_get_device_count_open(mv_pose_landmark_h handle, const char *engine_type,
- unsigned int *device_count)
-{
- lock_guard<mutex> lock(g_pose_landmark_mutex);
-
- if (!handle) {
- LOGE("Handle is NULL.");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- try {
- auto context = static_cast<Context *>(handle);
- auto task = static_cast<LandmarkDetectionTask *>(context->__tasks.at("pose_landmark"));
-
- task->getNumberOfDevices(engine_type, device_count);
- // TODO.
- } catch (const BaseException &e) {
- LOGE("%s", e.what());
- return e.getError();
- }
-
- LOGD("LEAVE");
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_pose_landmark_get_device_type_open(mv_pose_landmark_h handle, const char *engine_type,
- const unsigned int device_index, char **device_type)
-{
- lock_guard<mutex> lock(g_pose_landmark_mutex);
-
- if (!handle) {
- LOGE("Handle is NULL.");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- try {
- auto context = static_cast<Context *>(handle);
- auto task = static_cast<LandmarkDetectionTask *>(context->__tasks.at("pose_landmark"));
-
- task->getDeviceType(engine_type, device_index, device_type);
- // TODO.
- } catch (const BaseException &e) {
- LOGE("%s", e.what());
- return e.getError();
- }
-
- LOGD("LEAVE");
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_pose_landmark_configure_open(mv_pose_landmark_h handle)
-{
- LOGD("ENTER");
-
- lock_guard<mutex> lock(g_pose_landmark_mutex);
-
- if (!handle) {
- LOGE("Handle is NULL.");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- try {
- auto context = static_cast<Context *>(handle);
- auto task = static_cast<LandmarkDetectionTask *>(context->__tasks.at("pose_landmark"));
-
- task->configure();
- } catch (const BaseException &e) {
- LOGE("%s", e.what());
- return e.getError();
- }
-
- LOGD("LEAVE");
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_pose_landmark_prepare_open(mv_pose_landmark_h handle)
-{
- LOGD("ENTER");
-
- lock_guard<mutex> lock(g_pose_landmark_mutex);
-
- if (!handle) {
- LOGE("Handle is NULL.");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- try {
- auto context = static_cast<Context *>(handle);
- auto task = static_cast<LandmarkDetectionTask *>(context->__tasks.at("pose_landmark"));
-
- task->prepare();
- } catch (const BaseException &e) {
- LOGE("%s", e.what());
- return e.getError();
- }
-
- LOGD("LEAVE");
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_pose_landmark_inference_open(mv_pose_landmark_h handle, mv_source_h source)
-{
- LOGD("ENTER");
-
- lock_guard<mutex> lock(g_pose_landmark_mutex);
-
- if (!handle) {
- LOGE("Handle is NULL.");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- try {
- auto context = static_cast<Context *>(handle);
- auto task = static_cast<LandmarkDetectionTask *>(context->__tasks.at("pose_landmark"));
-
- LandmarkDetectionInput input = { source };
-
- task->setInput(input);
- task->perform();
- } catch (const BaseException &e) {
- LOGE("%s", e.what());
- return e.getError();
- }
-
- LOGD("LEAVE");
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_pose_landmark_get_pos_open(mv_pose_landmark_h handle, unsigned int *number_of_landmarks, unsigned int **pos_x,
- unsigned int **pos_y)
-{
- LOGD("ENTER");
-
- lock_guard<mutex> lock(g_pose_landmark_mutex);
-
- if (!handle) {
- LOGE("Handle is NULL.");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- try {
- auto context = static_cast<Context *>(handle);
- auto task = static_cast<LandmarkDetectionTask *>(context->__tasks.at("pose_landmark"));
-
- LandmarkDetectionResult &result = task->getOutput();
- *number_of_landmarks = result.number_of_landmarks;
- *pos_x = result.x_pos.data();
- *pos_y = result.y_pos.data();
- } catch (const BaseException &e) {
- LOGE("%s", e.what());
- return e.getError();
- }
-
- LOGD("LEAVE");
-
- return MEDIA_VISION_ERROR_NONE;
-}
+++ /dev/null
-/**
- * Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "mv_private.h"
-#include "mv_face_detection_internal.h"
-#include "mv_face_detection_open.h"
-
-/**
- * @file mv_face_detection.c
- * @brief This file contains Media Vision inference module.
- */
-
-int mv_face_detection_create(mv_face_detection_h *infer)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_inference_check_system_info_feature_supported());
- MEDIA_VISION_NULL_ARG_CHECK(infer);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv_face_detection_create_open(infer);
-
- MEDIA_VISION_FUNCTION_LEAVE();
- return ret;
-}
-
-int mv_face_detection_destroy(mv_face_detection_h infer)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_inference_check_system_info_feature_supported());
- MEDIA_VISION_INSTANCE_CHECK(infer);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv_face_detection_destroy_open(infer);
-
- MEDIA_VISION_FUNCTION_LEAVE();
- return ret;
-}
-
-int mv_face_detection_set_model(mv_face_detection_h handle, const char *model_name, const char *model_file,
- const char *meta_file, const char *label_file)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported());
-
- MEDIA_VISION_INSTANCE_CHECK(handle);
- MEDIA_VISION_INSTANCE_CHECK(model_name);
- MEDIA_VISION_NULL_ARG_CHECK(model_file);
- MEDIA_VISION_NULL_ARG_CHECK(meta_file);
- MEDIA_VISION_NULL_ARG_CHECK(label_file);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv_face_detection_set_model_open(handle, model_name, model_file, meta_file, label_file);
-
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
-
-int mv_face_detection_set_engine(mv_face_detection_h handle, const char *backend_type, const char *device_type)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported());
-
- MEDIA_VISION_INSTANCE_CHECK(handle);
- MEDIA_VISION_NULL_ARG_CHECK(backend_type);
- MEDIA_VISION_NULL_ARG_CHECK(device_type);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv_face_detection_set_engine_open(handle, backend_type, device_type);
-
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
-
-int mv_face_detection_get_engine_count(mv_face_detection_h handle, unsigned int *engine_count)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported());
-
- MEDIA_VISION_INSTANCE_CHECK(handle);
- MEDIA_VISION_NULL_ARG_CHECK(engine_count);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv_face_detection_get_engine_count_open(handle, engine_count);
-
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
-
-int mv_face_detection_get_engine_type(mv_face_detection_h handle, const unsigned int engine_index, char **engine_type)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported());
-
- MEDIA_VISION_INSTANCE_CHECK(handle);
- MEDIA_VISION_NULL_ARG_CHECK(engine_type);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv_face_detection_get_engine_type_open(handle, engine_index, engine_type);
-
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
-
-int mv_face_detection_get_device_count(mv_face_detection_h handle, const char *engine_type, unsigned int *device_count)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported());
-
- MEDIA_VISION_INSTANCE_CHECK(handle);
- MEDIA_VISION_NULL_ARG_CHECK(device_count);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv_face_detection_get_device_count_open(handle, engine_type, device_count);
-
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
-
-int mv_face_detection_get_device_type(mv_face_detection_h handle, const char *engine_type,
- const unsigned int device_index, char **device_type)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported());
-
- MEDIA_VISION_INSTANCE_CHECK(handle);
- MEDIA_VISION_NULL_ARG_CHECK(engine_type);
- MEDIA_VISION_NULL_ARG_CHECK(device_type);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv_face_detection_get_device_type_open(handle, engine_type, device_index, device_type);
-
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
-
-int mv_face_detection_configure(mv_face_detection_h infer)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_inference_check_system_info_feature_supported());
- MEDIA_VISION_INSTANCE_CHECK(infer);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv_face_detection_configure_open(infer);
-
- MEDIA_VISION_FUNCTION_LEAVE();
- return ret;
-}
-
-int mv_face_detection_prepare(mv_face_detection_h infer)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_inference_check_system_info_feature_supported());
- MEDIA_VISION_INSTANCE_CHECK(infer);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv_face_detection_prepare_open(infer);
-
- MEDIA_VISION_FUNCTION_LEAVE();
- return ret;
-}
-
-int mv_face_detection_inference(mv_face_detection_h infer, mv_source_h source)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_inference_image_check_system_info_feature_supported());
- MEDIA_VISION_INSTANCE_CHECK(source);
- MEDIA_VISION_INSTANCE_CHECK(infer);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv_face_detection_inference_open(infer, source);
-
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
-
-int mv_face_detection_get_result(mv_face_detection_h infer, unsigned int *number_of_objects,
- const unsigned int **indices, const float **confidences, const int **left,
- const int **top, const int **right, const int **bottom)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_inference_image_check_system_info_feature_supported());
- MEDIA_VISION_INSTANCE_CHECK(infer);
- MEDIA_VISION_INSTANCE_CHECK(number_of_objects);
- MEDIA_VISION_INSTANCE_CHECK(indices);
- MEDIA_VISION_INSTANCE_CHECK(confidences);
- MEDIA_VISION_INSTANCE_CHECK(left);
- MEDIA_VISION_INSTANCE_CHECK(top);
- MEDIA_VISION_INSTANCE_CHECK(right);
- MEDIA_VISION_INSTANCE_CHECK(bottom);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret =
- mv_face_detection_get_result_open(infer, number_of_objects, indices, confidences, left, top, right, bottom);
-
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
-
-int mv_face_detection_get_label(mv_face_detection_h infer, const unsigned int index, const char **out_label)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_inference_image_check_system_info_feature_supported());
- MEDIA_VISION_INSTANCE_CHECK(infer);
- MEDIA_VISION_INSTANCE_CHECK(out_label);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv_face_detection_get_label_open(infer, index, out_label);
-
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
\ No newline at end of file
--- /dev/null
+/**
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "mv_private.h"
+#include "itask.h"
+#include "mv_face_detection_internal.h"
+#include "face_detection_adapter.h"
+#include "machine_learning_exception.h"
+#include "object_detection_type.h"
+#include "context.h"
+
+#include <new>
+#include <unistd.h>
+#include <string>
+#include <algorithm>
+#include <mutex>
+#include <iostream>
+
+using namespace std;
+using namespace mediavision::inference;
+using namespace mediavision::common;
+using namespace mediavision::machine_learning;
+using namespace MediaVision::Common;
+using namespace mediavision::machine_learning::exception;
+using FaceDetectionTask = ITask<ObjectDetectionInput, ObjectDetectionResult>;
+
+static mutex g_face_detection_mutex;
+
+int mv_face_detection_create(mv_face_detection_h *handle)
+{
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_check_system_info_feature_supported());
+ MEDIA_VISION_NULL_ARG_CHECK(handle);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ Context *context = nullptr;
+ FaceDetectionTask *task = nullptr;
+
+ try {
+ context = new Context();
+ task = new FaceDetectionAdapter<ObjectDetectionInput, ObjectDetectionResult>();
+ context->__tasks.insert(make_pair("face_detection", task));
+ *handle = static_cast<mv_face_detection_h>(context);
+ } catch (const BaseException &e) {
+ delete task;
+ delete context;
+ return e.getError();
+ }
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_face_detection_destroy(mv_face_detection_h handle)
+{
+ lock_guard<mutex> lock(g_face_detection_mutex);
+
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_check_system_info_feature_supported());
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ auto context = static_cast<Context *>(handle);
+
+ for (auto &m : context->__tasks)
+ delete static_cast<FaceDetectionTask *>(m.second);
+
+ delete context;
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_face_detection_set_model(mv_face_detection_h handle, const char *model_name, const char *model_file,
+ const char *meta_file, const char *label_file)
+{
+ lock_guard<mutex> lock(g_face_detection_mutex);
+
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported());
+
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+ MEDIA_VISION_INSTANCE_CHECK(model_name);
+ MEDIA_VISION_NULL_ARG_CHECK(model_file);
+ MEDIA_VISION_NULL_ARG_CHECK(meta_file);
+ MEDIA_VISION_NULL_ARG_CHECK(label_file);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ try {
+ auto context = static_cast<Context *>(handle);
+ auto task = static_cast<FaceDetectionTask *>(context->__tasks.at("face_detection"));
+
+ task->setModelInfo(model_file, meta_file, label_file, model_name);
+ } catch (const BaseException &e) {
+ LOGE("%s", e.what());
+ return e.getError();
+ }
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_face_detection_set_engine(mv_face_detection_h handle, const char *backend_type, const char *device_type)
+{
+ lock_guard<mutex> lock(g_face_detection_mutex);
+
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported());
+
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+ MEDIA_VISION_NULL_ARG_CHECK(backend_type);
+ MEDIA_VISION_NULL_ARG_CHECK(device_type);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ try {
+ auto context = static_cast<Context *>(handle);
+ auto task = static_cast<FaceDetectionTask *>(context->__tasks.at("face_detection"));
+
+ task->setEngineInfo(backend_type, device_type);
+ } catch (const BaseException &e) {
+ LOGE("%s", e.what());
+ return e.getError();
+ }
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_face_detection_get_engine_count(mv_face_detection_h handle, unsigned int *engine_count)
+{
+ lock_guard<mutex> lock(g_face_detection_mutex);
+
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported());
+
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+ MEDIA_VISION_NULL_ARG_CHECK(engine_count);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ try {
+ auto context = static_cast<Context *>(handle);
+ auto task = static_cast<FaceDetectionTask *>(context->__tasks.at("face_detection"));
+
+ task->getNumberOfEngines(engine_count);
+ // TODO.
+ } catch (const BaseException &e) {
+ LOGE("%s", e.what());
+ return e.getError();
+ }
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_face_detection_get_engine_type(mv_face_detection_h handle, const unsigned int engine_index, char **engine_type)
+{
+ lock_guard<mutex> lock(g_face_detection_mutex);
+
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported());
+
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+ MEDIA_VISION_NULL_ARG_CHECK(engine_type);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ try {
+ auto context = static_cast<Context *>(handle);
+ auto task = static_cast<FaceDetectionTask *>(context->__tasks.at("face_detection"));
+
+ task->getEngineType(engine_index, engine_type);
+ // TODO.
+ } catch (const BaseException &e) {
+ LOGE("%s", e.what());
+ return e.getError();
+ }
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_face_detection_get_device_count(mv_face_detection_h handle, const char *engine_type, unsigned int *device_count)
+{
+ lock_guard<mutex> lock(g_face_detection_mutex);
+
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported());
+
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+ MEDIA_VISION_NULL_ARG_CHECK(device_count);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ try {
+ auto context = static_cast<Context *>(handle);
+ auto task = static_cast<FaceDetectionTask *>(context->__tasks.at("face_detection"));
+
+ task->getNumberOfDevices(engine_type, device_count);
+ // TODO.
+ } catch (const BaseException &e) {
+ LOGE("%s", e.what());
+ return e.getError();
+ }
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_face_detection_get_device_type(mv_face_detection_h handle, const char *engine_type,
+ const unsigned int device_index, char **device_type)
+{
+ lock_guard<mutex> lock(g_face_detection_mutex);
+
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported());
+
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+ MEDIA_VISION_NULL_ARG_CHECK(engine_type);
+ MEDIA_VISION_NULL_ARG_CHECK(device_type);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ try {
+ auto context = static_cast<Context *>(handle);
+ auto task = static_cast<FaceDetectionTask *>(context->__tasks.at("face_detection"));
+
+ task->getDeviceType(engine_type, device_index, device_type);
+ // TODO.
+ } catch (const BaseException &e) {
+ LOGE("%s", e.what());
+ return e.getError();
+ }
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_face_detection_configure(mv_face_detection_h handle)
+{
+ lock_guard<mutex> lock(g_face_detection_mutex);
+
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_check_system_info_feature_supported());
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ try {
+ auto context = static_cast<Context *>(handle);
+ auto task = static_cast<FaceDetectionTask *>(context->__tasks.at("face_detection"));
+
+ task->configure();
+ } catch (const BaseException &e) {
+ LOGE("%s", e.what());
+ return e.getError();
+ }
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_face_detection_prepare(mv_face_detection_h handle)
+{
+ lock_guard<mutex> lock(g_face_detection_mutex);
+
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_check_system_info_feature_supported());
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ try {
+ auto context = static_cast<Context *>(handle);
+ auto task = static_cast<FaceDetectionTask *>(context->__tasks.at("face_detection"));
+
+ task->prepare();
+ } catch (const BaseException &e) {
+ LOGE("%s", e.what());
+ return e.getError();
+ }
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_face_detection_inference(mv_face_detection_h handle, mv_source_h source)
+{
+ lock_guard<mutex> lock(g_face_detection_mutex);
+
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_image_check_system_info_feature_supported());
+ MEDIA_VISION_INSTANCE_CHECK(source);
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ try {
+ auto context = static_cast<Context *>(handle);
+ auto task = static_cast<FaceDetectionTask *>(context->__tasks.at("face_detection"));
+
+ ObjectDetectionInput input = { .inference_src = source };
+
+ task->setInput(input);
+ task->perform();
+ } catch (const BaseException &e) {
+ LOGE("%s", e.what());
+ return e.getError();
+ }
+
+ MEDIA_VISION_FUNCTION_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)
+{
+ lock_guard<mutex> lock(g_face_detection_mutex);
+
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_image_check_system_info_feature_supported());
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+ MEDIA_VISION_INSTANCE_CHECK(number_of_objects);
+ MEDIA_VISION_INSTANCE_CHECK(indices);
+ MEDIA_VISION_INSTANCE_CHECK(confidences);
+ MEDIA_VISION_INSTANCE_CHECK(left);
+ MEDIA_VISION_INSTANCE_CHECK(top);
+ MEDIA_VISION_INSTANCE_CHECK(right);
+ MEDIA_VISION_INSTANCE_CHECK(bottom);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ try {
+ auto context = static_cast<Context *>(handle);
+ auto task = static_cast<FaceDetectionTask *>(context->__tasks.at("face_detection"));
+
+ ObjectDetectionResult &result = task->getOutput();
+ *number_of_objects = result.number_of_objects;
+ *indices = result.indices.data();
+ *confidences = result.confidences.data();
+ *left = result.left.data();
+ *top = result.top.data();
+ *right = result.right.data();
+ *bottom = result.bottom.data();
+ } catch (const BaseException &e) {
+ LOGE("%s", e.what());
+ return e.getError();
+ }
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_face_detection_get_label(mv_face_detection_h handle, const unsigned int index, const char **out_label)
+{
+ lock_guard<mutex> lock(g_face_detection_mutex);
+
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_image_check_system_info_feature_supported());
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+ MEDIA_VISION_INSTANCE_CHECK(out_label);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ try {
+ auto context = static_cast<Context *>(handle);
+ auto task = static_cast<FaceDetectionTask *>(context->__tasks.at("face_detection"));
+
+ ObjectDetectionResult &result = task->getOutput();
+
+ if (result.number_of_objects <= index)
+ throw InvalidParameter("Invalid index range.");
+
+ *out_label = result.names[index].c_str();
+ } catch (const BaseException &e) {
+ LOGE("%s", e.what());
+ return e.getError();
+ }
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
\ No newline at end of file
+++ /dev/null
-/**
- * Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "mv_private.h"
-#include "itask.h"
-#include "mv_face_detection_open.h"
-#include "face_detection_adapter.h"
-#include "machine_learning_exception.h"
-#include "object_detection_type.h"
-#include "context.h"
-
-#include <new>
-#include <unistd.h>
-#include <string>
-#include <algorithm>
-#include <mutex>
-#include <iostream>
-
-using namespace std;
-using namespace mediavision::inference;
-using namespace mediavision::common;
-using namespace mediavision::machine_learning;
-using namespace MediaVision::Common;
-using namespace mediavision::machine_learning::exception;
-using FaceDetectionTask = ITask<ObjectDetectionInput, ObjectDetectionResult>;
-
-static mutex g_face_detection_mutex;
-
-int mv_face_detection_create_open(mv_face_detection_h *out_handle)
-{
- if (!out_handle) {
- LOGE("Handle can't be created because handle pointer is NULL");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- Context *context = nullptr;
- FaceDetectionTask *task = nullptr;
-
- try {
- context = new Context();
- task = new FaceDetectionAdapter<ObjectDetectionInput, ObjectDetectionResult>();
- context->__tasks.insert(make_pair("face_detection", task));
- *out_handle = static_cast<mv_face_detection_h>(context);
- } catch (const BaseException &e) {
- delete task;
- delete context;
- return e.getError();
- }
-
- LOGD("face detection handle [%p] has been created", *out_handle);
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_face_detection_destroy_open(mv_face_detection_h handle)
-{
- lock_guard<mutex> lock(g_face_detection_mutex);
-
- if (!handle) {
- LOGE("Handle is NULL.");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- auto context = static_cast<Context *>(handle);
-
- for (auto &m : context->__tasks)
- delete static_cast<FaceDetectionTask *>(m.second);
-
- delete context;
-
- LOGD("Object detection handle has been destroyed.");
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_face_detection_set_model_open(mv_face_detection_h handle, const char *model_name, const char *model_file,
- const char *meta_file, const char *label_file)
-{
- 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"));
-
- task->setModelInfo(model_file, meta_file, label_file, model_name);
- } catch (const BaseException &e) {
- LOGE("%s", e.what());
- return e.getError();
- }
-
- LOGD("LEAVE");
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_face_detection_set_engine_open(mv_face_detection_h handle, const char *backend_type, const char *device_type)
-{
- 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"));
-
- task->setEngineInfo(backend_type, device_type);
- } catch (const BaseException &e) {
- LOGE("%s", e.what());
- return e.getError();
- }
-
- LOGD("LEAVE");
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_face_detection_get_engine_count_open(mv_face_detection_h handle, unsigned int *engine_count)
-{
- 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"));
-
- task->getNumberOfEngines(engine_count);
- // TODO.
- } catch (const BaseException &e) {
- LOGE("%s", e.what());
- return e.getError();
- }
-
- LOGD("LEAVE");
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_face_detection_get_engine_type_open(mv_face_detection_h handle, const unsigned int engine_index,
- char **engine_type)
-{
- 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"));
-
- task->getEngineType(engine_index, engine_type);
- // TODO.
- } catch (const BaseException &e) {
- LOGE("%s", e.what());
- return e.getError();
- }
-
- LOGD("LEAVE");
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_face_detection_get_device_count_open(mv_face_detection_h handle, const char *engine_type,
- unsigned int *device_count)
-{
- 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"));
-
- task->getNumberOfDevices(engine_type, device_count);
- // TODO.
- } catch (const BaseException &e) {
- LOGE("%s", e.what());
- return e.getError();
- }
-
- LOGD("LEAVE");
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_face_detection_get_device_type_open(mv_face_detection_h handle, const char *engine_type,
- const unsigned int device_index, char **device_type)
-{
- 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"));
-
- task->getDeviceType(engine_type, device_index, device_type);
- // TODO.
- } catch (const BaseException &e) {
- LOGE("%s", e.what());
- return e.getError();
- }
-
- LOGD("LEAVE");
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_face_detection_configure_open(mv_face_detection_h handle)
-{
- 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"));
-
- task->configure();
- } catch (const BaseException &e) {
- LOGE("%s", e.what());
- return e.getError();
- }
-
- LOGD("LEAVE");
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_face_detection_prepare_open(mv_face_detection_h handle)
-{
- 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"));
-
- task->prepare();
- } catch (const BaseException &e) {
- LOGE("%s", e.what());
- return e.getError();
- }
-
- LOGD("LEAVE");
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_face_detection_inference_open(mv_face_detection_h handle, mv_source_h source)
-{
- 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 = { .inference_src = source };
-
- task->setInput(input);
- task->perform();
- } catch (const BaseException &e) {
- LOGE("%s", e.what());
- return e.getError();
- }
-
- LOGD("LEAVE");
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_face_detection_get_result_open(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)
-{
- 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"));
-
- ObjectDetectionResult &result = task->getOutput();
- *number_of_objects = result.number_of_objects;
- *indices = result.indices.data();
- *confidences = result.confidences.data();
- *left = result.left.data();
- *top = result.top.data();
- *right = result.right.data();
- *bottom = result.bottom.data();
- } catch (const BaseException &e) {
- LOGE("%s", e.what());
- return e.getError();
- }
-
- LOGD("LEAVE");
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_face_detection_get_label_open(mv_face_detection_h handle, const unsigned int index, const char **out_label)
-{
- 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"));
-
- ObjectDetectionResult &result = task->getOutput();
-
- if (result.number_of_objects <= index)
- throw InvalidParameter("Invalid index range.");
-
- *out_label = result.names[index].c_str();
- } catch (const BaseException &e) {
- LOGE("%s", e.what());
- return e.getError();
- }
-
- LOGD("LEAVE");
-
- return MEDIA_VISION_ERROR_NONE;
-}
\ No newline at end of file
+++ /dev/null
-/**
- * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "mv_private.h"
-#include "mv_object_detection_internal.h"
-#include "mv_object_detection_open.h"
-
-/**
- * @file mv_object_detection.c
- * @brief This file contains Media Vision inference module.
- */
-
-int mv_object_detection_create(mv_object_detection_h *handle)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_inference_check_system_info_feature_supported());
- MEDIA_VISION_NULL_ARG_CHECK(handle);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv_object_detection_create_open(handle);
-
- MEDIA_VISION_FUNCTION_LEAVE();
- return ret;
-}
-
-int mv_object_detection_destroy(mv_object_detection_h handle)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_inference_check_system_info_feature_supported());
- MEDIA_VISION_INSTANCE_CHECK(handle);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv_object_detection_destroy_open(handle);
-
- MEDIA_VISION_FUNCTION_LEAVE();
- return ret;
-}
-
-int mv_object_detection_set_model(mv_object_detection_h handle, const char *model_name, const char *model_file,
- const char *meta_file, const char *label_file)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported());
-
- MEDIA_VISION_INSTANCE_CHECK(handle);
- MEDIA_VISION_INSTANCE_CHECK(model_name);
- MEDIA_VISION_NULL_ARG_CHECK(model_file);
- MEDIA_VISION_NULL_ARG_CHECK(meta_file);
- MEDIA_VISION_NULL_ARG_CHECK(label_file);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv_object_detection_set_model_open(handle, model_name, model_file, meta_file, label_file);
-
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
-
-int mv_object_detection_set_engine(mv_object_detection_h handle, const char *backend_type, const char *device_type)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported());
-
- MEDIA_VISION_INSTANCE_CHECK(handle);
- MEDIA_VISION_NULL_ARG_CHECK(backend_type);
- MEDIA_VISION_NULL_ARG_CHECK(device_type);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv_object_detection_set_engine_open(handle, backend_type, device_type);
-
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
-
-int mv_object_detection_get_engine_count(mv_object_detection_h handle, unsigned int *engine_count)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported());
-
- MEDIA_VISION_INSTANCE_CHECK(handle);
- MEDIA_VISION_NULL_ARG_CHECK(engine_count);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv_object_detection_get_engine_count_open(handle, engine_count);
-
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
-
-int mv_object_detection_get_engine_type(mv_object_detection_h handle, const unsigned int engine_index,
- char **engine_type)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported());
-
- MEDIA_VISION_INSTANCE_CHECK(handle);
- MEDIA_VISION_NULL_ARG_CHECK(engine_type);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv_object_detection_get_engine_type_open(handle, engine_index, engine_type);
-
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
-
-int mv_object_detection_get_device_count(mv_object_detection_h handle, const char *engine_type,
- unsigned int *device_count)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported());
-
- MEDIA_VISION_INSTANCE_CHECK(handle);
- MEDIA_VISION_NULL_ARG_CHECK(device_count);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv_object_detection_get_device_count_open(handle, engine_type, device_count);
-
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
-
-int mv_object_detection_get_device_type(mv_object_detection_h handle, const char *engine_type,
- const unsigned int device_index, char **device_type)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported());
-
- MEDIA_VISION_INSTANCE_CHECK(handle);
- MEDIA_VISION_NULL_ARG_CHECK(engine_type);
- MEDIA_VISION_NULL_ARG_CHECK(device_type);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv_object_detection_get_device_type_open(handle, engine_type, device_index, device_type);
-
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
-
-int mv_object_detection_configure(mv_object_detection_h handle)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_inference_check_system_info_feature_supported());
- MEDIA_VISION_INSTANCE_CHECK(handle);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv_object_detection_configure_open(handle);
-
- MEDIA_VISION_FUNCTION_LEAVE();
- return ret;
-}
-
-int mv_object_detection_prepare(mv_object_detection_h handle)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_inference_check_system_info_feature_supported());
- MEDIA_VISION_INSTANCE_CHECK(handle);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv_object_detection_prepare_open(handle);
-
- MEDIA_VISION_FUNCTION_LEAVE();
- return ret;
-}
-
-int mv_object_detection_inference(mv_object_detection_h handle, mv_source_h source)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_inference_image_check_system_info_feature_supported());
- MEDIA_VISION_INSTANCE_CHECK(handle);
- MEDIA_VISION_INSTANCE_CHECK(source);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv_object_detection_inference_open(handle, source);
-
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
-
-int mv_object_detection_inference_async(mv_object_detection_h handle, mv_source_h source,
- mv_completion_cb completion_cb, void *user_data)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_inference_image_check_system_info_feature_supported());
- MEDIA_VISION_INSTANCE_CHECK(handle);
- MEDIA_VISION_INSTANCE_CHECK(source);
- MEDIA_VISION_INSTANCE_CHECK(completion_cb);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv_object_detection_inference_async_open(handle, source, completion_cb, user_data);
-
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
-
-int mv_object_detection_get_result(mv_object_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)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_inference_image_check_system_info_feature_supported());
- MEDIA_VISION_INSTANCE_CHECK(handle);
- MEDIA_VISION_INSTANCE_CHECK(number_of_objects);
- MEDIA_VISION_INSTANCE_CHECK(indices);
- MEDIA_VISION_INSTANCE_CHECK(confidences);
- MEDIA_VISION_INSTANCE_CHECK(left);
- MEDIA_VISION_INSTANCE_CHECK(top);
- MEDIA_VISION_INSTANCE_CHECK(right);
- MEDIA_VISION_INSTANCE_CHECK(bottom);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv_object_detection_get_result_open(handle, number_of_objects, indices, confidences, left, top, right,
- bottom);
-
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
-
-int mv_object_detection_get_label(mv_object_detection_h handle, const unsigned int index, const char **label)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_inference_image_check_system_info_feature_supported());
- MEDIA_VISION_INSTANCE_CHECK(handle);
- MEDIA_VISION_INSTANCE_CHECK(label);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv_object_detection_get_label_open(handle, index, label);
-
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
\ No newline at end of file
--- /dev/null
+/**
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "mv_private.h"
+#include "itask.h"
+#include "mv_object_detection_internal.h"
+#include "object_detection_adapter.h"
+#include "machine_learning_exception.h"
+#include "object_detection_type.h"
+#include "context.h"
+
+#include <new>
+#include <unistd.h>
+#include <string>
+#include <algorithm>
+#include <mutex>
+#include <iostream>
+
+using namespace std;
+using namespace mediavision::inference;
+using namespace mediavision::common;
+using namespace mediavision::machine_learning;
+using namespace MediaVision::Common;
+using namespace mediavision::machine_learning::exception;
+using ObjectDetectionTask = ITask<ObjectDetectionInput, ObjectDetectionResult>;
+
+static mutex g_object_detection_mutex;
+
+int mv_object_detection_create(mv_object_detection_h *handle)
+{
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_check_system_info_feature_supported());
+ MEDIA_VISION_NULL_ARG_CHECK(handle);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ Context *context = nullptr;
+ ObjectDetectionTask *task = nullptr;
+
+ try {
+ context = new Context();
+ task = new ObjectDetectionAdapter<ObjectDetectionInput, ObjectDetectionResult>();
+ context->__tasks.insert(make_pair("object_detection", task));
+ *handle = static_cast<mv_object_detection_h>(context);
+ } catch (const BaseException &e) {
+ delete task;
+ delete context;
+ return e.getError();
+ }
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_object_detection_destroy(mv_object_detection_h handle)
+{
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_check_system_info_feature_supported());
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ // TODO. find proper solution later.
+ // For thread safety, lock is needed here but if async API is used then dead lock occurs
+ // because mv_object_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_object_detection_get_result_open and mv_object_detection_get_label_open
+ // - called to obtain results from the thread loop.
+
+ auto context = static_cast<Context *>(handle);
+
+ for (auto &m : context->__tasks)
+ delete static_cast<ObjectDetectionTask *>(m.second);
+
+ delete context;
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_object_detection_set_model(mv_object_detection_h handle, const char *model_name, const char *model_file,
+ const char *meta_file, const char *label_file)
+{
+ lock_guard<mutex> lock(g_object_detection_mutex);
+
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported());
+
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+ MEDIA_VISION_INSTANCE_CHECK(model_name);
+ MEDIA_VISION_NULL_ARG_CHECK(model_file);
+ MEDIA_VISION_NULL_ARG_CHECK(meta_file);
+ MEDIA_VISION_NULL_ARG_CHECK(label_file);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ try {
+ auto context = static_cast<Context *>(handle);
+ auto task = static_cast<ObjectDetectionTask *>(context->__tasks.at("object_detection"));
+
+ task->setModelInfo(model_file, meta_file, label_file, model_name);
+ } catch (const BaseException &e) {
+ LOGE("%s", e.what());
+ return e.getError();
+ }
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_object_detection_set_engine(mv_object_detection_h handle, const char *backend_type, const char *device_type)
+{
+ lock_guard<mutex> lock(g_object_detection_mutex);
+
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported());
+
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+ MEDIA_VISION_NULL_ARG_CHECK(backend_type);
+ MEDIA_VISION_NULL_ARG_CHECK(device_type);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ try {
+ auto context = static_cast<Context *>(handle);
+ auto task = static_cast<ObjectDetectionTask *>(context->__tasks.at("object_detection"));
+
+ task->setEngineInfo(backend_type, device_type);
+ } catch (const BaseException &e) {
+ LOGE("%s", e.what());
+ return e.getError();
+ }
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_object_detection_get_engine_count(mv_object_detection_h handle, unsigned int *engine_count)
+{
+ lock_guard<mutex> lock(g_object_detection_mutex);
+
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported());
+
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+ MEDIA_VISION_NULL_ARG_CHECK(engine_count);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ try {
+ auto context = static_cast<Context *>(handle);
+ auto task = static_cast<ObjectDetectionTask *>(context->__tasks.at("object_detection"));
+
+ task->getNumberOfEngines(engine_count);
+ // TODO.
+ } catch (const BaseException &e) {
+ LOGE("%s", e.what());
+ return e.getError();
+ }
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_object_detection_get_engine_type(mv_object_detection_h handle, const unsigned int engine_index,
+ char **engine_type)
+{
+ lock_guard<mutex> lock(g_object_detection_mutex);
+
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported());
+
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+ MEDIA_VISION_NULL_ARG_CHECK(engine_type);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ try {
+ auto context = static_cast<Context *>(handle);
+ auto task = static_cast<ObjectDetectionTask *>(context->__tasks.at("object_detection"));
+
+ task->getEngineType(engine_index, engine_type);
+ // TODO.
+ } catch (const BaseException &e) {
+ LOGE("%s", e.what());
+ return e.getError();
+ }
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_object_detection_get_device_count(mv_object_detection_h handle, const char *engine_type,
+ unsigned int *device_count)
+{
+ lock_guard<mutex> lock(g_object_detection_mutex);
+
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported());
+
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+ MEDIA_VISION_NULL_ARG_CHECK(device_count);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ try {
+ auto context = static_cast<Context *>(handle);
+ auto task = static_cast<ObjectDetectionTask *>(context->__tasks.at("object_detection"));
+
+ task->getNumberOfDevices(engine_type, device_count);
+ // TODO.
+ } catch (const BaseException &e) {
+ LOGE("%s", e.what());
+ return e.getError();
+ }
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_object_detection_get_device_type(mv_object_detection_h handle, const char *engine_type,
+ const unsigned int device_index, char **device_type)
+{
+ lock_guard<mutex> lock(g_object_detection_mutex);
+
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported());
+
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+ MEDIA_VISION_NULL_ARG_CHECK(engine_type);
+ MEDIA_VISION_NULL_ARG_CHECK(device_type);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ try {
+ auto context = static_cast<Context *>(handle);
+ auto task = static_cast<ObjectDetectionTask *>(context->__tasks.at("object_detection"));
+
+ task->getDeviceType(engine_type, device_index, device_type);
+ // TODO.
+ } catch (const BaseException &e) {
+ LOGE("%s", e.what());
+ return e.getError();
+ }
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_object_detection_configure(mv_object_detection_h handle)
+{
+ lock_guard<mutex> lock(g_object_detection_mutex);
+
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_check_system_info_feature_supported());
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ try {
+ auto context = static_cast<Context *>(handle);
+ auto task = static_cast<ObjectDetectionTask *>(context->__tasks.at("object_detection"));
+
+ task->configure();
+ } catch (const BaseException &e) {
+ LOGE("%s", e.what());
+ return e.getError();
+ }
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_object_detection_prepare(mv_object_detection_h handle)
+{
+ lock_guard<mutex> lock(g_object_detection_mutex);
+
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_check_system_info_feature_supported());
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ try {
+ auto context = static_cast<Context *>(handle);
+ auto task = static_cast<ObjectDetectionTask *>(context->__tasks.at("object_detection"));
+
+ task->prepare();
+ } catch (const BaseException &e) {
+ LOGE("%s", e.what());
+ return e.getError();
+ }
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_object_detection_inference(mv_object_detection_h handle, mv_source_h source)
+{
+ lock_guard<mutex> lock(g_object_detection_mutex);
+
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_image_check_system_info_feature_supported());
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+ MEDIA_VISION_INSTANCE_CHECK(source);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ try {
+ auto context = static_cast<Context *>(handle);
+ auto task = static_cast<ObjectDetectionTask *>(context->__tasks.at("object_detection"));
+
+ ObjectDetectionInput input = { .inference_src = source };
+
+ task->setInput(input);
+ task->perform();
+ } catch (const BaseException &e) {
+ LOGE("%s", e.what());
+ return e.getError();
+ }
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_object_detection_inference_async(mv_object_detection_h handle, mv_source_h source,
+ mv_completion_cb completion_cb, void *user_data)
+{
+ lock_guard<mutex> lock(g_object_detection_mutex);
+
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_image_check_system_info_feature_supported());
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+ MEDIA_VISION_INSTANCE_CHECK(source);
+ MEDIA_VISION_INSTANCE_CHECK(completion_cb);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ try {
+ auto context = static_cast<Context *>(handle);
+ auto task = static_cast<ObjectDetectionTask *>(context->__tasks.at("object_detection"));
+
+ ObjectDetectionInput input = { handle, source, completion_cb, user_data };
+
+ task->performAsync(input);
+ } catch (const BaseException &e) {
+ LOGE("%s", e.what());
+ return e.getError();
+ }
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_object_detection_get_result(mv_object_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)
+{
+ lock_guard<mutex> lock(g_object_detection_mutex);
+
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_image_check_system_info_feature_supported());
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+ MEDIA_VISION_INSTANCE_CHECK(number_of_objects);
+ MEDIA_VISION_INSTANCE_CHECK(indices);
+ MEDIA_VISION_INSTANCE_CHECK(confidences);
+ MEDIA_VISION_INSTANCE_CHECK(left);
+ MEDIA_VISION_INSTANCE_CHECK(top);
+ MEDIA_VISION_INSTANCE_CHECK(right);
+ MEDIA_VISION_INSTANCE_CHECK(bottom);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ try {
+ auto context = static_cast<Context *>(handle);
+ auto task = static_cast<ObjectDetectionTask *>(context->__tasks.at("object_detection"));
+
+ ObjectDetectionResult &result = task->getOutput();
+ *number_of_objects = result.number_of_objects;
+ *indices = result.indices.data();
+ *confidences = result.confidences.data();
+ *left = result.left.data();
+ *top = result.top.data();
+ *right = result.right.data();
+ *bottom = result.bottom.data();
+ } catch (const BaseException &e) {
+ LOGE("%s", e.what());
+ return e.getError();
+ }
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_object_detection_get_label(mv_object_detection_h handle, const unsigned int index, const char **label)
+{
+ lock_guard<mutex> lock(g_object_detection_mutex);
+
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_image_check_system_info_feature_supported());
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+ MEDIA_VISION_INSTANCE_CHECK(label);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ try {
+ auto context = static_cast<Context *>(handle);
+ auto task = static_cast<ObjectDetectionTask *>(context->__tasks.at("object_detection"));
+
+ ObjectDetectionResult &result = task->getOutput();
+
+ if (result.number_of_objects <= index)
+ throw InvalidParameter("Invalid index range.");
+
+ *label = result.names[index].c_str();
+ } catch (const BaseException &e) {
+ LOGE("%s", e.what());
+ return e.getError();
+ }
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
\ No newline at end of file
+++ /dev/null
-/**
- * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "mv_private.h"
-#include "itask.h"
-#include "mv_object_detection_open.h"
-#include "object_detection_adapter.h"
-#include "machine_learning_exception.h"
-#include "object_detection_type.h"
-#include "context.h"
-
-#include <new>
-#include <unistd.h>
-#include <string>
-#include <algorithm>
-#include <mutex>
-#include <iostream>
-
-using namespace std;
-using namespace mediavision::inference;
-using namespace mediavision::common;
-using namespace mediavision::machine_learning;
-using namespace MediaVision::Common;
-using namespace mediavision::machine_learning::exception;
-using ObjectDetectionTask = ITask<ObjectDetectionInput, ObjectDetectionResult>;
-
-static mutex g_object_detection_mutex;
-
-int mv_object_detection_create_open(mv_object_detection_h *handle)
-{
- if (!handle) {
- LOGE("Handle can't be created because handle pointer is NULL");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- Context *context = nullptr;
- ObjectDetectionTask *task = nullptr;
-
- try {
- context = new Context();
- task = new ObjectDetectionAdapter<ObjectDetectionInput, ObjectDetectionResult>();
- context->__tasks.insert(make_pair("object_detection", task));
- *handle = static_cast<mv_object_detection_h>(context);
- } catch (const BaseException &e) {
- delete task;
- delete context;
- return e.getError();
- }
-
- LOGD("object detection handle [%p] has been created", *handle);
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_object_detection_destroy_open(mv_object_detection_h handle)
-{
- // TODO. find proper solution later.
- // For thread safety, lock is needed here but if async API is used then dead lock occurs
- // because mv_object_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_object_detection_get_result_open and mv_object_detection_get_label_open
- // - called to obtain results from the thread loop.
-
- if (!handle) {
- LOGE("Handle is NULL.");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- auto context = static_cast<Context *>(handle);
-
- for (auto &m : context->__tasks)
- delete static_cast<ObjectDetectionTask *>(m.second);
-
- delete context;
-
- LOGD("Object detection handle has been destroyed.");
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_object_detection_set_model_open(mv_object_detection_h handle, const char *model_name, const char *model_file,
- const char *meta_file, const char *label_file)
-{
- lock_guard<mutex> lock(g_object_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<ObjectDetectionTask *>(context->__tasks.at("object_detection"));
-
- task->setModelInfo(model_file, meta_file, label_file, model_name);
- } catch (const BaseException &e) {
- LOGE("%s", e.what());
- return e.getError();
- }
-
- LOGD("LEAVE");
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_object_detection_set_engine_open(mv_object_detection_h handle, const char *backend_type, const char *device_type)
-{
- lock_guard<mutex> lock(g_object_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<ObjectDetectionTask *>(context->__tasks.at("object_detection"));
-
- task->setEngineInfo(backend_type, device_type);
- } catch (const BaseException &e) {
- LOGE("%s", e.what());
- return e.getError();
- }
-
- LOGD("LEAVE");
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_object_detection_get_engine_count_open(mv_object_detection_h handle, unsigned int *engine_count)
-{
- lock_guard<mutex> lock(g_object_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<ObjectDetectionTask *>(context->__tasks.at("object_detection"));
-
- task->getNumberOfEngines(engine_count);
- // TODO.
- } catch (const BaseException &e) {
- LOGE("%s", e.what());
- return e.getError();
- }
-
- LOGD("LEAVE");
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_object_detection_get_engine_type_open(mv_object_detection_h handle, const unsigned int engine_index,
- char **engine_type)
-{
- lock_guard<mutex> lock(g_object_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<ObjectDetectionTask *>(context->__tasks.at("object_detection"));
-
- task->getEngineType(engine_index, engine_type);
- // TODO.
- } catch (const BaseException &e) {
- LOGE("%s", e.what());
- return e.getError();
- }
-
- LOGD("LEAVE");
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_object_detection_get_device_count_open(mv_object_detection_h handle, const char *engine_type,
- unsigned int *device_count)
-{
- lock_guard<mutex> lock(g_object_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<ObjectDetectionTask *>(context->__tasks.at("object_detection"));
-
- task->getNumberOfDevices(engine_type, device_count);
- // TODO.
- } catch (const BaseException &e) {
- LOGE("%s", e.what());
- return e.getError();
- }
-
- LOGD("LEAVE");
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_object_detection_get_device_type_open(mv_object_detection_h handle, const char *engine_type,
- const unsigned int device_index, char **device_type)
-{
- lock_guard<mutex> lock(g_object_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<ObjectDetectionTask *>(context->__tasks.at("object_detection"));
-
- task->getDeviceType(engine_type, device_index, device_type);
- // TODO.
- } catch (const BaseException &e) {
- LOGE("%s", e.what());
- return e.getError();
- }
-
- LOGD("LEAVE");
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_object_detection_configure_open(mv_object_detection_h handle)
-{
- LOGD("ENTER");
-
- lock_guard<mutex> lock(g_object_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<ObjectDetectionTask *>(context->__tasks.at("object_detection"));
-
- task->configure();
- } catch (const BaseException &e) {
- LOGE("%s", e.what());
- return e.getError();
- }
-
- LOGD("LEAVE");
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_object_detection_prepare_open(mv_object_detection_h handle)
-{
- LOGD("ENTER");
-
- lock_guard<mutex> lock(g_object_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<ObjectDetectionTask *>(context->__tasks.at("object_detection"));
-
- task->prepare();
- } catch (const BaseException &e) {
- LOGE("%s", e.what());
- return e.getError();
- }
-
- LOGD("LEAVE");
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_object_detection_inference_open(mv_object_detection_h handle, mv_source_h source)
-{
- LOGD("ENTER");
-
- lock_guard<mutex> lock(g_object_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<ObjectDetectionTask *>(context->__tasks.at("object_detection"));
-
- ObjectDetectionInput input = { .inference_src = source };
-
- task->setInput(input);
- task->perform();
- } catch (const BaseException &e) {
- LOGE("%s", e.what());
- return e.getError();
- }
-
- LOGD("LEAVE");
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_object_detection_inference_async_open(mv_object_detection_h handle, mv_source_h source,
- mv_completion_cb completion_cb, void *user_data)
-{
- LOGD("ENTER");
-
- lock_guard<mutex> lock(g_object_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<ObjectDetectionTask *>(context->__tasks.at("object_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_object_detection_get_result_open(mv_object_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)
-{
- LOGD("ENTER");
-
- lock_guard<mutex> lock(g_object_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<ObjectDetectionTask *>(context->__tasks.at("object_detection"));
-
- ObjectDetectionResult &result = task->getOutput();
- *number_of_objects = result.number_of_objects;
- *indices = result.indices.data();
- *confidences = result.confidences.data();
- *left = result.left.data();
- *top = result.top.data();
- *right = result.right.data();
- *bottom = result.bottom.data();
- } catch (const BaseException &e) {
- LOGE("%s", e.what());
- return e.getError();
- }
-
- LOGD("LEAVE");
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_object_detection_get_label_open(mv_object_detection_h handle, const unsigned int index, const char **label)
-{
- LOGD("ENTER");
-
- lock_guard<mutex> lock(g_object_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<ObjectDetectionTask *>(context->__tasks.at("object_detection"));
-
- ObjectDetectionResult &result = task->getOutput();
-
- if (result.number_of_objects <= index)
- throw InvalidParameter("Invalid index range.");
-
- *label = result.names[index].c_str();
- } catch (const BaseException &e) {
- LOGE("%s", e.what());
- return e.getError();
- }
-
- LOGD("LEAVE");
-
- return MEDIA_VISION_ERROR_NONE;
-}
\ No newline at end of file
+++ /dev/null
-/**
- * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "mv_private.h"
-#include "mv_object_detection_3d_internal.h"
-#include "mv_object_detection_3d_open.h"
-
-/**
- * @file mv_object_detection_3d.c
- * @brief This file contains Media Vision inference module.
- */
-
-int mv_object_detection_3d_create(mv_object_detection_3d_h *infer)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_inference_check_system_info_feature_supported());
- MEDIA_VISION_NULL_ARG_CHECK(infer);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv_object_detection_3d_create_open(infer);
-
- MEDIA_VISION_FUNCTION_LEAVE();
- return ret;
-}
-
-int mv_object_detection_3d_destroy(mv_object_detection_3d_h infer)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_inference_check_system_info_feature_supported());
- MEDIA_VISION_INSTANCE_CHECK(infer);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv_object_detection_3d_destroy_open(infer);
-
- MEDIA_VISION_FUNCTION_LEAVE();
- return ret;
-}
-
-int mv_object_detection_3d_set_model(mv_object_detection_3d_h handle, const char *model_name, const char *model_file,
- const char *meta_file, const char *label_file)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported());
-
- MEDIA_VISION_INSTANCE_CHECK(handle);
- MEDIA_VISION_INSTANCE_CHECK(model_name);
- MEDIA_VISION_NULL_ARG_CHECK(model_file);
- MEDIA_VISION_NULL_ARG_CHECK(meta_file);
- MEDIA_VISION_NULL_ARG_CHECK(label_file);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv_object_detection_3d_set_model_open(handle, model_name, model_file, meta_file, label_file);
-
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
-
-int mv_object_detection_3d_set_engine(mv_object_detection_3d_h handle, const char *backend_type,
- const char *device_type)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported());
-
- MEDIA_VISION_INSTANCE_CHECK(handle);
- MEDIA_VISION_NULL_ARG_CHECK(backend_type);
- MEDIA_VISION_NULL_ARG_CHECK(device_type);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv_object_detection_3d_set_engine_open(handle, backend_type, device_type);
-
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
-
-int mv_object_detection_3d_get_engine_count(mv_object_detection_3d_h handle, unsigned int *engine_count)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported());
-
- MEDIA_VISION_INSTANCE_CHECK(handle);
- MEDIA_VISION_NULL_ARG_CHECK(engine_count);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv_object_detection_3d_get_engine_count_open(handle, engine_count);
-
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
-
-int mv_object_detection_3d_get_engine_type(mv_object_detection_3d_h handle, const unsigned int engine_index,
- char **engine_type)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported());
-
- MEDIA_VISION_INSTANCE_CHECK(handle);
- MEDIA_VISION_NULL_ARG_CHECK(engine_type);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv_object_detection_3d_get_engine_type_open(handle, engine_index, engine_type);
-
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
-
-int mv_object_detection_3d_get_device_count(mv_object_detection_3d_h handle, const char *engine_type,
- unsigned int *device_count)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported());
-
- MEDIA_VISION_INSTANCE_CHECK(handle);
- MEDIA_VISION_NULL_ARG_CHECK(device_count);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv_object_detection_3d_get_device_count_open(handle, engine_type, device_count);
-
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
-
-int mv_object_detection_3d_get_device_type(mv_object_detection_3d_h handle, const char *engine_type,
- const unsigned int device_index, char **device_type)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported());
-
- MEDIA_VISION_INSTANCE_CHECK(handle);
- MEDIA_VISION_NULL_ARG_CHECK(engine_type);
- MEDIA_VISION_NULL_ARG_CHECK(device_type);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv_object_detection_3d_get_device_type_open(handle, engine_type, device_index, device_type);
-
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
-
-int mv_object_detection_3d_configure(mv_object_detection_3d_h infer)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_inference_check_system_info_feature_supported());
- MEDIA_VISION_INSTANCE_CHECK(infer);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv_object_detection_3d_configure_open(infer);
-
- MEDIA_VISION_FUNCTION_LEAVE();
- return ret;
-}
-
-int mv_object_detection_3d_prepare(mv_object_detection_3d_h infer)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_inference_check_system_info_feature_supported());
- MEDIA_VISION_INSTANCE_CHECK(infer);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv_object_detection_3d_prepare_open(infer);
-
- MEDIA_VISION_FUNCTION_LEAVE();
- return ret;
-}
-
-int mv_object_detection_3d_inference(mv_object_detection_3d_h infer, mv_source_h source)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_inference_image_check_system_info_feature_supported());
- MEDIA_VISION_INSTANCE_CHECK(source);
- MEDIA_VISION_INSTANCE_CHECK(infer);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv_object_detection_3d_inference_open(infer, source);
-
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
-
-int mv_object_detection_3d_get_probability(mv_object_detection_3d_h handle, unsigned int *out_probability)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported());
-
- MEDIA_VISION_INSTANCE_CHECK(handle);
- MEDIA_VISION_NULL_ARG_CHECK(out_probability);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv_object_detection_3d_get_probability_open(handle, out_probability);
-
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
-
-int mv_object_detection_3d_get_num_of_points(mv_object_detection_3d_h handle, unsigned int *out_num_of_points)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported());
-
- MEDIA_VISION_INSTANCE_CHECK(handle);
- MEDIA_VISION_NULL_ARG_CHECK(out_num_of_points);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv_object_detection_3d_get_num_of_points_open(handle, out_num_of_points);
-
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
-
-int mv_object_detection_3d_get_points(mv_object_detection_3d_h handle, unsigned int **out_x, unsigned int **out_y)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported());
-
- MEDIA_VISION_INSTANCE_CHECK(handle);
- MEDIA_VISION_NULL_ARG_CHECK(out_x);
- MEDIA_VISION_NULL_ARG_CHECK(out_y);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv_object_detection_3d_get_points_open(handle, out_x, out_y);
-
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
--- /dev/null
+/**
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "mv_private.h"
+#include "itask.h"
+#include "mv_object_detection_3d_internal.h"
+#include "object_detection_3d_adapter.h"
+#include "machine_learning_exception.h"
+#include "object_detection_3d_type.h"
+#include "context.h"
+
+#include <new>
+#include <unistd.h>
+#include <string>
+#include <algorithm>
+#include <mutex>
+
+using namespace std;
+using namespace mediavision::inference;
+using namespace mediavision::common;
+using namespace mediavision::machine_learning;
+using namespace MediaVision::Common;
+using namespace mediavision::machine_learning::exception;
+using ObjectDetection3dTask = ITask<ObjectDetection3dInput, ObjectDetection3dResult>;
+
+static mutex g_object_detection_3d_mutex;
+
+int mv_object_detection_3d_create(mv_object_detection_3d_h *handle)
+{
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_check_system_info_feature_supported());
+
+ MEDIA_VISION_NULL_ARG_CHECK(handle);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ Context *context = nullptr;
+ ObjectDetection3dTask *task = nullptr;
+
+ try {
+ context = new Context();
+ task = new ObjectDetection3dAdapter<ObjectDetection3dInput, ObjectDetection3dResult>();
+ context->__tasks.insert(make_pair("object_detection_3d", task));
+ *handle = static_cast<mv_object_detection_3d_h>(context);
+ } catch (const BaseException &e) {
+ delete task;
+ delete context;
+ return e.getError();
+ }
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_object_detection_3d_destroy(mv_object_detection_3d_h handle)
+{
+ lock_guard<mutex> lock(g_object_detection_3d_mutex);
+
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_check_system_info_feature_supported());
+
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ auto context = static_cast<Context *>(handle);
+
+ for (auto &m : context->__tasks)
+ delete static_cast<ObjectDetection3dTask *>(m.second);
+
+ delete context;
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_object_detection_3d_set_model(mv_object_detection_3d_h handle, const char *model_name, const char *model_file,
+ const char *meta_file, const char *label_file)
+{
+ lock_guard<mutex> lock(g_object_detection_3d_mutex);
+
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported());
+
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+ MEDIA_VISION_INSTANCE_CHECK(model_name);
+ MEDIA_VISION_NULL_ARG_CHECK(model_file);
+ MEDIA_VISION_NULL_ARG_CHECK(meta_file);
+ MEDIA_VISION_NULL_ARG_CHECK(label_file);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ try {
+ auto context = static_cast<Context *>(handle);
+ auto task = static_cast<ObjectDetection3dTask *>(context->__tasks.at("object_detection_3d"));
+
+ task->setModelInfo(model_file, meta_file, label_file, model_name);
+ } catch (const BaseException &e) {
+ LOGE("%s", e.what());
+ return e.getError();
+ }
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_object_detection_3d_set_engine(mv_object_detection_3d_h handle, const char *backend_type,
+ const char *device_type)
+{
+ lock_guard<mutex> lock(g_object_detection_3d_mutex);
+
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported());
+
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+ MEDIA_VISION_NULL_ARG_CHECK(backend_type);
+ MEDIA_VISION_NULL_ARG_CHECK(device_type);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ try {
+ auto context = static_cast<Context *>(handle);
+ auto task = static_cast<ObjectDetection3dTask *>(context->__tasks.at("object_detection_3d"));
+
+ task->setEngineInfo(backend_type, device_type);
+ } catch (const BaseException &e) {
+ LOGE("%s", e.what());
+ return e.getError();
+ }
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_object_detection_3d_get_engine_count(mv_object_detection_3d_h handle, unsigned int *engine_count)
+{
+ lock_guard<mutex> lock(g_object_detection_3d_mutex);
+
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported());
+
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+ MEDIA_VISION_NULL_ARG_CHECK(engine_count);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ try {
+ auto context = static_cast<Context *>(handle);
+ auto task = static_cast<ObjectDetection3dTask *>(context->__tasks.at("object_detection_3d"));
+
+ task->getNumberOfEngines(engine_count);
+ // TODO.
+ } catch (const BaseException &e) {
+ LOGE("%s", e.what());
+ return e.getError();
+ }
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_object_detection_3d_get_engine_type(mv_object_detection_3d_h handle, const unsigned int engine_index,
+ char **engine_type)
+{
+ lock_guard<mutex> lock(g_object_detection_3d_mutex);
+
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported());
+
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+ MEDIA_VISION_NULL_ARG_CHECK(engine_type);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ try {
+ auto context = static_cast<Context *>(handle);
+ auto task = static_cast<ObjectDetection3dTask *>(context->__tasks.at("object_detection_3d"));
+
+ task->getEngineType(engine_index, engine_type);
+ // TODO.
+ } catch (const BaseException &e) {
+ LOGE("%s", e.what());
+ return e.getError();
+ }
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_object_detection_3d_get_device_count(mv_object_detection_3d_h handle, const char *engine_type,
+ unsigned int *device_count)
+{
+ lock_guard<mutex> lock(g_object_detection_3d_mutex);
+
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported());
+
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+ MEDIA_VISION_NULL_ARG_CHECK(device_count);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ try {
+ auto context = static_cast<Context *>(handle);
+ auto task = static_cast<ObjectDetection3dTask *>(context->__tasks.at("object_detection_3d"));
+
+ task->getNumberOfDevices(engine_type, device_count);
+ // TODO.
+ } catch (const BaseException &e) {
+ LOGE("%s", e.what());
+ return e.getError();
+ }
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_object_detection_3d_get_device_type(mv_object_detection_3d_h handle, const char *engine_type,
+ const unsigned int device_index, char **device_type)
+{
+ lock_guard<mutex> lock(g_object_detection_3d_mutex);
+
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported());
+
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+
+ MEDIA_VISION_NULL_ARG_CHECK(engine_type);
+ MEDIA_VISION_NULL_ARG_CHECK(device_type);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ try {
+ auto context = static_cast<Context *>(handle);
+ auto task = static_cast<ObjectDetection3dTask *>(context->__tasks.at("object_detection_3d"));
+
+ task->getDeviceType(engine_type, device_index, device_type);
+ // TODO.
+ } catch (const BaseException &e) {
+ LOGE("%s", e.what());
+ return e.getError();
+ }
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_object_detection_3d_configure(mv_object_detection_3d_h handle)
+{
+ lock_guard<mutex> lock(g_object_detection_3d_mutex);
+
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_check_system_info_feature_supported());
+
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ try {
+ auto context = static_cast<Context *>(handle);
+ auto task = static_cast<ObjectDetection3dTask *>(context->__tasks.at("object_detection_3d"));
+
+ task->configure();
+ } catch (const BaseException &e) {
+ LOGE("%s", e.what());
+ return e.getError();
+ }
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_object_detection_3d_prepare(mv_object_detection_3d_h handle)
+{
+ lock_guard<mutex> lock(g_object_detection_3d_mutex);
+
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_check_system_info_feature_supported());
+
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ try {
+ auto context = static_cast<Context *>(handle);
+ auto task = static_cast<ObjectDetection3dTask *>(context->__tasks.at("object_detection_3d"));
+
+ task->prepare();
+ } catch (const BaseException &e) {
+ LOGE("%s", e.what());
+ return e.getError();
+ }
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_object_detection_3d_inference(mv_object_detection_3d_h handle, mv_source_h source)
+{
+ lock_guard<mutex> lock(g_object_detection_3d_mutex);
+
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_image_check_system_info_feature_supported());
+
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+ MEDIA_VISION_INSTANCE_CHECK(source);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ try {
+ auto context = static_cast<Context *>(handle);
+ auto task = static_cast<ObjectDetection3dTask *>(context->__tasks.at("object_detection_3d"));
+
+ ObjectDetection3dInput input = { source };
+
+ task->setInput(input);
+ task->perform();
+ } catch (const BaseException &e) {
+ LOGE("%s", e.what());
+ return e.getError();
+ }
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_object_detection_3d_get_probability(mv_object_detection_3d_h handle, unsigned int *out_probability)
+{
+ lock_guard<mutex> lock(g_object_detection_3d_mutex);
+
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported());
+
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+ MEDIA_VISION_NULL_ARG_CHECK(out_probability);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ try {
+ auto context = static_cast<Context *>(handle);
+ auto task = static_cast<ObjectDetection3dTask *>(context->__tasks.at("object_detection_3d"));
+
+ ObjectDetection3dResult &result = task->getOutput();
+
+ *out_probability = result.probability;
+ } catch (const BaseException &e) {
+ LOGE("%s", e.what());
+ return e.getError();
+ }
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_object_detection_3d_get_num_of_points(mv_object_detection_3d_h handle, unsigned int *out_num_of_points)
+{
+ lock_guard<mutex> lock(g_object_detection_3d_mutex);
+
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported());
+
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+ MEDIA_VISION_NULL_ARG_CHECK(out_num_of_points);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ try {
+ auto context = static_cast<Context *>(handle);
+ auto task = static_cast<ObjectDetection3dTask *>(context->__tasks.at("object_detection_3d"));
+
+ ObjectDetection3dResult &result = task->getOutput();
+
+ *out_num_of_points = result.number_of_points;
+ } catch (const BaseException &e) {
+ LOGE("%s", e.what());
+ return e.getError();
+ }
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_object_detection_3d_get_points(mv_object_detection_3d_h handle, unsigned int **out_x, unsigned int **out_y)
+{
+ lock_guard<mutex> lock(g_object_detection_3d_mutex);
+
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported());
+
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+ MEDIA_VISION_NULL_ARG_CHECK(out_x);
+ MEDIA_VISION_NULL_ARG_CHECK(out_y);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ try {
+ Context *context = static_cast<Context *>(handle);
+ auto task = static_cast<ObjectDetection3dTask *>(context->__tasks.at("object_detection_3d"));
+
+ ObjectDetection3dResult &result = task->getOutput();
+
+ *out_x = result.x_vec.data();
+ *out_y = result.y_vec.data();
+
+ for (auto &edge : result.edge_index_vec)
+ LOGI("%d,%d ", edge.start, edge.end);
+
+ for (unsigned int i = 0; i < result.number_of_points; ++i)
+ LOGI("%d %d", (*out_x)[i], (*out_y)[i]);
+ } catch (const BaseException &e) {
+ LOGE("%s", e.what());
+ return e.getError();
+ }
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+++ /dev/null
-/**
- * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "mv_private.h"
-#include "itask.h"
-#include "mv_object_detection_3d_open.h"
-#include "object_detection_3d_adapter.h"
-#include "machine_learning_exception.h"
-#include "object_detection_3d_type.h"
-#include "context.h"
-
-#include <new>
-#include <unistd.h>
-#include <string>
-#include <algorithm>
-#include <mutex>
-
-using namespace std;
-using namespace mediavision::inference;
-using namespace mediavision::common;
-using namespace mediavision::machine_learning;
-using namespace MediaVision::Common;
-using namespace mediavision::machine_learning::exception;
-using ObjectDetection3dTask = ITask<ObjectDetection3dInput, ObjectDetection3dResult>;
-
-static mutex g_object_detection_3d_mutex;
-
-int mv_object_detection_3d_create_open(mv_object_detection_3d_h *out_handle)
-{
- if (!out_handle) {
- LOGE("Handle can't be created because handle pointer is NULL");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- Context *context = nullptr;
- ObjectDetection3dTask *task = nullptr;
-
- try {
- context = new Context();
- task = new ObjectDetection3dAdapter<ObjectDetection3dInput, ObjectDetection3dResult>();
- context->__tasks.insert(make_pair("object_detection_3d", task));
- *out_handle = static_cast<mv_object_detection_3d_h>(context);
- } catch (const BaseException &e) {
- delete task;
- delete context;
- return e.getError();
- }
-
- LOGD("object detection 3d handle [%p] has been created", *out_handle);
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_object_detection_3d_destroy_open(mv_object_detection_3d_h handle)
-{
- lock_guard<mutex> lock(g_object_detection_3d_mutex);
-
- if (!handle) {
- LOGE("Handle is NULL.");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- auto context = static_cast<Context *>(handle);
-
- for (auto &m : context->__tasks)
- delete static_cast<ObjectDetection3dTask *>(m.second);
-
- delete context;
-
- LOGD("Object detection 3d handle has been destroyed.");
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_object_detection_3d_set_model_open(mv_object_detection_3d_h handle, const char *model_name,
- const char *model_file, const char *meta_file, const char *label_file)
-{
- LOGD("ENTER");
-
- lock_guard<mutex> lock(g_object_detection_3d_mutex);
-
- if (!handle) {
- LOGE("Handle is NULL.");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- try {
- auto context = static_cast<Context *>(handle);
- auto task = static_cast<ObjectDetection3dTask *>(context->__tasks.at("object_detection_3d"));
-
- task->setModelInfo(model_file, meta_file, label_file, model_name);
- } catch (const BaseException &e) {
- LOGE("%s", e.what());
- return e.getError();
- }
-
- LOGD("LEAVE");
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_object_detection_3d_set_engine_open(mv_object_detection_3d_h handle, const char *backend_type,
- const char *device_type)
-{
- LOGD("ENTER");
-
- lock_guard<mutex> lock(g_object_detection_3d_mutex);
-
- if (!handle) {
- LOGE("Handle is NULL.");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- try {
- auto context = static_cast<Context *>(handle);
- auto task = static_cast<ObjectDetection3dTask *>(context->__tasks.at("object_detection_3d"));
-
- task->setEngineInfo(backend_type, device_type);
- } catch (const BaseException &e) {
- LOGE("%s", e.what());
- return e.getError();
- }
-
- LOGD("LEAVE");
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_object_detection_3d_get_engine_count_open(mv_object_detection_3d_h handle, unsigned int *engine_count)
-{
- LOGD("ENTER");
-
- lock_guard<mutex> lock(g_object_detection_3d_mutex);
-
- if (!handle) {
- LOGE("Handle is NULL.");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- try {
- auto context = static_cast<Context *>(handle);
- auto task = static_cast<ObjectDetection3dTask *>(context->__tasks.at("object_detection_3d"));
-
- task->getNumberOfEngines(engine_count);
- // TODO.
- } catch (const BaseException &e) {
- LOGE("%s", e.what());
- return e.getError();
- }
-
- LOGD("LEAVE");
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_object_detection_3d_get_engine_type_open(mv_object_detection_3d_h handle, const unsigned int engine_index,
- char **engine_type)
-{
- LOGD("ENTER");
-
- lock_guard<mutex> lock(g_object_detection_3d_mutex);
-
- if (!handle) {
- LOGE("Handle is NULL.");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- try {
- auto context = static_cast<Context *>(handle);
- auto task = static_cast<ObjectDetection3dTask *>(context->__tasks.at("object_detection_3d"));
-
- task->getEngineType(engine_index, engine_type);
- // TODO.
- } catch (const BaseException &e) {
- LOGE("%s", e.what());
- return e.getError();
- }
-
- LOGD("LEAVE");
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_object_detection_3d_get_device_count_open(mv_object_detection_3d_h handle, const char *engine_type,
- unsigned int *device_count)
-{
- LOGD("ENTER");
-
- lock_guard<mutex> lock(g_object_detection_3d_mutex);
-
- if (!handle) {
- LOGE("Handle is NULL.");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- try {
- auto context = static_cast<Context *>(handle);
- auto task = static_cast<ObjectDetection3dTask *>(context->__tasks.at("object_detection_3d"));
-
- task->getNumberOfDevices(engine_type, device_count);
- // TODO.
- } catch (const BaseException &e) {
- LOGE("%s", e.what());
- return e.getError();
- }
-
- LOGD("LEAVE");
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_object_detection_3d_get_device_type_open(mv_object_detection_3d_h handle, const char *engine_type,
- const unsigned int device_index, char **device_type)
-{
- LOGD("ENTER");
-
- lock_guard<mutex> lock(g_object_detection_3d_mutex);
-
- if (!handle) {
- LOGE("Handle is NULL.");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- try {
- auto context = static_cast<Context *>(handle);
- auto task = static_cast<ObjectDetection3dTask *>(context->__tasks.at("object_detection_3d"));
-
- task->getDeviceType(engine_type, device_index, device_type);
- // TODO.
- } catch (const BaseException &e) {
- LOGE("%s", e.what());
- return e.getError();
- }
-
- LOGD("LEAVE");
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_object_detection_3d_configure_open(mv_object_detection_3d_h handle)
-{
- LOGD("ENTER");
-
- lock_guard<mutex> lock(g_object_detection_3d_mutex);
-
- if (!handle) {
- LOGE("Handle is NULL.");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- try {
- auto context = static_cast<Context *>(handle);
- auto task = static_cast<ObjectDetection3dTask *>(context->__tasks.at("object_detection_3d"));
-
- task->configure();
- } catch (const BaseException &e) {
- LOGE("%s", e.what());
- return e.getError();
- }
-
- LOGD("LEAVE");
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_object_detection_3d_prepare_open(mv_object_detection_3d_h handle)
-{
- LOGD("ENTER");
-
- lock_guard<mutex> lock(g_object_detection_3d_mutex);
-
- if (!handle) {
- LOGE("Handle is NULL.");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- try {
- auto context = static_cast<Context *>(handle);
- auto task = static_cast<ObjectDetection3dTask *>(context->__tasks.at("object_detection_3d"));
-
- task->prepare();
- } catch (const BaseException &e) {
- LOGE("%s", e.what());
- return e.getError();
- }
-
- LOGD("LEAVE");
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_object_detection_3d_inference_open(mv_object_detection_3d_h handle, mv_source_h source)
-{
- LOGD("ENTER");
-
- lock_guard<mutex> lock(g_object_detection_3d_mutex);
-
- if (!handle) {
- LOGE("Handle is NULL.");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- try {
- auto context = static_cast<Context *>(handle);
- auto task = static_cast<ObjectDetection3dTask *>(context->__tasks.at("object_detection_3d"));
-
- ObjectDetection3dInput input = { source };
-
- task->setInput(input);
- task->perform();
- } catch (const BaseException &e) {
- LOGE("%s", e.what());
- return e.getError();
- }
-
- LOGD("LEAVE");
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_object_detection_3d_get_probability_open(mv_object_detection_3d_h handle, unsigned int *out_probability)
-{
- LOGD("ENTER");
-
- lock_guard<mutex> lock(g_object_detection_3d_mutex);
-
- if (!handle) {
- LOGE("Handle is NULL.");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- try {
- auto context = static_cast<Context *>(handle);
- auto task = static_cast<ObjectDetection3dTask *>(context->__tasks.at("object_detection_3d"));
-
- ObjectDetection3dResult &result = task->getOutput();
-
- *out_probability = result.probability;
- } catch (const BaseException &e) {
- LOGE("%s", e.what());
- return e.getError();
- }
-
- LOGD("LEAVE");
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_object_detection_3d_get_num_of_points_open(mv_object_detection_3d_h handle, unsigned int *out_num_of_points)
-{
- LOGD("ENTER");
-
- lock_guard<mutex> lock(g_object_detection_3d_mutex);
-
- if (!handle) {
- LOGE("Handle is NULL.");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- try {
- auto context = static_cast<Context *>(handle);
- auto task = static_cast<ObjectDetection3dTask *>(context->__tasks.at("object_detection_3d"));
-
- ObjectDetection3dResult &result = task->getOutput();
-
- *out_num_of_points = result.number_of_points;
- } catch (const BaseException &e) {
- LOGE("%s", e.what());
- return e.getError();
- }
-
- LOGD("LEAVE");
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_object_detection_3d_get_points_open(mv_object_detection_3d_h handle, unsigned int **out_x, unsigned int **out_y)
-{
- LOGD("ENTER");
-
- lock_guard<mutex> lock(g_object_detection_3d_mutex);
-
- if (!handle) {
- LOGE("Handle is NULL.");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- try {
- Context *context = static_cast<Context *>(handle);
- auto task = static_cast<ObjectDetection3dTask *>(context->__tasks.at("object_detection_3d"));
-
- ObjectDetection3dResult &result = task->getOutput();
-
- *out_x = result.x_vec.data();
- *out_y = result.y_vec.data();
-
- for (auto &edge : result.edge_index_vec)
- LOGI("%d,%d ", edge.start, edge.end);
-
- for (unsigned int i = 0; i < result.number_of_points; ++i)
- LOGI("%d %d", (*out_x)[i], (*out_y)[i]);
- } catch (const BaseException &e) {
- LOGE("%s", e.what());
- return e.getError();
- }
-
- LOGD("LEAVE");
-
- return MEDIA_VISION_ERROR_NONE;
-}
\ No newline at end of file