int mv_object_detection_3d_inference(mv_object_detection_3d_h infer, mv_source_h source);
/**
- * @brief Gets the object detection 3d result.
- * @details Use this function to get the detected result after calling @ref mv_object_detection_3d_inference().
+ * @brief Gets the probability value to the detected object.
+ * @details Use this function to get the probability value after calling @ref mv_object_detection_3d_inference().
*
* @since_tizen 7.0
*
* @remarks The @a result must NOT be released using free()
*
- * @param[in] handle The handle to the face recognition object.
- * @param[out] out_result The structure point which contains object detection 3d inference result.
+ * @param[in] handle The handle to the face recognition object.
+ * @param[out] out_probability A pointer to probability array.
*
* @return @c 0 on success, otherwise a negative error value
* @retval #MEDIA_VISION_ERROR_NONE Successful
*
* @pre Request an inference by calling @ref mv_object_detection_3d_inference()
*/
-int mv_object_detection_3d_get_result(mv_object_detection_3d_h handle, mv_object_detection_3d_result_s *out_result);
+int mv_object_detection_3d_get_probability(mv_object_detection_3d_h handle, unsigned int *out_probability);
+
+/**
+ * @brief Gets the number of points to the 3D bounding box of the detected object.
+ * @details Use this function to get the number of points after calling @ref mv_object_detection_3d_inference().
+ *
+ * @since_tizen 7.0
+ *
+ * @remarks The @a result must NOT be released using free()
+ *
+ * @param[in] handle The handle to the face recognition object.
+ * @param[out] out_num_of_points Number of points.
+ *
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #MEDIA_VISION_ERROR_NONE Successful
+ * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_VISION_ERROR_INVALID_OPERATION Invalid operation
+ *
+ * @pre Request an inference by calling @ref mv_object_detection_3d_inference()
+ */
+int mv_object_detection_3d_get_num_of_points(mv_object_detection_3d_h handle, unsigned int *out_num_of_points);
+
+/**
+ * @brief Gets the x and y coordinates values to the 3D bounding box of the detected object.
+ * @details Use this function to get the coordinates values after calling @ref mv_object_detection_3d_inference().
+ *
+ * @since_tizen 7.0
+ *
+ * @remarks The @a result must NOT be released using free()
+ *
+ * @param[in] handle The handle to the face recognition object.
+ * @param[out] out_x A pointer to x coordinates array.
+ * @param[out] out_y A pointer to y coordinates array.
+ *
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #MEDIA_VISION_ERROR_NONE Successful
+ * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_VISION_ERROR_INVALID_OPERATION Invalid operation
+ *
+ * @pre Request 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 The structure to object detection 3d result.
- *
- * @since_tizen 7.0
- * @remarks @a points should not be released by app.
- * The number of elements in @a points is equal to @a number_of_points.
- *
- * @probability The probability value to the detected object.
- * @number_of_points The number of points.
- * @points 2d coodinations to keypoints.
- * @number_of_edges The number of edges.
- * @edge_indexes pair index per a edge to the points array.
- *
- * @pre Call mv_object_detection_3d_inference() function to perform 3d detection of the objects
- * in @a source and to get a result.
- *
- * @see mv_object_detect_3d_inference()
- */
-typedef struct mv_object_detection_3d_result {
- unsigned int probability;
- unsigned int number_of_points;
- mv_point_s points[9];
- unsigned int number_of_edges;
- unsigned int edge_indexes[12][2];
-} mv_object_detection_3d_result_s;
-
-/**
* @brief The object detection 3d object handle.
*
* @since_tizen 7.0
virtual void prepare() = 0;
virtual void setInput(T &t) = 0;
virtual void perform() = 0;
- virtual V &getOutput() = 0;
+ virtual V* getOutput() = 0;
};
} // namespace
} // namespace
int RegisterNewFace(mv_source_h img_src, std::string label_name);
int RecognizeFace(mv_source_h img_src);
int DeleteLabel(std::string label_name);
- mv_face_recognition_result_s &GetResult();
+ int GetLabel(const char **out_label);
+ mv_face_recognition_result_s* GetResult();
};
} // machine_learning
} // mediavision
-#endif
\ No newline at end of file
+#endif
void prepare() override;
void setInput(T &t) override;
void perform() override;
- V &getOutput() override;
+ V* getOutput() override;
};
} // machine_learning
return MEDIA_VISION_ERROR_NONE;
}
-mv_face_recognition_result_s &FaceRecognition::GetResult()
+int FaceRecognition::GetLabel(const char **out_label)
+{
+ if (_status != INFERENCED) {
+ LOGE("Inference not completed yet.");
+ return MEDIA_VISION_ERROR_INVALID_OPERATION;
+ }
+
+ try {
+ _label_manager->GetLabelString(_result.label, _result.label_idx);
+ } catch (const BaseException &e) {
+ LOGE("%s", e.what());
+ return e.getError();
+ }
+
+ *out_label = _result.label.c_str();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+mv_face_recognition_result_s* FaceRecognition::GetResult()
{
if (_status != INFERENCED)
throw InvalidOperation("Inference not completed yet.");
throw e;
}
- return _result;
+ return &_result;
}
} // machine_learning
-} // mediavision
\ No newline at end of file
+} // mediavision
}
}
-template<typename T, typename V> V &FaceRecognitionAdapter<T, V>::getOutput()
+template<typename T, typename V> V* FaceRecognitionAdapter<T, V>::getOutput()
{
return _face_recognition->GetResult();
}
Context *context = static_cast<Context *>(handle);
auto task = static_cast<FaceRecognitionTask *>(context->__tasks["face_recognition"]);
- *out_label = task->getOutput().label.c_str();
+ *out_label = task->getOutput()->label.c_str();
} catch (const BaseException &e) {
LOGE("%s", e.what());
return e.getError();
int mv_object_detection_3d_inference_open(mv_object_detection_3d_h handle, mv_source_h source);
/**
- * @brief Get a label name and store it to @a out_label.
- * @details Use this function to get a label name after calling mv_object_detection_3d_inference_open function.
+ * @brief Gets the probability value to the detected object.
+ * @details Use this function to get the probability value after calling @ref mv_object_detection_3d_inference().
*
* @since_tizen 7.0
*
- * @param[in] handle The handle to the object detection 3d object.
- * @param[out]
+ * @remarks The @a result must NOT be released using free()
+ *
+ * @param[in] handle The handle to the face recognition object.
+ * @param[out] out_probability A pointer to probability array.
+ *
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #MEDIA_VISION_ERROR_NONE Successful
+ * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_VISION_ERROR_INVALID_OPERATION Invalid operation
+ *
+ * @pre Request an inference by calling @ref mv_object_detection_3d_inference()
+ */
+ int mv_object_detection_3d_get_probability_open(mv_object_detection_3d_h handle, unsigned int *out_probability);
+
+ /**
+ * @brief Gets the number of points to the 3D bounding box of the detected object.
+ * @details Use this function to get the number of points after calling @ref mv_object_detection_3d_inference().
+ *
+ * @since_tizen 7.0
+ *
+ * @remarks The @a result must NOT be released using free()
+ *
+ * @param[in] handle The handle to the face recognition object.
+ * @param[out] out_num_of_points Number of points.
+ *
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #MEDIA_VISION_ERROR_NONE Successful
+ * @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_VISION_ERROR_INVALID_OPERATION Invalid operation
+ *
+ * @pre Request an inference by calling @ref mv_object_detection_3d_inference()
+ */
+ int mv_object_detection_3d_get_num_of_points_open(mv_object_detection_3d_h handle, unsigned int *out_num_of_points);
+
+ /**
+ * @brief Gets the x and y coordinates values to the 3D bounding box of the detected object.
+ * @details Use this function to get the coordinates values after calling @ref mv_object_detection_3d_inference().
+ *
+ * @since_tizen 7.0
+ *
+ * @remarks The @a result must NOT be released using free()
+ *
+ * @param[in] handle The handle to the face recognition object.
+ * @param[out] out_x A pointer to x coordinates array.
+ * @param[out] out_y A pointer to y coordinates array.
*
* @return @c 0 on success, otherwise a negative error value
* @retval #MEDIA_VISION_ERROR_NONE Successful
* @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #MEDIA_VISION_ERROR_INVALID_OPERATION Invalid operation
*
- * @pre Request a inference by calling @ref mv_object_detection_3d_inference_open()
+ * @pre Request an inference by calling @ref mv_object_detection_3d_inference()
*/
- int mv_object_detection_3d_get_result_open(mv_object_detection_3d_h handle, mv_object_detection_3d_result_s *out_result);
+ int mv_object_detection_3d_get_points_open(mv_object_detection_3d_h handle, unsigned int **out_x, unsigned int **out_y);
#ifdef __cplusplus
}
void configure();
void prepare();
void inference(mv_source_h source);
- virtual object_detection_3d_result_s& getResult() = 0;
+ virtual object_detection_3d_result_s* getResult() = 0;
};
} // machine_learning
void prepare() override;
void setInput(T &t) override;
void perform() override;
- V &getOutput() override;
+ V* getOutput() override;
};
} // machine_learning
typedef struct {
unsigned int probability;
unsigned int number_of_points;
- mv_point_s points[9];
+ unsigned int x[9];
+ unsigned int y[9];
unsigned int number_of_edges;
unsigned int edge_indexes[12][2];
} object_detection_3d_result_s;
Objectron();
~Objectron();
void parseMetaFile() override;
- object_detection_3d_result_s& getResult() override;
+ object_detection_3d_result_s* getResult() override;
};
} // machine_learning
return ret;
}
-int mv_object_detection_3d_get_result(mv_object_detection_3d_h handle, mv_object_detection_3d_result_s *out_result)
+int mv_object_detection_3d_get_probability(mv_object_detection_3d_h handle, unsigned int *out_probability)
{
MEDIA_VISION_SUPPORT_CHECK(
_mv_inference_face_check_system_info_feature_supported());
MEDIA_VISION_INSTANCE_CHECK(handle);
- MEDIA_VISION_NULL_ARG_CHECK(out_result);
+ MEDIA_VISION_NULL_ARG_CHECK(out_probability);
MEDIA_VISION_FUNCTION_ENTER();
int ret = MEDIA_VISION_ERROR_NONE;
- ret = mv_object_detection_3d_get_result_open(handle, out_result);
+ ret = mv_object_detection_3d_get_probability_open(handle, out_probability);
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return ret;
+}
+
+int mv_object_detection_3d_get_num_of_points(mv_object_detection_3d_h handle, unsigned int *out_num_of_points)
+{
+ MEDIA_VISION_SUPPORT_CHECK(
+ _mv_inference_face_check_system_info_feature_supported());
+
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+ MEDIA_VISION_NULL_ARG_CHECK(out_num_of_points);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ int ret = MEDIA_VISION_ERROR_NONE;
+
+ ret = mv_object_detection_3d_get_num_of_points_open(handle, out_num_of_points);
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return ret;
+}
+
+int mv_object_detection_3d_get_points(mv_object_detection_3d_h handle, unsigned int **out_x, unsigned int **out_y)
+{
+ MEDIA_VISION_SUPPORT_CHECK(
+ _mv_inference_face_check_system_info_feature_supported());
+
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+ MEDIA_VISION_NULL_ARG_CHECK(out_x);
+ MEDIA_VISION_NULL_ARG_CHECK(out_y);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ int ret = MEDIA_VISION_ERROR_NONE;
+
+ ret = mv_object_detection_3d_get_points_open(handle, out_x, out_y);
MEDIA_VISION_FUNCTION_LEAVE();
return MEDIA_VISION_ERROR_NONE;
}
-int mv_object_detection_3d_get_result_open(mv_object_detection_3d_h handle, mv_object_detection_3d_result_s *out_result)
+int mv_object_detection_3d_get_probability_open(mv_object_detection_3d_h handle, unsigned int *out_probability)
{
LOGD("ENTER");
auto context = static_cast<Context *>(handle);
auto task = static_cast<ObjectDetectionTask *>(context->__tasks["objectron"]);
- object_detection_3d_result_s result = task->getOutput();
+ object_detection_3d_result_s *result = task->getOutput();
- out_result->probability = result.probability;
- out_result->number_of_points = result.number_of_points;
- out_result->number_of_edges = result.number_of_edges;
+ *out_probability = result->probability;
+ } catch (const BaseException &e) {
+ LOGE("%s", e.what());
+ return e.getError();
+ }
+
+ LOGD("LEAVE");
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_object_detection_3d_get_num_of_points_open(mv_object_detection_3d_h handle, unsigned int *out_num_of_points)
+{
+ LOGD("ENTER");
+
+ if (!handle) {
+ LOGE("Handle is NULL.");
+ return MEDIA_VISION_ERROR_INVALID_PARAMETER;
+ }
+
+ try {
+ auto context = static_cast<Context *>(handle);
+ auto task = static_cast<ObjectDetectionTask *>(context->__tasks["objectron"]);
+
+ auto result = task->getOutput();
- for (unsigned int idx = 0; idx < out_result->number_of_points; ++idx)
- out_result->points[idx] = result.points[idx];
+ *out_num_of_points = result->number_of_points;
+ } catch (const BaseException &e) {
+ LOGE("%s", e.what());
+ return e.getError();
+ }
+
+ LOGD("LEAVE");
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_object_detection_3d_get_points_open(mv_object_detection_3d_h handle, unsigned int **out_x, unsigned int **out_y)
+{
+ LOGD("ENTER");
+
+ if (!handle) {
+ LOGE("Handle is NULL.");
+ return MEDIA_VISION_ERROR_INVALID_PARAMETER;
+ }
- for (unsigned int idx = 0; idx < out_result->number_of_edges; ++idx) {
- out_result->edge_indexes[idx][0] = result.edge_indexes[idx][0];
- out_result->edge_indexes[idx][1] = result.edge_indexes[idx][1];
- }
+ try {
+ Context *context = static_cast<Context *>(handle);
+ auto task = static_cast<ObjectDetectionTask *>(context->__tasks["objectron"]);
+
+ auto result = task->getOutput();
+
+ *out_x = result->x;
+ *out_y = result->y;
} catch (const BaseException &e) {
LOGE("%s", e.what());
return e.getError();
}
+ for (unsigned int i = 0; i < 9; ++i)
+ LOGI("%d %d", (*out_x)[i], (*out_y)[i]);
+
LOGD("LEAVE");
return MEDIA_VISION_ERROR_NONE;
}
}
-template<typename T, typename V> V& ObjectDetectionAdapter<T, V>::getOutput()
+template<typename T, typename V> V* ObjectDetectionAdapter<T, V>::getOutput()
{
return _object_detection->getResult();
}
throw InvalidOperation("Fail to ParseMetadata");
}
-object_detection_3d_result_s& Objectron::getResult()
+object_detection_3d_result_s* Objectron::getResult()
{
TensorBuffer& tensor_buffer_obj = _inference->GetOutputTensorBuffer();
IETensorBuffer &ie_tensor_buffer = tensor_buffer_obj.getIETensorBuffer();
float y_scale = static_cast<float>(_inference->getSourceHeight()) / static_cast<float>(_inference->getInputHeight());
for (unsigned int idx = 0; idx < output_size; idx += 2) {
- _result.points[result_idx].x = static_cast<int>(keypoints[idx] * x_scale);
- _result.points[result_idx++].y = static_cast<int>(keypoints[idx + 1] * y_scale);
+ _result.x[result_idx] = static_cast<int>(keypoints[idx] * x_scale);
+ _result.y[result_idx++] = static_cast<int>(keypoints[idx + 1] * y_scale);
}
_result.number_of_points = output_size / 2;
::copy(&edges[0][0], &edges[0][0] + 12 * 2, &_result.edge_indexes[0][0]);
- return _result;
+ return &_result;
}
}
ret = mv_object_detection_3d_inference(handle, mv_source);
ASSERT_EQ(ret, 0);
- mv_object_detection_3d_result_s result;
- ret = mv_object_detection_3d_get_result(handle, &result);
+ unsigned int probability;
+
+ ret = mv_object_detection_3d_get_probability(handle, &probability);
ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
- std::cout << "Probability = " << result.probability << std::endl;
+ std::cout << "Probability = " << probability << std::endl;
- for (unsigned int idx = 0; idx < result.number_of_points; ++idx) {
- std::cout << "index = " << idx + 1 << " : " << result.points[idx].x
- << " x " << result.points[idx].y << std::endl;
- }
+ unsigned int num_of_points;
+
+ ret = mv_object_detection_3d_get_num_of_points(handle, &num_of_points);
+ ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
- std::cout << "Number of edges = " << result.number_of_edges << std::endl;
+ unsigned int *x_array, *y_array;
- for (unsigned int idx = 0; idx < result.number_of_edges; ++idx)
- std::cout << result.edge_indexes[idx][0] << " to " << result.edge_indexes[idx][1] << std::endl;
+ 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_destroy_source(mv_source);
ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);