From: Inki Dae Date: Mon, 8 Apr 2024 00:51:23 +0000 (+0900) Subject: cleanup BaseResultType X-Git-Tag: accepted/tizen/unified/20240903.110722~76^2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5590d72046292b6cfdb0fde8ec55fc01c55a2df9;p=platform%2Fcore%2Fapi%2Fsingleo.git cleanup BaseResultType Clean up BaseResultType by moving common members from specific structure to BaseResultType. Signed-off-by: Inki Dae --- diff --git a/common/include/SingleoCommonTypes.h b/common/include/SingleoCommonTypes.h index 6ee4b52..cd572eb 100644 --- a/common/include/SingleoCommonTypes.h +++ b/common/include/SingleoCommonTypes.h @@ -67,6 +67,7 @@ enum class ResultType { NONE, OBJECT_DETECTION, FACE_DETECTION, LANDMARK }; struct BaseResultType { ResultType _type { ResultType::NONE }; unsigned int _frame_number {}; + std::vector _rects; BaseResultType(ResultType type) : _type(type) {} virtual ~BaseResultType() @@ -76,16 +77,12 @@ struct BaseResultType { struct OdResultType : public BaseResultType { OdResultType() : BaseResultType(ResultType::OBJECT_DETECTION) {} - unsigned int _frame_number {}; - std::vector rects; // TODO }; struct FdResultType : public BaseResultType { FdResultType() : BaseResultType(ResultType::FACE_DETECTION) {} - unsigned int _frame_number {}; - std::vector rects; // TODO }; diff --git a/inference/backends/mediavision/src/MvFaceDetection.cpp b/inference/backends/mediavision/src/MvFaceDetection.cpp index 9c28e71..ac2c61a 100644 --- a/inference/backends/mediavision/src/MvFaceDetection.cpp +++ b/inference/backends/mediavision/src/MvFaceDetection.cpp @@ -95,7 +95,7 @@ BaseResultType &MvFaceDetection::result() if (ret != MEDIA_VISION_ERROR_NONE) throw runtime_error("Fail to get face detection result count."); - _output_data.rects.clear(); + _output_data._rects.clear(); _output_data._frame_number = frame_number; for (unsigned int idx = 0; idx < result_cnt; ++idx) { @@ -105,7 +105,7 @@ BaseResultType &MvFaceDetection::result() if (ret != MEDIA_VISION_ERROR_NONE) throw runtime_error("Fail to get face detection bound box."); - _output_data.rects.push_back(rect); + _output_data._rects.push_back(rect); } return _output_data; diff --git a/inference/backends/mediavision/src/MvObjectDetection.cpp b/inference/backends/mediavision/src/MvObjectDetection.cpp index b7b4667..4a7c279 100644 --- a/inference/backends/mediavision/src/MvObjectDetection.cpp +++ b/inference/backends/mediavision/src/MvObjectDetection.cpp @@ -95,7 +95,7 @@ BaseResultType &MvObjectDetection::result() if (ret != MEDIA_VISION_ERROR_NONE) throw runtime_error("Fail to get object detection result count."); - _output_data.rects.clear(); + _output_data._rects.clear(); _output_data._frame_number = frame_number; for (unsigned int idx = 0; idx < result_cnt; ++idx) { @@ -105,7 +105,7 @@ BaseResultType &MvObjectDetection::result() if (ret != MEDIA_VISION_ERROR_NONE) throw runtime_error("Fail to get object detection bound box."); - _output_data.rects.push_back(rect); + _output_data._rects.push_back(rect); } return _output_data; diff --git a/services/auto_zoom/src/AutoZoom.cpp b/services/auto_zoom/src/AutoZoom.cpp index 5bb817a..010081f 100644 --- a/services/auto_zoom/src/AutoZoom.cpp +++ b/services/auto_zoom/src/AutoZoom.cpp @@ -178,17 +178,12 @@ void AutoZoom::updateResult(BaseDataType &in_data) AutoZoomResult autozoom_result; vector rects; - if (output_data._type == ResultType::OBJECT_DETECTION) { - auto &result = static_cast(output_data); - rects = result.rects; - autozoom_result.frame_number = result._frame_number; - } - else if (output_data._type == ResultType::FACE_DETECTION) { - auto &result = static_cast(output_data); - rects = result.rects; - autozoom_result.frame_number = result._frame_number; - } + if (output_data._type != ResultType::OBJECT_DETECTION && + output_data._type != ResultType::FACE_DETECTION) + throw InvalidParameter("Invalid result type"); + rects = output_data._rects; + autozoom_result.frame_number = output_data._frame_number; autozoom_result.num_of_objects = rects.size(); for (size_t idx = 0; idx < rects.size(); ++idx) {