#ifndef OPENPOSE_GUI_W_GUI_3D_HPP #define OPENPOSE_GUI_W_GUI_3D_HPP #include #include #include namespace op { // This worker will do 3-D rendering template class WGui3D : public WorkerConsumer { public: explicit WGui3D(const std::shared_ptr& gui3D); virtual ~WGui3D(); void initializationOnThread(); void workConsumer(const TDatums& tDatums); private: std::shared_ptr spGui3D; DELETE_COPY(WGui3D); }; } // Implementation #include namespace op { template WGui3D::WGui3D(const std::shared_ptr& gui3D) : spGui3D{gui3D} { } template WGui3D::~WGui3D() { } template void WGui3D::initializationOnThread() { try { spGui3D->initializationOnThread(); } catch (const std::exception& e) { error(e.what(), __LINE__, __FUNCTION__, __FILE__); } } template void WGui3D::workConsumer(const TDatums& tDatums) { try { // tDatums might be empty but we still wanna update the GUI if (tDatums != nullptr) { // Debugging log opLogIfDebug("", Priority::Low, __LINE__, __FUNCTION__, __FILE__); // Profiling speed const auto profilerKey = Profiler::timerInit(__LINE__, __FUNCTION__, __FILE__); // Update cvMat & keypoints if (!tDatums->empty()) { // Update cvMat std::vector cvOutputDatas; for (auto& tDatumPtr : *tDatums) cvOutputDatas.emplace_back(tDatumPtr->cvOutputData); spGui3D->setImage(cvOutputDatas); // Update keypoints auto& tDatumPtr = (*tDatums)[0]; spGui3D->setKeypoints( tDatumPtr->poseKeypoints3D, tDatumPtr->faceKeypoints3D, tDatumPtr->handKeypoints3D[0], tDatumPtr->handKeypoints3D[1]); } // Refresh/update GUI spGui3D->update(); // Read OpenCV mat equivalent if (!tDatums->empty()) { auto& tDatumPtr = (*tDatums)[0]; tDatumPtr->cvOutputData3D = spGui3D->readCvMat(); } // Profiling speed if (!tDatums->empty()) { Profiler::timerEnd(profilerKey); Profiler::printAveragedTimeMsOnIterationX(profilerKey, __LINE__, __FUNCTION__, __FILE__); } // Debugging log opLogIfDebug("", Priority::Low, __LINE__, __FUNCTION__, __FILE__); } } catch (const std::exception& e) { this->stop(); error(e.what(), __LINE__, __FUNCTION__, __FILE__); } } COMPILE_TEMPLATE_DATUM(WGui3D); } #endif // OPENPOSE_GUI_W_GUI_3D_HPP