From: Tae-Young Chung Date: Fri, 26 Apr 2024 07:07:26 +0000 (+0900) Subject: [WIP-07] Add HeadPoseEstimator X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0e42a58cd9e4ed66f59368dd19cddfc4a8a654a6;p=platform%2Fcore%2Fapi%2Fsingleo.git [WIP-07] Add HeadPoseEstimator Signed-off-by: Tae-Young Chung --- diff --git a/services/smart_pointer/CMakeLists.txt b/services/smart_pointer/CMakeLists.txt index 298e736..27d84b9 100644 --- a/services/smart_pointer/CMakeLists.txt +++ b/services/smart_pointer/CMakeLists.txt @@ -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 diff --git a/services/smart_pointer/include/FaceShapeModelManager.h b/services/smart_pointer/include/FaceShapeModelManager.h index e430bda..578b525 100644 --- a/services/smart_pointer/include/FaceShapeModelManager.h +++ b/services/smart_pointer/include/FaceShapeModelManager.h @@ -39,9 +39,10 @@ private: public: FaceShapeModelManager(const std::string &model_path); ~FaceShapeModelManager(); + const std::vector &getFaceShape(); }; } // smartpointer } // services } // singleo -#endif +#endif \ No newline at end of file diff --git a/services/smart_pointer/include/GazeEstimator.h b/services/smart_pointer/include/GazeEstimator.h index 28aec9d..66b993b 100644 --- a/services/smart_pointer/include/GazeEstimator.h +++ b/services/smart_pointer/include/GazeEstimator.h @@ -35,7 +35,6 @@ class GazeEstimator private: std::unique_ptr _face_estimator; std::unique_ptr _input_service; - std::unique_ptr _face_shape_model_manager; std::vector _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 index 0000000..05ba2b4 --- /dev/null +++ b/services/smart_pointer/include/HeadPoseEstimator.h @@ -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 +#include +#include +#include + +namespace singleo +{ +namespace services +{ +namespace smartpointer +{ +class HeadPoseEstimator +{ +private: + std::vector _landmarks_2d; + std::vector _landmarks_3d; + +public: + HeadPoseEstimator(); + ~HeadPoseEstimator(); +}; +} // smartpointer +} // services +} // singleo + +#endif diff --git a/services/smart_pointer/src/FaceShapeModelManager.cpp b/services/smart_pointer/src/FaceShapeModelManager.cpp index 207d9cc..1c96429 100644 --- a/services/smart_pointer/src/FaceShapeModelManager.cpp +++ b/services/smart_pointer/src/FaceShapeModelManager.cpp @@ -79,6 +79,11 @@ void FaceShapeModelManager::loadModelFromFile(const std::string &model_path) SINGLEO_LOGI("%zd landarks", _faceShape.size()); } +const vector &FaceShapeModelManager::getFaceShape() +{ + return _faceShape; +} + template float FaceShapeModelManager::ToNumber(const string &text); } // smartpointer } // services diff --git a/services/smart_pointer/src/GazeEstimator.cpp b/services/smart_pointer/src/GazeEstimator.cpp index 2519fcd..870dbf7 100644 --- a/services/smart_pointer/src/GazeEstimator.cpp +++ b/services/smart_pointer/src/GazeEstimator.cpp @@ -37,7 +37,6 @@ GazeEstimator::GazeEstimator(InputConfigBase& config) _face_estimator->configure(); _face_estimator->prepare(); - _face_shape_model_manager = make_unique("/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 index 0000000..a8bf827 --- /dev/null +++ b/services/smart_pointer/src/HeadPoseEstimator.cpp @@ -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 faceShape = faceShapeModelmgr.getFaceShape(); + + for (auto &point : faceShape) + _landmarks_3d.push_back(cv::Point3f(point.x, point.y, point.z)); + +} + +HeadPoseEstimator::~HeadPoseEstimator() +{ + +} + +} // smartpointer +} // services +} // singleo