OpenPose  1.7.0
The first real-time multi-person system to jointly detect human body, hand, facial, and foot keypoints
op::WrapperT< TDatum, TDatums, TDatumsSP, TWorker > Class Template Reference

#include <wrapper.hpp>

Public Member Functions

 WrapperT (const ThreadManagerMode threadManagerMode=ThreadManagerMode::Synchronous)
 
virtual ~WrapperT ()
 
void disableMultiThreading ()
 
void setWorker (const WorkerType workerType, const TWorker &worker, const bool workerOnNewThread=true)
 
void configure (const WrapperStructPose &wrapperStructPose)
 
void configure (const WrapperStructFace &wrapperStructFace)
 
void configure (const WrapperStructHand &wrapperStructHand)
 
void configure (const WrapperStructExtra &wrapperStructExtra)
 
void configure (const WrapperStructInput &wrapperStructInput)
 
void configure (const WrapperStructOutput &wrapperStructOutput)
 
void configure (const WrapperStructGui &wrapperStructGui)
 
void exec ()
 
void start ()
 
void stop ()
 
bool isRunning () const
 
void setDefaultMaxSizeQueues (const long long defaultMaxSizeQueues=-1)
 
bool tryEmplace (TDatumsSP &tDatums)
 
bool waitAndEmplace (TDatumsSP &tDatums)
 
bool waitAndEmplace (Matrix &matrix)
 
bool tryPush (const TDatumsSP &tDatums)
 
bool waitAndPush (const TDatumsSP &tDatums)
 
bool waitAndPush (const Matrix &matrix)
 
bool tryPop (TDatumsSP &tDatums)
 
bool waitAndPop (TDatumsSP &tDatums)
 
bool emplaceAndPop (TDatumsSP &tDatums)
 
TDatumsSP emplaceAndPop (const Matrix &matrix)
 

Detailed Description

template<typename TDatum = BASE_DATUM, typename TDatums = std::vector<std::shared_ptr<TDatum>>, typename TDatumsSP = std::shared_ptr<TDatums>, typename TWorker = std::shared_ptr<Worker<TDatumsSP>>>
class op::WrapperT< TDatum, TDatums, TDatumsSP, TWorker >

WrapperT: OpenPose all-in-one wrapper template class. Simplified into Wrapper for WrapperT<std::vector<Datum>> WrapperT allows the user to set up the input (video, webcam, custom input, etc.), pose, face and/or hands estimation and rendering, and output (integrated small GUI, custom output, etc.).

This function can be used in 2 ways:

  • Synchronous mode: call the full constructor with your desired input and output workers.
  • Asynchronous mode: call the empty constructor WrapperT() + use the emplace and pop functions to push the original frames and retrieve the processed ones.
  • Mix of them:
    • Synchronous input + asynchronous output: call the constructor WrapperT(ThreadManagerMode::Synchronous, workersInput, {}, true)
    • Asynchronous input + synchronous output: call the constructor WrapperT(ThreadManagerMode::Synchronous, nullptr, workersOutput, irrelevantBoolean, true)

Definition at line 36 of file wrapper.hpp.

Constructor & Destructor Documentation

◆ WrapperT()

template<typename TDatum , typename TDatums , typename TDatumsSP , typename TWorker >
op::WrapperT< TDatum, TDatums, TDatumsSP, TWorker >::WrapperT ( const ThreadManagerMode  threadManagerMode = ThreadManagerMode::Synchronous)
explicit

Constructor.

Parameters
threadManagerModeThread synchronization mode. If set to ThreadManagerMode::Synchronous, everything will run inside the WrapperT. If ThreadManagerMode::Synchronous(In/Out), then input (frames producer) and/or output (GUI, writing results, etc.) will be controlled outside the WrapperT class by the user. See ThreadManagerMode for a detailed explanation of when to use each one.

Definition at line 261 of file wrapper.hpp.

◆ ~WrapperT()

template<typename TDatum , typename TDatums , typename TDatumsSP , typename TWorker >
op::WrapperT< TDatum, TDatums, TDatumsSP, TWorker >::~WrapperT
virtual

Destructor. It automatically frees resources.

