mv_machine_learning: merge mv_inference.cpp and mv_inference_open.cpp 46/304546/3
authorVibhav Aggarwal <v.aggarwal@samsung.com>
Fri, 19 Jan 2024 07:20:12 +0000 (16:20 +0900)
committerInki Dae <inki.dae@samsung.com>
Tue, 23 Jan 2024 06:57:42 +0000 (06:57 +0000)
[Issue type] code cleanup

Change-Id: Icda88605c20ab7f764588c14a197a6cc5ed5e67e
Signed-off-by: Vibhav Aggarwal <v.aggarwal@samsung.com>
mv_machine_learning/inference/include/mv_inference_open.h [deleted file]
mv_machine_learning/inference/src/mv_inference.cpp
mv_machine_learning/inference/src/mv_inference_open.cpp [deleted file]

diff --git a/mv_machine_learning/inference/include/mv_inference_open.h b/mv_machine_learning/inference/include/mv_inference_open.h
deleted file mode 100644 (file)
index 1001a29..0000000
+++ /dev/null
@@ -1,574 +0,0 @@
-/**
- * Copyright (c) 2019 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_INFERENCE_OPEN_H__
-#define __MEDIA_VISION_INFERENCE_OPEN_H__
-
-#include <mv_common.h>
-#include <mv_inference_type.h>
-#include <mv_inference.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-/**
-        * @file   mv_inference_open.h
-        * @brief  This file contains the Media Vision Inference Open API.
-        */
-
-/*************/
-/* Inference */
-/*************/
-
-mv_engine_config_h mv_inference_get_engine_config(mv_inference_h infer);
-
-/**
-        * @brief Create infernce handle.
-        * @details Use this function to create an inference handle. After creation
-        *          the inference handle has to be prepared with
-        *          @ref mv_inference_prepare() function to prepare an inference.
-        *
-        * @since_tizen 5.5
-        *
-        * @param [out] infer    The handle to the inference 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 infer by using
-        *       @ref mv_inference_destroy() function when it is not needed
-        *       anymore
-        *
-        * @see mv_inference_destroy_open()
-        * @see mv_inference_prepare_open()
-        */
-int mv_inference_create_open(mv_inference_h *infer);
-
-/**
-        * @brief Destroy inference handle and releases all its resources.
-        *
-        * @since_tizen 5.5
-        *
-        * @param [in] infer    The handle to the inference 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 inference handle by using @ref mv_inference_create_open()
-        *
-        * @see mv_inference_create_open()
-        */
-int mv_inference_destroy_open(mv_inference_h infer);
-
-/**
-        * @brief Configure the backend to the inference handle
-        *
-        * @since_tizen 5.5
-        *
-        * @param [in] infer         The handle to the inference
-        * @param [in] engine_config The handle to the configuration of
-        *                           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
-        *                                               in @a engine_config
-        * @retval #MEDIA_VISION_ERROR_INVALID_PATH Invalid path of model data
-        *                                          in @a engine_config
-        * @retval #MEDIA_VISION_ERROR_INVALID_DATA Invalid model data
-        * @retval #MEDIA_VISION_ERROR_OUT_OF_MEMORY Out of memory
-        * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported
-        */
-int mv_inference_configure_engine_open(mv_inference_h infer, mv_engine_config_h engine_config);
-
-/**
-        * @brief Configure the number of output to the inference handle
-        *
-        * @since_tizen 5.5
-        * @remarks deprecated Replaced by mv_inference_configure_post_process_info_open
-        *
-        * @param [in] infer         The handle to the inference
-        * @param [in] engine_config The handle to the configuration of
-        *                           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
-        *                                               in @a engine_config
-        * @retval #MEDIA_VISION_ERROR_INVALID_PATH Invalid path of model data
-        *                                          in @a engine_config
-        * @retval #MEDIA_VISION_ERROR_INVALID_DATA Invalid model data
-        * @retval #MEDIA_VISION_ERROR_OUT_OF_MEMORY Out of memory
-        * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported
-        */
-int mv_inference_configure_output_open(mv_inference_h infer, mv_engine_config_h engine_config);
-
-/**
-        * @brief Configure the confidence threshold value to the inference handle
-        *
-        * @since_tizen 5.5
-        * @remarks deprecated Replaced by mv_inference_configure_post_process_info_open
-        *
-        * @param [in] infer         The handle to the inference
-        * @param [in] engine_config The handle to the configuration of
-        *                           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
-        *                                               in @a engine_config
-        * @retval #MEDIA_VISION_ERROR_INVALID_PATH Invalid path of model data
-        *                                          in @a engine_config
-        * @retval #MEDIA_VISION_ERROR_INVALID_DATA Invalid model data
-        * @retval #MEDIA_VISION_ERROR_OUT_OF_MEMORY Out of memory
-        * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported
-        */
-int mv_inference_configure_confidence_threshold_open(mv_inference_h infer, mv_engine_config_h engine_config);
-
-/**
-        * @brief Configure the set of output node names to the inference handle
-        *
-        * @since_tizen 5.5
-        * @remarks deprecated Replaced by mv_inference_configure_output_info_open
-        *
-        * @param [in] infer         The handle to the inference
-        * @param [in] engine_config The handle to the configuration of
-        *                           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
-        *                                               in @a engine_config
-        * @retval #MEDIA_VISION_ERROR_INVALID_PATH Invalid path of model data
-        *                                          in @a engine_config
-        * @retval #MEDIA_VISION_ERROR_INVALID_DATA Invalid model data
-        * @retval #MEDIA_VISION_ERROR_OUT_OF_MEMORY Out of memory
-        * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported
-        */
-int mv_inference_configure_output_node_names_open(mv_inference_h infer, mv_engine_config_h engine_config);
-
-/**
-        * @brief Prepare inference.
-        * @details Use this function to prepare inference based on
-        *          the configured network.
-        *
-        * @since_tizen 5.5
-        *
-        * @param [in] infer         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_PARAMETER Invalid parameter
-        *                                               in @a engine_config
-        * @retval #MEDIA_VISION_ERROR_INVALID_PATH Invalid path of model data
-        *                                          in @a engine_config
-        * @retval #MEDIA_VISION_ERROR_INVALID_DATA Invalid model data
-        * @retval #MEDIA_VISION_ERROR_OUT_OF_MEMORY Out of memory
-        */
-int mv_inference_prepare_open(mv_inference_h infer);
-
-/**
-        * @brief Traverses the list of supported engines for inference.
-        * @details Using this function the supported engines can be obtained.
-        *          The names can be used with mv_engine_config_h related
-        *          getters and setters to get/set MV_INFERENCE_BACKEND_TYPE attribute
-        *          value.
-        *
-        * @since_tizen 5.5
-        * @param [in] infer The handle to the inference
-        * @param [in] callback The iteration callback function
-        * @param [in] user_data The user data to be passed to the callback function
-        * @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
-        * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported
-        *
-        * @pre @a engine_cfg must be created
-        *
-        * @see mv_engine_config_set_string_attribute()
-        * @see mv_engine_config_get_string_attribute()
-        */
-int mv_inference_foreach_supported_engine_open(mv_inference_h infer, mv_inference_supported_engine_cb callback,
-                                                                                          void *user_data);
-
-/**
-        * @brief Performs image classification on the @a source
-        * @details Use this function to launch image classification.
-        *          Each time when mv_inference_image_classify is
-        *          called, @a classified_cb will receive classes
-        *          which the media source may belong to.
-        *
-        * @since_tizen 5.5
-        *
-        * @param [in] source         The handle to the source of the media
-        * @param [in] infer          The handle to the inference
-        * @param [in] roi            Rectangular box bounding the region-of-interest on the
-        *                           @a source. If NULL, then full source will be
-        *                           analyzed.
-        * @param [in] classified_cb  The callback which will be called for
-        *                            classification on media source.
-        *                            This callback will receive classification results.
-        * @param [in] user_data      The user data passed from the code where
-        *                            @ref mv_inference_image_classify_open() is invoked. This data will
-        *                            be accessible from @a classified_cb callback.
-        * @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_INTERNAL          Internal error
-        * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED_FORMAT Source colorspace
-        *                                                  isn't supported
-        * @retval #MEDIA_VISION_ERROR_OUT_OF_MEMORY Out of memory
-        * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported
-        *
-        * @pre Create a source handle by calling @ref mv_create_source()
-        * @pre Create an inference handle by calling @ref mv_inference_create()
-        * @pre Configure an inference handle by calling @ref mv_inference_configure()
-        * @pre Prepare an inference by calling @ref mv_inference_prepare()
-        * @post @a classified_cb will be called to process classification results
-        *
-        * @see mv_inference_image_classified_cb
-        */
-int mv_inference_image_classify_open(mv_source_h source, mv_inference_h infer, mv_rectangle_s *roi,
-                                                                        mv_inference_image_classified_cb classified_cb, void *user_data);
-
-/**
-        * @brief Performs object detection on the @a source
-        * @details Use this function to launch object detection.
-        *          Each time when mv_inference_object_detection is
-        *          called, @a detected_cb will receive  a list of objects and their locations
-        *          on the media source.
-        *
-        * @since_tizen 5.5
-        *
-        * @param [in] source         The handle to the source of the media
-        * @param [in] infer          The handle to the inference
-        * @param [in] detected_cb    The callback which will be called for
-        *                            detecting objects on media source.
-        *                            This callback will receive the detection results.
-        * @param [in] user_data      The user data passed from the code where
-        *                            @ref mv_inference_object_detect() is invoked. This data will
-        *                            be accessible from @a detected_cb callback.
-        * @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_INTERNAL          Internal error
-        * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED_FORMAT Source colorspace
-        *                                                  isn't supported
-        * @retval #MEDIA_VISION_ERROR_OUT_OF_MEMORY Out of memory
-        * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported
-        *
-        * @pre Create a source handle by calling @ref mv_create_source()
-        * @pre Create an inference handle by calling @ref mv_inference_create()
-        * @pre Configure an inference handle by calling @ref mv_inference_configure()
-        * @pre Prepare an inference by calling @ref mv_inference_prepare()
-        * @post @a detected_cb will be called to process detection results
-        *
-        * @see mv_inference_object_detected_cb
-        */
-int mv_inference_object_detect_open(mv_source_h source, mv_inference_h infer,
-                                                                       mv_inference_object_detected_cb detected_cb, void *user_data);
-
-/**
-        * @brief Performs face detection on the @a source
-        * @details Use this function to launch face detection.
-        *          Each time when mv_inference_face_detection is
-        *          called, @a detected_cb will receive  a list of faces and their locations
-        *          on the media source.
-        *
-        * @since_tizen 5.5
-        *
-        * @param [in] source         The handle to the source of the media
-        * @param [in] infer          The handle to the inference
-        * @param [in] detected_cb    The callback which will be called for
-        *                            detecting faces on media source.
-        *                            This callback will receive the detection results.
-        * @param [in] user_data      The user data passed from the code where
-        *                            @ref mv_inference_face_detect() is invoked. This data will
-        *                            be accessible from @a detected_cb callback.
-        * @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_INTERNAL          Internal error
-        * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED_FORMAT Source colorspace
-        *                                                  isn't supported
-        * @retval #MEDIA_VISION_ERROR_OUT_OF_MEMORY Out of memory
-        * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported
-        *
-        * @pre Create a source handle by calling @ref mv_create_source()
-        * @pre Create an inference handle by calling @ref mv_inference_create()
-        * @pre Configure an inference handle by calling @ref mv_inference_configure()
-        * @pre Prepare an inference by calling @ref mv_inference_prepare()
-        * @post @a detected_cb will be called to process detection results
-        *
-        * @see mv_inference_face_detected_cb
-        */
-int mv_inference_face_detect_open(mv_source_h source, mv_inference_h infer, mv_inference_face_detected_cb detected_cb,
-                                                                 void *user_data);
-
-/**
-        * @brief Performs facial landmarks detection on the @a source
-        * @details Use this function to launch facial landmark detection.
-        *          Each time when mv_inference_facial_landmark_detect() is
-        *          called, @a detected_cb will receive a list facial landmark's locations
-        *          on the media source.
-        *
-        * @since_tizen 5.5
-        *
-        * @param [in] source         The handle to the source of the media
-        * @param [in] infer          The handle to the inference
-        * @param[in] roi            Rectangular box bounding face image on the
-        *                           @a source. If NULL, then full source will be
-        *                           analyzed.
-        * @param [in] detected_cb    The callback which will be called for
-        *                            detecting facial landmark on media source.
-        *                            This callback will receive the detection results.
-        * @param [in] user_data      The user data passed from the code where
-        *                            @ref mv_inference_facial_landmark_detect() is invoked.
-        *                            This data will be accessible from @a detected_cb callback.
-        *
-        * @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_INTERNAL          Internal error
-        * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED_FORMAT Source colorspace
-        *                                                  isn't supported
-        * @retval #MEDIA_VISION_ERROR_OUT_OF_MEMORY Out of memory
-        * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported
-        *
-        * @pre Create a source handle by calling @ref mv_create_source()
-        * @pre Create an inference handle by calling @ref mv_inference_create()
-        * @pre Configure an inference handle by calling @ref mv_inference_configure()
-        * @pre Prepare an inference by calling @ref mv_inference_prepare()
-        * @post @a detected_cb will be called to process detection results
-        *
-        * @see mv_inference_facial_landmark_detected_cb
-        */
-int mv_inference_facial_landmark_detect_open(mv_source_h source, mv_inference_h infer, mv_rectangle_s *roi,
-                                                                                        mv_inference_facial_landmark_detected_cb detected_cb, void *user_data);
-
-/**
-        * @brief Performs pose landmarks detection on the @a source.
-        * @details Use this function to launch pose landmark detection.
-        *          Each time when mv_inference_pose_landmark_detect_open() is
-        *          called, @a detected_cb will receive a list pose landmark's locations
-        *          in the media source.
-        *
-        * @since_tizen 6.0
-        * @remarks This function is synchronous and may take considerable time to run.
-        *
-        * @param[in] source         The handle to the source of the media
-        * @param[in] infer          The handle to the inference
-        * @param[in] roi            Rectangular area including a face in @a source which
-        *                           will be analyzed. If NULL, then the whole source will be
-        *                           analyzed.
-        * @param[in] detected_cb    The callback which will receive the detection results.
-        * @param[in] user_data      The user data passed from the code where
-        *                           mv_inference_pose_landmark_detect_open() is invoked.
-        *                           This data will be accessible in @a detected_cb callback.
-        * @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
-        * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED_FORMAT Source colorspace
-        *                                                  isn't supported
-        *
-        * @pre Create a source handle by calling mv_create_source_open()
-        * @pre Create an inference handle by calling mv_inference_create_open()
-        * @pre Configure an inference handle by calling mv_inference_configure_open()
-        * @pre Prepare an inference by calling mv_inference_prepare_open()
-        * @post @a detected_cb will be called to provide detection results
-        *
-        * @see mv_inference_pose_landmark_detected_cb()
-        */
-int mv_inference_pose_landmark_detect_open(mv_source_h source, mv_inference_h infer, mv_rectangle_s *roi,
-                                                                                  mv_inference_pose_landmark_detected_cb detected_cb, void *user_data);
-
-/**
-        * @brief Gets the number of pose.
-        *
-        * @since_tizen 6.0
-        *
-        * @param[in] result                    The handle to inference result
-        * @param[out] number_of_poses  The pointer to the number of poses
-        *
-        * @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
-        */
-int mv_inference_pose_get_number_of_poses_open(mv_inference_pose_result_h result, int *number_of_poses);
-
-/**
-        * @brief Gets the number of landmark per a pose.
-        *
-        * @since_tizen 6.0
-        *
-        * @param[in] result                            The handle to inference result
-        * @param[out] number_of_landmarks  The pointer to the number of landmarks
-        *
-        * @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
-        */
-int mv_inference_pose_get_number_of_landmarks_open(mv_inference_pose_result_h result, int *number_of_landmarks);
-
-/**
-        * @brief Gets landmark location of a part of a pose.
-        *
-        * @since_tizen 6.0
-        *
-        * @param[in] result            The handle to inference result
-        * @param[in] pose_index                The pose index
-        * @param[in] pose_part         The part of a pose
-        * @param[out] location         The location of a landmark
-        * @param[out] score            The score of a landmark
-        *
-        * @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
-        *
-        */
-int mv_inference_pose_get_landmark_open(mv_inference_pose_result_h result, int pose_index, int part_index,
-                                                                               mv_point_s *location, float *score);
-
-/**
-        * @brief Gets a label of a pose.
-        *
-        * @since_tizen 6.0
-        *
-        * @param[in] result            The handle to inference result
-        * @param[in] pose_index        The pose index between 0 and
-        *                              the number of poses which can be gotten by
-        *                              mv_inference_pose_get_number_of_poses()
-        * @param[out] label         The label of a pose
-        *
-        * @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
-        *
-        * @see mv_inference_pose_get_number_of_poses()
-        * @see mv_inference_pose_get_number_of_landmarks()
-        * @see mv_inference_pose_landmark_detected_cb()
-        * @see mv_inference_pose_result_h
-        */
-int mv_inference_pose_get_label_open(mv_inference_pose_result_h result, int pose_index, int *label);
-
-/**
-        * @brief Creates pose handle.
-        * @details Use this function to create a pose.
-        *
-        * @since_tizen 6.0
-        *
-        * @remarks The @a pose should be released using mv_pose_destroy_open().
-        *
-        * @param[out] infer    The handle to the pose to be created
-        *
-        * @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_OUT_OF_MEMORY Out of memory
-        *
-        * @see mv_pose_destroy_open()
-        */
-int mv_pose_create_open(mv_pose_h *pose);
-
-/**
-        * @brief Destroys pose handle and releases all its resources.
-        *
-        * @since_tizen 6.0
-        *
-        * @param[in] pose    The handle to the pose to be destroyed
-        *
-        * @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
-        *
-        * @pre Create pose handle by using mv_pose_create_open()
-        *
-        * @see mv_pose_create_open()
-        */
-int mv_pose_destroy_open(mv_pose_h pose);
-
-/**
-        * @brief Sets a motion capture file and its pose mapping file to the pose.
-        * @details Use this function to set a motion capture file and
-        *          its pose mapping file. These are used by mv_pose_compare_open()
-        *          to compare a given pose by mv_inference_pose_landmark_estimation_open().
-        *
-        * @since_tizen 6.0
-        * @remarks If the app sets paths to media storage,
-        *          then the media storage privilege
-        *          %http://tizen.org/privilege/mediastorage is needed.\n
-        *          If the app sets the paths to external storage,
-        *          then the external storage privilege
-        *          %http://tizen.org/privilege/externalstorage is needed.\n
-        *          If the required privileges aren't set properly,
-        *          mv_pose_set_from_file_open() will returned #MEDIA_VISION_ERROR_PERMISSION_DENIED.
-        *
-        * @param[in] pose                  The handle to the pose
-        * @param[in] motionCaptureFilePath The file path to the motion capture file
-        * @param[in] motionMappingFilePath The file path to the motion mapping file
-        *
-        * @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_PERMISSION_DENIED Permission denied
-        * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
-        * @retval #MEDIA_VISION_ERROR_INVALID_PATH Invalid path of file paths
-        * @retval #MEDIA_VISION_ERROR_INTERNAL Internal error
-        */
-int mv_pose_set_from_file_open(mv_pose_h pose, const char *motionCaptureFilePath, const char *motionMappingFilePath);
-
-/**
-        * @brief Compares an action pose with the pose which is set by mv_pose_set_from_file_open().
-        * @details Use this function to compare action pose with the pose
-        *          which is set by mv_pose_set_from_file_open().
-        *          Parts to be compared can be selected by #mv_inference_human_body_part_e.
-        *          Their similarity can be given by the score between 0 ~ 1.
-        *
-        * @since_tizen 6.0
-        *
-        * @param[in] pose   The handle to the pose
-        * @param[in] action The action pose
-        * @param[in] parts  The parts to be compared
-        * @param[out] score The similarity score
-        *
-        * @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_INVALID_OPERATION Invalid operation
-        *
-        * @pre Sets the pose by using mv_pose_set_from_file()
-        */
-int mv_pose_compare_open(mv_pose_h pose, mv_inference_pose_result_h action, int parts, float *score);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* __MEDIA_VISION_INFERENCE_OPEN_H__ */
index 80aafacb3e1f0565bbe5ba8c6335da10da75c24b..84dc65a7ef070e4f842171ca36801f5a3bf3eb45 100644 (file)
 #include "mv_private.h"
 #include "mv_feature_key.h"
 #include "mv_inference.h"
