OpenPose 1.0.0rc2 OpenPose: A Real-Time Multi-Person Key-Point Detection And Multi-Threading C++ Library

- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Public Member Functions | List of all members
op::WrapperT< 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
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)

## Detailed Description

### template<typename TDatums = std::vector<Datum>, typename TDatumsSP = std::shared_ptr<TDatums>, typename TWorker = std::shared_ptr<Worker<TDatumsSP>>>
class op::WrapperT< 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)

## Constructor & Destructor Documentation

template<typename TDatums , typename TDatumsSP , typename TWorker >

op::WrapperT< TDatums, TDatumsSP, TWorker >::WrapperT | ( | const ThreadManagerMode | threadManagerMode = `ThreadManagerMode::Synchronous` | ) |
| explicit

Constructor.

Parameters

  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.

template<typename TDatums , typename TDatumsSP , typename TWorker >

op::WrapperT< TDatums, TDatumsSP, TWorker >::~WrapperT | ( |  | ) |
| virtual

Destructor. It automatically frees resources.

## Member Function Documentation

template<typename TDatums , typename TDatumsSP , typename TWorker >

void op::WrapperT< TDatums, TDatumsSP, TWorker >::configure | ( | const WrapperStructPose & | wrapperStructPose | ) |

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

template<typename TDatums , typename TDatumsSP , typename TWorker >

void op::WrapperT< TDatums, TDatumsSP, TWorker >::configure | ( | const WrapperStructFace & | wrapperStructFace | ) |

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

template<typename TDatums , typename TDatumsSP , typename TWorker >

void op::WrapperT< TDatums, TDatumsSP, TWorker >::configure | ( | const WrapperStructHand & | wrapperStructHand | ) |

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

template<typename TDatums , typename TDatumsSP , typename TWorker >

void op::WrapperT< TDatums, TDatumsSP, TWorker >::configure | ( | const WrapperStructExtra & | wrapperStructExtra | ) |

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

template<typename TDatums , typename TDatumsSP , typename TWorker >

void op::WrapperT< TDatums, TDatumsSP, TWorker >::configure | ( | const WrapperStructInput & | wrapperStructInput | ) |

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

template<typename TDatums , typename TDatumsSP , typename TWorker >

void op::WrapperT< TDatums, TDatumsSP, TWorker >::configure | ( | const WrapperStructOutput & | wrapperStructOutput | ) |

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

template<typename TDatums , typename TDatumsSP , typename TWorker >

void op::WrapperT< TDatums, TDatumsSP, TWorker >::configure | ( | const WrapperStructGui & | wrapperStructGui | ) |

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

template<typename TDatums , typename TDatumsSP , typename TWorker >

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.

template<typename TDatums , typename TDatumsSP , typename TWorker >

bool op::WrapperT< TDatums, TDatumsSP, TWorker >::emplaceAndPop | ( | TDatumsSP & | tDatums | ) |

Runs both waitAndEmplace and waitAndPop

template<typename TDatums , typename TDatumsSP , typename TWorker >

TDatumsSP op::WrapperT< TDatums, TDatumsSP, TWorker >::emplaceAndPop | ( | const cv::Mat & | cvMat | ) |

Runs both waitAndEmplace and waitAndPop

template<typename TDatums , typename TDatumsSP , typename TWorker >

void op::WrapperT< 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.

template<typename TDatums , typename TDatumsSP , typename TWorker >

bool op::WrapperT< TDatums, TDatumsSP, TWorker >::isRunning | ( |  | ) | const

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.

template<typename TDatums , typename TDatumsSP , typename TWorker >

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, ...).

Parameters

  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.

template<typename TDatums , typename TDatumsSP , typename TWorker >

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.

template<typename TDatums , typename TDatumsSP , typename TWorker >

void op::WrapperT< TDatums, TDatumsSP, TWorker >::stop | ( |  | ) |

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

template<typename TDatums , typename TDatumsSP , typename TWorker >

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.

Parameters

  tDatums | TDatumsSP element to be emplaced.

Returns
  Boolean specifying whether the tDatums could be emplaced.

template<typename TDatums , typename TDatumsSP , typename TWorker >

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.

Parameters

  tDatums | TDatumsSP element where the retrieved element will be placed.

Returns
  Boolean specifying whether the tDatums could be retrieved.

template<typename TDatums , typename TDatumsSP , typename TWorker >

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.

Parameters

  tDatums | TDatumsSP element to be pushed.

Returns
  Boolean specifying whether the tDatums could be pushed.

template<typename TDatums , typename TDatumsSP , typename TWorker >

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.

Parameters

  tDatums | TDatumsSP element to be emplaced.

Returns
  Boolean specifying whether the tDatums could be emplaced.

template<typename TDatums , typename TDatumsSP , typename TWorker >

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.

Parameters

  tDatums | TDatumsSP element where the retrieved element will be placed.

Returns
  Boolean specifying whether the tDatums could be retrieved.

template<typename TDatums , typename TDatumsSP , typename TWorker >

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.

Parameters

  tDatums | TDatumsSP element to be pushed.

Returns
  Boolean specifying whether the tDatums could be pushed.

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

- /home/travis/build/CMU-Perceptual-Computing-Lab/openpose/include/openpose/wrapper/wrapper.hpp