mirror of
https://github.com/gosticks/openpose.git
synced 2026-10-18 12:50:25 +00:00
WrapperT.configure() modified
This commit is contained in:
@@ -108,7 +108,7 @@ private:
|
||||
unsigned long long mCounter;
|
||||
};
|
||||
|
||||
int openPoseDemo()
|
||||
int tutorialApiCpp7()
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -157,11 +157,9 @@ int openPoseDemo()
|
||||
const auto multipleView = false;
|
||||
// Enabling Google Logging
|
||||
const bool enableGoogleLogging = true;
|
||||
// Logging
|
||||
op::log("", op::Priority::Low, __LINE__, __FUNCTION__, __FILE__);
|
||||
|
||||
// OpenPose wrapper
|
||||
op::log("Configuring OpenPose wrapper...", op::Priority::Low, __LINE__, __FUNCTION__, __FILE__);
|
||||
op::log("Configuring OpenPose...", op::Priority::High);
|
||||
op::WrapperT<std::vector<UserDatum>> opWrapperT;
|
||||
|
||||
// Initializing the user custom classes
|
||||
@@ -178,23 +176,22 @@ int openPoseDemo()
|
||||
poseModel, !FLAGS_disable_blending, (float)FLAGS_alpha_pose, (float)FLAGS_alpha_heatmap,
|
||||
FLAGS_part_to_show, FLAGS_model_folder, heatMapTypes, heatMapScale, FLAGS_part_candidates,
|
||||
(float)FLAGS_render_threshold, FLAGS_number_people_max, enableGoogleLogging};
|
||||
opWrapperT.configure(wrapperStructPose);
|
||||
// Face configuration (use op::WrapperStructFace{} to disable it)
|
||||
const op::WrapperStructFace wrapperStructFace{
|
||||
FLAGS_face, faceNetInputSize, op::flagsToRenderMode(FLAGS_face_render, multipleView, FLAGS_render_pose),
|
||||
(float)FLAGS_face_alpha_pose, (float)FLAGS_face_alpha_heatmap, (float)FLAGS_face_render_threshold};
|
||||
opWrapperT.configure(wrapperStructFace);
|
||||
// Hand configuration (use op::WrapperStructHand{} to disable it)
|
||||
const op::WrapperStructHand wrapperStructHand{
|
||||
FLAGS_hand, handNetInputSize, FLAGS_hand_scale_number, (float)FLAGS_hand_scale_range, FLAGS_hand_tracking,
|
||||
op::flagsToRenderMode(FLAGS_hand_render, multipleView, FLAGS_render_pose), (float)FLAGS_hand_alpha_pose,
|
||||
(float)FLAGS_hand_alpha_heatmap, (float)FLAGS_hand_render_threshold};
|
||||
opWrapperT.configure(wrapperStructHand);
|
||||
// Extra functionality configuration (use op::WrapperStructExtra{} to disable it)
|
||||
const op::WrapperStructExtra wrapperStructExtra{
|
||||
FLAGS_3d, FLAGS_3d_min_views, FLAGS_identification, FLAGS_tracking, FLAGS_ik_threads};
|
||||
// Producer (use default to disable any input)
|
||||
// const op::WrapperStructInput wrapperStructInput{producerSharedPtr, FLAGS_frame_first, FLAGS_frame_last,
|
||||
// FLAGS_process_real_time, FLAGS_frame_flip, FLAGS_frame_rotate,
|
||||
// FLAGS_frames_repeat};
|
||||
const op::WrapperStructInput wrapperStructInput;
|
||||
opWrapperT.configure(wrapperStructExtra);
|
||||
// Consumer (comment or use default argument to disable any output)
|
||||
const op::WrapperStructOutput wrapperStructOutput{
|
||||
op::flagsToDisplayMode(FLAGS_display, FLAGS_3d), !FLAGS_no_gui_verbose, FLAGS_fullscreen,
|
||||
@@ -202,41 +199,15 @@ int openPoseDemo()
|
||||
FLAGS_write_coco_json, FLAGS_write_coco_foot_json, FLAGS_write_images, FLAGS_write_images_format,
|
||||
FLAGS_write_video, FLAGS_camera_fps, FLAGS_write_heatmaps, FLAGS_write_heatmaps_format,
|
||||
FLAGS_write_video_adam, FLAGS_write_bvh, FLAGS_udp_host, FLAGS_udp_port};
|
||||
// Configure wrapper
|
||||
|
||||
opWrapperT.configure(wrapperStructPose, wrapperStructFace, wrapperStructHand, wrapperStructExtra,
|
||||
wrapperStructInput, wrapperStructOutput);
|
||||
opWrapperT.configure(wrapperStructOutput);
|
||||
// Set to single-thread (for sequential processing and/or debugging and/or reducing latency)
|
||||
if (FLAGS_disable_multi_thread)
|
||||
opWrapperT.disableMultiThreading();
|
||||
|
||||
// Start processing
|
||||
// Two different ways of running the program on multithread environment
|
||||
// Start, run, and stop processing - exec() blocks this thread until OpenPose wrapper has finished
|
||||
op::log("Starting thread(s)...", op::Priority::High);
|
||||
// Start, run & stop threads - it blocks this thread until all others have finished
|
||||
opWrapperT.exec();
|
||||
|
||||
// // Option b) Keeping this thread free in case you want to do something else meanwhile, e.g. profiling the GPU
|
||||
// memory
|
||||
// // VERY IMPORTANT NOTE: if OpenCV is compiled with Qt support, this option will not work. Qt needs the main
|
||||
// // thread to plot visual results, so the final GUI (which uses OpenCV) would return an exception similar to:
|
||||
// // `QMetaMethod::invoke: Unable to invoke methods with return values in queued connections`
|
||||
// // Start threads
|
||||
// opWrapperT.start();
|
||||
// // Profile used GPU memory
|
||||
// // 1: wait ~10sec so the memory has been totally loaded on GPU
|
||||
// // 2: profile the GPU memory
|
||||
// const auto sleepTimeMs = 10;
|
||||
// for (auto i = 0 ; i < 10000/sleepTimeMs && opWrapperT.isRunning() ; i++)
|
||||
// std::this_thread::sleep_for(std::chrono::milliseconds{sleepTimeMs});
|
||||
// op::Profiler::profileGpuMemory(__LINE__, __FUNCTION__, __FILE__);
|
||||
// // Keep program alive while running threads
|
||||
// while (opWrapperT.isRunning())
|
||||
// std::this_thread::sleep_for(std::chrono::milliseconds{sleepTimeMs});
|
||||
// // Stop and join threads
|
||||
// op::log("Stopping thread(s)", op::Priority::High);
|
||||
// opWrapperT.stop();
|
||||
|
||||
// Measuring total time
|
||||
const auto now = std::chrono::high_resolution_clock::now();
|
||||
const auto totalTimeSec = (double)std::chrono::duration_cast<std::chrono::nanoseconds>(now-timerBegin).count()
|
||||
@@ -260,6 +231,6 @@ int main(int argc, char *argv[])
|
||||
// Parsing command line flags
|
||||
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
||||
|
||||
// Running openPoseDemo
|
||||
return openPoseDemo();
|
||||
// Running tutorialApiCpp7
|
||||
return tutorialApiCpp7();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user