#ifndef OPENPOSE_CORE_W_CV_MAT_TO_OP_INPUT_HPP #define OPENPOSE_CORE_W_CV_MAT_TO_OP_INPUT_HPP #include #include #include namespace op { template class WCvMatToOpInput : public Worker { public: explicit WCvMatToOpInput(const std::shared_ptr& cvMatToOpInput); virtual ~WCvMatToOpInput(); void initializationOnThread(); void work(TDatums& tDatums); private: const std::shared_ptr spCvMatToOpInput; DELETE_COPY(WCvMatToOpInput); }; } // Implementation #include namespace op { template WCvMatToOpInput::WCvMatToOpInput(const std::shared_ptr& cvMatToOpInput) : spCvMatToOpInput{cvMatToOpInput} { } template WCvMatToOpInput::~WCvMatToOpInput() { } template void WCvMatToOpInput::initializationOnThread() { } template void WCvMatToOpInput::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__); // cv::Mat -> float* for (auto& tDatumPtr : *tDatums) tDatumPtr->inputNetData = spCvMatToOpInput->createArray( tDatumPtr->cvInputData, tDatumPtr->scaleInputToNetInputs, tDatumPtr->netInputSizes); // 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(WCvMatToOpInput); } #endif // OPENPOSE_CORE_W_CV_MAT_TO_OP_INPUT_HPP