struct OdResultType : public BaseResultType {
OdResultType() : BaseResultType(ResultType::OBJECT_DETECTION)
{}
- Rect rect;
+ unsigned int _frame_number {};
+ std::vector<Rect> rects;
// TODO
};
struct FdResultType : public BaseResultType {
FdResultType() : BaseResultType(ResultType::FACE_DETECTION)
{}
- Rect rect;
+ unsigned int _frame_number {};
+ std::vector<Rect> rects;
// TODO
};
#include "IInferenceTaskInterface.h"
#include "mv_face_detection_internal.h"
-#include "MvFdOutputData.h"
+#include "SingleoCommonTypes.h"
namespace singleo
{
{
private:
mv_face_detection_h _handle {};
- MvFdOutputData _output_data {};
+ FdResultType _output_data {};
public:
MvFaceDetection();
void configure() override;
void prepare() override;
void invoke(BaseDataType &input, bool async) override;
- const SingleoOutputData &result() override;
+ BaseResultType &result() override;
};
} // backends
+++ /dev/null
-/**
- * Copyright (c) 2024 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 __MV_FD_OUTPUT_DATA_H__
-#define __MV_FD_OUTPUT_DATA_H__
-
-#include "SingleoOutputData.h"
-
-namespace singleo
-{
-namespace inference
-{
-namespace backends
-{
-class MvFdOutputData : public SingleoOutputData
-{
-private:
- unsigned int _frame_number {};
- std::vector<FdResultType> _vec_result;
-
-public:
- MvFdOutputData() {};
- virtual ~MvFdOutputData() {};
-
- void setFrameNumber(unsigned int frame_number)
- {
- _frame_number = frame_number;
- }
-
- void addResult(FdResultType &result)
- {
- _vec_result.push_back(result);
- }
-
- void clear() override
- {
- _vec_result.clear();
- }
-
- unsigned int getFrameNumber() const override
- {
- return _frame_number;
- }
-
- const std::vector<FdResultType> &getFdResult() const override
- {
- return _vec_result;
- }
-};
-
-} // backends
-} // inference
-} // singleo
-
-#endif
\ No newline at end of file
#include "IInferenceTaskInterface.h"
#include "mv_object_detection_internal.h"
-#include "MvOdOutputData.h"
+#include "SingleoCommonTypes.h"
namespace singleo
{
{
private:
mv_object_detection_h _handle {};
- MvOdOutputData _output_data {};
+ OdResultType _output_data {};
public:
MvObjectDetection();
void configure() override;
void prepare() override;
void invoke(BaseDataType &input, bool async) override;
- const SingleoOutputData &result() override;
+ BaseResultType &result() override;
};
} // backends
+++ /dev/null
-/**
- * Copyright (c) 2024 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 __MV_OD_OUTPUT_DATA_H__
-#define __MV_OD_OUTPUT_DATA_H__
-
-#include "SingleoOutputData.h"
-
-namespace singleo
-{
-namespace inference
-{
-namespace backends
-{
-class MvOdOutputData : public SingleoOutputData
-{
-private:
- unsigned int _frame_number {};
- std::vector<OdResultType> _vec_result;
-
-public:
- MvOdOutputData() {};
- virtual ~MvOdOutputData() {};
-
- void setFrameNumber(unsigned int frame_number)
- {
- _frame_number = frame_number;
- }
-
- void addResult(OdResultType &result)
- {
- _vec_result.push_back(result);
- }
-
- void clear() override
- {
- _vec_result.clear();
- }
-
- unsigned int getFrameNumber() const override
- {
- return _frame_number;
- }
-
- const std::vector<OdResultType> &getOdResult() const override
- {
- return _vec_result;
- }
-};
-
-} // backends
-} // inference
-} // singleo
-
-#endif
\ No newline at end of file
throw runtime_error("Fail to destroy mv source.");
}
-const SingleoOutputData &MvFaceDetection::result()
+BaseResultType &MvFaceDetection::result()
{
unsigned long frame_number;
unsigned int result_cnt;
if (ret != MEDIA_VISION_ERROR_NONE)
throw runtime_error("Fail to get face detection result count.");
- _output_data.clear();
- _output_data.setFrameNumber(frame_number);
+ _output_data.rects.clear();
+ _output_data._frame_number = frame_number;
for (unsigned int idx = 0; idx < result_cnt; ++idx) {
- FdResultType result_rect;
+ Rect rect;
- ret = mv_face_detection_get_bbox(_handle, idx, &result_rect.rect.left, &result_rect.rect.top,
- &result_rect.rect.right, &result_rect.rect.bottom);
+ ret = mv_face_detection_get_bbox(_handle, idx, &rect.left, &rect.top, &rect.right, &rect.bottom);
if (ret != MEDIA_VISION_ERROR_NONE)
throw runtime_error("Fail to get face detection bound box.");
- _output_data.addResult(result_rect);
+ _output_data.rects.push_back(rect);
}
return _output_data;
throw runtime_error("Fail to destroy mv source.");
}
-const SingleoOutputData &MvObjectDetection::result()
+BaseResultType &MvObjectDetection::result()
{
unsigned long frame_number;
unsigned int result_cnt;
if (ret != MEDIA_VISION_ERROR_NONE)
throw runtime_error("Fail to get object detection result count.");
- _output_data.clear();
- _output_data.setFrameNumber(frame_number);
+ _output_data.rects.clear();
+ _output_data._frame_number = frame_number;
for (unsigned int idx = 0; idx < result_cnt; ++idx) {
- OdResultType result_rect;
+ Rect rect;
- ret = mv_object_detection_get_bbox(_handle, idx, &result_rect.rect.left, &result_rect.rect.top,
- &result_rect.rect.right, &result_rect.rect.bottom);
+ ret = mv_object_detection_get_bbox(_handle, idx, &rect.left, &rect.top, &rect.right, &rect.bottom);
if (ret != MEDIA_VISION_ERROR_NONE)
throw runtime_error("Fail to get object detection bound box.");
- _output_data.addResult(result_rect);
+ _output_data.rects.push_back(rect);
}
return _output_data;
virtual void configure() = 0;
virtual void prepare() = 0;
virtual void invoke(BaseDataType &input, bool async = false) = 0;
- virtual const SingleoOutputData &result() = 0;
+ virtual BaseResultType &result() = 0;
};
} // inference
#ifndef __IINFERENCE_TASK_INTERFACE_H__
#define __IINFERENCE_TASK_INTERFACE_H__
-#include "SingleoOutputData.h"
+#include "SingleoCommonTypes.h"
namespace singleo
{
virtual void configure() = 0;
virtual void prepare() = 0;
virtual void invoke(BaseDataType &input, bool async = false) = 0;
- virtual const SingleoOutputData &result() = 0;
+ virtual BaseResultType &result() = 0;
};
} // inference
#include "IInferenceServiceInterface.h"
#include "IInferenceTaskInterface.h"
#include "SingleoInferenceTypes.h"
+#include "SingleoCommonTypes.h"
namespace singleo
{
void configure() override;
void prepare() override;
void invoke(BaseDataType &input, bool async = false) override;
- const SingleoOutputData &result() override;
+ BaseResultType &result() override;
};
} // inference
#include "IInferenceServiceInterface.h"
#include "IInferenceTaskInterface.h"
#include "SingleoInferenceTypes.h"
+#include "SingleoCommonTypes.h"
namespace singleo
{
void configure() override;
void prepare() override;
void invoke(BaseDataType &input, bool async = false) override;
- const SingleoOutputData &result() override;
+ BaseResultType &result() override;
};
} // inference
+++ /dev/null
-/**
- * Copyright (c) 2024 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 __ISINGLEO_OUTPUT_DATA_H__
-#define __ISINGLEO_OUTPUT_DATA_H__
-
-#include "SingleoCommonTypes.h"
-#include "SingleoException.h"
-
-namespace singleo
-{
-namespace inference
-{
-class SingleoOutputData
-{
-public:
- SingleoOutputData() = default;
- virtual ~SingleoOutputData() = default;
-
- virtual void clear() = 0;
- virtual unsigned int getFrameNumber() const = 0;
- virtual const std::vector<OdResultType> &getOdResult() const
- {
- throw exception::InvalidOperation("Not supported.");
- }
- virtual const std::vector<FdResultType> &getFdResult() const
- {
- throw exception::InvalidOperation("Not supported.");
- }
-};
-
-} // inference
-} // singleo
-
-#endif
\ No newline at end of file
_task->invoke(input, async);
}
-const SingleoOutputData &InferenceServiceDefault::result()
+BaseResultType &InferenceServiceDefault::result()
{
return _task->result();
}
throw runtime_error("Not support yet.");
}
-const SingleoOutputData &InferenceServiceExternal::result()
+BaseResultType &InferenceServiceExternal::result()
{
throw runtime_error("Not support yet.");
}
void AutoZoom::updateResult(BaseDataType &in_data)
{
auto &output_data = _inference_service->result();
- unsigned int frame_number = output_data.getFrameNumber();
AutoZoomResult autozoom_result;
+ vector<Rect> rects;
- if (_task_type == TaskType::OBJECT_DETECTION) {
- const vector<OdResultType> &result = output_data.getOdResult();
- autozoom_result.num_of_objects = result.size();
- for (size_t idx = 0; idx < result.size(); ++idx) {
- SINGLEO_LOGD("%dx%d ~ %dx%d", result[idx].rect.left, result[idx].rect.top, result[idx].rect.right,
- result[idx].rect.bottom);
-
- if (idx == 0) {
- autozoom_result.merged_rect = result[idx].rect;
- continue;
- }
- autozoom_result.merged_rect.left = min(result[idx].rect.left, autozoom_result.merged_rect.left);
- autozoom_result.merged_rect.top = min(result[idx].rect.top, autozoom_result.merged_rect.top);
- autozoom_result.merged_rect.right = max(result[idx].rect.right, autozoom_result.merged_rect.right);
- autozoom_result.merged_rect.bottom = max(result[idx].rect.bottom, autozoom_result.merged_rect.bottom);
- }
- } else {
- const vector<FdResultType> &result = output_data.getFdResult();
- autozoom_result.num_of_objects = result.size();
- for (size_t idx = 0; idx < result.size(); ++idx) {
- SINGLEO_LOGD("%dx%d ~ %dx%d", result[idx].rect.left, result[idx].rect.top, result[idx].rect.right,
- result[idx].rect.bottom);
-
- if (idx == 0) {
- autozoom_result.merged_rect = result[idx].rect;
- continue;
- }
- autozoom_result.merged_rect.left = min(result[idx].rect.left, autozoom_result.merged_rect.left);
- autozoom_result.merged_rect.top = min(result[idx].rect.top, autozoom_result.merged_rect.top);
- autozoom_result.merged_rect.right = max(result[idx].rect.right, autozoom_result.merged_rect.right);
- autozoom_result.merged_rect.bottom = max(result[idx].rect.bottom, autozoom_result.merged_rect.bottom);
- }
+ if (output_data._type == ResultType::OBJECT_DETECTION) {
+ auto &result = static_cast<OdResultType &>(output_data);
+ rects = result.rects;
+ autozoom_result.frame_number = result._frame_number;
+ }
+ else if (output_data._type == ResultType::FACE_DETECTION) {
+ auto &result = static_cast<OdResultType &>(output_data);
+ rects = result.rects;
+ autozoom_result.frame_number = result._frame_number;
}
- autozoom_result.frame_number = frame_number;
+ autozoom_result.num_of_objects = rects.size();
- // TODO. implement Postprocessor which calculates Autozoom position using above 'result' vector.
+ for (size_t idx = 0; idx < rects.size(); ++idx) {
+ SINGLEO_LOGD("%dx%d ~ %dx%d", rects[idx].left, rects[idx].top, rects[idx].right, rects[idx].bottom);
+
+ if (idx == 0) {
+ autozoom_result.merged_rect = rects[idx];
+ continue;
+ }
+ autozoom_result.merged_rect.left = min(rects[idx].left, autozoom_result.merged_rect.left);
+ autozoom_result.merged_rect.top = min(rects[idx].top, autozoom_result.merged_rect.top);
+ autozoom_result.merged_rect.right = max(rects[idx].right, autozoom_result.merged_rect.right);
+ autozoom_result.merged_rect.bottom = max(rects[idx].bottom, autozoom_result.merged_rect.bottom);
+ }
SINGLEO_LOGD("detected object count = %zu", autozoom_result.num_of_objects);