[WIP-07] Add HeadPoseEstimator
authorTae-Young Chung <ty83.chung@samsung.com>
Fri, 26 Apr 2024 07:07:26 +0000 (16:07 +0900)
committerTae-Young Chung <ty83.chung@samsung.com>
Fri, 26 Apr 2024 07:07:26 +0000 (16:07 +0900)
Signed-off-by: Tae-Young Chung <ty83.chung@samsung.com>
services/smart_pointer/CMakeLists.txt
services/smart_pointer/include/FaceShapeModelManager.h
services/smart_pointer/include/GazeEstimator.h
services/smart_pointer/include/HeadPoseEstimator.h [new file with mode: 0644]
services/smart_pointer/src/FaceShapeModelManager.cpp
services/smart_pointer/src/GazeEstimator.cpp
services/smart_pointer/src/HeadPoseEstimator.cpp [new file with mode: 0644]

index 298e736d261dd52f49ed948ae05b8ae3327bb769..27d84b994e9446c526a3bff03c601f90dec6f542 100644 (file)
@@ -3,6 +3,7 @@ SET(SINGLEO_SERVICE_SOURCE_FILES
     smart_pointer/src/SmartPointer.cpp
     smart_pointer/src/GazeEstimator.cpp
     smart_pointer/src/FaceShapeModelManager.cpp
+    smart_pointer/src/HeadPoseEstimator.cpp
 )
 
 LIST(APPEND SERVICE_LIBRARY_LIST singleo_inference)
\ No newline at end of file
index e430bda95a4d76da6bb82558e031ce48da0d8fb8..578b525766e315521948678e23fafda23266db64 100644 (file)
@@ -39,9 +39,10 @@ private:
 public:
     FaceShapeModelManager(const std::string &model_path);
     ~FaceShapeModelManager();
+    const std::vector<Point3f> &getFaceShape();
 };
 } // smartpointer
 } // services 
 } // singleo
 
-#endif
+#endif
\ No newline at end of file
index 28aec9ddf6a4a7aa0f8071cc24b5b8634ecf2cad..66b993bf84301a97ff6b9d0ae80719f547a56907 100644 (file)
@@ -35,7 +35,6 @@ class GazeEstimator
 private:
     std::unique_ptr<singleo::inference::IInferenceFaceService> _face_estimator;
     std::unique_ptr<singleo::input::IInputService> _input_service;
-    std::unique_ptr<FaceShapeModelManager> _face_shape_model_manager;
 
     std::vector<inference::TaskType> _tasks { inference::TaskType::FACE_DETECTION, inference::TaskType::FACE_LANDMARK_DETECTION };
 
diff --git a/services/smart_pointer/include/HeadPoseEstimator.h b/services/smart_pointer/include/HeadPoseEstimator.h
new file mode 100644 (file)
index 0000000..05ba2b4
--- /dev/null
@@ -0,0 +1,45 @@
+/**
+ * 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 __HEAD_POSE_ESTIMATOR_H__
+#define __HEAD_POSE_ESTIMATOR_H__
+
+#include <memory>
+#include <vector>
+#include <opencv2/core.hpp>
+#include <opencv2/calib3d.hpp>
+
+namespace singleo
+{
+namespace services
+{
+namespace smartpointer
+{
+class HeadPoseEstimator
+{
+private:
+    std::vector<cv::Point2f> _landmarks_2d;
+    std::vector<cv::Point3f> _landmarks_3d;
+
+public:
+    HeadPoseEstimator();
+    ~HeadPoseEstimator();
+};
+} // smartpointer
+} // services 
+} // singleo
+
+#endif
index 207d9cc80b7b72b3930417216ad1de321520dd3d..1c964291763c6323ba9e7067eaea8eb2493443df 100644 (file)
@@ -79,6 +79,11 @@ void FaceShapeModelManager::loadModelFromFile(const std::string &model_path)
     SINGLEO_LOGI("%zd landarks", _faceShape.size());
 }
 
+const vector<Point3f> &FaceShapeModelManager::getFaceShape()
+{
+    return _faceShape;
+}
+
 template float FaceShapeModelManager::ToNumber(const string &text);
 } // smartpointer
 } // services
index 2519fcd0db7e67750da4caabd6ac43f379d95750..870dbf7fa632a2951b32d6f7d4200f3fd7d6e820 100644 (file)
@@ -37,7 +37,6 @@ GazeEstimator::GazeEstimator(InputConfigBase& config)
     _face_estimator->configure();
        _face_estimator->prepare();
 
-    _face_shape_model_manager = make_unique<FaceShapeModelManager>("/usr/share/singleo/pdm.txt");
     _headPose.reset();
 }
 
diff --git a/services/smart_pointer/src/HeadPoseEstimator.cpp b/services/smart_pointer/src/HeadPoseEstimator.cpp
new file mode 100644 (file)
index 0000000..a8bf827
--- /dev/null
@@ -0,0 +1,47 @@
+/**
+ * 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 "FaceShapeModelManager.h"
+#include "HeadPoseEstimator.h"
+#include "SingleoLog.h"
+
+using namespace std;
+using namespace cv;
+
+namespace singleo
+{
+namespace services
+{
+namespace smartpointer
+{
+HeadPoseEstimator::HeadPoseEstimator()
+{
+    FaceShapeModelManager faceShapeModelmgr("/usr/share/singleo/pdm.txt");
+    const vector<Point3f> faceShape = faceShapeModelmgr.getFaceShape();
+
+    for (auto &point : faceShape)
+        _landmarks_3d.push_back(cv::Point3f(point.x, point.y, point.z));
+
+}
+
+HeadPoseEstimator::~HeadPoseEstimator()
+{
+
+}
+
+} // smartpointer
+} // services
+} // singleo