-#include "mv_inference_open.h"
+#include "Inference.h"
+#include "Posture.h"
+
+#include <new>
+#include <unistd.h>
+#include <string>
+#include <mv_common.h>
+#include <mv_inference_type.h>
+#include <mv_inference.h>
 
 /**
  * @file  mv_inference.cpp
@@ -28,6 +36,280 @@ static const char *feature_keys[] = { "http://tizen.org/feature/vision.inference
                                                                          "http://tizen.org/feature/vision.inference.face" };
 static const size_t num_keys = sizeof(feature_keys) / sizeof(char *);
 
+using namespace mediavision::inference;
+
+static bool IsJsonFile(const std::string &fileName)
+{
+       return (!fileName.substr(fileName.find_last_of(".") + 1).compare("json"));
+}
+
+static bool IsValidBackendType(const int backend_type)
+{
+       return (backend_type > MV_INFERENCE_BACKEND_NONE && backend_type < MV_INFERENCE_BACKEND_MAX);
+}
+
+static bool IsConfigFilePathRequired(const int target_device_type, const int backend_type)
+{
+       LOGW("DEPRECATION WARNING : MV_INFERENCE_BACKEND_MLAPI type is deprecated and will be removed from next release.");
+
+       // In case of MV_INFERENCE_TARGET_DEVICE_CUSTOM via MLAPI backend, config file path is required.
+       return (backend_type == MV_INFERENCE_BACKEND_MLAPI && target_device_type & MV_INFERENCE_TARGET_DEVICE_CUSTOM);
+}
+
+mv_engine_config_h mv_inference_get_engine_config(mv_inference_h infer)
+{
+       Inference *pInfer = static_cast<Inference *>(infer);
+
+       return pInfer->getEngineConfig();
+}
+
+static int configure_tensor_info_from_meta_file(Inference *pInfer, mv_engine_config_h engine_config)
+{
+       char *modelMetaFilePath = NULL;
+
+       int ret =
+                       mv_engine_config_get_string_attribute(engine_config, MV_INFERENCE_MODEL_META_FILE_PATH, &modelMetaFilePath);
+       if (ret != MEDIA_VISION_ERROR_NONE) {
+               LOGE("Fail to get model meta file path");
+               goto out_of_function;
+       }
+
+       if (std::string(modelMetaFilePath).empty()) {
+               LOGW("Skip ParseMetadata and run without Metadata");
+               ret = MEDIA_VISION_ERROR_INVALID_OPERATION;
+               goto release_model_meta_file_path;
+       }
+
+       if (!IsJsonFile(std::string(modelMetaFilePath))) {
+               ret = MEDIA_VISION_ERROR_INVALID_PATH;
+               LOGE("Model meta file should be json");
+               goto release_model_meta_file_path;
+       }
+
+       ret = pInfer->parseMetadata(std::string(modelMetaFilePath));
+       if (ret != MEDIA_VISION_ERROR_NONE) {
+               LOGE("Fail to ParseMetadata");
+       }
+
+release_model_meta_file_path:
+       free(modelMetaFilePath);
+
+out_of_function:
+       LOGI("LEAVE");
+
+       return ret;
+}
+
+static int configure_model(Inference *pInfer, mv_engine_config_h engine_config)
+{
+       LOGI("ENTER");
+
+       char *modelConfigFilePath = NULL;
+       char *modelWeightFilePath = NULL;
+       char *modelUserFilePath = NULL;
+       int backendType = 0;
+       size_t userFileLength = 0;
+
+       int ret = mv_engine_config_get_string_attribute(engine_config, MV_INFERENCE_MODEL_CONFIGURATION_FILE_PATH,
+                                                                                                       &modelConfigFilePath);
+       if (ret != MEDIA_VISION_ERROR_NONE) {
+               LOGE("Fail to get model configuration file path");
+               goto out_of_function;
+       }
+
+       ret = mv_engine_config_get_string_attribute(engine_config, MV_INFERENCE_MODEL_WEIGHT_FILE_PATH,
+                                                                                               &modelWeightFilePath);
+       if (ret != MEDIA_VISION_ERROR_NONE) {
+               LOGE("Fail to get model weight file path");
+               goto release_model_config_file_path;
+       }
+
+       ret = mv_engine_config_get_string_attribute(engine_config, MV_INFERENCE_MODEL_USER_FILE_PATH, &modelUserFilePath);
+       if (ret != MEDIA_VISION_ERROR_NONE) {
+               LOGE("Fail to get model user file path");
+               goto release_model_weight_file_path;
+       }
+
+       ret = mv_engine_config_get_int_attribute(engine_config, MV_INFERENCE_BACKEND_TYPE, &backendType);
+       if (ret != MEDIA_VISION_ERROR_NONE) {
+               LOGE("Fail to get inference backend type");
+               goto release_model_user_file_path;
+       }
+
+       if (!IsValidBackendType(backendType)) {
+               LOGE("Invalid backend type(%d).", backendType);
+               ret = MEDIA_VISION_ERROR_INVALID_PARAMETER;
+               goto release_model_user_file_path;
+       }
+
+       if (access(modelWeightFilePath, F_OK)) {
+               LOGE("weightFilePath in [%s] ", modelWeightFilePath);
+               ret = MEDIA_VISION_ERROR_INVALID_PATH;
+               goto release_model_user_file_path;
+       }
+
+       if (IsConfigFilePathRequired(pInfer->getTargetType(), backendType)) {
+               if (access(modelConfigFilePath, F_OK)) {
+                       LOGE("modelConfigFilePath in [%s] ", modelConfigFilePath);
+                       ret = MEDIA_VISION_ERROR_INVALID_PATH;
+                       goto release_model_user_file_path;
+               }
+       }
+
+       userFileLength = strlen(modelUserFilePath);
+
+       if (userFileLength > 0 && access(modelUserFilePath, F_OK)) {
+               LOGE("categoryFilePath in [%s] ", modelUserFilePath);
+               ret = MEDIA_VISION_ERROR_INVALID_PATH;
+               goto release_model_user_file_path;
+       }
+
+       pInfer->configureModelFiles(std::string(modelConfigFilePath), std::string(modelWeightFilePath),
+                                                               std::string(modelUserFilePath));
+
+release_model_user_file_path:
+       free(modelUserFilePath);
+
+release_model_weight_file_path:
+       free(modelWeightFilePath);
+
+release_model_config_file_path:
+       free(modelConfigFilePath);
+
+out_of_function:
+       LOGI("LEAVE");
+
+       return ret;
+}
+
+static int configure_input_info(Inference *pInfer, mv_engine_config_h engine_config)
+{
+       LOGI("ENTER");
+
+       int tensorWidth, tensorHeight, tensorCh;
+       double meanValue, stdValue;
+       char *node_name = NULL;
+       int dataType = 0;
+
+       int ret = mv_engine_config_get_int_attribute(engine_config, MV_INFERENCE_INPUT_TENSOR_WIDTH, &tensorWidth);
+       if (ret != MEDIA_VISION_ERROR_NONE) {
+               LOGE("Fail to get tensor width");
+               goto out_of_function;
+       }
+
+       ret = mv_engine_config_get_int_attribute(engine_config, MV_INFERENCE_INPUT_TENSOR_HEIGHT, &tensorHeight);
+       if (ret != MEDIA_VISION_ERROR_NONE) {
+               LOGE("Fail to get tensor height");
+               goto out_of_function;
+       }
+
+       ret = mv_engine_config_get_int_attribute(engine_config, MV_INFERENCE_INPUT_TENSOR_CHANNELS, &tensorCh);
+       if (ret != MEDIA_VISION_ERROR_NONE) {
+               LOGE("Fail to get tensor channels");
+               goto out_of_function;
+       }
+
+       ret = mv_engine_config_get_double_attribute(engine_config, MV_INFERENCE_MODEL_MEAN_VALUE, &meanValue);
+       if (ret != MEDIA_VISION_ERROR_NONE) {
+               LOGE("Fail to get meanValue");
+               goto out_of_function;
+       }
+
+       ret = mv_engine_config_get_double_attribute(engine_config, MV_INFERENCE_MODEL_STD_VALUE, &stdValue);
+       if (ret != MEDIA_VISION_ERROR_NONE) {
+               LOGE("Fail to get stdValue");
+               goto out_of_function;
+       }
+
+       ret = mv_engine_config_get_int_attribute(engine_config, MV_INFERENCE_INPUT_DATA_TYPE, &dataType);
+       if (ret != MEDIA_VISION_ERROR_NONE) {
+               LOGE("Fail to get a input tensor data type");
+               goto out_of_function;
+       }
+
+       ret = mv_engine_config_get_string_attribute(engine_config, MV_INFERENCE_INPUT_NODE_NAME, &node_name);
+       if (ret != MEDIA_VISION_ERROR_NONE) {
+               LOGE("Fail to get tensor width");
+               goto out_of_function;
+       }
+
+       pInfer->configureInputInfo(tensorWidth, tensorHeight, 1, tensorCh, stdValue, meanValue, dataType,
+                                                          std::vector<std::string>(1, std::string(node_name)));
+
+       free(node_name);
+       node_name = NULL;
+
+out_of_function:
+       LOGI("LEAVE");
+
+       return ret;
+}
+
+static int configure_post_process_info(Inference *pInfer, mv_engine_config_h engine_config)
+{
+       LOGI("ENTER");
+
+       int maxOutput = 0;
+       double threshold = 0;
+
+       int ret = mv_engine_config_get_int_attribute(engine_config, MV_INFERENCE_OUTPUT_MAX_NUMBER, &maxOutput);
+       if (ret != MEDIA_VISION_ERROR_NONE) {
+               LOGE("Fail to get inference output maximum numbers");
+               goto out_of_function;
+       }
+
+       pInfer->configureOutput(maxOutput);
+
+       ret = mv_engine_config_get_double_attribute(engine_config, MV_INFERENCE_CONFIDENCE_THRESHOLD, &threshold);
+       if (ret != MEDIA_VISION_ERROR_NONE) {
+               LOGE("Fail to get inference confidence threshold value");
+               goto out_of_function;
+       }
+
+       pInfer->configureThreshold(threshold);
+
+out_of_function:
+       LOGI("LEAVE");
+
+       return ret;
+}
+
+static int configure_output_info(Inference *pInfer, mv_engine_config_h engine_config)
+{
+       LOGI("ENTER");
+
+       int idx = 0;
+       char **node_names = NULL;
+       int size = 0;
+       std::vector<std::string> names;
+
+       int ret = mv_engine_config_get_array_string_attribute(engine_config, MV_INFERENCE_OUTPUT_NODE_NAMES, &node_names,
+                                                                                                                 &size);
+       if (ret != MEDIA_VISION_ERROR_NONE) {
+               LOGE("Fail to get _output_node_names");
+               return ret;
+       }
+
+       for (idx = 0; idx < size; ++idx)
+               names.push_back(std::string(node_names[idx]));
+
+       std::vector<inference_engine_tensor_info> tensors_info;
+
+       pInfer->configureOutputInfo(names, tensors_info);
+
+       if (node_names) {
+               for (idx = 0; idx < size; ++idx)
+                       free(node_names[idx]);
+
+               free(node_names);
+               node_names = NULL;
+       }
+
+       LOGI("LEAVE");
+
+       return ret;
+}
+
 int mv_inference_create(mv_inference_h *infer)
 {
        MEDIA_VISION_SUPPORT_CHECK(mv_check_feature_key(feature_keys, num_keys, true));
@@ -37,7 +319,14 @@ int mv_inference_create(mv_inference_h *infer)
 
        int ret = MEDIA_VISION_ERROR_NONE;
 
-       ret = mv_inference_create_open(infer);
+       (*infer) = static_cast<mv_inference_h>(new (std::nothrow) Inference());
+
+       if (*infer == NULL) {
+               LOGE("Failed to create inference handle");
+               ret = MEDIA_VISION_ERROR_OUT_OF_MEMORY;
+       }
+
+       LOGD("Inference handle [%p] has been created", *infer);
 
        MEDIA_VISION_FUNCTION_LEAVE();
        return ret;
@@ -52,7 +341,9 @@ int mv_inference_destroy(mv_inference_h infer)
 
        int ret = MEDIA_VISION_ERROR_NONE;
 
-       ret = mv_inference_destroy_open(infer);
+       LOGD("Destroying inference handle [%p]", infer);
+       delete static_cast<Inference *>(infer);
+       LOGD("Inference handle has been destroyed");
 
        MEDIA_VISION_FUNCTION_LEAVE();
        return ret;
@@ -68,9 +359,36 @@ int mv_inference_configure(mv_inference_h infer, mv_engine_config_h engine_confi
 
        int ret = MEDIA_VISION_ERROR_NONE;
 
-       ret = mv_inference_configure_engine_open(infer, engine_config);
+       Inference *pInfer = static_cast<Inference *>(infer);
+       int backendType = 0;
+       int targetTypes = 0;
+
+       pInfer->setEngineConfig(engine_config);
+
+       ret = mv_engine_config_get_int_attribute(engine_config, MV_INFERENCE_BACKEND_TYPE, &backendType);
+       if (ret != MEDIA_VISION_ERROR_NONE) {
+               LOGE("Fail to get inference backend type");
+               return ret;
+       }
+
+       ret = mv_engine_config_get_int_attribute(engine_config, MV_INFERENCE_TARGET_DEVICE_TYPE, &targetTypes);
        if (ret != MEDIA_VISION_ERROR_NONE) {
-               LOGE("Fail to configure engine and target");
+               LOGE("Fail to get inference target type");
+               return ret;
+       }
+
+       // Set target device type.
+       if (pInfer->configureTargetDevices(targetTypes) != MEDIA_VISION_ERROR_NONE) {
+               LOGE("Tried to configure invalid target types.");
+               return ret;
+       }
+
+       // Create a inference-engine-common class object and load its corresponding library.
+       // Ps. Inference engine gets a capability from a given backend by Bind call
+       // so access to mBackendCapacity should be done after Bind.
+       ret = pInfer->bind(backendType, targetTypes);
+       if (ret != MEDIA_VISION_ERROR_NONE) {
+               LOGE("Fail to bind a backend engine.");
                return ret;
        }
 
@@ -87,7 +405,57 @@ int mv_inference_prepare(mv_inference_h infer)
 
        int ret = MEDIA_VISION_ERROR_NONE;
 
-       ret = mv_inference_prepare_open(infer);
+       Inference *pInfer = static_cast<Inference *>(infer);
+       mv_engine_config_h engine_config = mv_inference_get_engine_config(infer);
+
+       ret = configure_model(pInfer, engine_config);
+       if (ret != MEDIA_VISION_ERROR_NONE) {
+               LOGE("Fail to configure model");
+               return ret;
+       }
+
+       // If input and output tensor info aren't configured from model meta file then
+       // use legacy way for the configuration. TODO. the legacy way will be deprecated.
+       ret = configure_tensor_info_from_meta_file(pInfer, engine_config);
+       if (ret != MEDIA_VISION_ERROR_NONE) {
+               // input tensor, input layer
+               ret = configure_input_info(pInfer, engine_config);
+               if (ret != MEDIA_VISION_ERROR_NONE) {
+                       LOGE("Fail to configure input info");
+                       return ret;
+               }
+
+               // output layer
+               ret = configure_output_info(pInfer, engine_config);
+               if (ret != MEDIA_VISION_ERROR_NONE) {
+                       LOGE("Fail to configure output info");
+                       return ret;
+               }
+
+               // maximum candidates, threshold
+               ret = configure_post_process_info(pInfer, engine_config);
+               if (ret != MEDIA_VISION_ERROR_NONE) {
+                       LOGE("Fail to configure post process info");
+                       return ret;
+               }
+       } else {
+               ret = pInfer->configureInputMetaInfo();
+               if (ret != MEDIA_VISION_ERROR_NONE) {
+                       LOGE("Fail to configure input meta info.");
+                       return ret;
+               }
+
+               ret = pInfer->configureOutputMetaInfo();
+               if (ret != MEDIA_VISION_ERROR_NONE) {
+                       LOGE("Fail to configure output meta info.");
+                       return ret;
+               }
+       }
+
+       // Request to load model files to a backend engine.
+       ret = pInfer->load();
+       if (ret != MEDIA_VISION_ERROR_NONE)
+               LOGE("Fail to load model files.");
 
        MEDIA_VISION_FUNCTION_LEAVE();
        return ret;
@@ -103,7 +471,13 @@ int mv_inference_foreach_supported_engine(mv_inference_h infer, mv_inference_sup
 
        int ret = MEDIA_VISION_ERROR_NONE;
 
-       ret = mv_inference_foreach_supported_engine_open(infer, callback, user_data);
+       Inference *pInfer = static_cast<Inference *>(infer);
+       std::pair<std::string, bool> backend;
+
+       for (int i = 0; i < MV_INFERENCE_BACKEND_MAX; ++i) {
+               backend = pInfer->getSupportedInferenceBackend(i);
+               callback((backend.first).c_str(), backend.second, user_data);
+       }
 
        MEDIA_VISION_FUNCTION_LEAVE();
 
@@ -122,7 +496,47 @@ int mv_inference_image_classify(mv_source_h source, mv_inference_h infer, mv_rec
 
        int ret = MEDIA_VISION_ERROR_NONE;
 
-       ret = mv_inference_image_classify_open(source, infer, roi, classified_cb, user_data);
+       Inference *pInfer = static_cast<Inference *>(infer);
+       std::vector<mv_source_h> sources;
+       std::vector<mv_rectangle_s> rects;
+
+       sources.push_back(source);
+
+       if (roi != NULL)
+               rects.push_back(*roi);
+
+       ret = pInfer->run(sources, rects);
+       if (ret != MEDIA_VISION_ERROR_NONE) {
+               LOGE("Fail to run inference");
+               return ret;
+       }
+
+       ImageClassificationResults classificationResults;
+
+       ret = pInfer->getClassficationResults(&classificationResults);
+       if (ret != MEDIA_VISION_ERROR_NONE) {
+               LOGE("Fail to get inference results");
+               return ret;
+       }
+
+       int numberOfOutputs = classificationResults.number_of_classes;
+       static const int START_CLASS_NUMBER = 10;
+       static std::vector<const char *> names(START_CLASS_NUMBER);
+
+       if (numberOfOutputs > START_CLASS_NUMBER)
+               names.resize(numberOfOutputs);
+
+       LOGI("mv_inference: number_of_classes: %d\n", numberOfOutputs);
+
+       for (int output_index = 0; output_index < numberOfOutputs; ++output_index) {
+               LOGI("names: %s", classificationResults.names[output_index].c_str());
+               names[output_index] = classificationResults.names[output_index].c_str();
+       }
+
+       auto *indices = classificationResults.indices.data();
+       auto *confidences = classificationResults.confidences.data();
+
+       classified_cb(source, numberOfOutputs, indices, names.data(), confidences, user_data);
 
        MEDIA_VISION_FUNCTION_LEAVE();
 
@@ -141,7 +555,51 @@ int mv_inference_object_detect(mv_source_h source, mv_inference_h infer, mv_infe
 
        int ret = MEDIA_VISION_ERROR_NONE;
 
-       ret = mv_inference_object_detect_open(source, infer, detected_cb, user_data);
+       Inference *pInfer = static_cast<Inference *>(infer);
+       std::vector<mv_source_h> sources;
+       std::vector<mv_rectangle_s> rects;
+
+       sources.push_back(source);
+       ret = pInfer->run(sources, rects);
+       if (ret != MEDIA_VISION_ERROR_NONE) {
+               LOGE("Fail to run inference");
+               return ret;
+       }
+
+       ObjectDetectionResults objectDetectionResults;
+
+       ret = pInfer->getObjectDetectionResults(&objectDetectionResults);
+       if (ret != MEDIA_VISION_ERROR_NONE) {
+               LOGE("Fail to get inference results");
+               return ret;
+       }
+
+       int numberOfOutputs = objectDetectionResults.number_of_objects;
+       static const int START_OBJECT_NUMBER = 20;
+       static std::vector<const char *> names(START_OBJECT_NUMBER);
+       static std::vector<mv_rectangle_s> locations(START_OBJECT_NUMBER);
+
+       if (numberOfOutputs > START_OBJECT_NUMBER) {
+               names.resize(numberOfOutputs);
+               locations.resize(numberOfOutputs);
+       }
+
+       for (int output_idx = 0; output_idx < numberOfOutputs; ++output_idx) {
+               LOGI("names: %s", objectDetectionResults.names[output_idx].c_str());
+               names[output_idx] = objectDetectionResults.names[output_idx].c_str();
+
+               locations[output_idx].point.x = objectDetectionResults.locations[output_idx].x;
+               locations[output_idx].point.y = objectDetectionResults.locations[output_idx].y;
+               locations[output_idx].width = objectDetectionResults.locations[output_idx].width;
+               locations[output_idx].height = objectDetectionResults.locations[output_idx].height;
+               LOGI("%d, %d, %d, %d", locations[output_idx].point.x, locations[output_idx].point.y,
+                        locations[output_idx].width, locations[output_idx].height);
+       }
+
+       int *indices = objectDetectionResults.indices.data();
+       float *confidences = objectDetectionResults.confidences.data();
+
+       detected_cb(source, numberOfOutputs, indices, names.data(), confidences, locations.data(), user_data);
 
        MEDIA_VISION_FUNCTION_LEAVE();
 
@@ -160,7 +618,39 @@ int mv_inference_face_detect(mv_source_h source, mv_inference_h infer, mv_infere
 
        int ret = MEDIA_VISION_ERROR_NONE;
 
-       ret = mv_inference_face_detect_open(source, infer, detected_cb, user_data);
+       Inference *pInfer = static_cast<Inference *>(infer);
+       std::vector<mv_source_h> sources;
+       std::vector<mv_rectangle_s> rects;
+
+       sources.push_back(source);
+
+       ret = pInfer->run(sources, rects);
+       if (ret != MEDIA_VISION_ERROR_NONE) {
+               LOGE("Fail to run inference");
+               return ret;
+       }
+
+       FaceDetectionResults faceDetectionResults;
+
+       ret = pInfer->getFaceDetectionResults(&faceDetectionResults);
+       if (ret != MEDIA_VISION_ERROR_NONE) {
+               LOGE("Fail to get inference results");
+               return ret;
+       }
+
+       int numberOfOutputs = faceDetectionResults.number_of_faces;
+       std::vector<mv_rectangle_s> locations(numberOfOutputs);
+
+       for (int output_idx = 0; output_idx < numberOfOutputs; ++output_idx) {
+               locations[output_idx].point.x = faceDetectionResults.locations[output_idx].x;
+               locations[output_idx].point.y = faceDetectionResults.locations[output_idx].y;
+               locations[output_idx].width = faceDetectionResults.locations[output_idx].width;
+               locations[output_idx].height = faceDetectionResults.locations[output_idx].height;
+       }
+
+       float *confidences = faceDetectionResults.confidences.data();
+
+       detected_cb(source, numberOfOutputs, confidences, locations.data(), user_data);
 
        MEDIA_VISION_FUNCTION_LEAVE();
 
@@ -179,7 +669,38 @@ int mv_inference_facial_landmark_detect(mv_source_h source, mv_inference_h infer
 
        int ret = MEDIA_VISION_ERROR_NONE;
 
-       ret = mv_inference_facial_landmark_detect_open(source, infer, roi, detected_cb, user_data);
+       Inference *pInfer = static_cast<Inference *>(infer);
+       std::vector<mv_source_h> sources;
+       std::vector<mv_rectangle_s> rects;
+
+       sources.push_back(source);
+
+       if (roi != NULL)
+               rects.push_back(*roi);
+
+       ret = pInfer->run(sources, rects);
+       if (ret != MEDIA_VISION_ERROR_NONE) {
+               LOGE("Fail to run inference");
+               return ret;
+       }
+
+       FacialLandMarkDetectionResults facialLandMarkDetectionResults;
+
+       ret = pInfer->getFacialLandMarkDetectionResults(&facialLandMarkDetectionResults);
+       if (ret != MEDIA_VISION_ERROR_NONE) {
+               LOGE("Fail to get inference results");
+               return ret;
+       }
+
+       int numberOfLandmarks = facialLandMarkDetectionResults.number_of_landmarks;
+       std::vector<mv_point_s> locations(numberOfLandmarks);
+
+       for (int landmark_idx = 0; landmark_idx < numberOfLandmarks; ++landmark_idx) {
+               locations[landmark_idx].x = facialLandMarkDetectionResults.locations[landmark_idx].x;
+               locations[landmark_idx].y = facialLandMarkDetectionResults.locations[landmark_idx].y;
+       }
+
+       detected_cb(source, numberOfLandmarks, locations.data(), user_data);
 
        MEDIA_VISION_FUNCTION_LEAVE();
 
@@ -198,7 +719,53 @@ int mv_inference_pose_landmark_detect(mv_source_h source, mv_inference_h infer,
 
        int ret = MEDIA_VISION_ERROR_NONE;
 
-       ret = mv_inference_pose_landmark_detect_open(source, infer, roi, detected_cb, user_data);
+       Inference *pInfer = static_cast<Inference *>(infer);
+       unsigned int width, height;
+
+       ret = mv_source_get_width(source, &width);
+       if (ret != MEDIA_VISION_ERROR_NONE) {
+               LOGE("Fail to get width");
+               return ret;
+       }
+
+       ret = mv_source_get_height(source, &height);
+       if (ret != MEDIA_VISION_ERROR_NONE) {
+               LOGE("Fail to get height");
+               return ret;
+       }
+
+       std::vector<mv_source_h> sources;
+       std::vector<mv_rectangle_s> rects;
+
+       sources.push_back(source);
+
+       if (roi != NULL)
+               rects.push_back(*roi);
+
+       ret = pInfer->run(sources, rects);
+       if (ret != MEDIA_VISION_ERROR_NONE) {
+               LOGE("Fail to run inference");
+               return ret;
+       }
+
+       std::unique_ptr<mv_inference_pose_s> pose;
+
+       ret = pInfer->getPoseLandmarkDetectionResults(pose, width, height);
+       if (ret != MEDIA_VISION_ERROR_NONE) {
+               LOGE("Fail to get inference results");
+               return ret;
+       }
+
+       for (int pose_index = 0; pose_index < pose->number_of_poses; ++pose_index) {
+               for (int landmark_index = 0; landmark_index < pose->number_of_landmarks_per_pose; ++landmark_index) {
+                       LOGI("PoseIdx[%2d]: x[%d], y[%d], score[%.3f]", landmark_index,
+                                pose->landmarks[pose_index][landmark_index].point.x,
+                                pose->landmarks[pose_index][landmark_index].point.y,
+                                pose->landmarks[pose_index][landmark_index].score);
+               }
+       }
+
+       detected_cb(source, static_cast<mv_inference_pose_result_h>(pose.get()), user_data);
 
        MEDIA_VISION_FUNCTION_LEAVE();
 
@@ -216,7 +783,9 @@ int mv_inference_pose_get_number_of_poses(mv_inference_pose_result_h result, int
 
        int ret = MEDIA_VISION_ERROR_NONE;
 
-       ret = mv_inference_pose_get_number_of_poses_open(result, number_of_poses);
+       mv_inference_pose_s *handle = static_cast<mv_inference_pose_s *>(result);
+       *number_of_poses = handle->number_of_poses;
+       LOGI("%d", *number_of_poses);
 
        MEDIA_VISION_FUNCTION_LEAVE();
 
@@ -234,7 +803,9 @@ int mv_inference_pose_get_number_of_landmarks(mv_inference_pose_result_h result,
 
        int ret = MEDIA_VISION_ERROR_NONE;
 
-       ret = mv_inference_pose_get_number_of_landmarks_open(result, number_of_landmarks);
+       mv_inference_pose_s *handle = static_cast<mv_inference_pose_s *>(result);
+       *number_of_landmarks = handle->number_of_landmarks_per_pose;
+       LOGI("%d", *number_of_landmarks);
 
        MEDIA_VISION_FUNCTION_LEAVE();
 
@@ -250,14 +821,21 @@ int mv_inference_pose_get_landmark(mv_inference_pose_result_h result, int pose_i
        MEDIA_VISION_NULL_ARG_CHECK(location);
        MEDIA_VISION_NULL_ARG_CHECK(score);
 
-       if (pose_index < 0 || part_index < 0)
-               return MEDIA_VISION_ERROR_INVALID_PARAMETER;
-
        MEDIA_VISION_FUNCTION_ENTER();
 
        int ret = MEDIA_VISION_ERROR_NONE;
 
-       ret = mv_inference_pose_get_landmark_open(result, pose_index, part_index, location, score);
+       mv_inference_pose_s *pose_obj = static_cast<mv_inference_pose_s *>(result);
+
+       if (pose_index < 0 || pose_index >= pose_obj->number_of_poses)
+               return MEDIA_VISION_ERROR_INVALID_PARAMETER;
+
+       if (part_index < 0 || part_index >= pose_obj->number_of_landmarks_per_pose)
+               return MEDIA_VISION_ERROR_INVALID_PARAMETER;
+
+       *location = pose_obj->landmarks[pose_index][part_index].point;
+       *score = pose_obj->landmarks[pose_index][part_index].score;
+       LOGI("[%d]:(%dx%d) - %.4f", pose_index, location->x, location->y, *score);
 
        MEDIA_VISION_FUNCTION_LEAVE();
 
@@ -271,14 +849,17 @@ int mv_inference_pose_get_label(mv_inference_pose_result_h result, int pose_inde
 
        MEDIA_VISION_NULL_ARG_CHECK(label);
 
-       if (pose_index < 0)
-               return MEDIA_VISION_ERROR_INVALID_PARAMETER;
-
        MEDIA_VISION_FUNCTION_ENTER();
 
        int ret = MEDIA_VISION_ERROR_NONE;
 
-       ret = mv_inference_pose_get_label_open(result, pose_index, label);
+       mv_inference_pose_s *pose_obj = static_cast<mv_inference_pose_s *>(result);
+
+       if (pose_index < 0 || pose_index >= pose_obj->number_of_poses)
+               return MEDIA_VISION_ERROR_INVALID_PARAMETER;
+
+       *label = pose_obj->landmarks[pose_index][0].label;
+       LOGI("[%d]: label(%d)", pose_index, *label);
 
        MEDIA_VISION_FUNCTION_LEAVE();
 
@@ -294,7 +875,14 @@ int mv_pose_create(mv_pose_h *pose)
 
        int ret = MEDIA_VISION_ERROR_NONE;
 
-       ret = mv_pose_create_open(pose);
+       (*pose) = static_cast<mv_pose_h>(new (std::nothrow) Posture);
+
+       if (*pose == NULL) {
+               LOGE("Failed to create pose handle");
+               return MEDIA_VISION_ERROR_OUT_OF_MEMORY;
+       }
+
+       LOGD("Inference handle [%p] has been created", *pose);
 
        MEDIA_VISION_FUNCTION_LEAVE();
 
@@ -310,7 +898,9 @@ int mv_pose_destroy(mv_pose_h pose)
 
        int ret = MEDIA_VISION_ERROR_NONE;
 
-       ret = mv_pose_destroy_open(pose);
+       LOGD("Destroy pose handle [%p]", pose);
+       delete static_cast<Posture *>(pose);
+       LOGD("Pose handle has been destroyed");
 
        MEDIA_VISION_FUNCTION_LEAVE();
 
@@ -328,7 +918,21 @@ int mv_pose_set_from_file(mv_pose_h pose, const char *motion_capture_file_path,
 
        int ret = MEDIA_VISION_ERROR_NONE;
 
-       ret = mv_pose_set_from_file_open(pose, motion_capture_file_path, motion_mapping_file_path);
+       Posture *pPose = static_cast<Posture *>(pose);
+
+       // check file
+       if (access(motion_capture_file_path, F_OK) || access(motion_mapping_file_path, F_OK)) {
+               LOGE("Invalid Motion Capture file path [%s]", motion_capture_file_path);
+               LOGE("Invalid Motion Mapping file path [%s]", motion_mapping_file_path);
+
+               return MEDIA_VISION_ERROR_INVALID_PATH;
+       }
+
+       ret = pPose->setPoseFromFile(std::string(motion_capture_file_path), std::string(motion_mapping_file_path));
+       if (ret != MEDIA_VISION_ERROR_NONE) {
+               LOGE("Fail to setPoseFromFile");
+               return ret;
+       }
 
        MEDIA_VISION_FUNCTION_LEAVE();
 
@@ -346,7 +950,27 @@ int mv_pose_compare(mv_pose_h pose, mv_inference_pose_result_h action, int parts
 
        int ret = MEDIA_VISION_ERROR_NONE;
 
-       ret = mv_pose_compare_open(pose, action, parts, score);
+       Posture *pPose = static_cast<Posture *>(pose);
+       std::vector<std::pair<bool, cv::Point> > actionParts;
+       mv_inference_pose_s *pAction = static_cast<mv_inference_pose_s *>(action);
+
+       for (int k = 0; k < HUMAN_POSE_MAX_LANDMARKS; ++k) {
+               if (pAction->landmarks[0][k].point.x == -1 || pAction->landmarks[0][k].point.y == -1) {
+                       actionParts.push_back(std::make_pair(false, cv::Point(-1, -1)));
+                       continue;
+               }
+
+               actionParts.push_back(
+                               std::make_pair(true, cv::Point(pAction->landmarks[0][k].point.x, pAction->landmarks[0][k].point.y)));
+       }
+
+       ret = pPose->compare(parts, actionParts, score);
+       if (ret != MEDIA_VISION_ERROR_NONE) {
+               LOGE("Fail to compare");
+               return ret;
+       }
+
+       LOGD("score: %1.4f", *score);
 
        MEDIA_VISION_FUNCTION_LEAVE();
 
diff --git a/mv_machine_learning/inference/src/mv_inference_open.cpp b/mv_machine_learning/inference/src/mv_inference_open.cpp
deleted file mode 100644 (file)
index e82c2c9..0000000
+++ /dev/null
@@ -1,858 +0,0 @@
-/**
- * Copyright (c) 2018 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_inference_open.h"
-
-#include "Inference.h"
-#include "Posture.h"
-
-#include <new>
-#include <unistd.h>
-#include <string>
-
-using namespace mediavision::inference;
-
-mv_engine_config_h mv_inference_get_engine_config(mv_inference_h infer)
-{
-       Inference *pInfer = static_cast<Inference *>(infer);
-
-       return pInfer->getEngineConfig();
-}
-
-int mv_inference_create_open(mv_inference_h *infer)
-{
-       if (infer == NULL) {
-               LOGE("Handle can't be created because handle pointer is NULL");
-               return MEDIA_VISION_ERROR_INVALID_PARAMETER;
-       }
-
-       (*infer) = static_cast<mv_inference_h>(new (std::nothrow) Inference());
-
-       if (*infer == NULL) {
-               LOGE("Failed to create inference handle");
-               return MEDIA_VISION_ERROR_OUT_OF_MEMORY;
-       }
-
-       LOGD("Inference handle [%p] has been created", *infer);
-
-       return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_inference_destroy_open(mv_inference_h infer)
-{
-       if (!infer) {
-               LOGE("Handle can't be destroyed because handle is NULL");
-               return MEDIA_VISION_ERROR_INVALID_PARAMETER;
-       }
-
-       LOGD("Destroying inference handle [%p]", infer);
-       delete static_cast<Inference *>(infer);
-       LOGD("Inference handle has been destroyed");
-
-       return MEDIA_VISION_ERROR_NONE;
-}
-
-static bool IsJsonFile(const std::string &fileName)
-{
-       return (!fileName.substr(fileName.find_last_of(".") + 1).compare("json"));
-}
-
-static bool IsValidBackendType(const int backend_type)
-{
-       return (backend_type > MV_INFERENCE_BACKEND_NONE && backend_type < MV_INFERENCE_BACKEND_MAX);
-}
-
-static bool IsConfigFilePathRequired(const int target_device_type, const int backend_type)
-{
-       LOGW("DEPRECATION WARNING : MV_INFERENCE_BACKEND_MLAPI type is deprecated and will be removed from next release.");
-
-       // In case of MV_INFERENCE_TARGET_DEVICE_CUSTOM via MLAPI backend, config file path is required.
-       return (backend_type == MV_INFERENCE_BACKEND_MLAPI && target_device_type & MV_INFERENCE_TARGET_DEVICE_CUSTOM);
-}
-
-static int configure_tensor_info_from_meta_file(Inference *pInfer, mv_engine_config_h engine_config)
-{
-       char *modelMetaFilePath = NULL;
-
-       int ret =
-                       mv_engine_config_get_string_attribute(engine_config, MV_INFERENCE_MODEL_META_FILE_PATH, &modelMetaFilePath);
-       if (ret != MEDIA_VISION_ERROR_NONE) {
-               LOGE("Fail to get model meta file path");
-               goto out_of_function;
-       }
-
-       if (std::string(modelMetaFilePath).empty()) {
-               LOGW("Skip ParseMetadata and run without Metadata");
-               ret = MEDIA_VISION_ERROR_INVALID_OPERATION;
-               goto release_model_meta_file_path;
-       }
-
-       if (!IsJsonFile(std::string(modelMetaFilePath))) {
-               ret = MEDIA_VISION_ERROR_INVALID_PATH;
-               LOGE("Model meta file should be json");
-               goto release_model_meta_file_path;
-       }
-
-       ret = pInfer->parseMetadata(std::string(modelMetaFilePath));
-       if (ret != MEDIA_VISION_ERROR_NONE) {
-               LOGE("Fail to ParseMetadata");
-       }
-
-release_model_meta_file_path:
-       free(modelMetaFilePath);
-
-out_of_function:
-       LOGI("LEAVE");
-
-       return ret;
-}
-
-static int configure_model_open(Inference *pInfer, mv_engine_config_h engine_config)
-{
-       LOGI("ENTER");
-
-       char *modelConfigFilePath = NULL;
-       char *modelWeightFilePath = NULL;
-       char *modelUserFilePath = NULL;
-       int backendType = 0;
-       size_t userFileLength = 0;
-
-       int ret = mv_engine_config_get_string_attribute(engine_config, MV_INFERENCE_MODEL_CONFIGURATION_FILE_PATH,
-                                                                                                       &modelConfigFilePath);
-       if (ret != MEDIA_VISION_ERROR_NONE) {
-               LOGE("Fail to get model configuration file path");
-               goto out_of_function;
-       }
-
-       ret = mv_engine_config_get_string_attribute(engine_config, MV_INFERENCE_MODEL_WEIGHT_FILE_PATH,
-                                                                                               &modelWeightFilePath);
-       if (ret != MEDIA_VISION_ERROR_NONE) {
-               LOGE("Fail to get model weight file path");
-               goto release_model_config_file_path;
-       }
-
-       ret = mv_engine_config_get_string_attribute(engine_config, MV_INFERENCE_MODEL_USER_FILE_PATH, &modelUserFilePath);
-       if (ret != MEDIA_VISION_ERROR_NONE) {
-               LOGE("Fail to get model user file path");
-               goto release_model_weight_file_path;
-       }
-
-       ret = mv_engine_config_get_int_attribute(engine_config, MV_INFERENCE_BACKEND_TYPE, &backendType);
-       if (ret != MEDIA_VISION_ERROR_NONE) {
-               LOGE("Fail to get inference backend type");
-               goto release_model_user_file_path;
-       }
-
-       if (!IsValidBackendType(backendType)) {
-               LOGE("Invalid backend type(%d).", backendType);
-               ret = MEDIA_VISION_ERROR_INVALID_PARAMETER;
-               goto release_model_user_file_path;
-       }
-
-       if (access(modelWeightFilePath, F_OK)) {
-               LOGE("weightFilePath in [%s] ", modelWeightFilePath);
-               ret = MEDIA_VISION_ERROR_INVALID_PATH;
-               goto release_model_user_file_path;
-       }
-
-       if (IsConfigFilePathRequired(pInfer->getTargetType(), backendType)) {
-               if (access(modelConfigFilePath, F_OK)) {
-                       LOGE("modelConfigFilePath in [%s] ", modelConfigFilePath);
-                       ret = MEDIA_VISION_ERROR_INVALID_PATH;
-                       goto release_model_user_file_path;
-               }
-       }
-
-       userFileLength = strlen(modelUserFilePath);
-
-       if (userFileLength > 0 && access(modelUserFilePath, F_OK)) {
-               LOGE("categoryFilePath in [%s] ", modelUserFilePath);
-               ret = MEDIA_VISION_ERROR_INVALID_PATH;
-               goto release_model_user_file_path;
-       }
-
-       pInfer->configureModelFiles(std::string(modelConfigFilePath), std::string(modelWeightFilePath),
-                                                               std::string(modelUserFilePath));
-
-release_model_user_file_path:
-       free(modelUserFilePath);
-
-release_model_weight_file_path:
-       free(modelWeightFilePath);
-
-release_model_config_file_path:
-       free(modelConfigFilePath);
-
-out_of_function:
-       LOGI("LEAVE");
-
-       return ret;
-}
-
-static int configure_input_info_open(Inference *pInfer, mv_engine_config_h engine_config)
-{
-       LOGI("ENTER");
-
-       int tensorWidth, tensorHeight, tensorCh;
-       double meanValue, stdValue;
-       char *node_name = NULL;
-       int dataType = 0;
-
-       int ret = mv_engine_config_get_int_attribute(engine_config, MV_INFERENCE_INPUT_TENSOR_WIDTH, &tensorWidth);
-       if (ret != MEDIA_VISION_ERROR_NONE) {
-               LOGE("Fail to get tensor width");
-               goto out_of_function;
-       }
-
-       ret = mv_engine_config_get_int_attribute(engine_config, MV_INFERENCE_INPUT_TENSOR_HEIGHT, &tensorHeight);
-       if (ret != MEDIA_VISION_ERROR_NONE) {
-               LOGE("Fail to get tensor height");
-               goto out_of_function;
-       }
-
-       ret = mv_engine_config_get_int_attribute(engine_config, MV_INFERENCE_INPUT_TENSOR_CHANNELS, &tensorCh);
-       if (ret != MEDIA_VISION_ERROR_NONE) {
-               LOGE("Fail to get tensor channels");
-               goto out_of_function;
-       }
-
-       ret = mv_engine_config_get_double_attribute(engine_config, MV_INFERENCE_MODEL_MEAN_VALUE, &meanValue);
-       if (ret != MEDIA_VISION_ERROR_NONE) {
-               LOGE("Fail to get meanValue");
-               goto out_of_function;
-       }
-
-       ret = mv_engine_config_get_double_attribute(engine_config, MV_INFERENCE_MODEL_STD_VALUE, &stdValue);
-       if (ret != MEDIA_VISION_ERROR_NONE) {
-               LOGE("Fail to get stdValue");
-               goto out_of_function;
-       }
-
-       ret = mv_engine_config_get_int_attribute(engine_config, MV_INFERENCE_INPUT_DATA_TYPE, &dataType);
-       if (ret != MEDIA_VISION_ERROR_NONE) {
-               LOGE("Fail to get a input tensor data type");
-               goto out_of_function;
-       }
-
-       ret = mv_engine_config_get_string_attribute(engine_config, MV_INFERENCE_INPUT_NODE_NAME, &node_name);
-       if (ret != MEDIA_VISION_ERROR_NONE) {
-               LOGE("Fail to get tensor width");
-               goto out_of_function;
-       }
-
-       pInfer->configureInputInfo(tensorWidth, tensorHeight, 1, tensorCh, stdValue, meanValue, dataType,
-                                                          std::vector<std::string>(1, std::string(node_name)));
-
-       free(node_name);
-       node_name = NULL;
-
-out_of_function:
-       LOGI("LEAVE");
-
-       return ret;
-}
-
-int mv_inference_configure_engine_open(mv_inference_h infer, mv_engine_config_h engine_config)
-{
-       LOGI("ENTER");
-
-       Inference *pInfer = static_cast<Inference *>(infer);
-       int backendType = 0;
-       int targetTypes = 0;
-
-       pInfer->setEngineConfig(engine_config);
-
-       int ret = mv_engine_config_get_int_attribute(engine_config, MV_INFERENCE_BACKEND_TYPE, &backendType);
-       if (ret != MEDIA_VISION_ERROR_NONE) {
-               LOGE("Fail to get inference backend type");
-               goto out_of_function;
-       }
-
-       ret = mv_engine_config_get_int_attribute(engine_config, MV_INFERENCE_TARGET_DEVICE_TYPE, &targetTypes);
-       if (ret != MEDIA_VISION_ERROR_NONE) {
-               LOGE("Fail to get inference target type");
-               goto out_of_function;
-       }
-
-       // Set target device type.
-       if (pInfer->configureTargetDevices(targetTypes) != MEDIA_VISION_ERROR_NONE) {
-               LOGE("Tried to configure invalid target types.");
-               goto out_of_function;
-       }
-
-       // Create a inference-engine-common class object and load its corresponding library.
-       // Ps. Inference engine gets a capability from a given backend by Bind call
-       // so access to mBackendCapacity should be done after Bind.
-       ret = pInfer->bind(backendType, targetTypes);
-       if (ret != MEDIA_VISION_ERROR_NONE) {
-               LOGE("Fail to bind a backend engine.");
-               goto out_of_function;
-       }
-
-out_of_function:
-       LOGI("LEAVE");
-
-       return ret;
-}
-
-int mv_inference_configure_output_open(mv_inference_h infer, mv_engine_config_h engine_config)
-{
-       LOGI("ENTER");
-
-       Inference *pInfer = static_cast<Inference *>(infer);
-       int maxOutput = 0;
-
-       int ret = mv_engine_config_get_int_attribute(engine_config, MV_INFERENCE_OUTPUT_MAX_NUMBER, &maxOutput);
-       if (ret != MEDIA_VISION_ERROR_NONE) {
-               LOGE("Fail to get inference output maximum numbers");
-               goto out_of_function;
-       }
-
-       pInfer->configureOutput(maxOutput);
-
-out_of_function:
-       LOGI("LEAVE");
-
-       return ret;
-}
-
-int mv_inference_configure_confidence_threshold_open(mv_inference_h infer, mv_engine_config_h engine_config)
-{
-       LOGI("ENTER");
-
-       Inference *pInfer = static_cast<Inference *>(infer);
-       double threshold = 0;
-
-       int ret = mv_engine_config_get_double_attribute(engine_config, MV_INFERENCE_CONFIDENCE_THRESHOLD, &threshold);
-       if (ret != MEDIA_VISION_ERROR_NONE) {
-               LOGE("Fail to get inference confidence threshold value");
-               goto out_of_function;
-       }
-
-       pInfer->configureThreshold(threshold);
-
-out_of_function:
-       LOGI("LEAVE");
-
-       return ret;
-}
-
-static int configure_post_process_info_open(Inference *pInfer, mv_engine_config_h engine_config)
-{
-       LOGI("ENTER");
-
-       int maxOutput = 0;
-       double threshold = 0;
-
-       int ret = mv_engine_config_get_int_attribute(engine_config, MV_INFERENCE_OUTPUT_MAX_NUMBER, &maxOutput);
-       if (ret != MEDIA_VISION_ERROR_NONE) {
-               LOGE("Fail to get inference output maximum numbers");
-               goto out_of_function;
-       }
-
-       pInfer->configureOutput(maxOutput);
-
-       ret = mv_engine_config_get_double_attribute(engine_config, MV_INFERENCE_CONFIDENCE_THRESHOLD, &threshold);
-       if (ret != MEDIA_VISION_ERROR_NONE) {
-               LOGE("Fail to get inference confidence threshold value");
-               goto out_of_function;
-       }
-
-       pInfer->configureThreshold(threshold);
-
-out_of_function:
-       LOGI("LEAVE");
-
-       return ret;
-}
-
-static int configure_output_info_open(Inference *pInfer, mv_engine_config_h engine_config)
-{
-       LOGI("ENTER");
-
-       int idx = 0;
-       char **node_names = NULL;
-       int size = 0;
-       std::vector<std::string> names;
-
-       int ret = mv_engine_config_get_array_string_attribute(engine_config, MV_INFERENCE_OUTPUT_NODE_NAMES, &node_names,
-                                                                                                                 &size);
-       if (ret != MEDIA_VISION_ERROR_NONE) {
-               LOGE("Fail to get _output_node_names");
-               return ret;
-       }
-
-       for (idx = 0; idx < size; ++idx)
-               names.push_back(std::string(node_names[idx]));
-
-       std::vector<inference_engine_tensor_info> tensors_info;
-
-       pInfer->configureOutputInfo(names, tensors_info);
-
-       if (node_names) {
-               for (idx = 0; idx < size; ++idx)
-                       free(node_names[idx]);
-
-               free(node_names);
-               node_names = NULL;
-       }
-
-       LOGI("LEAVE");
-
-       return ret;
-}
-
-int mv_inference_prepare_open(mv_inference_h infer)
-{
-       LOGI("ENTER");
-
-       Inference *pInfer = static_cast<Inference *>(infer);
-       mv_engine_config_h engine_config = mv_inference_get_engine_config(infer);
-
-       int ret = configure_model_open(pInfer, engine_config);
-       if (ret != MEDIA_VISION_ERROR_NONE) {
-               LOGE("Fail to configure model");
-               return ret;
-       }
-
-       // If input and output tensor info aren't configured from model meta file then
-       // use legacy way for the configuration. TODO. the legacy way will be deprecated.
-       ret = configure_tensor_info_from_meta_file(pInfer, engine_config);
-       if (ret != MEDIA_VISION_ERROR_NONE) {
-               // input tensor, input layer
-               ret = configure_input_info_open(pInfer, engine_config);
-               if (ret != MEDIA_VISION_ERROR_NONE) {
-                       LOGE("Fail to configure input info");
-                       return ret;
-               }
-
-               // output layer
-               ret = configure_output_info_open(pInfer, engine_config);
-               if (ret != MEDIA_VISION_ERROR_NONE) {
-                       LOGE("Fail to configure output info");
-                       return ret;
-               }
-
-               // maximum candidates, threshold
-               ret = configure_post_process_info_open(pInfer, engine_config);
-               if (ret != MEDIA_VISION_ERROR_NONE) {
-                       LOGE("Fail to configure post process info");
-                       return ret;
-               }
-       } else {
-               ret = pInfer->configureInputMetaInfo();
-               if (ret != MEDIA_VISION_ERROR_NONE) {
-                       LOGE("Fail to configure input meta info.");
-                       return ret;
-               }
-
-               ret = pInfer->configureOutputMetaInfo();
-               if (ret != MEDIA_VISION_ERROR_NONE) {
-                       LOGE("Fail to configure output meta info.");
-                       return ret;
-               }
-       }
-
-       // Request to load model files to a backend engine.
-       ret = pInfer->load();
-       if (ret != MEDIA_VISION_ERROR_NONE)
-               LOGE("Fail to load model files.");
-
-       LOGI("LEAVE");
-
-       return ret;
-}
-
-int mv_inference_foreach_supported_engine_open(mv_inference_h infer, mv_inference_supported_engine_cb callback,
-                                                                                          void *user_data)
-{
-       LOGI("ENTER");
-
-       Inference *pInfer = static_cast<Inference *>(infer);
-       std::pair<std::string, bool> backend;
-
-       for (int i = 0; i < MV_INFERENCE_BACKEND_MAX; ++i) {
-               backend = pInfer->getSupportedInferenceBackend(i);
-               callback((backend.first).c_str(), backend.second, user_data);
-       }
-
-       LOGI("LEAVE");
-
-       return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_inference_image_classify_open(mv_source_h source, mv_inference_h infer, mv_rectangle_s *roi,
-                                                                        mv_inference_image_classified_cb classified_cb, void *user_data)
-{
-       Inference *pInfer = static_cast<Inference *>(infer);
-       std::vector<mv_source_h> sources;
-       std::vector<mv_rectangle_s> rects;
-
-       sources.push_back(source);
-
-       if (roi != NULL)
-               rects.push_back(*roi);
-
-       int ret = pInfer->run(sources, rects);
-       if (ret != MEDIA_VISION_ERROR_NONE) {
-               LOGE("Fail to run inference");
-               return ret;
-       }
-
-       ImageClassificationResults classificationResults;
-
-       ret = pInfer->getClassficationResults(&classificationResults);
-       if (ret != MEDIA_VISION_ERROR_NONE) {
-               LOGE("Fail to get inference results");
-               return ret;
-       }
-
-       int numberOfOutputs = classificationResults.number_of_classes;
-       static const int START_CLASS_NUMBER = 10;
-       static std::vector<const char *> names(START_CLASS_NUMBER);
-
-       if (numberOfOutputs > START_CLASS_NUMBER)
-               names.resize(numberOfOutputs);
-
-       LOGI("mv_inference_open: number_of_classes: %d\n", numberOfOutputs);
-
-       for (int output_index = 0; output_index < numberOfOutputs; ++output_index) {
-               LOGI("names: %s", classificationResults.names[output_index].c_str());
-               names[output_index] = classificationResults.names[output_index].c_str();
-       }
-
-       auto *indices = classificationResults.indices.data();
-       auto *confidences = classificationResults.confidences.data();
-
-       classified_cb(source, numberOfOutputs, indices, names.data(), confidences, user_data);
-
-       return ret;
-}
-
-int mv_inference_object_detect_open(mv_source_h source, mv_inference_h infer,
-                                                                       mv_inference_object_detected_cb detected_cb, void *user_data)
-{
-       Inference *pInfer = static_cast<Inference *>(infer);
-       std::vector<mv_source_h> sources;
-       std::vector<mv_rectangle_s> rects;
-
-       sources.push_back(source);
-       int ret = pInfer->run(sources, rects);
-       if (ret != MEDIA_VISION_ERROR_NONE) {
-               LOGE("Fail to run inference");
-               return ret;
-       }
-
-       ObjectDetectionResults objectDetectionResults;
-
-       ret = pInfer->getObjectDetectionResults(&objectDetectionResults);
-       if (ret != MEDIA_VISION_ERROR_NONE) {
-               LOGE("Fail to get inference results");
-               return ret;
-       }
-
-       int numberOfOutputs = objectDetectionResults.number_of_objects;
-       static const int START_OBJECT_NUMBER = 20;
-       static std::vector<const char *> names(START_OBJECT_NUMBER);
-       static std::vector<mv_rectangle_s> locations(START_OBJECT_NUMBER);
-
-       if (numberOfOutputs > START_OBJECT_NUMBER) {
-               names.resize(numberOfOutputs);
-               locations.resize(numberOfOutputs);
-       }
-
-       for (int output_idx = 0; output_idx < numberOfOutputs; ++output_idx) {
-               LOGI("names: %s", objectDetectionResults.names[output_idx].c_str());
-               names[output_idx] = objectDetectionResults.names[output_idx].c_str();
-
-               locations[output_idx].point.x = objectDetectionResults.locations[output_idx].x;
-               locations[output_idx].point.y = objectDetectionResults.locations[output_idx].y;
-               locations[output_idx].width = objectDetectionResults.locations[output_idx].width;
-               locations[output_idx].height = objectDetectionResults.locations[output_idx].height;
-               LOGI("%d, %d, %d, %d", locations[output_idx].point.x, locations[output_idx].point.y,
-                        locations[output_idx].width, locations[output_idx].height);
-       }
-
-       int *indices = objectDetectionResults.indices.data();
-       float *confidences = objectDetectionResults.confidences.data();
-
-       detected_cb(source, numberOfOutputs, indices, names.data(), confidences, locations.data(), user_data);
-
-       return ret;
-}
-
-int mv_inference_face_detect_open(mv_source_h source, mv_inference_h infer, mv_inference_face_detected_cb detected_cb,
-                                                                 void *user_data)
-{
-       Inference *pInfer = static_cast<Inference *>(infer);
-       std::vector<mv_source_h> sources;
-       std::vector<mv_rectangle_s> rects;
-
-       sources.push_back(source);
-
-       int ret = pInfer->run(sources, rects);
-       if (ret != MEDIA_VISION_ERROR_NONE) {
-               LOGE("Fail to run inference");
-               return ret;
-       }
-
-       FaceDetectionResults faceDetectionResults;
-
-       ret = pInfer->getFaceDetectionResults(&faceDetectionResults);
-       if (ret != MEDIA_VISION_ERROR_NONE) {
-               LOGE("Fail to get inference results");
-               return ret;
-       }
-
-       int numberOfOutputs = faceDetectionResults.number_of_faces;
-       std::vector<mv_rectangle_s> locations(numberOfOutputs);
-
-       for (int output_idx = 0; output_idx < numberOfOutputs; ++output_idx) {
-               locations[output_idx].point.x = faceDetectionResults.locations[output_idx].x;
-               locations[output_idx].point.y = faceDetectionResults.locations[output_idx].y;
-               locations[output_idx].width = faceDetectionResults.locations[output_idx].width;
-               locations[output_idx].height = faceDetectionResults.locations[output_idx].height;
-       }
-
-       float *confidences = faceDetectionResults.confidences.data();
-
-       detected_cb(source, numberOfOutputs, confidences, locations.data(), user_data);
-
-       return ret;
-}
-
-int mv_inference_facial_landmark_detect_open(mv_source_h source, mv_inference_h infer, mv_rectangle_s *roi,
-                                                                                        mv_inference_facial_landmark_detected_cb detected_cb, void *user_data)
-{
-       Inference *pInfer = static_cast<Inference *>(infer);
-       std::vector<mv_source_h> sources;
-       std::vector<mv_rectangle_s> rects;
-
-       sources.push_back(source);
-
-       if (roi != NULL)
-               rects.push_back(*roi);
-
-       int ret = pInfer->run(sources, rects);
-       if (ret != MEDIA_VISION_ERROR_NONE) {
-               LOGE("Fail to run inference");
-               return ret;
-       }
-
-       FacialLandMarkDetectionResults facialLandMarkDetectionResults;
-
-       ret = pInfer->getFacialLandMarkDetectionResults(&facialLandMarkDetectionResults);
-       if (ret != MEDIA_VISION_ERROR_NONE) {
-               LOGE("Fail to get inference results");
-               return ret;
-       }
-
-       int numberOfLandmarks = facialLandMarkDetectionResults.number_of_landmarks;
-       std::vector<mv_point_s> locations(numberOfLandmarks);
-
-       for (int landmark_idx = 0; landmark_idx < numberOfLandmarks; ++landmark_idx) {
-               locations[landmark_idx].x = facialLandMarkDetectionResults.locations[landmark_idx].x;
-               locations[landmark_idx].y = facialLandMarkDetectionResults.locations[landmark_idx].y;
-       }
-
-       detected_cb(source, numberOfLandmarks, locations.data(), user_data);
-
-       return ret;
-}
-
-int mv_inference_pose_landmark_detect_open(mv_source_h source, mv_inference_h infer, mv_rectangle_s *roi,
-                                                                                  mv_inference_pose_landmark_detected_cb detected_cb, void *user_data)
-{
-       Inference *pInfer = static_cast<Inference *>(infer);
-       unsigned int width, height;
-
-       int ret = mv_source_get_width(source, &width);
-       if (ret != MEDIA_VISION_ERROR_NONE) {
-               LOGE("Fail to get width");
-               return ret;
-       }
-
-       ret = mv_source_get_height(source, &height);
-       if (ret != MEDIA_VISION_ERROR_NONE) {
-               LOGE("Fail to get height");
-               return ret;
-       }
-
-       std::vector<mv_source_h> sources;
-       std::vector<mv_rectangle_s> rects;
-
-       sources.push_back(source);
-
-       if (roi != NULL)
-               rects.push_back(*roi);
-
-       ret = pInfer->run(sources, rects);
-       if (ret != MEDIA_VISION_ERROR_NONE) {
-               LOGE("Fail to run inference");
-               return ret;
-       }
-
-       std::unique_ptr<mv_inference_pose_s> pose;
-
-       ret = pInfer->getPoseLandmarkDetectionResults(pose, width, height);
-       if (ret != MEDIA_VISION_ERROR_NONE) {
-               LOGE("Fail to get inference results");
-               return ret;
-       }
-
-       for (int pose_index = 0; pose_index < pose->number_of_poses; ++pose_index) {
-               for (int landmark_index = 0; landmark_index < pose->number_of_landmarks_per_pose; ++landmark_index) {
-                       LOGI("PoseIdx[%2d]: x[%d], y[%d], score[%.3f]", landmark_index,
-                                pose->landmarks[pose_index][landmark_index].point.x,
-                                pose->landmarks[pose_index][landmark_index].point.y,
-                                pose->landmarks[pose_index][landmark_index].score);
-               }
-       }
-
-       detected_cb(source, static_cast<mv_inference_pose_result_h>(pose.get()), user_data);
-
-       return ret;
-}
-
-int mv_inference_pose_get_number_of_poses_open(mv_inference_pose_result_h result, int *number_of_poses)
-{
-       mv_inference_pose_s *handle = static_cast<mv_inference_pose_s *>(result);
-       *number_of_poses = handle->number_of_poses;
-       LOGI("%d", *number_of_poses);
-
-       return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_inference_pose_get_number_of_landmarks_open(mv_inference_pose_result_h result, int *number_of_landmarks)
-{
-       mv_inference_pose_s *handle = static_cast<mv_inference_pose_s *>(result);
-       *number_of_landmarks = handle->number_of_landmarks_per_pose;
-       LOGI("%d", *number_of_landmarks);
-
-       return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_inference_pose_get_landmark_open(mv_inference_pose_result_h result, int pose_index, int part_index,
-                                                                               mv_point_s *location, float *score)
-{
-       mv_inference_pose_s *pose_obj = static_cast<mv_inference_pose_s *>(result);
-
-       if (pose_index < 0 || pose_index >= pose_obj->number_of_poses)
-               return MEDIA_VISION_ERROR_INVALID_PARAMETER;
-
-       if (part_index < 0 || part_index >= pose_obj->number_of_landmarks_per_pose)
-               return MEDIA_VISION_ERROR_INVALID_PARAMETER;
-
-       *location = pose_obj->landmarks[pose_index][part_index].point;
-       *score = pose_obj->landmarks[pose_index][part_index].score;
-       LOGI("[%d]:(%dx%d) - %.4f", pose_index, location->x, location->y, *score);
-
-       return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_inference_pose_get_label_open(mv_inference_pose_result_h result, int pose_index, int *label)
-{
-       mv_inference_pose_s *pose_obj = static_cast<mv_inference_pose_s *>(result);
-
-       if (pose_index < 0 || pose_index >= pose_obj->number_of_poses)
-               return MEDIA_VISION_ERROR_INVALID_PARAMETER;
-
-       *label = pose_obj->landmarks[pose_index][0].label;
-       LOGI("[%d]: label(%d)", pose_index, *label);
-
-       return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_pose_create_open(mv_pose_h *pose)
-{
-       if (pose == NULL) {
-               LOGE("Handle can't be created because handle pointer is NULL");
-               return MEDIA_VISION_ERROR_INVALID_PARAMETER;
-       }
-
-       (*pose) = static_cast<mv_pose_h>(new (std::nothrow) Posture);
-
-       if (*pose == NULL) {
-               LOGE("Failed to create pose handle");
-               return MEDIA_VISION_ERROR_OUT_OF_MEMORY;
-       }
-
-       LOGD("Inference handle [%p] has been created", *pose);
-
-       return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_pose_destroy_open(mv_pose_h pose)
-{
-       if (!pose) {
-               LOGE("Hand can't be destroyed because handle is NULL");
-               return MEDIA_VISION_ERROR_INVALID_PARAMETER;
-       }
-
-       LOGD("Destroy pose handle [%p]", pose);
-       delete static_cast<Posture *>(pose);
-       LOGD("Pose handle has been destroyed");
-
-       return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_pose_set_from_file_open(mv_pose_h pose, const char *motionCaptureFilePath, const char *motionMappingFilePath)
-{
-       Posture *pPose = static_cast<Posture *>(pose);
-
-       // check file
-       if (access(motionCaptureFilePath, F_OK) || access(motionMappingFilePath, F_OK)) {
-               LOGE("Invalid Motion Capture file path [%s]", motionCaptureFilePath);
-               LOGE("Invalid Motion Mapping file path [%s]", motionMappingFilePath);
-
-               return MEDIA_VISION_ERROR_INVALID_PATH;
-       }
-
-       int ret = pPose->setPoseFromFile(std::string(motionCaptureFilePath), std::string(motionMappingFilePath));
-       if (ret != MEDIA_VISION_ERROR_NONE) {
-               LOGE("Fail to setPoseFromFile");
-               return ret;
-       }
-
-       return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_pose_compare_open(mv_pose_h pose, mv_inference_pose_result_h action, int parts, float *score)
-{
-       Posture *pPose = static_cast<Posture *>(pose);
-       std::vector<std::pair<bool, cv::Point> > actionParts;
-       mv_inference_pose_s *pAction = static_cast<mv_inference_pose_s *>(action);
-
-       for (int k = 0; k < HUMAN_POSE_MAX_LANDMARKS; ++k) {
-               if (pAction->landmarks[0][k].point.x == -1 || pAction->landmarks[0][k].point.y == -1) {
-                       actionParts.push_back(std::make_pair(false, cv::Point(-1, -1)));
-                       continue;
-               }
-
-               actionParts.push_back(
-                               std::make_pair(true, cv::Point(pAction->landmarks[0][k].point.x, pAction->landmarks[0][k].point.y)));
-       }
-
-       int ret = pPose->compare(parts, actionParts, score);
-       if (ret != MEDIA_VISION_ERROR_NONE) {
-               LOGE("Fail to compare");
-               return ret;
-       }
-
-       LOGD("score: %1.4f", *score);
-
-       return MEDIA_VISION_ERROR_NONE;
-}