#include <mv_common.h>
#include <mv_inference_type.h>
-#include <mv_object_detection_type.h>
+#include "MachineLearningType.h"
namespace mediavision
{
namespace machine_learning
{
-struct ObjectDetectionInput {
- mv_source_h inference_src {};
- // TODO.
+struct ObjectDetectionInput : public InputBaseType {
+ ObjectDetectionInput(mv_source_h src = NULL) : InputBaseType(src)
+ {}
};
/**
* @brief The object detection result structure.
* @details Contains object detection result.
*/
-struct ObjectDetectionResult {
- unsigned long frame_number {};
+struct ObjectDetectionResult : public OutputBaseType {
unsigned int number_of_objects {};
std::vector<unsigned int> indices;
std::vector<std::string> names;
template<typename T, typename V> void FaceDetectionAdapter<T, V>::performAsync(T &t)
{
- _object_detection->performAsync(t);
+ _object_detection->performAsync(static_cast<ObjectDetectionInput &>(t));
}
template<typename T, typename V> V &FaceDetectionAdapter<T, V>::getOutput()
return _object_detection->getOutputCache();
}
-template class FaceDetectionAdapter<ObjectDetectionInput, ObjectDetectionResult>;
+template class FaceDetectionAdapter<InputBaseType, OutputBaseType>;
}
}
using namespace mediavision::machine_learning;
using namespace MediaVision::Common;
using namespace mediavision::machine_learning::exception;
-using FaceDetectionTask = ITask<ObjectDetectionInput, ObjectDetectionResult>;
+using FaceDetectionTask = ITask<InputBaseType, OutputBaseType>;
int mv_face_detection_create(mv_face_detection_h *handle)
{
try {
context = new Context();
- task = new FaceDetectionAdapter<ObjectDetectionInput, ObjectDetectionResult>();
+ task = new FaceDetectionAdapter<InputBaseType, OutputBaseType>();
context->__tasks.insert(make_pair("face_detection", task));
*handle = static_cast<mv_face_detection_h>(context);
} catch (const BaseException &e) {
auto context = static_cast<Context *>(handle);
auto task = static_cast<FaceDetectionTask *>(context->__tasks.at("face_detection"));
- ObjectDetectionInput input = { .inference_src = source };
+ ObjectDetectionInput input(source);
task->setInput(input);
task->perform();
auto context = static_cast<Context *>(handle);
auto task = static_cast<FaceDetectionTask *>(context->__tasks.at("face_detection"));
- ObjectDetectionInput input = { source };
+ ObjectDetectionInput input(source);
task->performAsync(input);
} catch (const BaseException &e) {
auto context = static_cast<Context *>(handle);
auto task = static_cast<FaceDetectionTask *>(context->__tasks.at("face_detection"));
- ObjectDetectionResult &result = task->getOutput();
+ auto &result = static_cast<ObjectDetectionResult &>(task->getOutput());
*number_of_objects = result.number_of_objects;
*frame_number = result.frame_number;
*confidences = result.confidences.data();
auto context = static_cast<Context *>(handle);
auto task = static_cast<FaceDetectionTask *>(context->__tasks.at("face_detection"));
- ObjectDetectionResult &result = task->getOutputCache();
+ auto &result = static_cast<ObjectDetectionResult &>(task->getOutputCache());
if (result.number_of_objects <= index)
throw InvalidParameter("Invalid index range.");
using namespace mediavision::machine_learning;
using namespace MediaVision::Common;
using namespace mediavision::machine_learning::exception;
-using ObjectDetectionTask = ITask<ObjectDetectionInput, ObjectDetectionResult>;
+using ObjectDetectionTask = ITask<InputBaseType, OutputBaseType>;
int mv_object_detection_create(mv_object_detection_h *handle)
{
try {
context = new Context();
- task = new ObjectDetectionAdapter<ObjectDetectionInput, ObjectDetectionResult>();
+ task = new ObjectDetectionAdapter<InputBaseType, OutputBaseType>();
context->__tasks.insert(make_pair("object_detection", task));
*handle = static_cast<mv_object_detection_h>(context);
} catch (const BaseException &e) {
auto context = static_cast<Context *>(handle);
auto task = static_cast<ObjectDetectionTask *>(context->__tasks.at("object_detection"));
- ObjectDetectionInput input = { .inference_src = source };
+ ObjectDetectionInput input(source);
task->setInput(input);
task->perform();
auto context = static_cast<Context *>(handle);
auto task = static_cast<ObjectDetectionTask *>(context->__tasks.at("object_detection"));
- ObjectDetectionInput input = { source };
+ ObjectDetectionInput input(source);
task->performAsync(input);
} catch (const BaseException &e) {
auto context = static_cast<Context *>(handle);
auto task = static_cast<ObjectDetectionTask *>(context->__tasks.at("object_detection"));
- ObjectDetectionResult &result = task->getOutput();
+ auto &result = static_cast<ObjectDetectionResult &>(task->getOutput());
*number_of_objects = result.number_of_objects;
*frame_number = result.frame_number;
*confidences = result.confidences.data();
auto context = static_cast<Context *>(handle);
auto task = static_cast<ObjectDetectionTask *>(context->__tasks.at("object_detection"));
- ObjectDetectionResult &result = task->getOutputCache();
+ auto &result = static_cast<ObjectDetectionResult &>(task->getOutputCache());
if (result.number_of_objects <= index)
throw InvalidParameter("Invalid index range.");
template<typename T, typename V> void ObjectDetectionAdapter<T, V>::performAsync(T &t)
{
- _object_detection->performAsync(t);
+ _object_detection->performAsync(static_cast<ObjectDetectionInput &>(t));
}
-template class ObjectDetectionAdapter<ObjectDetectionInput, ObjectDetectionResult>;
+template class ObjectDetectionAdapter<InputBaseType, OutputBaseType>;
}
}
\ No newline at end of file