*/
int mv_object_detection_3d_destroy(mv_object_detection_3d_h infer);
+/**
+ * @brief Set user-given model information.
+ * @details Use this function to change the model information instead of default one after calling @ref mv_object_detection_3d_create().
+ *
+ * @since_tizen 7.5
+ *
+ * @param[in] handle The handle to the object detection 3d object.
+ * @param[in] model_name Model name.
+ * @param[in] model_file Model file name.
+ * @param[in] meta_file Model meta file name.
+ * @param[in] label_file Label file name.
+ *
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #MEDIA_VISION_ERROR_NONE Successful
+ * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_VISION_ERROR_INVALID_OPERATION Invalid operation
+ *
+ * @pre Create a object detection 3d handle by calling @ref mv_object_detection_3d_create()
+ */
+int mv_object_detection_3d_set_model(mv_object_detection_3d_h handle, const char *model_name, const char *model_file,
+ const char *meta_file, const char *label_file);
+
/**
* @brief Configures the backend for the object detection inference.
*
* @pre Request an inference by calling @ref mv_object_detection_3d_inference()
*/
int mv_object_detection_3d_get_points(mv_object_detection_3d_h handle, unsigned int **out_x, unsigned int **out_y);
+
+/**
+ * @brief Set user-given inference engine and device types for inference.
+ * @details Use this function to change the inference engine and device types for inference instead of default ones after calling @ref mv_object_detection_3d_create().
+ *
+ * @since_tizen 7.5
+ *
+ * @param[in] handle The handle to the object detection 3d object.
+ * @param[in] engine_type A string of inference engine type.
+ * @param[in] device_type A string of device type.
+ *
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #MEDIA_VISION_ERROR_NONE Successful
+ * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_VISION_ERROR_INVALID_OPERATION Invalid operation
+ *
+ * @pre Create a object detection 3d handle by calling @ref mv_object_detection_3d_create()
+ */
+int mv_object_detection_3d_set_engine(mv_object_detection_3d_h handle, const char *engine_type,
+ const char *device_type);
+
+/**
+ * @brief Get a number of inference engines available for object detection 3d task API.
+ * @details Use this function to get how many inference engines are supported for object detection 3d after calling @ref mv_object_detection_3d_create().
+ *
+ * @since_tizen 7.5
+ *
+ * @param[in] handle The handle to the object detection 3d object.
+ * @param[out] engine_count A number of inference engines available for object detection 3d API.
+ *
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #MEDIA_VISION_ERROR_NONE Successful
+ * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_VISION_ERROR_INVALID_OPERATION Invalid operation
+ *
+ * @pre Create a object detection 3d handle by calling @ref mv_object_detection_3d_create()
+ */
+int mv_object_detection_3d_get_engine_count(mv_object_detection_3d_h handle, unsigned int *engine_count);
+
+/**
+ * @brief Get engine type to a given inference engine index.
+ * @details Use this function to get inference engine type with a given engine index after calling @ref mv_object_detection_3d_get_engine_count().
+ *
+ * @since_tizen 7.5
+ *
+ * @param[in] handle The handle to the object detection 3d object.
+ * @param[in] engine_index A inference engine index for getting the inference engine type.
+ * @param[out] engine_type A string to inference engine.
+ *
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #MEDIA_VISION_ERROR_NONE Successful
+ * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_VISION_ERROR_INVALID_OPERATION Invalid operation
+ *
+ * @pre Get a number of inference engines available for object detection 3d task API by calling @ref mv_object_detection_get_engine_count()
+ */
+int mv_object_detection_3d_get_engine_type(mv_object_detection_3d_h handle, const unsigned int engine_index,
+ char **engine_type);
+
+/**
+ * @brief Get a number of device types available to a given inference engine.
+ * @details Use this function to get how many device types are supported for a given inference engine after calling @ref mv_object_detection_3d_create().
+ *
+ * @since_tizen 7.5
+ *
+ * @param[in] handle The handle to the object detection 3d object.
+ * @param[in] engine_type A inference engine string.
+ * @param[out] device_count A number of device types available for a given inference engine.
+ *
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #MEDIA_VISION_ERROR_NONE Successful
+ * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_VISION_ERROR_INVALID_OPERATION Invalid operation
+ *
+ * @pre Create a object detection 3d handle by calling @ref mv_object_detection_3d_create()
+ */
+int mv_object_detection_3d_get_device_count(mv_object_detection_3d_h handle, const char *engine_type,
+ unsigned int *device_count);
+
+/**
+ * @brief Get device type list available.
+ * @details Use this function to get what device types are supported for current inference engine type after calling @ref mv_object_detection_3d_configure().
+ *
+ * @since_tizen 7.5
+ *
+ * @param[in] handle The handle to the object detection 3d object.
+ * @param[in] engine_type A inference engine string.
+ * @param[in] device_index A device index for getting the device type.
+ * @param[out] device_type A string to device type.
+ *
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #MEDIA_VISION_ERROR_NONE Successful
+ * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_VISION_ERROR_INVALID_OPERATION Invalid operation
+ *
+ * @pre Create a object detection 3d handle by calling @ref mv_object_detection_3d_create()
+ * @pre Configure object detection 3d task by calling @ref mv_object_detection_3d_configure()
+ */
+int mv_object_detection_3d_get_device_type(mv_object_detection_3d_h handle, const char *engine_type,
+ const unsigned int device_index, char **device_type);
+
/**
* @}
*/
*
* @since_tizen 7.5
*
- * @param[in] handle The handle to the image classification object.
+ * @param[in] handle The handle to the object detection object.
* @param[in] engine_type A string of inference engine type.
* @param[in] device_type A string of device type.
*
* @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #MEDIA_VISION_ERROR_INVALID_OPERATION Invalid operation
*
- * @pre Create a image classification handle by calling @ref mv_object_detection_create()
+ * @pre Create a object detection handle by calling @ref mv_object_detection_create()
*/
int mv_object_detection_set_engine(mv_object_detection_h handle, const char *engine_type, const char *device_type);
/**
- * @brief Get a number of inference engines available for image classification task API.
- * @details Use this function to get how many inference engines are supported for image classification after calling @ref mv_object_detection_create().
+ * @brief Get a number of inference engines available for object detection task API.
+ * @details Use this function to get how many inference engines are supported for object detection after calling @ref mv_object_detection_create().
*
* @since_tizen 7.5
*
- * @param[in] handle The handle to the image classification object.
- * @param[out] engine_count A number of inference engines available for image classification API.
+ * @param[in] handle The handle to the object detection object.
+ * @param[out] engine_count A number of inference engines available for object detection API.
*
* @return @c 0 on success, otherwise a negative error value
* @retval #MEDIA_VISION_ERROR_NONE Successful
* @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #MEDIA_VISION_ERROR_INVALID_OPERATION Invalid operation
*
- * @pre Create a image classification handle by calling @ref mv_object_detection_create()
+ * @pre Create a object detection handle by calling @ref mv_object_detection_create()
*/
int mv_object_detection_get_engine_count(mv_object_detection_h handle, unsigned int *engine_count);
*
* @since_tizen 7.5
*
- * @param[in] handle The handle to the image classification object.
+ * @param[in] handle The handle to the object detection object.
* @param[in] engine_index A inference engine index for getting the inference engine type.
* @param[out] engine_type A string to inference engine.
*
* @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #MEDIA_VISION_ERROR_INVALID_OPERATION Invalid operation
*
- * @pre Get a number of inference engines available for image classification task API by calling @ref mv_object_detection_get_engine_count()
+ * @pre Get a number of inference engines available for object detection task API by calling @ref mv_object_detection_get_engine_count()
*/
int mv_object_detection_get_engine_type(mv_object_detection_h handle, const unsigned int engine_index,
char **engine_type);
*
* @since_tizen 7.5
*
- * @param[in] handle The handle to the image classification object.
+ * @param[in] handle The handle to the object detection object.
* @param[in] engine_type A inference engine string.
* @param[out] device_count A number of device types available for a given inference engine.
*
* @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #MEDIA_VISION_ERROR_INVALID_OPERATION Invalid operation
*
- * @pre Create a image classification handle by calling @ref mv_object_detection_create()
+ * @pre Create a object detection handle by calling @ref mv_object_detection_create()
*/
int mv_object_detection_get_device_count(mv_object_detection_h handle, const char *engine_type,
unsigned int *device_count);
*
* @since_tizen 7.5
*
- * @param[in] handle The handle to the image classification object.
+ * @param[in] handle The handle to the object detection object.
* @param[in] engine_type A inference engine string.
* @param[in] device_index A device index for getting the device type.
* @param[out] device_type A string to device type.
* @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #MEDIA_VISION_ERROR_INVALID_OPERATION Invalid operation
*
- * @pre Create a image classification handle by calling @ref mv_object_detection_create()
- * @pre Configure image classification task by calling @ref mv_object_detection_configure()
+ * @pre Create a object detection handle by calling @ref mv_object_detection_create()
+ * @pre Configure object detection task by calling @ref mv_object_detection_configure()
*/
int mv_object_detection_get_device_type(mv_object_detection_h handle, const char *engine_type,
const unsigned int device_index, char **device_type);
-
+/**
+ * @}
+ */
#ifdef __cplusplus
}
#endif /* __cplusplus */
int mv_object_detection_set_engine_open(mv_object_detection_h handle, const char *backend_type, const char *device_type)
{
+ lock_guard<mutex> lock(g_object_detection_mutex);
+
if (!handle) {
LOGE("Handle is NULL.");
return MEDIA_VISION_ERROR_INVALID_PARAMETER;
int mv_object_detection_get_engine_count_open(mv_object_detection_h handle, unsigned int *engine_count)
{
+ lock_guard<mutex> lock(g_object_detection_mutex);
+
if (!handle) {
LOGE("Handle is NULL.");
return MEDIA_VISION_ERROR_INVALID_PARAMETER;
int mv_object_detection_get_engine_type_open(mv_object_detection_h handle, const unsigned int engine_index,
char **engine_type)
{
+ lock_guard<mutex> lock(g_object_detection_mutex);
+
if (!handle) {
LOGE("Handle is NULL.");
return MEDIA_VISION_ERROR_INVALID_PARAMETER;
int mv_object_detection_get_device_count_open(mv_object_detection_h handle, const char *engine_type,
unsigned int *device_count)
{
+ lock_guard<mutex> lock(g_object_detection_mutex);
+
if (!handle) {
LOGE("Handle is NULL.");
return MEDIA_VISION_ERROR_INVALID_PARAMETER;
int mv_object_detection_get_device_type_open(mv_object_detection_h handle, const char *engine_type,
const unsigned int device_index, char **device_type)
{
+ lock_guard<mutex> lock(g_object_detection_mutex);
+
if (!handle) {
LOGE("Handle is NULL.");
return MEDIA_VISION_ERROR_INVALID_PARAMETER;
template<typename T, typename V>
void ObjectDetectionAdapter<T, V>::setEngineInfo(const char *engine_type, const char *device_type)
-{}
+{
+ _object_detection->setEngineInfo(string(engine_type), string(device_type));
+}
template<typename T, typename V> void ObjectDetectionAdapter<T, V>::configure()
{
*/
int mv_object_detection_3d_get_points_open(mv_object_detection_3d_h handle, unsigned int **out_x, unsigned int **out_y);
+/**
+ * @brief Set user-given model information.
+ * @details Use this function to change the model information instead of default one after calling @ref mv_object_detection_3d_create().
+ *
+ * @since_tizen 7.5
+ *
+ * @param[in] handle The handle to the object detection 3d object.
+ * @param[in] model_name Model name.
+ * @param[in] model_file Model file name.
+ * @param[in] meta_type Model meta file name.
+ * @param[in] label_file Label file name.
+ *
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #MEDIA_VISION_ERROR_NONE Successful
+ * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_VISION_ERROR_INVALID_OPERATION Invalid operation
+ *
+ * @pre Create a object detection 3d handle by calling @ref mv_object_detection_3d_create()
+ */
+int mv_object_detection_3d_set_model_open(mv_object_detection_3d_h handle, const char *model_name,
+ const char *model_file, const char *meta_file, const char *label_file);
+/**
+ * @brief Set user-given backend and device types for inference.
+ * @details Use this function to change the backend and device types for inference instead of default ones after calling @ref mv_object_detection_3d_create_open().
+ *
+ * @since_tizen 7.5
+ *
+ * @param[in] handle The handle to the object detection 3d object.
+ * @param[in] backend_type A string of backend type.
+ * @param[in] device_type A string of device type.
+ *
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #MEDIA_VISION_ERROR_NONE Successful
+ * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_VISION_ERROR_INVALID_OPERATION Invalid operation
+ *
+ * @pre Create a object detection 3d handle by calling @ref mv_object_detection_3d_create_open()
+ */
+int mv_object_detection_3d_set_engine_open(mv_object_detection_3d_h handle, const char *backend_type,
+ const char *device_type);
+
+/**
+ * @brief Get a number of inference engines available for object detection 3d task API.
+ * @details Use this function to get how many inference engines are supported for object detection 3d after calling @ref mv_object_detection_3d_create_open().
+ *
+ * @since_tizen 7.5
+ *
+ * @param[in] handle The handle to the object detection 3d object.
+ * @param[out] engine_count A number of inference engines available for object detection 3d API.
+ *
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #MEDIA_VISION_ERROR_NONE Successful
+ * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_VISION_ERROR_INVALID_OPERATION Invalid operation
+ *
+ * @pre Create a object detection 3d handle by calling @ref mv_object_detection_3d_create_open()
+ */
+int mv_object_detection_3d_get_engine_count_open(mv_object_detection_3d_h handle, unsigned int *engine_count);
+
+/**
+ * @brief Get engine type to a given inference engine index.
+ * @details Use this function to get inference engine type with a given engine index after calling @ref mv_object_detection_3d_get_engine_count().
+ *
+ * @since_tizen 7.5
+ *
+ * @param[in] handle The handle to the object detection 3d object.
+ * @param[in] engine_index A inference engine index for getting the inference engine type.
+ * @param[out] engine_type A string to inference engine.
+ *
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #MEDIA_VISION_ERROR_NONE Successful
+ * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_VISION_ERROR_INVALID_OPERATION Invalid operation
+ *
+ * @pre Get a number of inference engines available for object detection 3d task API by calling @ref mv_object_detection_3d_get_engine_count()
+ */
+int mv_object_detection_3d_get_engine_type_open(mv_object_detection_3d_h handle, const unsigned int engine_index,
+ char **engine_type);
+
+/**
+ * @brief Get a number of device types available to a given inference engine.
+ * @details Use this function to get how many device types are supported for a given inference engine after calling @ref mv_object_detection_3d_create_open().
+ *
+ * @since_tizen 7.5
+ *
+ * @param[in] handle The handle to the object detection 3d object.
+ * @param[in] engine_type A inference engine string.
+ * @param[out] device_count A number of device types available for a given inference engine.
+ *
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #MEDIA_VISION_ERROR_NONE Successful
+ * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_VISION_ERROR_INVALID_OPERATION Invalid operation
+ *
+ * @pre Create a object detection 3d handle by calling @ref mv_object_detection_3d_create_open()
+ */
+int mv_object_detection_3d_get_device_count_open(mv_object_detection_3d_h handle, const char *engine_type,
+ unsigned int *device_count);
+
+/**
+ * @brief Get device type list available.
+ * @details Use this function to get what device types are supported for current inference engine type after calling @ref mv_object_detection_3d_configure().
+ *
+ * @since_tizen 7.5
+ *
+ * @param[in] handle The handle to the object detection 3d object.
+ * @param[in] engine_type A inference engine string.
+ * @param[in] device_index A device index for getting the device type.
+ * @param[out] device_type A string to device type.
+ *
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #MEDIA_VISION_ERROR_NONE Successful
+ * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_VISION_ERROR_INVALID_OPERATION Invalid operation
+ *
+ * @pre Create a object detection 3d handle by calling @ref mv_object_detection_3d_create_open()
+ * @pre Configure object detection 3d task by calling @ref mv_object_detection_3d_configure_open()
+ */
+int mv_object_detection_3d_get_device_type_open(mv_object_detection_3d_h handle, const char *engine_type,
+ const unsigned int device_index, char **device_type);
+
#ifdef __cplusplus
}
#endif /* __cplusplus */
{
class ObjectDetection3d
{
+private:
+ void getEngineList();
+ void getDeviceList(const char *engine_type);
+
+ ObjectDetection3dTaskType _task_type;
+
protected:
std::unique_ptr<mediavision::inference::Inference> _inference;
std::unique_ptr<MediaVision::Common::EngineConfig> _config;
std::unique_ptr<MetaParser> _parser;
+ std::vector<std::string> _labels;
+ std::vector<std::string> _valid_backends;
+ std::vector<std::string> _valid_devices;
Preprocess _preprocess;
std::string _modelFilePath;
std::string _modelMetaFilePath;
+ std::string _modelDefaultPath;
+ std::string _modelLabelFilePath;
int _backendType;
int _targetDeviceType;
void getOutputTensor(std::string &target_name, std::vector<float> &tensor);
public:
- ObjectDetection3d();
+ ObjectDetection3d(ObjectDetection3dTaskType task_type);
virtual ~ObjectDetection3d() = default;
+
+ ObjectDetection3dTaskType getTaskType();
+ void setUserModel(std::string model_file, std::string meta_file, std::string label_file);
+ void setEngineInfo(std::string engine_type, std::string device_type);
+ void getNumberOfEngines(unsigned int *number_of_engines);
+ void getEngineType(unsigned int engine_index, char **engine_type);
+ void getNumberOfDevices(const char *engine_type, unsigned int *number_of_devices);
+ void getDeviceType(const char *engine_type, const unsigned int device_index, char **device_type);
void parseMetaFile();
void configure();
void prepare();
void preprocess(mv_source_h &mv_src);
void inference(mv_source_h source);
- virtual object_detection_3d_result_s &result() = 0;
+ virtual ObjectDetection3dResult &result() = 0;
};
} // machine_learning
private:
std::unique_ptr<ObjectDetection3d> _object_detection_3d;
T _source;
+ std::string _model_name;
+ std::string _model_file;
+ std::string _meta_file;
+ std::string _label_file;
public:
ObjectDetection3dAdapter();
{
namespace machine_learning
{
-struct object_detection_3d_input_s {
+struct ObjectDetection3dInput {
mv_source_h inference_src;
};
-struct edge_index_s {
+struct EdgeIndex {
unsigned int start {};
unsigned int end {};
};
* @brief The object detection 3d result structure.
* @details Contains object detection 3d result.
*/
-struct object_detection_3d_result_s {
+struct ObjectDetection3dResult {
unsigned int probability {};
unsigned int number_of_points {};
std::vector<unsigned int> x_vec;
std::vector<unsigned int> y_vec;
unsigned int number_of_edges {};
- std::vector<edge_index_s> edge_index_vec;
+ std::vector<EdgeIndex> edge_index_vec;
};
-enum class object_detection_3d_task_type_e {
+enum class ObjectDetection3dTaskType {
OBJECT_DETECTION_3D_TASK_NONE = 0,
OBJECTRON
// TODO
class Objectron : public ObjectDetection3d
{
private:
- object_detection_3d_result_s _result;
+ ObjectDetection3dResult _result;
public:
- Objectron();
+ Objectron(ObjectDetection3dTaskType task_type);
~Objectron();
- object_detection_3d_result_s &result() override;
+
+ ObjectDetection3dResult &result() override;
};
} // machine_learning
return ret;
}
+int mv_object_detection_3d_set_model(mv_object_detection_3d_h handle, const char *model_name, const char *model_file,
+ const char *meta_file, const char *label_file)
+{
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported());
+
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+ MEDIA_VISION_INSTANCE_CHECK(model_name);
+ MEDIA_VISION_NULL_ARG_CHECK(model_file);
+ MEDIA_VISION_NULL_ARG_CHECK(meta_file);
+ MEDIA_VISION_NULL_ARG_CHECK(label_file);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ int ret = mv_object_detection_3d_set_model_open(handle, model_name, model_file, meta_file, label_file);
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return ret;
+}
+
+int mv_object_detection_3d_set_engine(mv_object_detection_3d_h handle, const char *backend_type,
+ const char *device_type)
+{
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported());
+
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+ MEDIA_VISION_NULL_ARG_CHECK(backend_type);
+ MEDIA_VISION_NULL_ARG_CHECK(device_type);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ int ret = mv_object_detection_3d_set_engine_open(handle, backend_type, device_type);
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return ret;
+}
+
+int mv_object_detection_3d_get_engine_count(mv_object_detection_3d_h handle, unsigned int *engine_count)
+{
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported());
+
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+ MEDIA_VISION_NULL_ARG_CHECK(engine_count);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ int ret = mv_object_detection_3d_get_engine_count_open(handle, engine_count);
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return ret;
+}
+
+int mv_object_detection_3d_get_engine_type(mv_object_detection_3d_h handle, const unsigned int engine_index,
+ char **engine_type)
+{
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported());
+
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+ MEDIA_VISION_NULL_ARG_CHECK(engine_type);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ int ret = mv_object_detection_3d_get_engine_type_open(handle, engine_index, engine_type);
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return ret;
+}
+
+int mv_object_detection_3d_get_device_count(mv_object_detection_3d_h handle, const char *engine_type,
+ unsigned int *device_count)
+{
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported());
+
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+ MEDIA_VISION_NULL_ARG_CHECK(device_count);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ int ret = mv_object_detection_3d_get_device_count_open(handle, engine_type, device_count);
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return ret;
+}
+
+int mv_object_detection_3d_get_device_type(mv_object_detection_3d_h handle, const char *engine_type,
+ const unsigned int device_index, char **device_type)
+{
+ MEDIA_VISION_SUPPORT_CHECK(_mv_inference_face_check_system_info_feature_supported());
+
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+ MEDIA_VISION_NULL_ARG_CHECK(engine_type);
+ MEDIA_VISION_NULL_ARG_CHECK(device_type);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ int ret = mv_object_detection_3d_get_device_type_open(handle, engine_type, device_index, device_type);
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return ret;
+}
+
int mv_object_detection_3d_configure(mv_object_detection_3d_h infer)
{
MEDIA_VISION_SUPPORT_CHECK(_mv_inference_check_system_info_feature_supported());
#include <unistd.h>
#include <string>
#include <algorithm>
+#include <mutex>
using namespace std;
using namespace mediavision::inference;
using namespace mediavision::machine_learning;
using namespace MediaVision::Common;
using namespace mediavision::machine_learning::exception;
-using ObjectDetection3dTask = ITask<object_detection_3d_input_s, object_detection_3d_result_s>;
+using ObjectDetection3dTask = ITask<ObjectDetection3dInput, ObjectDetection3dResult>;
+
+static mutex g_object_detection_3d_mutex;
int mv_object_detection_3d_create_open(mv_object_detection_3d_h *out_handle)
{
try {
context = new Context();
- task = new ObjectDetection3dAdapter<object_detection_3d_input_s, object_detection_3d_result_s>();
- task->create(static_cast<int>(object_detection_3d_task_type_e::OBJECTRON));
-
+ task = new ObjectDetection3dAdapter<ObjectDetection3dInput, ObjectDetection3dResult>();
context->__tasks.insert(make_pair("object_detection_3d", task));
*out_handle = static_cast<mv_object_detection_3d_h>(context);
} catch (const BaseException &e) {
int mv_object_detection_3d_destroy_open(mv_object_detection_3d_h handle)
{
+ lock_guard<mutex> lock(g_object_detection_3d_mutex);
+
if (!handle) {
LOGE("Handle is NULL.");
return MEDIA_VISION_ERROR_INVALID_PARAMETER;
return MEDIA_VISION_ERROR_NONE;
}
+int mv_object_detection_3d_set_model_open(mv_object_detection_3d_h handle, const char *model_name,
+ const char *model_file, const char *meta_file, const char *label_file)
+{
+ LOGD("ENTER");
+
+ lock_guard<mutex> lock(g_object_detection_3d_mutex);
+
+ if (!handle) {
+ LOGE("Handle is NULL.");
+ return MEDIA_VISION_ERROR_INVALID_PARAMETER;
+ }
+
+ try {
+ auto context = static_cast<Context *>(handle);
+ auto task = static_cast<ObjectDetection3dTask *>(context->__tasks.at("object_detection_3d"));
+
+ task->setModelInfo(model_file, meta_file, label_file, model_name);
+ } catch (const BaseException &e) {
+ LOGE("%s", e.what());
+ return e.getError();
+ }
+
+ LOGD("LEAVE");
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_object_detection_3d_set_engine_open(mv_object_detection_3d_h handle, const char *backend_type,
+ const char *device_type)
+{
+ LOGD("ENTER");
+
+ lock_guard<mutex> lock(g_object_detection_3d_mutex);
+
+ if (!handle) {
+ LOGE("Handle is NULL.");
+ return MEDIA_VISION_ERROR_INVALID_PARAMETER;
+ }
+
+ try {
+ auto context = static_cast<Context *>(handle);
+ auto task = static_cast<ObjectDetection3dTask *>(context->__tasks.at("object_detection_3d"));
+
+ task->setEngineInfo(backend_type, device_type);
+ } catch (const BaseException &e) {
+ LOGE("%s", e.what());
+ return e.getError();
+ }
+
+ LOGD("LEAVE");
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_object_detection_3d_get_engine_count_open(mv_object_detection_3d_h handle, unsigned int *engine_count)
+{
+ LOGD("ENTER");
+
+ lock_guard<mutex> lock(g_object_detection_3d_mutex);
+
+ if (!handle) {
+ LOGE("Handle is NULL.");
+ return MEDIA_VISION_ERROR_INVALID_PARAMETER;
+ }
+
+ try {
+ auto context = static_cast<Context *>(handle);
+ auto task = static_cast<ObjectDetection3dTask *>(context->__tasks.at("object_detection_3d"));
+
+ task->getNumberOfEngines(engine_count);
+ // TODO.
+ } catch (const BaseException &e) {
+ LOGE("%s", e.what());
+ return e.getError();
+ }
+
+ LOGD("LEAVE");
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_object_detection_3d_get_engine_type_open(mv_object_detection_3d_h handle, const unsigned int engine_index,
+ char **engine_type)
+{
+ LOGD("ENTER");
+
+ lock_guard<mutex> lock(g_object_detection_3d_mutex);
+
+ if (!handle) {
+ LOGE("Handle is NULL.");
+ return MEDIA_VISION_ERROR_INVALID_PARAMETER;
+ }
+
+ try {
+ auto context = static_cast<Context *>(handle);
+ auto task = static_cast<ObjectDetection3dTask *>(context->__tasks.at("object_detection_3d"));
+
+ task->getEngineType(engine_index, engine_type);
+ // TODO.
+ } catch (const BaseException &e) {
+ LOGE("%s", e.what());
+ return e.getError();
+ }
+
+ LOGD("LEAVE");
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_object_detection_3d_get_device_count_open(mv_object_detection_3d_h handle, const char *engine_type,
+ unsigned int *device_count)
+{
+ LOGD("ENTER");
+
+ lock_guard<mutex> lock(g_object_detection_3d_mutex);
+
+ if (!handle) {
+ LOGE("Handle is NULL.");
+ return MEDIA_VISION_ERROR_INVALID_PARAMETER;
+ }
+
+ try {
+ auto context = static_cast<Context *>(handle);
+ auto task = static_cast<ObjectDetection3dTask *>(context->__tasks.at("object_detection_3d"));
+
+ task->getNumberOfDevices(engine_type, device_count);
+ // TODO.
+ } catch (const BaseException &e) {
+ LOGE("%s", e.what());
+ return e.getError();
+ }
+
+ LOGD("LEAVE");
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_object_detection_3d_get_device_type_open(mv_object_detection_3d_h handle, const char *engine_type,
+ const unsigned int device_index, char **device_type)
+{
+ LOGD("ENTER");
+
+ lock_guard<mutex> lock(g_object_detection_3d_mutex);
+
+ if (!handle) {
+ LOGE("Handle is NULL.");
+ return MEDIA_VISION_ERROR_INVALID_PARAMETER;
+ }
+
+ try {
+ auto context = static_cast<Context *>(handle);
+ auto task = static_cast<ObjectDetection3dTask *>(context->__tasks.at("object_detection_3d"));
+
+ task->getDeviceType(engine_type, device_index, device_type);
+ // TODO.
+ } catch (const BaseException &e) {
+ LOGE("%s", e.what());
+ return e.getError();
+ }
+
+ LOGD("LEAVE");
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
int mv_object_detection_3d_configure_open(mv_object_detection_3d_h handle)
{
LOGD("ENTER");
+ lock_guard<mutex> lock(g_object_detection_3d_mutex);
+
if (!handle) {
LOGE("Handle is NULL.");
return MEDIA_VISION_ERROR_INVALID_PARAMETER;
{
LOGD("ENTER");
+ lock_guard<mutex> lock(g_object_detection_3d_mutex);
+
if (!handle) {
LOGE("Handle is NULL.");
return MEDIA_VISION_ERROR_INVALID_PARAMETER;
{
LOGD("ENTER");
+ lock_guard<mutex> lock(g_object_detection_3d_mutex);
+
if (!handle) {
LOGE("Handle is NULL.");
return MEDIA_VISION_ERROR_INVALID_PARAMETER;
auto context = static_cast<Context *>(handle);
auto task = static_cast<ObjectDetection3dTask *>(context->__tasks.at("object_detection_3d"));
- object_detection_3d_input_s input = { source };
+ ObjectDetection3dInput input = { source };
task->setInput(input);
task->perform();
{
LOGD("ENTER");
+ lock_guard<mutex> lock(g_object_detection_3d_mutex);
+
if (!handle) {
LOGE("Handle is NULL.");
return MEDIA_VISION_ERROR_INVALID_PARAMETER;
auto context = static_cast<Context *>(handle);
auto task = static_cast<ObjectDetection3dTask *>(context->__tasks.at("object_detection_3d"));
- object_detection_3d_result_s &result = task->getOutput();
+ ObjectDetection3dResult &result = task->getOutput();
*out_probability = result.probability;
} catch (const BaseException &e) {
{
LOGD("ENTER");
+ lock_guard<mutex> lock(g_object_detection_3d_mutex);
+
if (!handle) {
LOGE("Handle is NULL.");
return MEDIA_VISION_ERROR_INVALID_PARAMETER;
auto context = static_cast<Context *>(handle);
auto task = static_cast<ObjectDetection3dTask *>(context->__tasks.at("object_detection_3d"));
- object_detection_3d_result_s &result = task->getOutput();
+ ObjectDetection3dResult &result = task->getOutput();
*out_num_of_points = result.number_of_points;
} catch (const BaseException &e) {
{
LOGD("ENTER");
+ lock_guard<mutex> lock(g_object_detection_3d_mutex);
+
if (!handle) {
LOGE("Handle is NULL.");
return MEDIA_VISION_ERROR_INVALID_PARAMETER;
Context *context = static_cast<Context *>(handle);
auto task = static_cast<ObjectDetection3dTask *>(context->__tasks.at("object_detection_3d"));
- object_detection_3d_result_s &result = task->getOutput();
+ ObjectDetection3dResult &result = task->getOutput();
*out_x = result.x_vec.data();
*out_y = result.y_vec.data();
#include <algorithm>
#include "machine_learning_exception.h"
+#include "mv_machine_learning_common.h"
#include "mv_object_detection_3d_config.h"
#include "object_detection_3d.h"
using namespace std;
using namespace mediavision::inference;
using namespace MediaVision::Common;
+using namespace mediavision::common;
using namespace mediavision::machine_learning::exception;
namespace mediavision
{
namespace machine_learning
{
-ObjectDetection3d::ObjectDetection3d() : _backendType(), _targetDeviceType()
+ObjectDetection3d::ObjectDetection3d(ObjectDetection3dTaskType task_type)
+ : _task_type(task_type), _backendType(), _targetDeviceType()
{
_inference = make_unique<Inference>();
_parser = make_unique<ObjectDetection3dParser>();
}
+ObjectDetection3dTaskType ObjectDetection3d::getTaskType()
+{
+ return _task_type;
+}
+
+void ObjectDetection3d::getEngineList()
+{
+ for (auto idx = MV_INFERENCE_BACKEND_NONE + 1; idx < MV_INFERENCE_BACKEND_MAX; ++idx) {
+ auto backend = _inference->getSupportedInferenceBackend(idx);
+ // TODO. we need to describe what inference engines are supported by each Task API,
+ // and based on it, below inference engine types should be checked
+ // if a given type is supported by this Task API later. As of now, tflite only.
+ if (backend.second == true && backend.first.compare("tflite") == 0)
+ _valid_backends.push_back(backend.first);
+ }
+}
+
+void ObjectDetection3d::getDeviceList(const char *engine_type)
+{
+ // TODO. add device types available for a given engine type later.
+ // In default, cpu and gpu only.
+ _valid_devices.push_back("cpu");
+ _valid_devices.push_back("gpu");
+}
+
+void ObjectDetection3d::setEngineInfo(std::string engine_type, std::string device_type)
+{
+ if (engine_type.empty() || device_type.empty())
+ throw InvalidParameter("Invalid engine info.");
+
+ transform(engine_type.begin(), engine_type.end(), engine_type.begin(), ::toupper);
+ transform(device_type.begin(), device_type.end(), device_type.begin(), ::toupper);
+
+ _backendType = GetBackendType(engine_type);
+ _targetDeviceType = GetDeviceType(device_type);
+
+ LOGI("Engine type : %s => %d, Device type : %s => %d", engine_type.c_str(), GetBackendType(engine_type),
+ device_type.c_str(), GetDeviceType(device_type));
+
+ if (_backendType == MEDIA_VISION_ERROR_INVALID_PARAMETER ||
+ _targetDeviceType == MEDIA_VISION_ERROR_INVALID_PARAMETER)
+ throw InvalidParameter("backend or target device type not found.");
+}
+
+void ObjectDetection3d::getNumberOfEngines(unsigned int *number_of_engines)
+{
+ if (!_valid_backends.empty()) {
+ *number_of_engines = _valid_backends.size();
+ return;
+ }
+
+ getEngineList();
+ *number_of_engines = _valid_backends.size();
+}
+
+void ObjectDetection3d::getEngineType(unsigned int engine_index, char **engine_type)
+{
+ if (!_valid_backends.empty()) {
+ if (_valid_backends.size() <= engine_index)
+ throw InvalidParameter("Invalid engine index.");
+
+ *engine_type = const_cast<char *>(_valid_backends[engine_index].data());
+ return;
+ }
+
+ getEngineList();
+
+ if (_valid_backends.size() <= engine_index)
+ throw InvalidParameter("Invalid engine index.");
+
+ *engine_type = const_cast<char *>(_valid_backends[engine_index].data());
+}
+
+void ObjectDetection3d::getNumberOfDevices(const char *engine_type, unsigned int *number_of_devices)
+{
+ if (!_valid_devices.empty()) {
+ *number_of_devices = _valid_devices.size();
+ return;
+ }
+
+ getDeviceList(engine_type);
+ *number_of_devices = _valid_devices.size();
+}
+
+void ObjectDetection3d::getDeviceType(const char *engine_type, const unsigned int device_index, char **device_type)
+{
+ if (!_valid_devices.empty()) {
+ if (_valid_devices.size() <= device_index)
+ throw InvalidParameter("Invalid device index.");
+
+ *device_type = const_cast<char *>(_valid_devices[device_index].data());
+ return;
+ }
+
+ getDeviceList(engine_type);
+
+ if (_valid_devices.size() <= device_index)
+ throw InvalidParameter("Invalid device index.");
+
+ *device_type = const_cast<char *>(_valid_devices[device_index].data());
+}
+
+void ObjectDetection3d::setUserModel(string model_file, string meta_file, string label_file)
+{
+ _modelFilePath = model_file;
+ _modelMetaFilePath = meta_file;
+ _modelLabelFilePath = label_file;
+}
+
static bool IsJsonFile(const string &fileName)
{
return (!fileName.substr(fileName.find_last_of(".") + 1).compare("json"));
if (ret != MEDIA_VISION_ERROR_NONE)
throw InvalidOperation("Fail to get model default path");
- ret = _config->getStringAttribute(MV_OBJECT_DETECTION_3D_MODEL_FILE_PATH, &_modelFilePath);
- if (ret != MEDIA_VISION_ERROR_NONE)
- throw InvalidOperation("Fail to get model file path");
+ if (_modelFilePath.empty()) {
+ ret = _config->getStringAttribute(MV_OBJECT_DETECTION_3D_MODEL_FILE_PATH, &_modelFilePath);
+ if (ret != MEDIA_VISION_ERROR_NONE)
+ throw InvalidOperation("Fail to get model file path");
+ }
_modelFilePath = modelDefaultPath + _modelFilePath;
- ret = _config->getStringAttribute(MV_OBJECT_DETECTION_3D_MODEL_META_FILE_PATH, &_modelMetaFilePath);
- if (ret != MEDIA_VISION_ERROR_NONE)
- throw InvalidOperation("Fail to get model meta file path");
+ if (_modelMetaFilePath.empty()) {
+ ret = _config->getStringAttribute(MV_OBJECT_DETECTION_3D_MODEL_META_FILE_PATH, &_modelMetaFilePath);
+ if (ret != MEDIA_VISION_ERROR_NONE)
+ throw InvalidOperation("Fail to get model meta file path");
- if (_modelMetaFilePath.empty())
- throw InvalidOperation("Model meta file doesn't exist.");
+ if (_modelMetaFilePath.empty())
+ throw InvalidOperation("Model meta file doesn't exist.");
- if (!IsJsonFile(_modelMetaFilePath))
- throw InvalidOperation("Model meta file should be json");
+ if (!IsJsonFile(_modelMetaFilePath))
+ throw InvalidOperation("Model meta file should be json");
+ }
_modelMetaFilePath = modelDefaultPath + _modelMetaFilePath;
namespace machine_learning
{
template<typename T, typename V> ObjectDetection3dAdapter<T, V>::ObjectDetection3dAdapter() : _source()
-{}
+{
+ _object_detection_3d = make_unique<Objectron>(ObjectDetection3dTaskType::OBJECTRON);
+}
template<typename T, typename V> ObjectDetection3dAdapter<T, V>::~ObjectDetection3dAdapter()
{}
template<typename T, typename V> void ObjectDetection3dAdapter<T, V>::create(int type)
-{
- switch (static_cast<object_detection_3d_task_type_e>(type)) {
- case object_detection_3d_task_type_e::OBJECTRON:
- _object_detection_3d = make_unique<Objectron>();
- break;
- default:
- throw InvalidParameter("Invalid object detection task type.");
- }
-}
+{}
template<typename T, typename V>
void ObjectDetection3dAdapter<T, V>::setModelInfo(const char *model_file, const char *meta_file, const char *label_file,
const char *model_name)
-{}
+{
+ string model_name_str(model_name);
+
+ if (!model_name_str.empty()) {
+ transform(model_name_str.begin(), model_name_str.end(), model_name_str.begin(), ::toupper);
+
+ int model_type = 0;
+
+ if (model_name_str == string("OBJECTRON"))
+ model_type = static_cast<int>(ObjectDetection3dTaskType::OBJECTRON);
+ else
+ throw InvalidParameter("Invalid object detection 3d model name.");
+
+ create(static_cast<int>(model_type));
+ }
+
+ _model_file = string(model_file);
+ _meta_file = string(meta_file);
+ _label_file = string(label_file);
+
+ if (_model_file.empty() && _meta_file.empty() && _label_file.empty())
+ throw InvalidParameter("Model info not invalid.");
+
+ _object_detection_3d->setUserModel(_model_file, _meta_file, _label_file);
+}
template<typename T, typename V>
void ObjectDetection3dAdapter<T, V>::setEngineInfo(const char *engine_type, const char *device_type)
-{}
+{
+ _object_detection_3d->setEngineInfo(string(engine_type), string(device_type));
+}
template<typename T, typename V> void ObjectDetection3dAdapter<T, V>::configure()
{
template<typename T, typename V>
void ObjectDetection3dAdapter<T, V>::getNumberOfEngines(unsigned int *number_of_engines)
-{}
+{
+ _object_detection_3d->getNumberOfEngines(number_of_engines);
+}
template<typename T, typename V>
void ObjectDetection3dAdapter<T, V>::getEngineType(unsigned int engine_index, char **engine_type)
-{}
+{
+ _object_detection_3d->getEngineType(engine_index, engine_type);
+}
template<typename T, typename V>
void ObjectDetection3dAdapter<T, V>::getNumberOfDevices(const char *engine_type, unsigned int *number_of_devices)
-{}
+{
+ _object_detection_3d->getNumberOfDevices(engine_type, number_of_devices);
+}
template<typename T, typename V>
void ObjectDetection3dAdapter<T, V>::getDeviceType(const char *engine_type, unsigned int device_index,
char **device_type)
-{}
+{
+ _object_detection_3d->getDeviceType(engine_type, device_index, device_type);
+}
template<typename T, typename V> void ObjectDetection3dAdapter<T, V>::prepare()
{
return _object_detection_3d->result();
}
-template class ObjectDetection3dAdapter<object_detection_3d_input_s, object_detection_3d_result_s>;
+template class ObjectDetection3dAdapter<ObjectDetection3dInput, ObjectDetection3dResult>;
}
}
\ No newline at end of file
{
namespace machine_learning
{
-Objectron::Objectron() : _result()
+Objectron::Objectron(ObjectDetection3dTaskType task_type) : ObjectDetection3d(task_type), _result()
{}
Objectron::~Objectron()
{}
-object_detection_3d_result_s &Objectron::result()
+ObjectDetection3dResult &Objectron::result()
{
vector<string> names;
using namespace MediaVision::Common;
-TEST(ObjectDetection3DTest, InferenceShouldBeOk)
+struct model_info {
+ string model_name;
+ string model_file;
+ string meta_file;
+ string label_file;
+};
+
+TEST(ObjectDetection3dTest, GettingAvailableInferenceEnginesInfoShouldBeOk)
{
mv_object_detection_3d_h handle;
int ret = mv_object_detection_3d_create(&handle);
ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
- ret = mv_object_detection_3d_configure(handle);
+ unsigned int engine_count = 0;
+
+ ret = mv_object_detection_3d_get_engine_count(handle, &engine_count);
ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
- ret = mv_object_detection_3d_prepare(handle);
+ cout << "Engine count = " << engine_count << endl;
+ ASSERT_GE(engine_count, 1);
+
+ for (unsigned int engine_idx = 0; engine_idx < engine_count; ++engine_idx) {
+ char *engine_type = nullptr;
+
+ ret = mv_object_detection_3d_get_engine_type(handle, engine_idx, &engine_type);
+ ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
+
+ cout << "Engine type : " << engine_type << endl;
+
+ unsigned int device_count = 0;
+
+ ret = mv_object_detection_3d_get_device_count(handle, engine_type, &device_count);
+ ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
+
+ cout << "Device count = " << device_count << endl;
+
+ ASSERT_GE(engine_count, 1);
+
+ for (unsigned int device_idx = 0; device_idx < device_count; ++device_idx) {
+ char *device_type = nullptr;
+
+ ret = mv_object_detection_3d_get_device_type(handle, engine_type, device_idx, &device_type);
+ ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
+
+ cout << "Device type : " << device_type << endl;
+ }
+ }
+
+ ret = mv_object_detection_3d_destroy(handle);
ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
+}
+
+TEST(ObjectDetection3dTest, InferenceShouldBeOk)
+{
+ vector<model_info> test_models {
+ { "", "", "", "" }, // If empty then default model will be used.
+ { "objectron", "object_detection_3d_cup.tflite", "object_detection_3d_cup.json", "" }
+ // TODO.
+ };
const string image_path = IMAGE_PATH;
mv_source_h mv_source = NULL;
- ret = mv_create_source(&mv_source);
+ int ret = mv_create_source(&mv_source);
ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
ret = ImageHelper::loadImageToSource(image_path.c_str(), mv_source);
ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
- ret = mv_object_detection_3d_inference(handle, mv_source);
- ASSERT_EQ(ret, 0);
+ for (auto model : test_models) {
+ mv_object_detection_3d_h handle;
- unsigned int probability;
+ cout << "model name : " << model.model_file << endl;
- ret = mv_object_detection_3d_get_probability(handle, &probability);
- ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
+ ret = mv_object_detection_3d_create(&handle);
+ ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
- std::cout << "Probability = " << probability << std::endl;
+ mv_object_detection_3d_set_model(handle, model.model_name.c_str(), model.model_file.c_str(),
+ model.meta_file.c_str(), model.label_file.c_str());
+ mv_object_detection_3d_set_engine(handle, "tflite", "cpu");
- unsigned int num_of_points;
+ ret = mv_object_detection_3d_configure(handle);
+ ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
- ret = mv_object_detection_3d_get_num_of_points(handle, &num_of_points);
- ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
+ ret = mv_object_detection_3d_prepare(handle);
+ ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
- unsigned int *x_array, *y_array;
+ ret = mv_object_detection_3d_inference(handle, mv_source);
+ ASSERT_EQ(ret, 0);
- ret = mv_object_detection_3d_get_points(handle, &x_array, &y_array);
- ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
+ unsigned int probability;
+
+ ret = mv_object_detection_3d_get_probability(handle, &probability);
+ ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
+
+ std::cout << "Probability = " << probability << std::endl;
+
+ unsigned int num_of_points;
- for (unsigned int idx = 0; idx < num_of_points; ++idx) {
- std::cout << "index = " << idx + 1 << " : " << x_array[idx] << " x " << y_array[idx] << std::endl;
+ ret = mv_object_detection_3d_get_num_of_points(handle, &num_of_points);
+ ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
+
+ unsigned int *x_array, *y_array;
+
+ ret = mv_object_detection_3d_get_points(handle, &x_array, &y_array);
+ ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
+
+ for (unsigned int idx = 0; idx < num_of_points; ++idx)
+ std::cout << "index = " << idx + 1 << " : " << x_array[idx] << " x " << y_array[idx] << std::endl;
+
+ ret = mv_object_detection_3d_destroy(handle);
+ ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
}
ret = mv_destroy_source(mv_source);
ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
-
- ret = mv_object_detection_3d_destroy(handle);
- ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
}