extern "C" {
#endif /* __cplusplus */
+/**
+ * @file mv_roi_tracker.h
+ * @brief This file contains the ROI tracker based Media Vision API.
+ */
+
+/**
+ * @addtogroup CAPI_MEDIA_VISION_ROI_TRACKER_MODULE
+ * @{
+ */
+
/**
* @brief Creates tracker handle.
- * @details Use this function to create an tracker handle.
+ * @details Use this function to create a tracker handle.
*
* @since_tizen 7.0
*
int mv_roi_tracker_create(mv_roi_tracker_h *handle);
/**
- * @brief Destroy tracker handle and release all its resources.
+ * @brief Destroys tracker handle and release all its resources.
*
* @since_tizen 7.0
*
* @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
*
* @pre Create tracker handle by using mv_roi_tracker_create()
- *
- * @see mv_roi_tracker_create()
*/
int mv_roi_tracker_destroy(mv_roi_tracker_h handle);
/**
- * @brief Sets initial roi coordinates to roi tracker object handle.
- * @details Use this function to set the coordinates to the tracker object handle(for the tracking).
+ * @brief Sets initial ROI coordinates to tracker object handle.
*
* @since_tizen 7.0
*
* @param[in] handle The tracker handle to set coordinates.
- * @param[in] x The x coordiante to set initial ROI to be tracked
- * @param[in] y The y coordiante to set initial ROI to be tracked
+ * @param[in] x The x coordinate to set initial ROI to be tracked
+ * @param[in] y The y coordinate to set initial ROI to be tracked
* @param[in] width The width to set initial ROI to be tracked
* @param[in] height The height to set initial ROI to be tracked
*
int mv_roi_tracker_set_coordinate(mv_roi_tracker_h handle, int x, int y, int width, int height);
/**
- * @brief Sets tracker type to roi tracker object handle.
- * @details Use this function to set the tracker type to the tracker object handle(for the tracking).
+ * @brief Sets tracker type to ROI tracker object handle.
*
* @since_tizen 7.0
*
* @param[in] handle The tracker handle to set tracker type.
- * @param[in] type The tracker type to set default tracker type to be set
+ * @param[in] type The tracker type option to be set
*
* @return @c 0 on success, otherwise a negative error value
* @retval #MEDIA_VISION_ERROR_NONE Successful
/**
* @brief Tracks with a given tracker on the @a source.
* @details Use this function to track with a given source.
- * This function returns a proper label string to a given source.
+ * This function returns a proper ROI coordinates of the tracked region inside given source.
*
* @since_tizen 7.0
*
- * @param[in] handle The handle to the tracker object.
- * @param[in] source The handle to the source of the media.
- * @param[out] result The structure which is filled with result.
+ * @param[in] handle The handle to the tracker object.
+ * @param[in] source The handle to the source of the media.
*
* @return @c 0 on success, otherwise a negative error value
* @retval #MEDIA_VISION_ERROR_NONE Successful
*
* @pre Create a new tracker handle by calling @ref mv_roi_tracker_create()
*/
-int mv_roi_tracker_perform(mv_roi_tracker_h handle, mv_source_h source,
- mv_roi_tracker_result_s *result);
+int mv_roi_tracker_perform(mv_roi_tracker_h handle, mv_source_h source);
+
+/**
+ * @brief Gets ROI result
+ * @details Use this function to get ROI result after calling mv_roi_tracker_perform function.
+ * This function returns a proper ROI coordinates and size result of the tracked region.
+ *
+ * @since_tizen 7.0
+ *
+ * @param[in] handle The handle to the tracker object.
+ * @param[out] x The x coordinate of ROI result.
+ * @param[out] y The y coordinate of ROI result.
+ * @param[out] width The width of ROI result.
+ * @param[out] height The height of ROI result.
+ *
+ * @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 Perform tracking action by calling @ref mv_roi_tracker_perform()
+ */
+int mv_roi_tracker_get_result(mv_roi_tracker_h handle,
+ int *x, int *y, int *width, int *height);
+/**
+ * @}
+ */
#ifdef __cplusplus
}
#endif /* __cplusplus */
/**
- * @brief The roi tracker result structure.
+ * @file mv_roi_tracker_type.h
+ * @brief This file contains enumerations and a handle required by
+ * MediaVision ROI tracker API.
+ */
+
+/**
+ * @addtogroup CAPI_MEDIA_VISION_ROI_TRACKER_MODULE
+ * @{
+ */
+
+/**
+ * @brief The ROI tracker result structure.
* @details Contains roi tracker result such as coordinates.
* @since_tizen 7.0
*/
typedef struct {
- int x;
- int y;
- int width;
- int height;
+ int x; /**< Left-top x coordinate of tracked region */
+ int y; /**< Left-top y coordinate of tracked region */
+ int width; /**< Width of tracked region */
+ int height; /**< Height of tracked region */
} mv_roi_tracker_result_s;
/**
- * @brief The roi tracker handle.
+ * @brief The ROI tracker handle.
* @since_tizen 7.0
*/
typedef void *mv_roi_tracker_h;
typedef enum {
- MV_ROI_TRACKER_TYPE_NONE = 0,
- MV_ROI_TRACKER_TYPE_SPEED,
- MV_ROI_TRACKER_TYPE_BALANCE,
- MV_ROI_TRACKER_TYPE_ACCURACY
+ MV_ROI_TRACKER_TYPE_NONE = 0, /**< None */
+ MV_ROI_TRACKER_TYPE_SPEED, /**< Tracker type focused on speed */
+ MV_ROI_TRACKER_TYPE_BALANCE, /**< Tracker type focused on balance */
+ MV_ROI_TRACKER_TYPE_ACCURACY /**< Tracker type focused on accuracy */
} mv_roi_tracker_type_e;
+/**
+ * @}
+ */
#ifdef __cplusplus
}
cv::Rect boundingBox;
bool initialized;
mv_roi_tracker_type_e type;
+ mv_roi_tracker_result_s result;
};
} /* ROITracker */
*
* @since_tizen 7.0
*
- * @param [in] handle The handle to the tracker object
- * @param [in] type The tracker to set default tracker to be set
+ * @param [in] handle The handle to the tracker object
+ * @param [in] type The tracker to set default tracker to be set
* @return @c 0 on success, otherwise a negative error value
* @retval #MEDIA_VISION_ERROR_NONE Successful
* @retval #MEDIA_VISION_ERROR_INVALID_PARAMETER Invalid parameter
/**
* @brief Track with a given roi on the @a source.
* @details Use this function to track with a given source.
- * This function returns an proper roi to a given out_result.
+ * This function returns an proper roi to a given result.
*
* @since_tizen 7.0
*
* @param [in] handle The handle to the tracker object.
* @param [in] source The handle to the source of the media.
- * @param [out] result The structure which is filled with track result.
*
* @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_FORMAT Source colorspace
* isn't supported
* @retval #MEDIA_VISION_ERROR_OUT_OF_MEMORY Out of memory
* @pre Create a source handle by calling @ref mv_create_source()
* @pre Create an tracker handle by calling @ref mv_roi_tracker_create_open()
*/
-int mv_roi_tracker_perform_open(mv_roi_tracker_h handle, mv_source_h source,
- mv_roi_tracker_result_s *result);
+int mv_roi_tracker_perform_open(mv_roi_tracker_h handle, mv_source_h source);
+/**
+ * @brief Gets ROI result
+ * @details Use this function to get ROI result after calling mv_roi_tracker_perform function.
+ * This function returns a proper ROI coordinates and size result of the tracked region.
+ *
+ * @since_tizen 7.0
+ *
+ * @param[in] handle The handle to the tracker object.
+ * @param[out] x The x coordinate to set initial ROI to be tracked
+ * @param[out] y The y coordinate to set initial ROI to be tracked
+ * @param[out] width The width to set initial ROI to be tracked
+ * @param[out] height The height to set initial ROI to be tracked
+ *
+ * @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 Perform tracking action by calling @ref mv_roi_tracker_perform_open()
+ */
+int mv_roi_tracker_get_result_open(mv_roi_tracker_h handle, int *x, int *y, int *width, int *height);
#ifdef __cplusplus
}
#endif /* __cplusplus */
namespace ROITracker {
ROITracker::ROITracker()
: initialized(false),
- type(MV_ROI_TRACKER_TYPE_BALANCE)
+ type(MV_ROI_TRACKER_TYPE_BALANCE),
+ result()
{
}
return ret;
}
-int mv_roi_tracker_perform(mv_roi_tracker_h handle, mv_source_h source,
- mv_roi_tracker_result_s *result)
+int mv_roi_tracker_perform(mv_roi_tracker_h handle, mv_source_h source)
{
MEDIA_VISION_SUPPORT_CHECK(
__mv_roi_tracking_check_system_info_feature_supported());
MEDIA_VISION_INSTANCE_CHECK(handle);
MEDIA_VISION_INSTANCE_CHECK(source);
- MEDIA_VISION_NULL_ARG_CHECK(result);
MEDIA_VISION_FUNCTION_ENTER();
- int ret = mv_roi_tracker_perform_open(handle, source, result);
+ int ret = mv_roi_tracker_perform_open(handle, source);
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return ret;
+}
+
+int mv_roi_tracker_get_result(mv_roi_tracker_h handle,
+ int *x, int *y, int *width, int *height)
+{
+ MEDIA_VISION_SUPPORT_CHECK(
+ __mv_roi_tracking_check_system_info_feature_supported());
+
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+ MEDIA_VISION_NULL_ARG_CHECK(x);
+ MEDIA_VISION_NULL_ARG_CHECK(y);
+ MEDIA_VISION_NULL_ARG_CHECK(width);
+ MEDIA_VISION_NULL_ARG_CHECK(height);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ int ret = mv_roi_tracker_get_result_open(handle, x, y, width, height);
MEDIA_VISION_FUNCTION_LEAVE();
return MEDIA_VISION_ERROR_NONE;
}
-int mv_roi_tracker_perform_open(mv_roi_tracker_h handle, mv_source_h source,
- mv_roi_tracker_result_s *result)
+int mv_roi_tracker_perform_open(mv_roi_tracker_h handle, mv_source_h source)
{
LOGD("ENTER");
if (!handle) {
try {
cv::Mat frame = getTrackerFrame(colorspace, channels, width, height, buffer);
if (!pTracker->initialized) {
- *result = pTracker->Initialize(frame);
+ pTracker->result = pTracker->Initialize(frame);
return MEDIA_VISION_ERROR_NONE;
}
- *result = pTracker->Update(frame);
+ pTracker->result = pTracker->Update(frame);
} catch (const std::exception &e) {
LOGE("Failed : %s", e.what());
return MEDIA_VISION_ERROR_INVALID_OPERATION;
}
+ LOGD("LEAVE");
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_roi_tracker_get_result_open(mv_roi_tracker_h handle,
+ int *x, int *y, int *width, int *height)
+{
+ LOGD("ENTER");
+ if (!handle) {
+ LOGE("Handle is NULL.");
+ return MEDIA_VISION_ERROR_INVALID_PARAMETER;
+ }
+
+ auto *pTracker = static_cast<ROITracker *>(handle);
+
+ if (!pTracker->initialized) {
+ LOGE("ROI Tracker dosn't performed yet.");
+ return MEDIA_VISION_ERROR_INVALID_OPERATION;
+ }
+ *x = pTracker->result.x;
+ *y = pTracker->result.y;
+ *width = pTracker->result.width;
+ *height = pTracker->result.height;
+
+ LOGD("x:%d, y:%d w: %d, h: %d", *x, *y, *width, *height);
+
LOGD("LEAVE");
return MEDIA_VISION_ERROR_NONE;
}
\ No newline at end of file
/**
- * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
ret = ImageHelper::loadImageToSource(image_path.c_str(), mv_source);
ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
- mv_roi_tracker_result_s result;
- ret = mv_roi_tracker_perform(handle, mv_source, &result);
+ ret = mv_roi_tracker_perform(handle, mv_source);
+ ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
+
+ int x, y, width, height;
+ ret = mv_roi_tracker_get_result(handle, &x, &y, &width, &height);
+ ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
+
+ ret = mv_roi_tracker_perform(handle, mv_source);
+ ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
+
+ ret = mv_roi_tracker_get_result(handle, &x, &y, &width, &height);
ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
ret = mv_roi_tracker_destroy(handle);