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