[WIP-11] Move MvInferenceFaceService from inference to backend directory
authorTae-Young Chung <ty83.chung@samsung.com>
Fri, 3 May 2024 08:31:22 +0000 (17:31 +0900)
committerTae-Young Chung <ty83.chung@samsung.com>
Fri, 3 May 2024 08:31:32 +0000 (17:31 +0900)
Change-Id: Ic2909718233f91b20505f8ddf7800471d1df9092
Signed-off-by: Tae-Young Chung <ty83.chung@samsung.com>
inference/backends/mediavision/include/MvInferenceFaceService.h [new file with mode: 0644]
inference/backends/mediavision/src/MvInferenceFaceService.cpp [new file with mode: 0644]
inference/include/MvInferenceFaceService.h [deleted file]
inference/src/MvInferenceFaceService.cpp [deleted file]

diff --git a/inference/backends/mediavision/include/MvInferenceFaceService.h b/inference/backends/mediavision/include/MvInferenceFaceService.h
new file mode 100644 (file)
index 0000000..f332596
--- /dev/null
@@ -0,0 +1,48 @@
+/**
+ * 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_INFERENCE_FACE_SERVICE_H__
+#define __MV_INFERENCE_FACE_SERVICE_H__
+
+#include <memory>
+#include "IInferenceFaceService.h"
+#include "MvFaceTaskManager.h"
+
+using namespace singleo::inference::backends;
+
+namespace singleo
+{
+namespace inference
+{
+class MvInferenceFaceService : public IInferenceFaceService
+{
+private:
+       std::shared_ptr<MvFaceTaskManager> _taskManager;
+       FaceResult _result;
+
+public:
+       MvInferenceFaceService(std::vector<inference::TaskType> &tasks);
+       virtual ~MvInferenceFaceService() {};
+       void configure() override;
+       void prepare() override;
+       void invoke(BaseDataType &input) override;
+       FaceResult &result() override;
+};
+
+} // inference
+} // singleo
+
+#endif
\ No newline at end of file
diff --git a/inference/backends/mediavision/src/MvInferenceFaceService.cpp b/inference/backends/mediavision/src/MvInferenceFaceService.cpp
new file mode 100644 (file)
index 0000000..0bcb578
--- /dev/null
@@ -0,0 +1,98 @@
+/**
+ * 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.
+ */
+
+#include "SingleoCommonTypes.h"
+#include "MvInferenceFaceService.h"
+#include "MvFaceDetectionTask.h"
+#include "MvFaceLandmarkDetectionTask.h"
+#include <opencv2/core.hpp>
+#include <opencv2/imgcodecs.hpp>
+#include <opencv2/imgproc.hpp>
+
+using namespace std;
+
+namespace singleo
+{
+namespace inference
+{
+MvInferenceFaceService::MvInferenceFaceService(std::vector<inference::TaskType> &tasks)
+{
+    for (auto &task : tasks) {
+        switch (task) {
+        case TaskType::FACE_DETECTION:
+        {
+            if (_taskManager.use_count() > 0)
+                _taskManager->setNext(std::make_shared<MvFaceDetectionTask>());
+            else
+                _taskManager = std::make_shared<MvFaceDetectionTask>();
+        }
+            break;
+        case TaskType::FACE_LANDMARK_DETECTION:
+        {
+            if (_taskManager.use_count() > 0)
+                _taskManager->setNext(std::make_shared<MvFaceLandmarkDetectionTask>());
+            else
+                _taskManager = std::make_shared<MvFaceLandmarkDetectionTask>();
+        }
+            break;
+        default:
+            SINGLEO_LOGE("Not supported task type %d", tasks[0]);
+            break;
+        }
+    }
+}
+
+void MvInferenceFaceService::configure()
+{
+
+}
+
+void MvInferenceFaceService::prepare()
+{
+    
+}
+
+void MvInferenceFaceService::invoke(BaseDataType &input)
+{
+    if (input._data_type != DataType::IMAGE) {
+               SINGLEO_LOGE("Invalid input type.");
+               throw invalid_argument("Input type not support.");
+       }
+
+    ImageDataType &data = dynamic_cast<ImageDataType &>(input);
+    _result = _taskManager->handle(data.ptr, data.width, data.height, data.byte_per_pixel, _result);
+
+    cv::Mat _dump(cv::Size(data.width, data.height),CV_MAKE_TYPE(CV_8U, data.byte_per_pixel), data.ptr);
+
+    int id = 0;
+    for (auto &rect : _result._rects) {
+        cv::rectangle(_dump, cv::Rect(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top), cv::Scalar(0, 255, 0), 2);
+        auto &points = _result._landmarks[id];
+        for (auto &point : points)
+            cv::circle(_dump, cv::Point(point.x, point.y), 2, cv::Scalar(255, 255, 0), 2);
+        id++;
+    }
+
+    cv::cvtColor(_dump, _dump, cv::COLOR_RGB2BGR);
+    cv::imwrite("dump_face.jpg",_dump);
+}
+
+FaceResult& MvInferenceFaceService::result()
+{
+    return _result;
+}
+} // inference
+} // singleo
\ No newline at end of file
diff --git a/inference/include/MvInferenceFaceService.h b/inference/include/MvInferenceFaceService.h
deleted file mode 100644 (file)
index f332596..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-/**
- * 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_INFERENCE_FACE_SERVICE_H__
-#define __MV_INFERENCE_FACE_SERVICE_H__
-
-#include <memory>
-#include "IInferenceFaceService.h"
-#include "MvFaceTaskManager.h"
-
-using namespace singleo::inference::backends;
-
-namespace singleo
-{
-namespace inference
-{
-class MvInferenceFaceService : public IInferenceFaceService
-{
-private:
-       std::shared_ptr<MvFaceTaskManager> _taskManager;
-       FaceResult _result;
-
-public:
-       MvInferenceFaceService(std::vector<inference::TaskType> &tasks);
-       virtual ~MvInferenceFaceService() {};
-       void configure() override;
-       void prepare() override;
-       void invoke(BaseDataType &input) override;
-       FaceResult &result() override;
-};
-
-} // inference
-} // singleo
-
-#endif
\ No newline at end of file
diff --git a/inference/src/MvInferenceFaceService.cpp b/inference/src/MvInferenceFaceService.cpp
deleted file mode 100644 (file)
index 0bcb578..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-/**
- * 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.
- */
-
-#include "SingleoCommonTypes.h"
-#include "MvInferenceFaceService.h"
-#include "MvFaceDetectionTask.h"
-#include "MvFaceLandmarkDetectionTask.h"
-#include <opencv2/core.hpp>
-#include <opencv2/imgcodecs.hpp>
-#include <opencv2/imgproc.hpp>
-
-using namespace std;
-
-namespace singleo
-{
-namespace inference
-{
-MvInferenceFaceService::MvInferenceFaceService(std::vector<inference::TaskType> &tasks)
-{
-    for (auto &task : tasks) {
-        switch (task) {
-        case TaskType::FACE_DETECTION:
-        {
-            if (_taskManager.use_count() > 0)
-                _taskManager->setNext(std::make_shared<MvFaceDetectionTask>());
-            else
-                _taskManager = std::make_shared<MvFaceDetectionTask>();
-        }
-            break;
-        case TaskType::FACE_LANDMARK_DETECTION:
-        {
-            if (_taskManager.use_count() > 0)
-                _taskManager->setNext(std::make_shared<MvFaceLandmarkDetectionTask>());
-            else
-                _taskManager = std::make_shared<MvFaceLandmarkDetectionTask>();
-        }
-            break;
-        default:
-            SINGLEO_LOGE("Not supported task type %d", tasks[0]);
-            break;
-        }
-    }
-}
-
-void MvInferenceFaceService::configure()
-{
-
-}
-
-void MvInferenceFaceService::prepare()
-{
-    
-}
-
-void MvInferenceFaceService::invoke(BaseDataType &input)
-{
-    if (input._data_type != DataType::IMAGE) {
-               SINGLEO_LOGE("Invalid input type.");
-               throw invalid_argument("Input type not support.");
-       }
-
-    ImageDataType &data = dynamic_cast<ImageDataType &>(input);
-    _result = _taskManager->handle(data.ptr, data.width, data.height, data.byte_per_pixel, _result);
-
-    cv::Mat _dump(cv::Size(data.width, data.height),CV_MAKE_TYPE(CV_8U, data.byte_per_pixel), data.ptr);
-
-    int id = 0;
-    for (auto &rect : _result._rects) {
-        cv::rectangle(_dump, cv::Rect(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top), cv::Scalar(0, 255, 0), 2);
-        auto &points = _result._landmarks[id];
-        for (auto &point : points)
-            cv::circle(_dump, cv::Point(point.x, point.y), 2, cv::Scalar(255, 255, 0), 2);
-        id++;
-    }
-
-    cv::cvtColor(_dump, _dump, cv::COLOR_RGB2BGR);
-    cv::imwrite("dump_face.jpg",_dump);
-}
-
-FaceResult& MvInferenceFaceService::result()
-{
-    return _result;
-}
-} // inference
-} // singleo
\ No newline at end of file