Definition at line 269 of file wrapper.hpp.

Member Function Documentation

◆ configure() [1/7]

template<typename TDatum , typename TDatums , typename TDatumsSP , typename TWorker >
void op::WrapperT< TDatum, TDatums, TDatumsSP, TWorker >::configure ( const WrapperStructExtra wrapperStructExtra)

Analogous to configure() but applied to the extra options (WrapperStructExtra)

Definition at line 359 of file wrapper.hpp.

◆ configure() [2/7]

template<typename TDatum , typename TDatums , typename TDatumsSP , typename TWorker >
void op::WrapperT< TDatum, TDatums, TDatumsSP, TWorker >::configure ( const WrapperStructFace wrapperStructFace)

Analogous to configure(WrapperStructPose) but applied to face (WrapperStructFace)

Definition at line 333 of file wrapper.hpp.

◆ configure() [3/7]

template<typename TDatum , typename TDatums , typename TDatumsSP , typename TWorker >
void op::WrapperT< TDatum, TDatums, TDatumsSP, TWorker >::configure ( const WrapperStructGui wrapperStructGui)

Analogous to configure() but applied to the GUI (WrapperStructGui)

Definition at line 398 of file wrapper.hpp.

◆ configure() [4/7]

template<typename TDatum , typename TDatums , typename TDatumsSP , typename TWorker >
void op::WrapperT< TDatum, TDatums, TDatumsSP, TWorker >::configure ( const WrapperStructHand wrapperStructHand)

Analogous to configure() but applied to hand (WrapperStructHand)

Definition at line 346 of file wrapper.hpp.

◆ configure() [5/7]

template<typename TDatum , typename TDatums , typename TDatumsSP , typename TWorker >
void op::WrapperT< TDatum, TDatums, TDatumsSP, TWorker >::configure ( const WrapperStructInput wrapperStructInput)

Analogous to configure() but applied to the input (WrapperStructInput)

Definition at line 372 of file wrapper.hpp.

◆ configure() [6/7]

template<typename TDatum , typename TDatums , typename TDatumsSP , typename TWorker >
void op::WrapperT< TDatum, TDatums, TDatumsSP, TWorker >::configure ( const WrapperStructOutput wrapperStructOutput)

Analogous to configure() but applied to the output (WrapperStructOutput)

Definition at line 385 of file wrapper.hpp.

◆ configure() [7/7]

template<typename TDatum , typename TDatums , typename TDatumsSP , typename TWorker >
void op::WrapperT< TDatum, TDatums, TDatumsSP, TWorker >::configure ( const WrapperStructPose wrapperStructPose)

It configures the pose parameters. Do not call for default values.

Definition at line 320 of file wrapper.hpp.

◆ disableMultiThreading()

template<typename TDatum , typename TDatums , typename TDatumsSP , typename TWorker >
void op::WrapperT< TDatum, TDatums, TDatumsSP, TWorker >::disableMultiThreading

Disable multi-threading. Useful for debugging and logging, all the Workers will run in the same thread. Note that workerOnNewThread (argument for setWorker function) will not make any effect.

Definition at line 287 of file wrapper.hpp.

◆ emplaceAndPop() [1/2]

template<typename TDatum , typename TDatums , typename TDatumsSP , typename TWorker >
TDatumsSP op::WrapperT< TDatum, TDatums, TDatumsSP, TWorker >::emplaceAndPop ( const Matrix matrix)

Similar to emplaceAndPop(TDatumsSP& tDatums), but it takes a Matrix as input.

Parameters
matrixMatrix with the image to be processed.
Returns
TDatumsSP element where the processed information will be placed.

Definition at line 690 of file wrapper.hpp.

◆ emplaceAndPop() [2/2]

template<typename TDatum , typename TDatums , typename TDatumsSP , typename TWorker >
bool op::WrapperT< TDatum, TDatums, TDatumsSP, TWorker >::emplaceAndPop ( TDatumsSP &  tDatums)

Runs both waitAndEmplace and waitAndPop.

Parameters
tDatumsTDatumsSP element where the retrieved element will be placed.
Returns
Boolean specifying whether the tDatums could be retrieved.

