All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
wVideoSaver.hpp
Go to the documentation of this file.
#ifndef OPENPOSE_FILESTREAM_W_VIDEO_SAVER_HPP
#define OPENPOSE_FILESTREAM_W_VIDEO_SAVER_HPP
#include <openpose/core/common.hpp>
#include <openpose/filestream/videoSaver.hpp>
#include <openpose/thread/workerConsumer.hpp>
namespace op
{
template<typename TDatums>
class WVideoSaver : public WorkerConsumer<TDatums>
{
public:
explicit WVideoSaver(const std::shared_ptr<VideoSaver>& videoSaver);
virtual ~WVideoSaver();
void initializationOnThread();
void workConsumer(const TDatums& tDatums);
private:
std::shared_ptr<VideoSaver> spVideoSaver;
DELETE_COPY(WVideoSaver);
};
}
// Implementation
#include <openpose/utilities/pointerContainer.hpp>
namespace op
{
template<typename TDatums>
WVideoSaver<TDatums>::WVideoSaver(const std::shared_ptr<VideoSaver>& videoSaver) :
spVideoSaver{videoSaver}
{
}
template<typename TDatums>
WVideoSaver<TDatums>::~WVideoSaver()
{
}
template<typename TDatums>
void WVideoSaver<TDatums>::initializationOnThread()
{
}
template<typename TDatums>
void WVideoSaver<TDatums>::workConsumer(const TDatums& tDatums)
{
try
{
if (checkNoNullNorEmpty(tDatums))
{
// Debugging log
dLog("", Priority::Low, __LINE__, __FUNCTION__, __FILE__);
// Profiling speed
const auto profilerKey = Profiler::timerInit(__LINE__, __FUNCTION__, __FILE__);
// T* to T
auto& tDatumsNoPtr = *tDatums;
// Record video(s)
std::vector<cv::Mat> cvOutputDatas(tDatumsNoPtr.size());
for (auto i = 0u ; i < cvOutputDatas.size() ; i++)
cvOutputDatas[i] = tDatumsNoPtr[i].cvOutputData;
spVideoSaver->write(cvOutputDatas);
// 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();
error(e.what(), __LINE__, __FUNCTION__, __FILE__);
}
}
COMPILE_TEMPLATE_DATUM(WVideoSaver);
}
#endif // OPENPOSE_FILESTREAM_W_VIDEO_SAVER_HPP
op::Priority::Low
op::WorkerConsumer
Definition: workerConsumer.hpp:10
op::WVideoSaver::WVideoSaver
WVideoSaver(const std::shared_ptr< VideoSaver > &videoSaver)
Definition: wVideoSaver.hpp:38
op::WVideoSaver::~WVideoSaver
virtual ~WVideoSaver()
Definition: wVideoSaver.hpp:44
common.hpp
op::Profiler::timerInit
static const std::string timerInit(const int line, const std::string &function, const std::string &file)
op::WVideoSaver::workConsumer
void workConsumer(const TDatums &tDatums)
Definition: wVideoSaver.hpp:54
op::error
OP_API void error(const std::string &message, const int line=-1, const std::string &function="", const std::string &file="")
op::WVideoSaver::initializationOnThread
void initializationOnThread()
Definition: wVideoSaver.hpp:49
op::WVideoSaver
Definition: wVideoSaver.hpp:11
videoSaver.hpp
pointerContainer.hpp
op::dLog
void dLog(const T &message, const Priority priority=Priority::Max, const int line=-1, const std::string &function="", const std::string &file="")
Definition: errorAndLog.hpp:53
workerConsumer.hpp
op::checkNoNullNorEmpty
bool checkNoNullNorEmpty(const TPointerContainer &tPointerContainer)
Definition: pointerContainer.hpp:7
op::Profiler::printAveragedTimeMsOnIterationX
static void printAveragedTimeMsOnIterationX(const std::string &key, const int line, const std::string &function, const std::string &file, const unsigned long long x=DEFAULT_X)
op::COMPILE_TEMPLATE_DATUM
COMPILE_TEMPLATE_DATUM(WPoseTriangulation)
op::Profiler::timerEnd
static void timerEnd(const std::string &key)