template<typename T, typename V> class FaceDetectionAdapter : public mediavision::common::ITask<T, V>
{
private:
- std::unique_ptr<ObjectDetection> _object_detection;
+ std::unique_ptr<IObjectDetection> _object_detection;
T _source;
std::string _model_name;
std::string _model_file;
--- /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 __IOBJECT_DETECTION_H__
+#define __IOBJECT_DETECTION_H__
+
+#include <mv_common.h>
+
+#include "object_detection_type.h"
+
+namespace mediavision
+{
+namespace machine_learning
+{
+class IObjectDetection
+{
+public:
+ virtual ~IObjectDetection() {};
+ virtual void preDestroy() = 0;
+ virtual ObjectDetectionTaskType getTaskType() = 0;
+ virtual void setUserModel(std::string model_file, std::string meta_file, std::string label_file) = 0;
+ virtual void setEngineInfo(std::string engine_type, std::string device_type) = 0;
+ virtual void getNumberOfEngines(unsigned int *number_of_engines) = 0;
+ virtual void getEngineType(unsigned int engine_index, char **engine_type) = 0;
+ virtual void getNumberOfDevices(const char *engine_type, unsigned int *number_of_devices) = 0;
+ virtual void getDeviceType(const char *engine_type, const unsigned int device_index, char **device_type) = 0;
+ virtual void configure(std::string configFile) = 0;
+ virtual void prepare() = 0;
+ virtual void perform(mv_source_h &mv_src) = 0;
+ virtual void performAsync(ObjectDetectionInput &input) = 0;
+ virtual ObjectDetectionResult &getOutput() = 0;
+};
+
+} // machine_learning
+} // mediavision
+
+#endif
\ No newline at end of file
#include "object_detection_type.h"
#include "ObjectDetectionParser.h"
#include "Preprocess.h"
+#include "iobject_detection.h"
namespace mediavision
{
namespace machine_learning
{
-class ObjectDetection
+class ObjectDetection : public IObjectDetection
{
private:
ObjectDetectionTaskType _task_type;
public:
ObjectDetection(ObjectDetectionTaskType task_type);
virtual ~ObjectDetection() = default;
- void preDestroy();
- ObjectDetectionTaskType getTaskType();
- void setUserModel(std::string model_file, std::string meta_file, std::string label_file);
- void setEngineInfo(std::string engine_type, std::string device_type);
- void getNumberOfEngines(unsigned int *number_of_engines);
- void getEngineType(unsigned int engine_index, char **engine_type);
- void getNumberOfDevices(const char *engine_type, unsigned int *number_of_devices);
- void getDeviceType(const char *engine_type, const unsigned int device_index, char **device_type);
- void configure(std::string configFile);
- void prepare();
- void perform(mv_source_h &mv_src);
- void performAsync(ObjectDetectionInput &input);
- template<typename V> V &getOutput();
+ void preDestroy() override;
+ ObjectDetectionTaskType getTaskType() override;
+ void setUserModel(std::string model_file, std::string meta_file, std::string label_file) override;
+ void setEngineInfo(std::string engine_type, std::string device_type) override;
+ void getNumberOfEngines(unsigned int *number_of_engines) override;
+ void getEngineType(unsigned int engine_index, char **engine_type) override;
+ void getNumberOfDevices(const char *engine_type, unsigned int *number_of_devices) override;
+ void getDeviceType(const char *engine_type, const unsigned int device_index, char **device_type) override;
+ void configure(std::string configFile) override;
+ void prepare() override;
+ void perform(mv_source_h &mv_src) override;
+ void performAsync(ObjectDetectionInput &input) override;
+ ObjectDetectionResult &getOutput() override;
};
} // machine_learning
template<typename T, typename V> class ObjectDetectionAdapter : public mediavision::common::ITask<T, V>
{
private:
- std::unique_ptr<ObjectDetection> _object_detection;
+ std::unique_ptr<IObjectDetection> _object_detection;
T _source;
std::string _model_name;
std::string _model_file;
template<typename T, typename V> V &FaceDetectionAdapter<T, V>::getOutput()
{
- return _object_detection->getOutput<V>();
+ return _object_detection->getOutput();
}
template class FaceDetectionAdapter<ObjectDetectionInput, ObjectDetectionResult>;
_current_result.is_valid = true;
}
-template<typename V> V &ObjectDetection::getOutput()
+ObjectDetectionResult &ObjectDetection::getOutput()
{
if (_thread_handle) {
// There may be two or more Native APIs which utilize getOutput() function.
if (isOutputQueueEmpty())
throw InvalidOperation("Output queue is empty.");
- V result = popFromOutput();
+ ObjectDetectionResult result = popFromOutput();
updateResult(result);
return _current_result;
template void ObjectDetection::performAsync<unsigned char>(ObjectDetectionInput &input, shared_ptr<MetaInfo> metaInfo);
-template ObjectDetectionResult &ObjectDetection::getOutput();
-
}
}
\ No newline at end of file
template<typename T, typename V> V &ObjectDetectionAdapter<T, V>::getOutput()
{
- return _object_detection->getOutput<V>();
+ return _object_detection->getOutput();
}
template<typename T, typename V> void ObjectDetectionAdapter<T, V>::performAsync(T &t)