Definition at line 673 of file wrapper.hpp.

◆ exec()

template<typename TDatum , typename TDatums , typename TDatumsSP , typename TWorker >
void op::WrapperT< TDatum, TDatums, TDatumsSP, TWorker >::exec

Function to start multi-threading. Similar to start(), but exec() blocks the thread that calls the function (it saves 1 thread). Use exec() instead of start() if the calling thread will otherwise be waiting for the WrapperT to end.

Definition at line 411 of file wrapper.hpp.

◆ isRunning()

template<typename TDatum , typename TDatums , typename TDatumsSP , typename TWorker >
bool op::WrapperT< TDatum, TDatums, TDatumsSP, TWorker >::isRunning

Whether the WrapperT is running. It will return true after exec() or start() and before stop(), and false otherwise.

Returns
Boolean specifying whether the WrapperT is running.

Definition at line 460 of file wrapper.hpp.

◆ setDefaultMaxSizeQueues()

template<typename TDatum , typename TDatums , typename TDatumsSP , typename TWorker >
void op::WrapperT< TDatum, TDatums, TDatumsSP, TWorker >::setDefaultMaxSizeQueues ( const long long  defaultMaxSizeQueues = -1)

It sets the maximum number of elements in the queue. For maximum speed, set to a very large number, but the trade-off would be:

  • Latency will hugely increase.
  • The program might go out of RAM memory (so the computer might freeze). For minimum latency while keeping an optimal speed, set to -1, that will automatically detect the ideal number based on how many elements are connected to that queue.
    Parameters
    defaultMaxSizeQueueslong long element with the maximum number of elements on the queue.

Definition at line 474 of file wrapper.hpp.

◆ setWorker()

template<typename TDatum , typename TDatums , typename TDatumsSP , typename TWorker >
void op::WrapperT< TDatum, TDatums, TDatumsSP, TWorker >::setWorker ( const WorkerType  workerType,
const TWorker &  worker,
const bool  workerOnNewThread = true 
)

Add an user-defined extra Worker for a desired task (input, output, ...).

Parameters
workerTypeWorkerType to configure (e.g., Input, PreProcessing, PostProcessing, Output).
workerTWorker to be added.
workerOnNewThreadWhether to add this TWorker on a new thread (if it is computationally demanding) or simply reuse existing threads (for light functions). Set to true if the performance time is unknown.

Definition at line 300 of file wrapper.hpp.

◆ start()

template<typename TDatum , typename TDatums , typename TDatumsSP , typename TWorker >
void op::WrapperT< TDatum, TDatums, TDatumsSP, TWorker >::start

Function to start multi-threading. Similar to exec(), but start() does not block the thread that calls the function. It just opens new threads, so it lets the user perform other tasks meanwhile on the calling thread. VERY IMPORTANT NOTE: if the GUI is selected and OpenCV is compiled with Qt support, this option will not work. Qt needs the main thread to plot visual results, so the final GUI (which uses OpenCV) would return an exception similar to: QMetaMethod::invoke: Unable to invoke methods with return values in queued connections. Use exec() in that case.

Definition at line 429 of file wrapper.hpp.

◆ stop()

template<typename TDatum , typename TDatums , typename TDatumsSP , typename TWorker >
void op::WrapperT< TDatum, TDatums, TDatumsSP, TWorker >::stop

Function to stop multi-threading. It can be called internally or externally.

Definition at line 447 of file wrapper.hpp.

◆ tryEmplace()

template<typename TDatum , typename TDatums , typename TDatumsSP , typename TWorker >
bool op::WrapperT< TDatum, TDatums, TDatumsSP, TWorker >::tryEmplace ( TDatumsSP &  tDatums)

Emplace (move) an element on the first (input) queue. Only valid if ThreadManagerMode::Asynchronous or ThreadManagerMode::AsynchronousIn. If the input queue is full or the WrapperT was stopped, it will return false and not emplace it.

Parameters
tDatumsTDatumsSP element to be emplaced.
Returns
Boolean specifying whether the tDatums could be emplaced.

Definition at line 487 of file wrapper.hpp.

◆ tryPop()

