OpenPose  1.0.0rc2
OpenPose: A Real-Time Multi-Person Key-Point Detection And Multi-Threading C++ Library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
wrapperAuxiliary.hpp
Go to the documentation of this file.
1 #ifndef OPENPOSE_WRAPPER_WRAPPER_AUXILIARY_HPP
2 #define OPENPOSE_WRAPPER_WRAPPER_AUXILIARY_HPP
3 
12 
13 namespace op
14 {
29  WrapperStructPose& wrapperStructPose, const WrapperStructFace& wrapperStructFace,
30  const WrapperStructHand& wrapperStructHand, const WrapperStructExtra& wrapperStructExtra,
31  const WrapperStructInput& wrapperStructInput, const WrapperStructOutput& wrapperStructOutput,
32  const bool renderOutput, const bool userOutputWsEmpty, const std::shared_ptr<Producer>& producerSharedPtr,
33  const ThreadManagerMode threadManagerMode);
34 
43  OP_API void threadIdPP(unsigned long long& threadId, const bool multiThreadEnabled);
44 
51  template<typename TDatums,
52  typename TDatumsSP = std::shared_ptr<TDatums>,
53  typename TWorker = std::shared_ptr<Worker<TDatumsSP>>>
55  ThreadManager<TDatumsSP>& threadManager, const bool multiThreadEnabled,
56  const ThreadManagerMode threadManagerMode, const WrapperStructPose& wrapperStructPose,
57  const WrapperStructFace& wrapperStructFace, const WrapperStructHand& wrapperStructHand,
58  const WrapperStructExtra& wrapperStructExtra, const WrapperStructInput& wrapperStructInput,
59  const WrapperStructOutput& wrapperStructOutput,
60  const std::array<std::vector<TWorker>, int(WorkerType::Size)>& userWs,
61  const std::array<bool, int(WorkerType::Size)>& userWsOnNewThread);
62 }
63 
64 
65 
66 
67 
68 // Implementation
69 #include <openpose/3d/headers.hpp>
73 #include <openpose/gpu/gpu.hpp>
74 #include <openpose/gui/headers.hpp>
81 namespace op
82 {
83  template<typename TDatums, typename TDatumsSP, typename TWorker>
85  ThreadManager<TDatumsSP>& threadManager, const bool multiThreadEnabledTemp,
86  const ThreadManagerMode threadManagerMode, const WrapperStructPose& wrapperStructPoseTemp,
87  const WrapperStructFace& wrapperStructFace, const WrapperStructHand& wrapperStructHand,
88  const WrapperStructExtra& wrapperStructExtra, const WrapperStructInput& wrapperStructInput,
89  const WrapperStructOutput& wrapperStructOutput,
90  const std::array<std::vector<TWorker>, int(WorkerType::Size)>& userWs,
91  const std::array<bool, int(WorkerType::Size)>& userWsOnNewThread)
92  {
93  try
94  {
95  log("", Priority::Low, __LINE__, __FUNCTION__, __FILE__);
96 
97  // Create producer
98  auto producerSharedPtr = createProducer(
99  wrapperStructInput.producerType, wrapperStructInput.producerString,
100  wrapperStructInput.cameraResolution, wrapperStructInput.webcamFps,
101  wrapperStructInput.cameraParameterPath, wrapperStructInput.undistortImage,
102  wrapperStructInput.imageDirectoryStereo);
103 
104  // Editable arguments
105  auto wrapperStructPose = wrapperStructPoseTemp;
106  auto multiThreadEnabled = multiThreadEnabledTemp;
107 
108  // Workers
109  TWorker datumProducerW;
110  TWorker scaleAndSizeExtractorW;
111  TWorker cvMatToOpInputW;
112  TWorker cvMatToOpOutputW;
113  std::vector<std::vector<TWorker>> poseExtractorsWs;
114  std::vector<std::vector<TWorker>> poseTriangulationsWs;
115  std::vector<std::vector<TWorker>> jointAngleEstimationsWs;
116  std::vector<TWorker> postProcessingWs;
117  std::vector<TWorker> outputWs;
118  TWorker guiW;
119 
120  // User custom workers
121  const auto& userInputWs = userWs[int(WorkerType::Input)];
122  const auto& userPostProcessingWs = userWs[int(WorkerType::PostProcessing)];
123  const auto& userOutputWs = userWs[int(WorkerType::Output)];
124  const auto userInputWsOnNewThread = userWsOnNewThread[int(WorkerType::Input)];
125  const auto userPostProcessingWsOnNewThread = userWsOnNewThread[int(WorkerType::PostProcessing)];
126  const auto userOutputWsOnNewThread = userWsOnNewThread[int(WorkerType::Output)];
127 
128  // Video seek
129  const auto spVideoSeek = std::make_shared<std::pair<std::atomic<bool>, std::atomic<int>>>();
130  // It cannot be directly included in the constructor (compiler error for copying std::atomic)
131  spVideoSeek->first = false;
132  spVideoSeek->second = 0;
133 
134  // Required parameters
135  const auto renderOutput = wrapperStructPose.renderMode != RenderMode::None
136  || wrapperStructFace.renderMode != RenderMode::None
137  || wrapperStructHand.renderMode != RenderMode::None;
138  const auto renderOutputGpu = wrapperStructPose.renderMode == RenderMode::Gpu
139  || wrapperStructFace.renderMode == RenderMode::Gpu
140  || wrapperStructHand.renderMode == RenderMode::Gpu;
141  const auto renderFace = wrapperStructFace.enable && wrapperStructFace.renderMode != RenderMode::None;
142  const auto renderHand = wrapperStructHand.enable && wrapperStructHand.renderMode != RenderMode::None;
143  const auto renderHandGpu = wrapperStructHand.enable && wrapperStructHand.renderMode == RenderMode::Gpu;
144 
145  // Check no wrong/contradictory flags enabled
146  const auto userOutputWsEmpty = userOutputWs.empty();
148  wrapperStructPose, wrapperStructFace, wrapperStructHand, wrapperStructExtra, wrapperStructInput,
149  wrapperStructOutput, renderOutput, userOutputWsEmpty, producerSharedPtr, threadManagerMode);
150 
151  // Get number threads
152  auto numberThreads = wrapperStructPose.gpuNumber;
153  auto gpuNumberStart = wrapperStructPose.gpuNumberStart;
154  // CPU --> 1 thread or no pose extraction
155  if (getGpuMode() == GpuMode::NoGpu)
156  {
157  numberThreads = (wrapperStructPose.gpuNumber == 0 ? 0 : 1);
158  gpuNumberStart = 0;
159  // Disabling multi-thread makes the code 400 ms faster (2.3 sec vs. 2.7 in i7-6850K)
160  // and fixes the bug that the screen was not properly displayed and only refreshed sometimes
161  // Note: The screen bug could be also fixed by using waitKey(30) rather than waitKey(1)
162  multiThreadEnabled = false;
163  }
164  // GPU --> user picks (<= #GPUs)
165  else
166  {
167  // Get total number GPUs
168  const auto totalGpuNumber = getGpuNumber();
169  // If number GPU < 0 --> set it to all the available GPUs
170  if (numberThreads < 0)
171  {
172  if (totalGpuNumber <= gpuNumberStart)
173  error("Number of initial GPU (`--number_gpu_start`) must be lower than the total number of"
174  " used GPUs (`--number_gpu`)", __LINE__, __FUNCTION__, __FILE__);
175  numberThreads = totalGpuNumber - gpuNumberStart;
176  // Reset initial GPU to 0 (we want them all)
177  // Logging message
178  log("Auto-detecting all available GPUs... Detected " + std::to_string(totalGpuNumber)
179  + " GPU(s), using " + std::to_string(numberThreads) + " of them starting at GPU "
180  + std::to_string(gpuNumberStart) + ".", Priority::High);
181  }
182  // Sanity check
183  if (gpuNumberStart + numberThreads > totalGpuNumber)
184  error("Initial GPU selected (`--number_gpu_start`) + number GPUs to use (`--number_gpu`) must"
185  " be lower or equal than the total number of GPUs in your machine ("
186  + std::to_string(gpuNumberStart) + " + "
187  + std::to_string(numberThreads) + " vs. "
188  + std::to_string(totalGpuNumber) + ").",
189  __LINE__, __FUNCTION__, __FILE__);
190  }
191 
192  // Proper format
193  const auto writeImagesCleaned = formatAsDirectory(wrapperStructOutput.writeImages);
194  const auto writeKeypointCleaned = formatAsDirectory(wrapperStructOutput.writeKeypoint);
195  const auto writeJsonCleaned = formatAsDirectory(wrapperStructOutput.writeJson);
196  const auto writeHeatMapsCleaned = formatAsDirectory(wrapperStructOutput.writeHeatMaps);
197  const auto modelFolder = formatAsDirectory(wrapperStructPose.modelFolder);
198 
199  // Common parameters
200  auto finalOutputSize = wrapperStructPose.outputSize;
201  Point<int> producerSize{-1,-1};
202  const auto oPProducer = (producerSharedPtr != nullptr);
203  if (oPProducer)
204  {
205  // 1. Set producer properties
206  const auto displayProducerFpsMode = (wrapperStructInput.realTimeProcessing
208  producerSharedPtr->setProducerFpsMode(displayProducerFpsMode);
209  producerSharedPtr->set(ProducerProperty::Flip, wrapperStructInput.frameFlip);
210  producerSharedPtr->set(ProducerProperty::Rotation, wrapperStructInput.frameRotate);
211  producerSharedPtr->set(ProducerProperty::AutoRepeat, wrapperStructInput.framesRepeat);
212  // 2. Set finalOutputSize
213  producerSize = Point<int>{(int)producerSharedPtr->get(CV_CAP_PROP_FRAME_WIDTH),
214  (int)producerSharedPtr->get(CV_CAP_PROP_FRAME_HEIGHT)};
215  // Set finalOutputSize to input size if desired
216  if (finalOutputSize.x == -1 || finalOutputSize.y == -1)
217  finalOutputSize = producerSize;
218  }
219 
220  // Producer
221  if (oPProducer)
222  {
223  const auto datumProducer = std::make_shared<DatumProducer<TDatums>>(
224  producerSharedPtr, wrapperStructInput.frameFirst, wrapperStructInput.frameStep,
225  wrapperStructInput.frameLast, spVideoSeek
226  );
227  datumProducerW = std::make_shared<WDatumProducer<TDatumsSP, TDatums>>(datumProducer);
228  }
229  else
230  datumProducerW = nullptr;
231 
232  std::vector<std::shared_ptr<PoseExtractorNet>> poseExtractorNets;
233  std::vector<std::shared_ptr<FaceExtractorNet>> faceExtractorNets;
234  std::vector<std::shared_ptr<HandExtractorNet>> handExtractorNets;
235  std::vector<std::shared_ptr<PoseGpuRenderer>> poseGpuRenderers;
236  std::shared_ptr<PoseCpuRenderer> poseCpuRenderer;
237  if (numberThreads > 0)
238  {
239  // Get input scales and sizes
240  const auto scaleAndSizeExtractor = std::make_shared<ScaleAndSizeExtractor>(
241  wrapperStructPose.netInputSize, finalOutputSize, wrapperStructPose.scalesNumber,
242  wrapperStructPose.scaleGap
243  );
244  scaleAndSizeExtractorW = std::make_shared<WScaleAndSizeExtractor<TDatumsSP>>(scaleAndSizeExtractor);
245 
246  // Input cvMat to OpenPose input & output format
247  const auto cvMatToOpInput = std::make_shared<CvMatToOpInput>(wrapperStructPose.poseModel);
248  cvMatToOpInputW = std::make_shared<WCvMatToOpInput<TDatumsSP>>(cvMatToOpInput);
249  if (renderOutput)
250  {
251  const auto cvMatToOpOutput = std::make_shared<CvMatToOpOutput>();
252  cvMatToOpOutputW = std::make_shared<WCvMatToOpOutput<TDatumsSP>>(cvMatToOpOutput);
253  }
254 
255  // Pose estimators & renderers
256  std::vector<TWorker> cpuRenderers;
257  poseExtractorsWs.clear();
258  poseExtractorsWs.resize(numberThreads);
259  if (wrapperStructPose.enable)
260  {
261  // Pose estimators
262  for (auto gpuId = 0; gpuId < numberThreads; gpuId++)
263  poseExtractorNets.emplace_back(std::make_shared<PoseExtractorCaffe>(
264  wrapperStructPose.poseModel, modelFolder, gpuId + gpuNumberStart,
265  wrapperStructPose.heatMapTypes, wrapperStructPose.heatMapScale,
266  wrapperStructPose.addPartCandidates, wrapperStructPose.enableGoogleLogging
267  ));
268 
269  // Pose renderers
270  if (renderOutputGpu || wrapperStructPose.renderMode == RenderMode::Cpu)
271  {
272  // If wrapperStructPose.renderMode != RenderMode::Gpu but renderOutput, then we create an
273  // alpha = 0 pose renderer in order to keep the removing background option
274  const auto alphaKeypoint = (wrapperStructPose.renderMode != RenderMode::None
275  ? wrapperStructPose.alphaKeypoint : 0.f);
276  const auto alphaHeatMap = (wrapperStructPose.renderMode != RenderMode::None
277  ? wrapperStructPose.alphaHeatMap : 0.f);
278  // GPU rendering
279  if (renderOutputGpu)
280  {
281  for (const auto& poseExtractorNet : poseExtractorNets)
282  {
283  poseGpuRenderers.emplace_back(std::make_shared<PoseGpuRenderer>(
284  wrapperStructPose.poseModel, poseExtractorNet, wrapperStructPose.renderThreshold,
285  wrapperStructPose.blendOriginalFrame, alphaKeypoint,
286  alphaHeatMap, wrapperStructPose.defaultPartToRender
287  ));
288  }
289  }
290  // CPU rendering
291  if (wrapperStructPose.renderMode == RenderMode::Cpu)
292  {
293  poseCpuRenderer = std::make_shared<PoseCpuRenderer>(
294  wrapperStructPose.poseModel, wrapperStructPose.renderThreshold,
295  wrapperStructPose.blendOriginalFrame, alphaKeypoint, alphaHeatMap,
296  wrapperStructPose.defaultPartToRender);
297  cpuRenderers.emplace_back(std::make_shared<WPoseRenderer<TDatumsSP>>(poseCpuRenderer));
298  }
299  }
300  log("", Priority::Low, __LINE__, __FUNCTION__, __FILE__);
301 
302  // Pose extractor(s)
303  poseExtractorsWs.resize(poseExtractorNets.size());
304  const auto personIdExtractor = (wrapperStructExtra.identification
305  ? std::make_shared<PersonIdExtractor>() : nullptr);
306  // Keep top N people
307  // Added right after PoseExtractorNet to avoid:
308  // 1) Rendering people that are later deleted (wrong visualization).
309  // 2) Processing faces and hands on people that will be deleted (speed up).
310  // 3) Running tracking before deleting the people.
311  // Add KeepTopNPeople for each PoseExtractorNet
312  const auto keepTopNPeople = (wrapperStructPose.numberPeopleMax > 0 ?
313  std::make_shared<KeepTopNPeople>(wrapperStructPose.numberPeopleMax)
314  : nullptr);
315  // Person tracker
316  auto personTrackers = std::make_shared<std::vector<std::shared_ptr<PersonTracker>>>();
317  if (wrapperStructExtra.tracking > -1)
318  personTrackers->emplace_back(
319  std::make_shared<PersonTracker>(wrapperStructExtra.tracking == 0));
320  for (auto i = 0u; i < poseExtractorsWs.size(); i++)
321  {
322  // OpenPose keypoint detector + keepTopNPeople
323  // + ID extractor (experimental) + tracking (experimental)
324  const auto poseExtractor = std::make_shared<PoseExtractor>(
325  poseExtractorNets.at(i), keepTopNPeople, personIdExtractor, personTrackers,
326  wrapperStructPose.numberPeopleMax, wrapperStructExtra.tracking);
327  poseExtractorsWs.at(i) = {std::make_shared<WPoseExtractor<TDatumsSP>>(poseExtractor)};
328  // // Just OpenPose keypoint detector
329  // poseExtractorsWs.at(i) = {std::make_shared<WPoseExtractorNet<TDatumsSP>>(
330  // poseExtractorNets.at(i))};
331  }
332 
333  // // (Before tracking / id extractor)
334  // // Added right after PoseExtractorNet to avoid:
335  // // 1) Rendering people that are later deleted (wrong visualization).
336  // // 2) Processing faces and hands on people that will be deleted (speed up).
337  // if (wrapperStructPose.numberPeopleMax > 0)
338  // {
339  // // Add KeepTopNPeople for each PoseExtractorNet
340  // const auto keepTopNPeople = std::make_shared<KeepTopNPeople>(
341  // wrapperStructPose.numberPeopleMax);
342  // for (auto& wPose : poseExtractorsWs)
343  // wPose.emplace_back(std::make_shared<WKeepTopNPeople<TDatumsSP>>(keepTopNPeople));
344  // }
345  }
346 
347 
348  // Face extractor(s)
349  if (wrapperStructFace.enable)
350  {
351  // Face detector
352  // OpenPose face detector
353  if (wrapperStructPose.enable)
354  {
355  const auto faceDetector = std::make_shared<FaceDetector>(wrapperStructPose.poseModel);
356  for (auto& wPose : poseExtractorsWs)
357  wPose.emplace_back(std::make_shared<WFaceDetector<TDatumsSP>>(faceDetector));
358  }
359  // OpenCV face detector
360  else
361  {
362  log("Body keypoint detection is disabled. Hence, using OpenCV face detector (much less"
363  " accurate but faster).", Priority::High);
364  for (auto& wPose : poseExtractorsWs)
365  {
366  // 1 FaceDetectorOpenCV per thread, OpenCV face detector is not thread-safe
367  const auto faceDetectorOpenCV = std::make_shared<FaceDetectorOpenCV>(modelFolder);
368  wPose.emplace_back(
369  std::make_shared<WFaceDetectorOpenCV<TDatumsSP>>(faceDetectorOpenCV)
370  );
371  }
372  }
373  // Face keypoint extractor
374  for (auto gpu = 0u; gpu < poseExtractorsWs.size(); gpu++)
375  {
376  // Face keypoint extractor
377  const auto netOutputSize = wrapperStructFace.netInputSize;
378  const auto faceExtractorNet = std::make_shared<FaceExtractorCaffe>(
379  wrapperStructFace.netInputSize, netOutputSize, modelFolder,
380  gpu + gpuNumberStart, wrapperStructPose.heatMapTypes, wrapperStructPose.heatMapScale,
381  wrapperStructPose.enableGoogleLogging
382  );
383  faceExtractorNets.emplace_back(faceExtractorNet);
384  poseExtractorsWs.at(gpu).emplace_back(
385  std::make_shared<WFaceExtractorNet<TDatumsSP>>(faceExtractorNet));
386  }
387  }
388 
389  // Hand extractor(s)
390  if (wrapperStructHand.enable)
391  {
392  const auto handDetector = std::make_shared<HandDetector>(wrapperStructPose.poseModel);
393  for (auto gpu = 0u; gpu < poseExtractorsWs.size(); gpu++)
394  {
395  // Hand detector
396  // If tracking
397  if (wrapperStructHand.tracking)
398  poseExtractorsWs.at(gpu).emplace_back(
399  std::make_shared<WHandDetectorTracking<TDatumsSP>>(handDetector)
400  );
401  // If detection
402  else
403  poseExtractorsWs.at(gpu).emplace_back(
404  std::make_shared<WHandDetector<TDatumsSP>>(handDetector));
405  // Hand keypoint extractor
406  const auto netOutputSize = wrapperStructHand.netInputSize;
407  const auto handExtractorNet = std::make_shared<HandExtractorCaffe>(
408  wrapperStructHand.netInputSize, netOutputSize, modelFolder,
409  gpu + gpuNumberStart, wrapperStructHand.scalesNumber, wrapperStructHand.scaleRange,
410  wrapperStructPose.heatMapTypes, wrapperStructPose.heatMapScale,
411  wrapperStructPose.enableGoogleLogging
412  );
413  handExtractorNets.emplace_back(handExtractorNet);
414  poseExtractorsWs.at(gpu).emplace_back(
415  std::make_shared<WHandExtractorNet<TDatumsSP>>(handExtractorNet)
416  );
417  // If tracking
418  if (wrapperStructHand.tracking)
419  poseExtractorsWs.at(gpu).emplace_back(
420  std::make_shared<WHandDetectorUpdate<TDatumsSP>>(handDetector)
421  );
422  }
423  }
424 
425  // Pose renderer(s)
426  if (!poseGpuRenderers.empty())
427  for (auto i = 0u; i < poseExtractorsWs.size(); i++)
428  poseExtractorsWs.at(i).emplace_back(std::make_shared<WPoseRenderer<TDatumsSP>>(
429  poseGpuRenderers.at(i)
430  ));
431 
432  // Face renderer(s)
433  if (renderFace)
434  {
435  // CPU rendering
436  if (wrapperStructFace.renderMode == RenderMode::Cpu)
437  {
438  // Construct face renderer
439  const auto faceRenderer = std::make_shared<FaceCpuRenderer>(wrapperStructFace.renderThreshold,
440  wrapperStructFace.alphaKeypoint,
441  wrapperStructFace.alphaHeatMap);
442  // Add worker
443  cpuRenderers.emplace_back(std::make_shared<WFaceRenderer<TDatumsSP>>(faceRenderer));
444  }
445  // GPU rendering
446  else if (wrapperStructFace.renderMode == RenderMode::Gpu)
447  {
448  for (auto i = 0u; i < poseExtractorsWs.size(); i++)
449  {
450  // Construct face renderer
451  const auto faceRenderer = std::make_shared<FaceGpuRenderer>(
452  wrapperStructFace.renderThreshold, wrapperStructFace.alphaKeypoint,
453  wrapperStructFace.alphaHeatMap
454  );
455  // Performance boost -> share spGpuMemory for all renderers
456  if (!poseGpuRenderers.empty())
457  {
458  const bool isLastRenderer = !renderHandGpu;
459  const auto renderer = std::static_pointer_cast<PoseGpuRenderer>(
460  poseGpuRenderers.at(i)
461  );
462  faceRenderer->setSharedParametersAndIfLast(renderer->getSharedParameters(),
463  isLastRenderer);
464  }
465  // Add worker
466  poseExtractorsWs.at(i).emplace_back(
467  std::make_shared<WFaceRenderer<TDatumsSP>>(faceRenderer));
468  }
469  }
470  else
471  error("Unknown RenderMode.", __LINE__, __FUNCTION__, __FILE__);
472  }
473 
474  // Hand renderer(s)
475  if (renderHand)
476  {
477  // CPU rendering
478  if (wrapperStructHand.renderMode == RenderMode::Cpu)
479  {
480  // Construct hand renderer
481  const auto handRenderer = std::make_shared<HandCpuRenderer>(wrapperStructHand.renderThreshold,
482  wrapperStructHand.alphaKeypoint,
483  wrapperStructHand.alphaHeatMap);
484  // Add worker
485  cpuRenderers.emplace_back(std::make_shared<WHandRenderer<TDatumsSP>>(handRenderer));
486  }
487  // GPU rendering
488  else if (wrapperStructHand.renderMode == RenderMode::Gpu)
489  {
490  for (auto i = 0u; i < poseExtractorsWs.size(); i++)
491  {
492  // Construct hands renderer
493  const auto handRenderer = std::make_shared<HandGpuRenderer>(
494  wrapperStructHand.renderThreshold, wrapperStructHand.alphaKeypoint,
495  wrapperStructHand.alphaHeatMap
496  );
497  // Performance boost -> share spGpuMemory for all renderers
498  if (!poseGpuRenderers.empty())
499  {
500  const bool isLastRenderer = true;
501  const auto renderer = std::static_pointer_cast<PoseGpuRenderer>(
502  poseGpuRenderers.at(i)
503  );
504  handRenderer->setSharedParametersAndIfLast(renderer->getSharedParameters(),
505  isLastRenderer);
506  }
507  // Add worker
508  poseExtractorsWs.at(i).emplace_back(
509  std::make_shared<WHandRenderer<TDatumsSP>>(handRenderer));
510  }
511  }
512  else
513  error("Unknown RenderMode.", __LINE__, __FUNCTION__, __FILE__);
514  }
515 
516  // 3-D reconstruction
517  poseTriangulationsWs.clear();
518  if (wrapperStructExtra.reconstruct3d)
519  {
520  // For all (body/face/hands): PoseTriangulations ~30 msec, 8 GPUS ~30 msec for keypoint estimation
521  poseTriangulationsWs.resize(fastMax(1, int(poseExtractorsWs.size() / 4)));
522  for (auto i = 0u ; i < poseTriangulationsWs.size() ; i++)
523  {
524  const auto poseTriangulation = std::make_shared<PoseTriangulation>(
525  wrapperStructExtra.minViews3d);
526  poseTriangulationsWs.at(i) = {std::make_shared<WPoseTriangulation<TDatumsSP>>(
527  poseTriangulation)};
528  }
529  }
530  // Itermediate workers (e.g. OpenPose format to cv::Mat, json & frames recorder, ...)
531  postProcessingWs.clear();
532  // // Person ID identification (when no multi-thread and no dependency on tracking)
533  // if (wrapperStructExtra.identification)
534  // {
535  // const auto personIdExtractor = std::make_shared<PersonIdExtractor>();
536  // postProcessingWs.emplace_back(
537  // std::make_shared<WPersonIdExtractor<TDatumsSP>>(personIdExtractor)
538  // );
539  // }
540  // Frames processor (OpenPose format -> cv::Mat format)
541  if (renderOutput)
542  {
543  postProcessingWs = mergeVectors(postProcessingWs, cpuRenderers);
544  const auto opOutputToCvMat = std::make_shared<OpOutputToCvMat>();
545  postProcessingWs.emplace_back(std::make_shared<WOpOutputToCvMat<TDatumsSP>>(opOutputToCvMat));
546  }
547  // Re-scale pose if desired
548  // If desired scale is not the current input
549  if (wrapperStructPose.keypointScale != ScaleMode::InputResolution
550  // and desired scale is not output when size(input) = size(output)
551  && !(wrapperStructPose.keypointScale == ScaleMode::OutputResolution &&
552  (finalOutputSize == producerSize || finalOutputSize.x <= 0 || finalOutputSize.y <= 0))
553  // and desired scale is not net output when size(input) = size(net output)
554  && !(wrapperStructPose.keypointScale == ScaleMode::NetOutputResolution
555  && producerSize == wrapperStructPose.netInputSize))
556  {
557  // Then we must rescale the keypoints
558  auto keypointScaler = std::make_shared<KeypointScaler>(wrapperStructPose.keypointScale);
559  postProcessingWs.emplace_back(std::make_shared<WKeypointScaler<TDatumsSP>>(keypointScaler));
560  }
561  }
562 
563  // IK/Adam
564  const auto displayAdam = wrapperStructOutput.displayMode == DisplayMode::DisplayAdam
565  || (wrapperStructOutput.displayMode == DisplayMode::DisplayAll
566  && wrapperStructExtra.ikThreads > 0);
567  jointAngleEstimationsWs.clear();
568 #ifdef USE_3D_ADAM_MODEL
569  if (wrapperStructExtra.ikThreads > 0)
570  {
571  jointAngleEstimationsWs.resize(wrapperStructExtra.ikThreads);
572  // Pose extractor(s)
573  for (auto i = 0u; i < jointAngleEstimationsWs.size(); i++)
574  {
575  const auto jointAngleEstimation = std::make_shared<JointAngleEstimation>(displayAdam);
576  jointAngleEstimationsWs.at(i) = {std::make_shared<WJointAngleEstimation<TDatumsSP>>(
577  jointAngleEstimation)};
578  }
579  }
580 #endif
581 
582  // Output workers
583  outputWs.clear();
584  // Send information (e.g., to Unity) though UDP client-server communication
585 #ifdef USE_3D_ADAM_MODEL
586  if (!wrapperStructOutput.udpHost.empty() && !wrapperStructOutput.udpPort.empty())
587  {
588  const auto udpSender = std::make_shared<UdpSender>(wrapperStructOutput.udpHost,
589  wrapperStructOutput.udpPort);
590  outputWs.emplace_back(std::make_shared<WUdpSender<TDatumsSP>>(udpSender));
591  }
592 #endif
593  // Write people pose data on disk (json for OpenCV >= 3, xml, yml...)
594  if (!writeKeypointCleaned.empty())
595  {
596  const auto keypointSaver = std::make_shared<KeypointSaver>(writeKeypointCleaned,
597  wrapperStructOutput.writeKeypointFormat);
598  outputWs.emplace_back(std::make_shared<WPoseSaver<TDatumsSP>>(keypointSaver));
599  if (wrapperStructFace.enable)
600  outputWs.emplace_back(std::make_shared<WFaceSaver<TDatumsSP>>(keypointSaver));
601  if (wrapperStructHand.enable)
602  outputWs.emplace_back(std::make_shared<WHandSaver<TDatumsSP>>(keypointSaver));
603  }
604  // Write OpenPose output data on disk in json format (body/hand/face keypoints, body part locations if
605  // enabled, etc.)
606  if (!writeJsonCleaned.empty())
607  {
608  const auto peopleJsonSaver = std::make_shared<PeopleJsonSaver>(writeJsonCleaned);
609  outputWs.emplace_back(std::make_shared<WPeopleJsonSaver<TDatumsSP>>(peopleJsonSaver));
610  }
611  // Write people pose data on disk (COCO validation json format)
612  if (!wrapperStructOutput.writeCocoJson.empty())
613  {
614  // If humanFormat: bigger size (& maybe slower to process), but easier for user to read it
615  const auto humanFormat = true;
616  const auto cocoJsonSaver = std::make_shared<CocoJsonSaver>(
617  wrapperStructOutput.writeCocoJson, humanFormat,
618  (wrapperStructPose.poseModel != PoseModel::CAR_22
619  && wrapperStructPose.poseModel != PoseModel::CAR_12
621  outputWs.emplace_back(std::make_shared<WCocoJsonSaver<TDatumsSP>>(cocoJsonSaver));
622  }
623  // Write people foot pose data on disk (COCO validation json format for foot data)
624  if (!wrapperStructOutput.writeCocoFootJson.empty())
625  {
626  // If humanFormat: bigger size (& maybe slower to process), but easier for user to read it
627  const auto humanFormat = true;
628  const auto cocoJsonSaver = std::make_shared<CocoJsonSaver>(wrapperStructOutput.writeCocoFootJson,
629  humanFormat, CocoJsonFormat::Foot);
630  outputWs.emplace_back(std::make_shared<WCocoJsonSaver<TDatumsSP>>(cocoJsonSaver));
631  }
632  // Write frames as desired image format on hard disk
633  if (!writeImagesCleaned.empty())
634  {
635  const auto imageSaver = std::make_shared<ImageSaver>(writeImagesCleaned,
636  wrapperStructOutput.writeImagesFormat);
637  outputWs.emplace_back(std::make_shared<WImageSaver<TDatumsSP>>(imageSaver));
638  }
639  // Write frames as *.avi video on hard disk
640  const auto producerFps = (producerSharedPtr == nullptr ?
641  0. : producerSharedPtr->get(CV_CAP_PROP_FPS));
642  const auto originalVideoFps = (wrapperStructOutput.writeVideoFps > 0 ?
643  wrapperStructOutput.writeVideoFps
644  : producerFps);
645  if (!wrapperStructOutput.writeVideo.empty())
646  {
647  if (!oPProducer)
648  error("Video file can only be recorded inside `wrapper/wrapper.hpp` if the producer"
649  " is one of the default ones (e.g. video, webcam, ...).",
650  __LINE__, __FUNCTION__, __FILE__);
651  if (finalOutputSize.x <= 0 || finalOutputSize.y <= 0)
652  error("Video can only be recorded if outputSize is fixed (e.g. video, webcam, IP camera),"
653  "but not for a image directory.", __LINE__, __FUNCTION__, __FILE__);
654  const auto videoSaver = std::make_shared<VideoSaver>(
655  wrapperStructOutput.writeVideo, CV_FOURCC('M','J','P','G'), originalVideoFps, finalOutputSize
656  );
657  outputWs.emplace_back(std::make_shared<WVideoSaver<TDatumsSP>>(videoSaver));
658  }
659  // Write joint angles as *.bvh file on hard disk
660 #ifdef USE_3D_ADAM_MODEL
661  if (!wrapperStructOutput.writeBvh.empty())
662  {
663  const auto bvhSaver = std::make_shared<BvhSaver>(
664  wrapperStructOutput.writeBvh, JointAngleEstimation::getTotalModel(), originalVideoFps
665  );
666  outputWs.emplace_back(std::make_shared<WBvhSaver<TDatumsSP>>(bvhSaver));
667  }
668 #endif
669  // Write heat maps as desired image format on hard disk
670  if (!writeHeatMapsCleaned.empty())
671  {
672  const auto heatMapSaver = std::make_shared<HeatMapSaver>(writeHeatMapsCleaned,
673  wrapperStructOutput.writeHeatMapsFormat);
674  outputWs.emplace_back(std::make_shared<WHeatMapSaver<TDatumsSP>>(heatMapSaver));
675  }
676  // Add frame information for GUI
677  const bool guiEnabled = (wrapperStructOutput.displayMode != DisplayMode::NoDisplay);
678  // If this WGuiInfoAdder instance is placed before the WImageSaver or WVideoSaver, then the resulting
679  // recorded frames will look exactly as the final displayed image by the GUI
680  if (wrapperStructOutput.guiVerbose && (guiEnabled || !userOutputWs.empty()
681  || threadManagerMode == ThreadManagerMode::Asynchronous
682  || threadManagerMode == ThreadManagerMode::AsynchronousOut))
683  {
684  const auto guiInfoAdder = std::make_shared<GuiInfoAdder>(numberThreads, guiEnabled);
685  outputWs.emplace_back(std::make_shared<WGuiInfoAdder<TDatumsSP>>(guiInfoAdder));
686  }
687  // Minimal graphical user interface (GUI)
688  guiW = nullptr;
689  if (guiEnabled)
690  {
691  // PoseRenderers to Renderers
692  std::vector<std::shared_ptr<Renderer>> renderers;
693  if (wrapperStructPose.renderMode == RenderMode::Cpu)
694  renderers.emplace_back(std::static_pointer_cast<Renderer>(poseCpuRenderer));
695  else
696  for (const auto& poseGpuRenderer : poseGpuRenderers)
697  renderers.emplace_back(std::static_pointer_cast<Renderer>(poseGpuRenderer));
698  // Display
699  // Adam (+3-D/2-D) display
700  if (displayAdam)
701  {
702 #ifdef USE_3D_ADAM_MODEL
703  // Gui
704  const auto gui = std::make_shared<GuiAdam>(
705  finalOutputSize, wrapperStructOutput.fullScreen, threadManager.getIsRunningSharedPtr(),
706  spVideoSeek, poseExtractorNets, faceExtractorNets, handExtractorNets, renderers,
707  wrapperStructOutput.displayMode, JointAngleEstimation::getTotalModel(),
708  wrapperStructOutput.writeVideoAdam
709  );
710  // WGui
711  guiW = {std::make_shared<WGuiAdam<TDatumsSP>>(gui)};
712 #endif
713  }
714  // 3-D (+2-D) display
715  else if (wrapperStructOutput.displayMode == DisplayMode::Display3D
716  || wrapperStructOutput.displayMode == DisplayMode::DisplayAll)
717  {
718  // Gui
719  const auto gui = std::make_shared<Gui3D>(
720  finalOutputSize, wrapperStructOutput.fullScreen, threadManager.getIsRunningSharedPtr(),
721  spVideoSeek, poseExtractorNets, faceExtractorNets, handExtractorNets, renderers,
722  wrapperStructPose.poseModel, wrapperStructOutput.displayMode
723  );
724  // WGui
725  guiW = {std::make_shared<WGui3D<TDatumsSP>>(gui)};
726  }
727  // 2-D display
728  else if (wrapperStructOutput.displayMode == DisplayMode::Display2D)
729  {
730  // Gui
731  const auto gui = std::make_shared<Gui>(
732  finalOutputSize, wrapperStructOutput.fullScreen, threadManager.getIsRunningSharedPtr(),
733  spVideoSeek, poseExtractorNets, faceExtractorNets, handExtractorNets, renderers
734  );
735  // WGui
736  guiW = {std::make_shared<WGui<TDatumsSP>>(gui)};
737  }
738  else
739  error("Unknown DisplayMode.", __LINE__, __FUNCTION__, __FILE__);
740  }
741  // Set wrapper as configured
742  log("", Priority::Low, __LINE__, __FUNCTION__, __FILE__);
743 
744 
745 
746 
747 
748  // The less number of queues -> the less threads opened, and potentially the less lag
749 
750  // Sanity checks
751  if ((datumProducerW == nullptr) == (userInputWs.empty())
752  && threadManagerMode != ThreadManagerMode::Asynchronous
753  && threadManagerMode != ThreadManagerMode::AsynchronousIn)
754  {
755  const auto message = "You need to have 1 and only 1 producer selected. You can introduce your own"
756  " producer by using setWorker(WorkerType::Input, ...) or use the OpenPose"
757  " default producer by configuring it in the configure function) or use the"
758  " ThreadManagerMode::Asynchronous(In) mode.";
759  error(message, __LINE__, __FUNCTION__, __FILE__);
760  }
761  if (outputWs.empty() && userOutputWs.empty() && guiW == nullptr
762  && threadManagerMode != ThreadManagerMode::Asynchronous
763  && threadManagerMode != ThreadManagerMode::AsynchronousOut)
764  {
765  error("No output selected.", __LINE__, __FUNCTION__, __FILE__);
766  }
767 
768  // Thread Manager
769  // Clean previous thread manager (avoid configure to crash the program if used more than once)
770  threadManager.reset();
771  unsigned long long threadId = 0ull;
772  auto queueIn = 0ull;
773  auto queueOut = 1ull;
774  // After producer
775  // ID generator (before any multi-threading or any function that requires the ID)
776  const auto wIdGenerator = std::make_shared<WIdGenerator<TDatumsSP>>();
777  std::vector<TWorker> workersAux{wIdGenerator};
778  // Scale & cv::Mat to OP format
779  if (scaleAndSizeExtractorW != nullptr)
780  workersAux = mergeVectors(workersAux, {scaleAndSizeExtractorW});
781  if (cvMatToOpInputW != nullptr)
782  workersAux = mergeVectors(workersAux, {cvMatToOpInputW});
783  // cv::Mat to output format
784  if (cvMatToOpOutputW != nullptr)
785  workersAux = mergeVectors(workersAux, {cvMatToOpOutputW});
786 
787  // Producer
788  // If custom user Worker and uses its own thread
789  if (!userInputWs.empty() && userInputWsOnNewThread)
790  {
791  // Thread 0, queues 0 -> 1
792  log("", Priority::Low, __LINE__, __FUNCTION__, __FILE__);
793  threadManager.add(threadId, userInputWs, queueIn++, queueOut++);
794  threadIdPP(threadId, multiThreadEnabled);
795  }
796  // If custom user Worker in same thread
797  else if (!userInputWs.empty())
798  workersAux = mergeVectors(userInputWs, workersAux);
799  // If OpenPose producer (same thread)
800  else if (datumProducerW != nullptr)
801  workersAux = mergeVectors({datumProducerW}, workersAux);
802  // Otherwise
803  else if (threadManagerMode != ThreadManagerMode::Asynchronous
804  && threadManagerMode != ThreadManagerMode::AsynchronousIn)
805  error("No input selected.", __LINE__, __FUNCTION__, __FILE__);
806  // Thread 0 or 1, queues 0 -> 1
807  log("", Priority::Low, __LINE__, __FUNCTION__, __FILE__);
808  threadManager.add(threadId, workersAux, queueIn++, queueOut++);
809  // Increase thread
810  threadIdPP(threadId, multiThreadEnabled);
811 
812  // Pose estimation & rendering
813  // Thread 1 or 2...X, queues 1 -> 2, X = 2 + #GPUs
814  if (!poseExtractorsWs.empty())
815  {
816  if (multiThreadEnabled)
817  {
818  for (auto& wPose : poseExtractorsWs)
819  {
820  log("", Priority::Low, __LINE__, __FUNCTION__, __FILE__);
821  threadManager.add(threadId, wPose, queueIn, queueOut);
822  threadIdPP(threadId, multiThreadEnabled);
823  }
824  queueIn++;
825  queueOut++;
826  // Sort frames - Required own thread
827  if (poseExtractorsWs.size() > 1u)
828  {
829  const auto wQueueOrderer = std::make_shared<WQueueOrderer<TDatumsSP>>();
830  log("", Priority::Low, __LINE__, __FUNCTION__, __FILE__);
831  threadManager.add(threadId, wQueueOrderer, queueIn++, queueOut++);
832  threadIdPP(threadId, multiThreadEnabled);
833  }
834  }
835  else
836  {
837  if (poseExtractorsWs.size() > 1)
838  log("Multi-threading disabled, only 1 thread running. All GPUs have been disabled but the"
839  " first one, which is defined by gpuNumberStart (e.g. in the OpenPose demo, it is set"
840  " with the `--num_gpu_start` flag).", Priority::High);
841  log("", Priority::Low, __LINE__, __FUNCTION__, __FILE__);
842  threadManager.add(threadId, poseExtractorsWs.at(0), queueIn++, queueOut++);
843  }
844  }
845  // Assemble all frames from same time instant (3-D module)
846  const auto wQueueAssembler = std::make_shared<WQueueAssembler<TDatumsSP, TDatums>>();
847  // 3-D reconstruction
848  if (!poseTriangulationsWs.empty())
849  {
850  // Assemble frames
851  log("", Priority::Low, __LINE__, __FUNCTION__, __FILE__);
852  threadManager.add(threadId, wQueueAssembler, queueIn++, queueOut++);
853  threadIdPP(threadId, multiThreadEnabled);
854  // 3-D reconstruction
855  if (multiThreadEnabled)
856  {
857  for (auto& wPoseTriangulations : poseTriangulationsWs)
858  {
859  log("", Priority::Low, __LINE__, __FUNCTION__, __FILE__);
860  threadManager.add(threadId, wPoseTriangulations, queueIn, queueOut);
861  threadIdPP(threadId, multiThreadEnabled);
862  }
863  queueIn++;
864  queueOut++;
865  // Sort frames
866  if (poseTriangulationsWs.size() > 1u)
867  {
868  const auto wQueueOrderer = std::make_shared<WQueueOrderer<TDatumsSP>>();
869  log("", Priority::Low, __LINE__, __FUNCTION__, __FILE__);
870  threadManager.add(threadId, wQueueOrderer, queueIn++, queueOut++);
871  threadIdPP(threadId, multiThreadEnabled);
872  }
873  }
874  else
875  {
876  if (poseTriangulationsWs.size() > 1)
877  log("Multi-threading disabled, only 1 thread running for 3-D triangulation.",
879  log("", Priority::Low, __LINE__, __FUNCTION__, __FILE__);
880  threadManager.add(threadId, poseTriangulationsWs.at(0), queueIn++, queueOut++);
881  }
882  }
883  else
884  postProcessingWs = mergeVectors({wQueueAssembler}, postProcessingWs);
885  // Adam/IK step
886  if (!jointAngleEstimationsWs.empty())
887  {
888  if (multiThreadEnabled)
889  {
890  for (auto& wJointAngleEstimator : jointAngleEstimationsWs)
891  {
892  log("", Priority::Low, __LINE__, __FUNCTION__, __FILE__);
893  threadManager.add(threadId, wJointAngleEstimator, queueIn, queueOut);
894  threadIdPP(threadId, multiThreadEnabled);
895  }
896  queueIn++;
897  queueOut++;
898  // Sort frames
899  if (jointAngleEstimationsWs.size() > 1)
900  {
901  const auto wQueueOrderer = std::make_shared<WQueueOrderer<TDatumsSP>>();
902  log("", Priority::Low, __LINE__, __FUNCTION__, __FILE__);
903  threadManager.add(threadId, wQueueOrderer, queueIn++, queueOut++);
904  threadIdPP(threadId, multiThreadEnabled);
905  }
906  }
907  else
908  {
909  if (jointAngleEstimationsWs.size() > 1)
910  log("Multi-threading disabled, only 1 thread running for joint angle estimation.",
912  log("", Priority::Low, __LINE__, __FUNCTION__, __FILE__);
913  threadManager.add(threadId, jointAngleEstimationsWs.at(0), queueIn++, queueOut++);
914  }
915  }
916  // Post processing workers
917  if (!postProcessingWs.empty())
918  {
919  // Combining postProcessingWs and outputWs
920  outputWs = mergeVectors(postProcessingWs, outputWs);
921  // // If I wanna split them
922  // log("", Priority::Low, __LINE__, __FUNCTION__, __FILE__);
923  // threadManager.add(threadId, postProcessingWs, queueIn++, queueOut++);
924  // threadIdPP(threadId, multiThreadEnabled);
925  }
926  // If custom user Worker and uses its own thread
927  if (!userPostProcessingWs.empty())
928  {
929  // If custom user Worker in its own thread
930  if (userPostProcessingWsOnNewThread)
931  {
932  log("", Priority::Low, __LINE__, __FUNCTION__, __FILE__);
933  threadManager.add(threadId, userPostProcessingWs, queueIn++, queueOut++);
934  threadIdPP(threadId, multiThreadEnabled);
935  }
936  // If custom user Worker in same thread
937  // Merge with outputWs
938  else
939  outputWs = mergeVectors(outputWs, userPostProcessingWs);
940  }
941  // Output workers
942  if (!outputWs.empty())
943  {
944  // Thread 4 or 5, queues 4 -> 5
945  log("", Priority::Low, __LINE__, __FUNCTION__, __FILE__);
946  threadManager.add(threadId, outputWs, queueIn++, queueOut++);
947  threadIdPP(threadId, multiThreadEnabled);
948  }
949  // User output worker
950  // Thread Y, queues Q -> Q+1
951  if (!userOutputWs.empty())
952  {
953  if (userOutputWsOnNewThread)
954  {
955  log("", Priority::Low, __LINE__, __FUNCTION__, __FILE__);
956  threadManager.add(threadId, userOutputWs, queueIn++, queueOut++);
957  threadIdPP(threadId, multiThreadEnabled);
958  }
959  else
960  {
961  log("", Priority::Low, __LINE__, __FUNCTION__, __FILE__);
962  threadManager.add(threadId-1, userOutputWs, queueIn++, queueOut++);
963  }
964  }
965  // OpenPose GUI
966  if (guiW != nullptr)
967  {
968  // Thread Y+1, queues Q+1 -> Q+2
969  log("", Priority::Low, __LINE__, __FUNCTION__, __FILE__);
970  threadManager.add(threadId, guiW, queueIn++, queueOut++);
971  threadIdPP(threadId, multiThreadEnabled);
972  }
973  log("", Priority::Low, __LINE__, __FUNCTION__, __FILE__);
974  }
975  catch (const std::exception& e)
976  {
977  error(e.what(), __LINE__, __FUNCTION__, __FILE__);
978  }
979  }
980 }
981 
982 #endif // OPENPOSE_WRAPPER_WRAPPER_AUXILIARY_HPP
OP_API void threadIdPP(unsigned long long &threadId, const bool multiThreadEnabled)
Definition: wHandDetectorTracking.hpp:11
Definition: wGuiInfoAdder.hpp:11
OP_API std::shared_ptr< Producer > createProducer(const ProducerType producerType=ProducerType::None, const std::string &producerString="", const Point< int > &cameraResolution=Point< int >{-1,-1}, const double webcamFps=30., const std::string &cameraParameterPath="models/cameraParameters/", const bool undistortImage=true, const unsigned int imageDirectoryStereo=-1)
std::array< T, N > array
Definition: cl2.hpp:594
float alphaHeatMap
Definition: wrapperStructFace.hpp:46
bool guiVerbose
Definition: wrapperStructOutput.hpp:31
std::string writeHeatMapsFormat
Definition: wrapperStructOutput.hpp:106
Definition: wPoseSaver.hpp:12
std::string cameraParameterPath
Definition: wrapperStructInput.hpp:82
Definition: wrapperStructPose.hpp:17
std::string writeKeypoint
Definition: wrapperStructOutput.hpp:44
float alphaKeypoint
Definition: wrapperStructFace.hpp:39
bool frameFlip
Definition: wrapperStructInput.hpp:56
Definition: wFaceSaver.hpp:12
float alphaKeypoint
Definition: wrapperStructHand.hpp:61
int tracking
Definition: wrapperStructExtra.hpp:39
Definition: wPeopleJsonSaver.hpp:11
Definition: wHandRenderer.hpp:11
double writeVideoFps
Definition: wrapperStructOutput.hpp:111
Definition: wImageSaver.hpp:11
std::string udpPort
Definition: wrapperStructOutput.hpp:135
std::string writeImages
Definition: wrapperStructOutput.hpp:78
std::shared_ptr< std::atomic< bool > > getIsRunningSharedPtr()
Definition: threadManager.hpp:40
T fastMax(const T a, const T b)
Definition: fastMath.hpp:70
float alphaHeatMap
Definition: wrapperStructHand.hpp:68
bool framesRepeat
Definition: wrapperStructInput.hpp:67
Definition: wKeypointScaler.hpp:11
int minViews3d
Definition: wrapperStructExtra.hpp:27
std::string writeHeatMaps
Definition: wrapperStructOutput.hpp:100
std::string writeCocoJson
Definition: wrapperStructOutput.hpp:67
void add(const unsigned long long threadId, const std::vector< TWorker > &tWorkers, const unsigned long long queueInId, const unsigned long long queueOutId)
Definition: threadManager.hpp:125
Definition: wFaceDetector.hpp:11
void reset()
Definition: threadManager.hpp:157
Definition: wrapperStructFace.hpp:15
OP_API void error(const std::string &message, const int line=-1, const std::string &function="", const std::string &file="")
bool fullScreen
Definition: wrapperStructOutput.hpp:37
std::string udpHost
Definition: wrapperStructOutput.hpp:130
DataFormat writeKeypointFormat
Definition: wrapperStructOutput.hpp:51
Definition: wFaceExtractorNet.hpp:11
std::string writeCocoFootJson
Definition: wrapperStructOutput.hpp:72
RenderMode renderMode
Definition: wrapperStructPose.hpp:81
OP_API void wrapperConfigureSanityChecks(WrapperStructPose &wrapperStructPose, const WrapperStructFace &wrapperStructFace, const WrapperStructHand &wrapperStructHand, const WrapperStructExtra &wrapperStructExtra, const WrapperStructInput &wrapperStructInput, const WrapperStructOutput &wrapperStructOutput, const bool renderOutput, const bool userOutputWsEmpty, const std::shared_ptr< Producer > &producerSharedPtr, const ThreadManagerMode threadManagerMode)
float scaleRange
Definition: wrapperStructHand.hpp:41
OP_API GpuMode getGpuMode()
RenderMode renderMode
Definition: wrapperStructFace.hpp:33
bool tracking
Definition: wrapperStructHand.hpp:49
bool enable
Definition: wrapperStructFace.hpp:20
Definition: wFaceDetectorOpenCV.hpp:11
Definition: wVideoSaver.hpp:11
Definition: wUdpSender.hpp:11
Definition: wOpOutputToCvMat.hpp:11
int ikThreads
Definition: wrapperStructExtra.hpp:46
bool realTimeProcessing
Definition: wrapperStructInput.hpp:51
OP_API std::string formatAsDirectory(const std::string &directoryPathString)
Definition: wHandDetectorUpdate.hpp:11
Definition: wrapperStructInput.hpp:14
unsigned long long frameStep
Definition: wrapperStructInput.hpp:40
Definition: wHandExtractorNet.hpp:11
std::string writeBvh
Definition: wrapperStructOutput.hpp:125
Definition: wFaceRenderer.hpp:11
bool undistortImage
Definition: wrapperStructInput.hpp:87
Definition: wPoseRenderer.hpp:11
std::string writeJson
Definition: wrapperStructOutput.hpp:61
OP_API void log(const std::string &message, const Priority priority=Priority::Max, const int line=-1, const std::string &function="", const std::string &file="")
Definition: wCocoJsonSaver.hpp:11
Definition: wrapperStructExtra.hpp:13
Definition: wrapperStructHand.hpp:15
float renderThreshold
Definition: wrapperStructHand.hpp:76
Definition: poseGpuRenderer.hpp:13
Definition: wHandDetector.hpp:11
std::string writeVideoAdam
Definition: wrapperStructOutput.hpp:118
std::vector< T > mergeVectors(const std::vector< T > &vectorA, const std::vector< T > &vectorB)
Definition: standard.hpp:40
Point< int > cameraResolution
Definition: wrapperStructInput.hpp:72
Definition: wHandSaver.hpp:12
ProducerType producerType
Definition: wrapperStructInput.hpp:20
std::string writeVideo
Definition: wrapperStructOutput.hpp:93
unsigned long long frameLast
Definition: wrapperStructInput.hpp:46
bool identification
Definition: wrapperStructExtra.hpp:32
DisplayMode displayMode
Definition: wrapperStructOutput.hpp:25
Point< int > netInputSize
Definition: wrapperStructFace.hpp:27
void setSharedParametersAndIfLast(const std::tuple< std::shared_ptr< float * >, std::shared_ptr< bool >, std::shared_ptr< std::atomic< unsigned int >>, std::shared_ptr< std::atomic< unsigned long long >>, std::shared_ptr< const unsigned int >> &tuple, const bool isLast)
Definition: wHeatMapSaver.hpp:11
std::string producerString
Definition: wrapperStructInput.hpp:27
bool enable
Definition: wrapperStructHand.hpp:20
ThreadManagerMode
Definition: enumClasses.hpp:9
OP_API void configureThreadManager(ThreadManager< TDatumsSP > &threadManager, const bool multiThreadEnabled, const ThreadManagerMode threadManagerMode, const WrapperStructPose &wrapperStructPose, const WrapperStructFace &wrapperStructFace, const WrapperStructHand &wrapperStructHand, const WrapperStructExtra &wrapperStructExtra, const WrapperStructInput &wrapperStructInput, const WrapperStructOutput &wrapperStructOutput, const std::array< std::vector< TWorker >, int(WorkerType::Size)> &userWs, const std::array< bool, int(WorkerType::Size)> &userWsOnNewThread)
Definition: wrapperAuxiliary.hpp:84
unsigned int imageDirectoryStereo
Definition: wrapperStructInput.hpp:92
#define OP_API
Definition: macros.hpp:18
float renderThreshold
Definition: wrapperStructFace.hpp:54
int frameRotate
Definition: wrapperStructInput.hpp:62
std::string writeImagesFormat
Definition: wrapperStructOutput.hpp:86
unsigned long long frameFirst
Definition: wrapperStructInput.hpp:33
Definition: wrapperStructOutput.hpp:14
bool reconstruct3d
Definition: wrapperStructExtra.hpp:21
OP_API int getGpuNumber()
Point< int > netInputSize
Definition: wrapperStructHand.hpp:27
int scalesNumber
Definition: wrapperStructHand.hpp:35
double webcamFps
Definition: wrapperStructInput.hpp:77
RenderMode renderMode
Definition: wrapperStructHand.hpp:55