#ifndef OPENPOSE_FACE_W_FACE_EXTRACTOR_OPENCV_HPP #define OPENPOSE_FACE_W_FACE_EXTRACTOR_OPENCV_HPP #include #include #include namespace op { template class WFaceDetectorOpenCV : public Worker { public: explicit WFaceDetectorOpenCV(const std::shared_ptr& faceDetectorOpenCV); virtual ~WFaceDetectorOpenCV(); void initializationOnThread(); void work(TDatums& tDatums); private: std::shared_ptr spFaceDetectorOpenCV; DELETE_COPY(WFaceDetectorOpenCV); }; } // Implementation #include namespace op { template WFaceDetectorOpenCV::WFaceDetectorOpenCV(const std::shared_ptr& faceDetectorOpenCV) : spFaceDetectorOpenCV{faceDetectorOpenCV} { } template WFaceDetectorOpenCV::~WFaceDetectorOpenCV() { } template void WFaceDetectorOpenCV::initializationOnThread() { } template void WFaceDetectorOpenCV::work(TDatums& tDatums) { try { if (checkNoNullNorEmpty(tDatums)) { // Debugging log opLogIfDebug("", Priority::Low, __LINE__, __FUNCTION__, __FILE__); // Profiling speed const auto profilerKey = Profiler::timerInit(__LINE__, __FUNCTION__, __FILE__); // Detect people face for (auto& tDatumPtr : *tDatums) tDatumPtr->faceRectangles = spFaceDetectorOpenCV->detectFaces(tDatumPtr->cvInputData); // Profiling speed Profiler::timerEnd(profilerKey); Profiler::printAveragedTimeMsOnIterationX(profilerKey, __LINE__, __FUNCTION__, __FILE__); // Debugging log opLogIfDebug("", Priority::Low, __LINE__, __FUNCTION__, __FILE__); } } catch (const std::exception& e) { this->stop(); tDatums = nullptr; error(e.what(), __LINE__, __FUNCTION__, __FILE__); } } COMPILE_TEMPLATE_DATUM(WFaceDetectorOpenCV); } #endif // OPENPOSE_FACE_W_FACE_EXTRACTOR_OPENCV_HPP