template<typename TDatum , typename TDatums , typename TDatumsSP , typename TWorker >
bool op::WrapperT< TDatum, TDatums, TDatumsSP, TWorker >::tryPop ( TDatumsSP &  tDatums)

Pop (retrieve) an element from the last (output) queue. Only valid if ThreadManagerMode::Asynchronous or ThreadManagerMode::AsynchronousOut. If the output queue is empty or the WrapperT was stopped, it will return false and not retrieve it.

Parameters
tDatumsTDatumsSP element where the retrieved element will be placed.
Returns
Boolean specifying whether the tDatums could be retrieved.

Definition at line 639 of file wrapper.hpp.

◆ tryPush()

template<typename TDatum , typename TDatums , typename TDatumsSP , typename TWorker >
bool op::WrapperT< TDatum, TDatums, TDatumsSP, TWorker >::tryPush ( const TDatumsSP &  tDatums)

Push (copy) an element on the first (input) queue. Same as tryEmplace, but it copies the data instead of moving it.

Parameters
tDatumsTDatumsSP element to be pushed.
Returns
Boolean specifying whether the tDatums could be pushed.

Definition at line 583 of file wrapper.hpp.

◆ waitAndEmplace() [1/2]

template<typename TDatum , typename TDatums , typename TDatumsSP , typename TWorker >
bool op::WrapperT< TDatum, TDatums, TDatumsSP, TWorker >::waitAndEmplace ( Matrix matrix)

Similar to waitAndEmplace(const TDatumsSP& tDatums), but it takes a Matrix as input.

Parameters
matrixMatrix with the image to be processed.
Returns
Boolean specifying whether the tDatums could be emplaced.

Definition at line 561 of file wrapper.hpp.

◆ waitAndEmplace() [2/2]

template<typename TDatum , typename TDatums , typename TDatumsSP , typename TWorker >
bool op::WrapperT< TDatum, TDatums, TDatumsSP, TWorker >::waitAndEmplace ( TDatumsSP &  tDatums)

Emplace (move) an element on the first (input) queue. Similar to tryEmplace. However, if the input queue is full, it will wait until it can emplace it. If the WrapperT class is stopped before adding the element, it will return false and not emplace it.

Parameters
tDatumsTDatumsSP element to be emplaced.
Returns
Boolean specifying whether the tDatums could be emplaced.

Definition at line 523 of file wrapper.hpp.

◆ waitAndPop()

template<typename TDatum , typename TDatums , typename TDatumsSP , typename TWorker >
bool op::WrapperT< TDatum, TDatums, TDatumsSP, TWorker >::waitAndPop ( TDatumsSP &  tDatums)

Pop (retrieve) an element from the last (output) queue. Similar to tryPop. However, if the output queue is empty, it will wait until it can pop an element. If the WrapperT class is stopped before popping the element, it will return false and not retrieve it.

Parameters
tDatumsTDatumsSP element where the retrieved element will be placed.
Returns
Boolean specifying whether the tDatums could be retrieved.

Definition at line 656 of file wrapper.hpp.

◆ waitAndPush() [1/2]

template<typename TDatum , typename TDatums , typename TDatumsSP , typename TWorker >
bool op::WrapperT< TDatum, TDatums, TDatumsSP, TWorker >::waitAndPush ( const Matrix matrix)

Similar to waitAndPush(const TDatumsSP& tDatums), but it takes a Matrix as input.

Parameters
matrixMatrix with the image to be processed.
Returns
Boolean specifying whether the tDatums could be pushed.

Definition at line 617 of file wrapper.hpp.

◆ waitAndPush() [2/2]

template<typename TDatum , typename TDatums , typename TDatumsSP , typename TWorker >
bool op::WrapperT< TDatum, TDatums, TDatumsSP, TWorker >::waitAndPush ( const TDatumsSP &  tDatums)

Push (copy) an element on the first (input) queue. Same as waitAndEmplace, but it copies the data instead of moving it.

Parameters
tDatumsTDatumsSP element to be pushed.
Returns
Boolean specifying whether the tDatums could be pushed.

Definition at line 600 of file wrapper.hpp.


The documentation for this class was generated from the following file: