#ifndef OPENPOSE_3D_W_POSE_TRIANGULATION_HPP #define OPENPOSE_3D_W_POSE_TRIANGULATION_HPP #include #include #include namespace op { template class WPoseTriangulation : public Worker { public: explicit WPoseTriangulation(); void initializationOnThread(); void work(TDatums& tDatums); private: DELETE_COPY(WPoseTriangulation); }; } // Implementation #include namespace op { template WPoseTriangulation::WPoseTriangulation() { } template void WPoseTriangulation::initializationOnThread() { } template void WPoseTriangulation::work(TDatums& tDatums) { try { if (checkNoNullNorEmpty(tDatums)) { // Debugging log dLog("", Priority::Low, __LINE__, __FUNCTION__, __FILE__); // Profiling speed const auto profilerKey = Profiler::timerInit(__LINE__, __FUNCTION__, __FILE__); // 3-D triangulation and reconstruction std::vector cameraMatrices; std::vector> poseKeypointVector; std::vector> faceKeypointVector; std::vector> leftHandKeypointVector; std::vector> rightHandKeypointVector; for (auto& datumsElement : *tDatums) { poseKeypointVector.emplace_back(datumsElement.poseKeypoints); faceKeypointVector.emplace_back(datumsElement.faceKeypoints); leftHandKeypointVector.emplace_back(datumsElement.handKeypoints[0]); rightHandKeypointVector.emplace_back(datumsElement.handKeypoints[1]); cameraMatrices.emplace_back(datumsElement.cameraMatrix); } // Pose 3-D reconstruction auto poseKeypoints3D = reconstructArray(poseKeypointVector, cameraMatrices); auto faceKeypoints3D = reconstructArray(faceKeypointVector, cameraMatrices); auto leftHandKeypoints3D = reconstructArray(leftHandKeypointVector, cameraMatrices); auto rightHandKeypoints3D = reconstructArray(rightHandKeypointVector, cameraMatrices); // Assign to all tDatums for (auto& datumsElement : *tDatums) { datumsElement.poseKeypoints3D = poseKeypoints3D; datumsElement.faceKeypoints3D = faceKeypoints3D; datumsElement.handKeypoints3D[0] = leftHandKeypoints3D; datumsElement.handKeypoints3D[1] = rightHandKeypoints3D; } // Profiling speed Profiler::timerEnd(profilerKey); Profiler::printAveragedTimeMsOnIterationX(profilerKey, __LINE__, __FUNCTION__, __FILE__); // Debugging log dLog("", Priority::Low, __LINE__, __FUNCTION__, __FILE__); } } catch (const std::exception& e) { this->stop(); tDatums = nullptr; error(e.what(), __LINE__, __FUNCTION__, __FILE__); } } COMPILE_TEMPLATE_DATUM(WPoseTriangulation); } #endif // OPENPOSE_3D_W_POSE_TRIANGULATION_HPP