--- /dev/null
+/**
+ * Copyright (c) 2023 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 __MACHINE_LEARNING_TYPE_H__
+#define __MACHINE_LEARNING_TYPE_H__
+
+#include <mv_common.h>
+#include <mv_inference_type.h>
+
+namespace mediavision
+{
+namespace machine_learning
+{
+struct InputBaseType {
+ mv_source_h inference_src {};
+ InputBaseType(mv_source_h src = NULL) : inference_src(src)
+ {}
+};
+
+struct OutputBaseType {
+ unsigned long frame_number {};
+};
+
+} // machine_learning
+} // mediavision
+
+#endif
\ No newline at end of file
#include <mv_common.h>
#include <mv_inference_type.h>
+#include "MachineLearningType.h"
namespace mediavision
{
namespace machine_learning
{
-struct ImageClassificationInput {
- mv_source_h inference_src {};
- // TODO.
+struct ImageClassificationInput : public InputBaseType {
+ ImageClassificationInput(mv_source_h src = NULL) : InputBaseType(src)
+ {}
};
-/**
- * @brief The object detection result structure.
- * @details Contains object detection 3d result.
- */
-struct ImageClassificationResult {
- unsigned long frame_number {};
+struct ImageClassificationResult : public OutputBaseType {
std::string label;
};
enum class ImageClassificationTaskType {
IMAGE_CLASSIFICATION_TASK_NONE = 0,
- // TODO
};
}
template<typename T, typename V> void ImageClassificationAdapter<T, V>::performAsync(T &t)
{
- _image_classification->performAsync(t);
+ _image_classification->performAsync(static_cast<ImageClassificationInput &>(t));
}
template<typename T, typename V> V &ImageClassificationAdapter<T, V>::getOutput()
{
- return _image_classification->getOutput();
+ return static_cast<V &>(_image_classification->getOutput());
}
template<typename T, typename V> V &ImageClassificationAdapter<T, V>::getOutputCache()
throw InvalidOperation("Not support yet.");
}
-template class ImageClassificationAdapter<ImageClassificationInput, ImageClassificationResult>;
+template class ImageClassificationAdapter<InputBaseType, OutputBaseType>;
}
}
using namespace mediavision::machine_learning;
using namespace MediaVision::Common;
using namespace mediavision::machine_learning::exception;
-using ImageClassificationTask = ITask<ImageClassificationInput, ImageClassificationResult>;
+using ImageClassificationTask = ITask<InputBaseType, OutputBaseType>;
int mv_image_classification_create(mv_image_classification_h *out_handle)
{
try {
context = new Context();
- task = new ImageClassificationAdapter<ImageClassificationInput, ImageClassificationResult>();
+ task = new ImageClassificationAdapter<InputBaseType, OutputBaseType>();
context->__tasks.insert(make_pair("image_classification", task));
*out_handle = static_cast<mv_image_classification_h>(context);
return e.getError();
}
- LOGD("object detection 3d handle [%p] has been created", *out_handle);
+ LOGD("image classification handle [%p] has been created", *out_handle);
MEDIA_VISION_FUNCTION_LEAVE();
auto context = static_cast<Context *>(handle);
auto task = static_cast<ImageClassificationTask *>(context->__tasks.at("image_classification"));
- ImageClassificationInput input = { source };
+ ImageClassificationInput input(source);
task->setInput(input);
task->perform();
auto context = static_cast<Context *>(handle);
auto task = static_cast<ImageClassificationTask *>(context->__tasks.at("image_classification"));
- ImageClassificationInput input = { source };
+ ImageClassificationInput input(source);
task->performAsync(input);
} catch (const BaseException &e) {
auto context = static_cast<Context *>(handle);
auto task = static_cast<ImageClassificationTask *>(context->__tasks.at("image_classification"));
- ImageClassificationResult &result = task->getOutput();
+ const auto &result = static_cast<ImageClassificationResult &>(task->getOutput());
*out_label = result.label.c_str();
} catch (const BaseException &e) {