mirror of
https://github.com/gosticks/openpose.git
synced 2026-10-19 13:20:29 +00:00
Wrapper template simplified
This commit is contained in:
@@ -29,7 +29,8 @@ DEFINE_string(image_dir, "examples/media/",
|
||||
|
||||
// If the user needs his own variables, he can inherit the op::Datum struct and add them in there.
|
||||
// UserDatum can be directly used by the OpenPose wrapper because it inherits from op::Datum, just define
|
||||
// WrapperT<std::vector<UserDatum>> instead of Wrapper (or equivalently WrapperT<std::vector<UserDatum>>)
|
||||
// WrapperT<std::vector<std::shared_ptr<UserDatum>>> instead of Wrapper
|
||||
// (or equivalently WrapperT<std::vector<std::shared_ptr<UserDatum>>>)
|
||||
struct UserDatum : public op::Datum
|
||||
{
|
||||
bool boolThatUserNeedsForSomeReason;
|
||||
@@ -44,7 +45,7 @@ struct UserDatum : public op::Datum
|
||||
// in this case we assume a std::shared_ptr of a std::vector of UserDatum
|
||||
|
||||
// This worker will just read and return all the jpg files in a directory
|
||||
class WUserInput : public op::WorkerProducer<std::shared_ptr<std::vector<UserDatum>>>
|
||||
class WUserInput : public op::WorkerProducer<std::shared_ptr<std::vector<std::shared_ptr<UserDatum>>>>
|
||||
{
|
||||
public:
|
||||
WUserInput(const std::string& directoryPath) :
|
||||
@@ -59,7 +60,7 @@ public:
|
||||
|
||||
void initializationOnThread() {}
|
||||
|
||||
std::shared_ptr<std::vector<UserDatum>> workProducer()
|
||||
std::shared_ptr<std::vector<std::shared_ptr<UserDatum>>> workProducer()
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -76,15 +77,15 @@ public:
|
||||
else
|
||||
{
|
||||
// Create new datum
|
||||
auto datumsPtr = std::make_shared<std::vector<UserDatum>>();
|
||||
auto datumsPtr = std::make_shared<std::vector<std::shared_ptr<UserDatum>>>();
|
||||
datumsPtr->emplace_back();
|
||||
auto& datum = datumsPtr->at(0);
|
||||
auto& datumPtr = datumsPtr->at(0);
|
||||
|
||||
// Fill datum
|
||||
datum.cvInputData = cv::imread(mImageFiles.at(mCounter++));
|
||||
datumPtr->cvInputData = cv::imread(mImageFiles.at(mCounter++));
|
||||
|
||||
// If empty frame -> return nullptr
|
||||
if (datum.cvInputData.empty())
|
||||
if (datumPtr->cvInputData.empty())
|
||||
{
|
||||
op::log("Empty frame detected on path: " + mImageFiles.at(mCounter-1) + ". Closing program.",
|
||||
op::Priority::High);
|
||||
@@ -155,7 +156,7 @@ int tutorialApiCpp7()
|
||||
|
||||
// OpenPose wrapper
|
||||
op::log("Configuring OpenPose...", op::Priority::High);
|
||||
op::WrapperT<std::vector<UserDatum>> opWrapperT;
|
||||
op::WrapperT<UserDatum> opWrapperT;
|
||||
|
||||
// Initializing the user custom classes
|
||||
// Frames producer (e.g., video, webcam, ...)
|
||||
|
||||
Reference in New Issue
Block a user