898c200142b9667f9312b1b6ecbaf805eabdad14
[platform/core/api/mediavision.git] / mv_machine_learning / object_detection_3d / src / object_detection_3d_adapter.cpp
1 /**
2  * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #include "machine_learning_exception.h"
18 #include "object_detection_3d_adapter.h"
19
20 using namespace std;
21 using namespace MediaVision::Common;
22 using namespace mediavision::machine_learning;
23 using namespace mediavision::machine_learning::exception;
24
25 namespace mediavision
26 {
27 namespace machine_learning
28 {
29 template<typename T, typename V> ObjectDetection3dAdapter<T, V>::ObjectDetection3dAdapter() : _source()
30 {}
31
32 template<typename T, typename V> ObjectDetection3dAdapter<T, V>::~ObjectDetection3dAdapter()
33 {}
34
35 template<typename T, typename V> void ObjectDetection3dAdapter<T, V>::create(int type)
36 {
37         switch (static_cast<object_detection_3d_task_type_e>(type)) {
38         case object_detection_3d_task_type_e::OBJECTRON:
39                 _object_detection_3d = make_unique<Objectron>();
40                 break;
41         default:
42                 throw InvalidParameter("Invalid object detection task type.");
43         }
44 }
45
46 template<typename T, typename V> void ObjectDetection3dAdapter<T, V>::configure()
47 {
48         _object_detection_3d->parseMetaFile();
49         _object_detection_3d->configure();
50 }
51
52 template<typename T, typename V> void ObjectDetection3dAdapter<T, V>::prepare()
53 {
54         _object_detection_3d->prepare();
55 }
56
57 template<typename T, typename V> void ObjectDetection3dAdapter<T, V>::setInput(T &t)
58 {
59         _source = t;
60 }
61
62 template<typename T, typename V> void ObjectDetection3dAdapter<T, V>::perform()
63 {
64         _object_detection_3d->preprocess(_source.inference_src);
65         _object_detection_3d->inference(_source.inference_src);
66 }
67
68 template<typename T, typename V> V &ObjectDetection3dAdapter<T, V>::getOutput()
69 {
70         return _object_detection_3d->result();
71 }
72
73 template class ObjectDetection3dAdapter<object_detection_3d_input_s, object_detection_3d_result_s>;
74 }
75 }