mirror of
https://github.com/gosticks/openpose.git
synced 2026-08-12 20:30:20 +00:00
WrapperT.configure() modified
This commit is contained in:
@@ -63,7 +63,7 @@ void printKeypoints(const std::shared_ptr<std::vector<op::Datum>>& datumsPtr)
|
||||
op::log("Nullptr or empty datumsPtr found.", op::Priority::High);
|
||||
}
|
||||
|
||||
int bodyFromImage()
|
||||
int tutorialApiCpp1()
|
||||
{
|
||||
op::log("Starting OpenPose demo...", op::Priority::High);
|
||||
|
||||
@@ -98,6 +98,6 @@ int main(int argc, char *argv[])
|
||||
// Parsing command line flags
|
||||
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
||||
|
||||
// Running bodyFromImage
|
||||
return bodyFromImage();
|
||||
// Running tutorialApiCpp1
|
||||
return tutorialApiCpp1();
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ void printKeypoints(const std::shared_ptr<std::vector<op::Datum>>& datumsPtr)
|
||||
op::log("Nullptr or empty datumsPtr found.", op::Priority::High);
|
||||
}
|
||||
|
||||
int wholeBodyFromImage()
|
||||
int tutorialApiCpp2()
|
||||
{
|
||||
op::log("Starting OpenPose demo...", op::Priority::High);
|
||||
|
||||
@@ -80,6 +80,6 @@ int main(int argc, char *argv[])
|
||||
// Parsing command line flags
|
||||
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
||||
|
||||
// Running wholeBodyFromImage
|
||||
return wholeBodyFromImage();
|
||||
// Running tutorialApiCpp2
|
||||
return tutorialApiCpp2();
|
||||
}
|
||||
|
||||
@@ -44,100 +44,108 @@ void printKeypoints(const std::shared_ptr<std::vector<op::Datum>>& datumsPtr)
|
||||
op::log("Nullptr or empty datumsPtr found.", op::Priority::High);
|
||||
}
|
||||
|
||||
int wholeBodyFromImage()
|
||||
int tutorialApiCpp3()
|
||||
{
|
||||
op::log("Starting OpenPose demo...", op::Priority::High);
|
||||
|
||||
// logging_level
|
||||
op::check(0 <= FLAGS_logging_level && FLAGS_logging_level <= 255, "Wrong logging_level value.",
|
||||
__LINE__, __FUNCTION__, __FILE__);
|
||||
op::ConfigureLog::setPriorityThreshold((op::Priority)FLAGS_logging_level);
|
||||
op::Profiler::setDefaultX(FLAGS_profile_speed);
|
||||
|
||||
// Applying user defined configuration - GFlags to program variables
|
||||
// outputSize
|
||||
const auto outputSize = op::flagsToPoint(FLAGS_output_resolution, "-1x-1");
|
||||
// netInputSize
|
||||
const auto netInputSize = op::flagsToPoint(FLAGS_net_resolution, "-1x368");
|
||||
// faceNetInputSize
|
||||
const auto faceNetInputSize = op::flagsToPoint(FLAGS_face_net_resolution, "368x368 (multiples of 16)");
|
||||
// handNetInputSize
|
||||
const auto handNetInputSize = op::flagsToPoint(FLAGS_hand_net_resolution, "368x368 (multiples of 16)");
|
||||
// poseModel
|
||||
const auto poseModel = op::flagsToPoseModel(FLAGS_model_pose);
|
||||
// JSON saving
|
||||
if (!FLAGS_write_keypoint.empty())
|
||||
op::log("Flag `write_keypoint` is deprecated and will eventually be removed."
|
||||
" Please, use `write_json` instead.", op::Priority::Max);
|
||||
// keypointScale
|
||||
const auto keypointScale = op::flagsToScaleMode(FLAGS_keypoint_scale);
|
||||
// heatmaps to add
|
||||
const auto heatMapTypes = op::flagsToHeatMaps(FLAGS_heatmaps_add_parts, FLAGS_heatmaps_add_bkg,
|
||||
FLAGS_heatmaps_add_PAFs);
|
||||
const auto heatMapScale = op::flagsToHeatMapScaleMode(FLAGS_heatmaps_scale);
|
||||
// >1 camera view?
|
||||
const auto multipleView = (FLAGS_3d || FLAGS_3d_views > 1);
|
||||
// Enabling Google Logging
|
||||
const bool enableGoogleLogging = true;
|
||||
// Logging
|
||||
op::log("", op::Priority::Low, __LINE__, __FUNCTION__, __FILE__);
|
||||
|
||||
// Configuring OpenPose
|
||||
op::log("Configuring OpenPose...", op::Priority::High);
|
||||
op::Wrapper opWrapper{op::ThreadManagerMode::Asynchronous};
|
||||
// Pose configuration (use WrapperStructPose{} for default and recommended configuration)
|
||||
const op::WrapperStructPose wrapperStructPose{
|
||||
!FLAGS_body_disable, netInputSize, outputSize, keypointScale, FLAGS_num_gpu, FLAGS_num_gpu_start,
|
||||
FLAGS_scale_number, (float)FLAGS_scale_gap, op::flagsToRenderMode(FLAGS_render_pose, multipleView),
|
||||
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};
|
||||
// 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};
|
||||
// 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};
|
||||
// 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};
|
||||
// Consumer (comment or use default argument to disable any output)
|
||||
const auto displayMode = op::DisplayMode::NoDisplay;
|
||||
const bool guiVerbose = false;
|
||||
const bool fullScreen = false;
|
||||
const op::WrapperStructOutput wrapperStructOutput{
|
||||
displayMode, guiVerbose, fullScreen, FLAGS_write_keypoint,
|
||||
op::stringToDataFormat(FLAGS_write_keypoint_format), FLAGS_write_json, 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
|
||||
opWrapper.configure(wrapperStructPose, wrapperStructFace, wrapperStructHand, wrapperStructExtra,
|
||||
op::WrapperStructInput{}, wrapperStructOutput);
|
||||
// Set to single-thread (for sequential processing and/or debugging and/or reducing latency)
|
||||
if (FLAGS_disable_multi_thread)
|
||||
opWrapper.disableMultiThreading();
|
||||
// Starting OpenPose
|
||||
op::log("Starting thread(s)...", op::Priority::High);
|
||||
opWrapper.start();
|
||||
|
||||
// Process and display image
|
||||
const auto imageToProcess = cv::imread(FLAGS_image_path);
|
||||
auto datumProcessed = opWrapper.emplaceAndPop(imageToProcess);
|
||||
if (datumProcessed != nullptr)
|
||||
try
|
||||
{
|
||||
printKeypoints(datumProcessed);
|
||||
display(datumProcessed);
|
||||
}
|
||||
else
|
||||
op::log("Image could not be processed.", op::Priority::High);
|
||||
op::log("Starting OpenPose demo...", op::Priority::High);
|
||||
|
||||
// Return successful message
|
||||
op::log("Stopping OpenPose...", op::Priority::High);
|
||||
return 0;
|
||||
// logging_level
|
||||
op::check(0 <= FLAGS_logging_level && FLAGS_logging_level <= 255, "Wrong logging_level value.",
|
||||
__LINE__, __FUNCTION__, __FILE__);
|
||||
op::ConfigureLog::setPriorityThreshold((op::Priority)FLAGS_logging_level);
|
||||
op::Profiler::setDefaultX(FLAGS_profile_speed);
|
||||
|
||||
// Applying user defined configuration - GFlags to program variables
|
||||
// outputSize
|
||||
const auto outputSize = op::flagsToPoint(FLAGS_output_resolution, "-1x-1");
|
||||
// netInputSize
|
||||
const auto netInputSize = op::flagsToPoint(FLAGS_net_resolution, "-1x368");
|
||||
// faceNetInputSize
|
||||
const auto faceNetInputSize = op::flagsToPoint(FLAGS_face_net_resolution, "368x368 (multiples of 16)");
|
||||
// handNetInputSize
|
||||
const auto handNetInputSize = op::flagsToPoint(FLAGS_hand_net_resolution, "368x368 (multiples of 16)");
|
||||
// poseModel
|
||||
const auto poseModel = op::flagsToPoseModel(FLAGS_model_pose);
|
||||
// JSON saving
|
||||
if (!FLAGS_write_keypoint.empty())
|
||||
op::log("Flag `write_keypoint` is deprecated and will eventually be removed."
|
||||
" Please, use `write_json` instead.", op::Priority::Max);
|
||||
// keypointScale
|
||||
const auto keypointScale = op::flagsToScaleMode(FLAGS_keypoint_scale);
|
||||
// heatmaps to add
|
||||
const auto heatMapTypes = op::flagsToHeatMaps(FLAGS_heatmaps_add_parts, FLAGS_heatmaps_add_bkg,
|
||||
FLAGS_heatmaps_add_PAFs);
|
||||
const auto heatMapScale = op::flagsToHeatMapScaleMode(FLAGS_heatmaps_scale);
|
||||
// >1 camera view?
|
||||
const auto multipleView = (FLAGS_3d || FLAGS_3d_views > 1);
|
||||
// Enabling Google Logging
|
||||
const bool enableGoogleLogging = true;
|
||||
|
||||
// Configuring OpenPose
|
||||
op::log("Configuring OpenPose...", op::Priority::High);
|
||||
op::Wrapper opWrapper{op::ThreadManagerMode::Asynchronous};
|
||||
// Pose configuration (use WrapperStructPose{} for default and recommended configuration)
|
||||
const op::WrapperStructPose wrapperStructPose{
|
||||
!FLAGS_body_disable, netInputSize, outputSize, keypointScale, FLAGS_num_gpu, FLAGS_num_gpu_start,
|
||||
FLAGS_scale_number, (float)FLAGS_scale_gap, op::flagsToRenderMode(FLAGS_render_pose, multipleView),
|
||||
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};
|
||||
opWrapper.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};
|
||||
opWrapper.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};
|
||||
opWrapper.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};
|
||||
opWrapper.configure(wrapperStructExtra);
|
||||
// Consumer (comment or use default argument to disable any output)
|
||||
const auto displayMode = op::DisplayMode::NoDisplay;
|
||||
const bool guiVerbose = false;
|
||||
const bool fullScreen = false;
|
||||
const op::WrapperStructOutput wrapperStructOutput{
|
||||
displayMode, guiVerbose, fullScreen, FLAGS_write_keypoint,
|
||||
op::stringToDataFormat(FLAGS_write_keypoint_format), FLAGS_write_json, 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};
|
||||
opWrapper.configure(wrapperStructOutput);
|
||||
// Set to single-thread (for sequential processing and/or debugging and/or reducing latency)
|
||||
if (FLAGS_disable_multi_thread)
|
||||
opWrapper.disableMultiThreading();
|
||||
// Starting OpenPose
|
||||
op::log("Starting thread(s)...", op::Priority::High);
|
||||
opWrapper.start();
|
||||
|
||||
// Process and display image
|
||||
const auto imageToProcess = cv::imread(FLAGS_image_path);
|
||||
auto datumProcessed = opWrapper.emplaceAndPop(imageToProcess);
|
||||
if (datumProcessed != nullptr)
|
||||
{
|
||||
printKeypoints(datumProcessed);
|
||||
display(datumProcessed);
|
||||
}
|
||||
else
|
||||
op::log("Image could not be processed.", op::Priority::High);
|
||||
|
||||
// Return successful message
|
||||
op::log("Stopping OpenPose...", op::Priority::High);
|
||||
return 0;
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
op::error(e.what(), __LINE__, __FUNCTION__, __FILE__);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
@@ -145,6 +153,6 @@ int main(int argc, char *argv[])
|
||||
// Parsing command line flags
|
||||
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
||||
|
||||
// Running wholeBodyFromImage
|
||||
return wholeBodyFromImage();
|
||||
// Running tutorialApiCpp3
|
||||
return tutorialApiCpp3();
|
||||
}
|
||||
|
||||
@@ -176,7 +176,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
int example4()
|
||||
int tutorialApiCpp4()
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -214,11 +214,9 @@ int example4()
|
||||
const auto multipleView = (FLAGS_3d || FLAGS_3d_views > 1);
|
||||
// Enabling Google Logging
|
||||
const bool enableGoogleLogging = true;
|
||||
// Logging
|
||||
op::log("", op::Priority::Low, __LINE__, __FUNCTION__, __FILE__);
|
||||
|
||||
// Configure OpenPose
|
||||
op::log("Configuring OpenPose wrapper...", op::Priority::Low, __LINE__, __FUNCTION__, __FILE__);
|
||||
// Configuring OpenPose
|
||||
op::log("Configuring OpenPose...", op::Priority::High);
|
||||
op::WrapperT<std::vector<UserDatum>> opWrapperT{op::ThreadManagerMode::Asynchronous};
|
||||
// Pose configuration (use WrapperStructPose{} for default and recommended configuration)
|
||||
const op::WrapperStructPose wrapperStructPose{
|
||||
@@ -227,18 +225,22 @@ int example4()
|
||||
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};
|
||||
opWrapperT.configure(wrapperStructExtra);
|
||||
// Consumer (comment or use default argument to disable any output)
|
||||
const auto displayMode = op::DisplayMode::NoDisplay;
|
||||
const bool guiVerbose = false;
|
||||
@@ -249,13 +251,12 @@ int example4()
|
||||
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,
|
||||
op::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();
|
||||
opWrapperT.disableMultiThreading();
|
||||
|
||||
// Start, run, and stop processing - exec() blocks this thread until OpenPose wrapper has finished
|
||||
op::log("Starting thread(s)...", op::Priority::High);
|
||||
opWrapperT.start();
|
||||
|
||||
@@ -309,6 +310,6 @@ int main(int argc, char *argv[])
|
||||
// Parsing command line flags
|
||||
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
||||
|
||||
// Running example4
|
||||
return example4();
|
||||
// Running tutorialApiCpp4
|
||||
return tutorialApiCpp4();
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
int openPoseTutorialWrapper1()
|
||||
int tutorialApiCpp5()
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -135,10 +135,10 @@ int openPoseTutorialWrapper1()
|
||||
// handNetInputSize
|
||||
const auto handNetInputSize = op::flagsToPoint(FLAGS_hand_net_resolution, "368x368 (multiples of 16)");
|
||||
// producerType
|
||||
const auto producerSharedPtr = op::flagsToProducer(FLAGS_image_dir, FLAGS_video, FLAGS_ip_camera, FLAGS_camera,
|
||||
FLAGS_flir_camera, FLAGS_camera_resolution, FLAGS_camera_fps,
|
||||
FLAGS_camera_parameter_folder, !FLAGS_frame_keep_distortion,
|
||||
(unsigned int) FLAGS_3d_views, FLAGS_flir_camera_index);
|
||||
const auto producerSharedPtr = op::flagsToProducer(
|
||||
FLAGS_image_dir, FLAGS_video, FLAGS_ip_camera, FLAGS_camera, FLAGS_flir_camera, FLAGS_camera_resolution,
|
||||
FLAGS_camera_fps, FLAGS_camera_parameter_folder, !FLAGS_frame_keep_distortion,
|
||||
(unsigned int) FLAGS_3d_views, FLAGS_flir_camera_index);
|
||||
// poseModel
|
||||
const auto poseModel = op::flagsToPoseModel(FLAGS_model_pose);
|
||||
// JSON saving
|
||||
@@ -155,11 +155,9 @@ int openPoseTutorialWrapper1()
|
||||
const auto multipleView = (FLAGS_3d || FLAGS_3d_views > 1 || FLAGS_flir_camera);
|
||||
// Enabling Google Logging
|
||||
const bool enableGoogleLogging = true;
|
||||
// Logging
|
||||
op::log("", op::Priority::Low, __LINE__, __FUNCTION__, __FILE__);
|
||||
|
||||
// Configure OpenPose
|
||||
op::log("Configuring OpenPose wrapper...", op::Priority::Low, __LINE__, __FUNCTION__, __FILE__);
|
||||
// Configuring OpenPose
|
||||
op::log("Configuring OpenPose...", op::Priority::High);
|
||||
op::WrapperT<std::vector<UserDatum>> opWrapperT{op::ThreadManagerMode::AsynchronousOut};
|
||||
// Pose configuration (use WrapperStructPose{} for default and recommended configuration)
|
||||
const op::WrapperStructPose wrapperStructPose{
|
||||
@@ -168,22 +166,27 @@ int openPoseTutorialWrapper1()
|
||||
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};
|
||||
opWrapperT.configure(wrapperStructExtra);
|
||||
// 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};
|
||||
opWrapperT.configure(wrapperStructInput);
|
||||
// Consumer (comment or use default argument to disable any output)
|
||||
const auto displayMode = op::DisplayMode::NoDisplay;
|
||||
const bool guiVerbose = false;
|
||||
@@ -194,13 +197,12 @@ int openPoseTutorialWrapper1()
|
||||
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();
|
||||
opWrapperT.disableMultiThreading();
|
||||
|
||||
// Start, run, and stop processing - exec() blocks this thread until OpenPose wrapper has finished
|
||||
op::log("Starting thread(s)...", op::Priority::High);
|
||||
opWrapperT.start();
|
||||
|
||||
@@ -246,6 +248,6 @@ int main(int argc, char *argv[])
|
||||
// Parsing command line flags
|
||||
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
||||
|
||||
// Running openPoseTutorialWrapper1
|
||||
return openPoseTutorialWrapper1();
|
||||
// Running tutorialApiCpp5
|
||||
return tutorialApiCpp5();
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
int openPoseDemo()
|
||||
int tutorialApiCpp6()
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -95,10 +95,10 @@ int openPoseDemo()
|
||||
// handNetInputSize
|
||||
const auto handNetInputSize = op::flagsToPoint(FLAGS_hand_net_resolution, "368x368 (multiples of 16)");
|
||||
// producerType
|
||||
const auto producerSharedPtr = op::flagsToProducer(FLAGS_image_dir, FLAGS_video, FLAGS_ip_camera, FLAGS_camera,
|
||||
FLAGS_flir_camera, FLAGS_camera_resolution, FLAGS_camera_fps,
|
||||
FLAGS_camera_parameter_folder, !FLAGS_frame_keep_distortion,
|
||||
(unsigned int) FLAGS_3d_views, FLAGS_flir_camera_index);
|
||||
const auto producerSharedPtr = op::flagsToProducer(
|
||||
FLAGS_image_dir, FLAGS_video, FLAGS_ip_camera, FLAGS_camera, FLAGS_flir_camera, FLAGS_camera_resolution,
|
||||
FLAGS_camera_fps, FLAGS_camera_parameter_folder, !FLAGS_frame_keep_distortion,
|
||||
(unsigned int) FLAGS_3d_views, FLAGS_flir_camera_index);
|
||||
// poseModel
|
||||
const auto poseModel = op::flagsToPoseModel(FLAGS_model_pose);
|
||||
// JSON saving
|
||||
@@ -115,19 +115,17 @@ int openPoseDemo()
|
||||
const auto multipleView = (FLAGS_3d || FLAGS_3d_views > 1 || FLAGS_flir_camera);
|
||||
// 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::WrapperT<std::vector<UserDatum>> opWrapper;
|
||||
op::log("Configuring OpenPose...", op::Priority::High);
|
||||
op::WrapperT<std::vector<UserDatum>> opWrapperT;
|
||||
|
||||
// Initializing the user custom classes
|
||||
// Processing
|
||||
auto wUserPostProcessing = std::make_shared<WUserPostProcessing>();
|
||||
// Add custom processing
|
||||
const auto workerProcessingOnNewThread = true;
|
||||
opWrapper.setWorker(op::WorkerType::PostProcessing, wUserPostProcessing, workerProcessingOnNewThread);
|
||||
opWrapperT.setWorker(op::WorkerType::PostProcessing, wUserPostProcessing, workerProcessingOnNewThread);
|
||||
|
||||
// Pose configuration (use WrapperStructPose{} for default and recommended configuration)
|
||||
const op::WrapperStructPose wrapperStructPose{
|
||||
@@ -136,22 +134,27 @@ 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};
|
||||
opWrapperT.configure(wrapperStructExtra);
|
||||
// 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};
|
||||
// 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};
|
||||
opWrapperT.configure(wrapperStructInput);
|
||||
// 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,
|
||||
@@ -159,39 +162,14 @@ 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
|
||||
opWrapper.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)
|
||||
opWrapper.disableMultiThreading();
|
||||
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
|
||||
opWrapper.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
|
||||
// opWrapper.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 && opWrapper.isRunning() ; i++)
|
||||
// std::this_thread::sleep_for(std::chrono::milliseconds{sleepTimeMs});
|
||||
// op::Profiler::profileGpuMemory(__LINE__, __FUNCTION__, __FILE__);
|
||||
// // Keep program alive while running threads
|
||||
// while (opWrapper.isRunning())
|
||||
// std::this_thread::sleep_for(std::chrono::milliseconds{sleepTimeMs});
|
||||
// // Stop and join threads
|
||||
// op::log("Stopping thread(s)", op::Priority::High);
|
||||
// opWrapper.stop();
|
||||
opWrapperT.exec();
|
||||
|
||||
// Measuring total time
|
||||
const auto now = std::chrono::high_resolution_clock::now();
|
||||
@@ -216,6 +194,6 @@ int main(int argc, char *argv[])
|
||||
// Parsing command line flags
|
||||
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
||||
|
||||
// Running openPoseDemo
|
||||
return openPoseDemo();
|
||||
// Running tutorialApiCpp6
|
||||
return tutorialApiCpp6();
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
int openPoseDemo()
|
||||
int tutorialApiCpp8()
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -142,10 +142,10 @@ int openPoseDemo()
|
||||
// handNetInputSize
|
||||
const auto handNetInputSize = op::flagsToPoint(FLAGS_hand_net_resolution, "368x368 (multiples of 16)");
|
||||
// producerType
|
||||
const auto producerSharedPtr = op::flagsToProducer(FLAGS_image_dir, FLAGS_video, FLAGS_ip_camera, FLAGS_camera,
|
||||
FLAGS_flir_camera, FLAGS_camera_resolution, FLAGS_camera_fps,
|
||||
FLAGS_camera_parameter_folder, !FLAGS_frame_keep_distortion,
|
||||
(unsigned int) FLAGS_3d_views, FLAGS_flir_camera_index);
|
||||
const auto producerSharedPtr = op::flagsToProducer(
|
||||
FLAGS_image_dir, FLAGS_video, FLAGS_ip_camera, FLAGS_camera, FLAGS_flir_camera, FLAGS_camera_resolution,
|
||||
FLAGS_camera_fps, FLAGS_camera_parameter_folder, !FLAGS_frame_keep_distortion,
|
||||
(unsigned int) FLAGS_3d_views, FLAGS_flir_camera_index);
|
||||
// poseModel
|
||||
const auto poseModel = op::flagsToPoseModel(FLAGS_model_pose);
|
||||
// JSON saving
|
||||
@@ -162,11 +162,9 @@ int openPoseDemo()
|
||||
const auto multipleView = (FLAGS_3d || FLAGS_3d_views > 1 || FLAGS_flir_camera);
|
||||
// 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
|
||||
@@ -183,25 +181,28 @@ 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};
|
||||
opWrapperT.configure(wrapperStructExtra);
|
||||
// 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};
|
||||
opWrapperT.configure(wrapperStructInput);
|
||||
// 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, FLAGS_write_keypoint,
|
||||
const auto displayMode = op::DisplayMode::NoDisplay;
|
||||
const bool guiVerbose = false;
|
||||
const bool fullScreen = false;
|
||||
@@ -211,40 +212,15 @@ int openPoseDemo()
|
||||
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()
|
||||
@@ -268,6 +244,6 @@ int main(int argc, char *argv[])
|
||||
// Parsing command line flags
|
||||
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
||||
|
||||
// Running openPoseDemo
|
||||
return openPoseDemo();
|
||||
// Running tutorialApiCpp8
|
||||
return tutorialApiCpp8();
|
||||
}
|
||||
|
||||
@@ -215,7 +215,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
int openPoseTutorialWrapper2()
|
||||
int tutorialApiCpp9()
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -253,8 +253,6 @@ int openPoseTutorialWrapper2()
|
||||
const auto multipleView = (FLAGS_3d || FLAGS_3d_views > 1);
|
||||
// Enabling Google Logging
|
||||
const bool enableGoogleLogging = true;
|
||||
// Logging
|
||||
op::log("", op::Priority::Low, __LINE__, __FUNCTION__, __FILE__);
|
||||
|
||||
// Initializing the user custom classes
|
||||
// Frames producer (e.g. video, webcam, ...)
|
||||
@@ -264,6 +262,8 @@ int openPoseTutorialWrapper2()
|
||||
// GUI (Display)
|
||||
auto wUserOutput = std::make_shared<WUserOutput>();
|
||||
|
||||
// OpenPose wrapper
|
||||
op::log("Configuring OpenPose...", op::Priority::High);
|
||||
op::WrapperT<std::vector<UserDatum>> opWrapperT;
|
||||
// Add custom input
|
||||
const auto workerInputOnNewThread = false;
|
||||
@@ -274,26 +274,30 @@ int openPoseTutorialWrapper2()
|
||||
// Add custom output
|
||||
const auto workerOutputOnNewThread = true;
|
||||
opWrapperT.setWorker(op::WorkerType::Output, wUserOutput, workerOutputOnNewThread);
|
||||
// Configure OpenPose
|
||||
op::log("Configuring OpenPose wrapper...", op::Priority::Low, __LINE__, __FUNCTION__, __FILE__);
|
||||
|
||||
// Pose configuration (use WrapperStructPose{} for default and recommended configuration)
|
||||
const op::WrapperStructPose wrapperStructPose{
|
||||
!FLAGS_body_disable, netInputSize, outputSize, keypointScale, FLAGS_num_gpu, FLAGS_num_gpu_start,
|
||||
FLAGS_scale_number, (float)FLAGS_scale_gap, op::flagsToRenderMode(FLAGS_render_pose, multipleView),
|
||||
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};
|
||||
opWrapperT.configure(wrapperStructExtra);
|
||||
// Consumer (comment or use default argument to disable any output)
|
||||
const auto displayMode = op::DisplayMode::NoDisplay;
|
||||
const bool guiVerbose = false;
|
||||
@@ -304,36 +308,15 @@ int openPoseTutorialWrapper2()
|
||||
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,
|
||||
op::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, run, and stop processing - exec() blocks this thread until OpenPose wrapper has finished
|
||||
op::log("Starting thread(s)...", op::Priority::High);
|
||||
// Two different ways of running the program on multithread environment
|
||||
// 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
|
||||
// std::this_thread::sleep_for(std::chrono::milliseconds{1000});
|
||||
// op::log("Random task here...", op::Priority::High);
|
||||
// // Keep program alive while running threads
|
||||
// while (opWrapperT.isRunning())
|
||||
// std::this_thread::sleep_for(std::chrono::milliseconds{33});
|
||||
// // 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()
|
||||
@@ -357,6 +340,6 @@ int main(int argc, char *argv[])
|
||||
// Parsing command line flags
|
||||
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
||||
|
||||
// Running openPoseTutorialWrapper2
|
||||
return openPoseTutorialWrapper2();
|
||||
// Running tutorialApiCpp9
|
||||
return tutorialApiCpp9();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user