OpenPose
1.0.0rc2
OpenPose: A Real-Time Multi-Person Key-Point Detection And Multi-Threading C++ Library
|
#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 |
bool | tryEmplace (TDatumsSP &tDatums) |
bool | waitAndEmplace (TDatumsSP &tDatums) |
bool | tryPush (const TDatumsSP &tDatums) |
bool | waitAndPush (const TDatumsSP &tDatums) |
bool | tryPop (TDatumsSP &tDatums) |
bool | waitAndPop (TDatumsSP &tDatums) |
bool | emplaceAndPop (TDatumsSP &tDatums) |
TDatumsSP | emplaceAndPop (const cv::Mat &cvMat) |
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:
|
explicit |
Constructor.
threadManagerMode | Thread syncronization 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. |
|
virtual |
Destructor. It automatically frees resources.
void op::WrapperT< TDatums, TDatumsSP, TWorker >::configure | ( | const WrapperStructPose & | wrapperStructPose | ) |
It configures the pose parameters. Do not call for default values.
void op::WrapperT< TDatums, TDatumsSP, TWorker >::configure | ( | const WrapperStructFace & | wrapperStructFace | ) |
Analogous to configure(WrapperStructPose) but applied to face (WrapperStructFace)
void op::WrapperT< TDatums, TDatumsSP, TWorker >::configure | ( | const WrapperStructHand & | wrapperStructHand | ) |
Analogous to configure() but applied to hand (WrapperStructHand)
void op::WrapperT< TDatums, TDatumsSP, TWorker >::configure | ( | const WrapperStructExtra & | wrapperStructExtra | ) |
Analogous to configure() but applied to the extra options (WrapperStructExtra)
void op::WrapperT< TDatums, TDatumsSP, TWorker >::configure | ( | const WrapperStructInput & | wrapperStructInput | ) |
Analogous to configure() but applied to the input (WrapperStructInput)
void op::WrapperT< TDatums, TDatumsSP, TWorker >::configure | ( | const WrapperStructOutput & | wrapperStructOutput | ) |
Analogous to configure() but applied to the output (WrapperStructOutput)
void op::WrapperT< TDatums, TDatumsSP, TWorker >::configure | ( | const WrapperStructGui & | wrapperStructGui | ) |
Analogous to configure() but applied to the GUI (WrapperStructGui)
void op::WrapperT< 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.
bool op::WrapperT< TDatums, TDatumsSP, TWorker >::emplaceAndPop | ( | TDatumsSP & | tDatums | ) |
Runs both waitAndEmplace and waitAndPop
TDatumsSP op::WrapperT< TDatums, TDatumsSP, TWorker >::emplaceAndPop | ( | const cv::Mat & | cvMat | ) |
Runs both waitAndEmplace and waitAndPop
void op::WrapperT< TDatums, TDatumsSP, TWorker >::exec | ( | ) |
bool op::WrapperT< TDatums, TDatumsSP, TWorker >::isRunning | ( | ) | const |
void op::WrapperT< 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, ...).
workerType | WorkerType to configure (e.g., Input, PostProcessing, Output). |
worker | TWorker to be added. |
workerOnNewThread | Whether 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. |
void op::WrapperT< 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.
void op::WrapperT< TDatums, TDatumsSP, TWorker >::stop | ( | ) |
Function to stop multi-threading. It can be called internally or externally.
bool op::WrapperT< 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.
tDatums | TDatumsSP element to be emplaced. |
bool op::WrapperT< 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.
tDatums | TDatumsSP element where the retrieved element will be placed. |
bool op::WrapperT< 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.
tDatums | TDatumsSP element to be pushed. |
bool op::WrapperT< 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.
tDatums | TDatumsSP element to be emplaced. |
bool op::WrapperT< 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.
tDatums | TDatumsSP element where the retrieved element will be placed. |
bool op::WrapperT< 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.
tDatums | TDatumsSP element to be pushed. |