From dcc0c51348f29eeb468a0f6df764ded66e84a8bb Mon Sep 17 00:00:00 2001 From: gineshidalgo99 Date: Thu, 15 Nov 2018 14:12:10 -0500 Subject: [PATCH] WrapperStructOutput split into Output and Gui --- doc/release_notes.md | 2 + examples/openpose/openpose.cpp | 7 ++- examples/tests/pose_accuracy_coco_test_dev.sh | 10 ++-- examples/tests/pose_accuracy_coco_val.sh | 17 ++----- examples/tests/pose_accuracy_coco_val_2014.sh | 40 ---------------- .../tests/pose_accuracy_coco_val_server.sh | 24 ---------- .../pose_accuracy_coco_val_server_2014.sh | 24 ---------- .../1_custom_post_processing.cpp | 7 ++- .../3_keypoints_from_image_configurable.cpp | 15 +++--- ...nchronous_loop_custom_input_and_output.cpp | 15 +++--- .../5_asynchronous_loop_custom_output.cpp | 15 +++--- .../6_synchronous_custom_postprocessing.cpp | 7 ++- .../7_synchronous_custom_input.cpp | 7 ++- .../8_synchronous_custom_output.cpp | 15 +++--- .../9_synchronous_custom_all.cpp | 15 +++--- include/openpose/pose/poseParameters.hpp | 2 +- include/openpose/wrapper/headers.hpp | 1 + include/openpose/wrapper/wrapper.hpp | 34 ++++++++++--- include/openpose/wrapper/wrapperAuxiliary.hpp | 40 ++++++++-------- .../openpose/wrapper/wrapperStructExtra.hpp | 6 +-- .../openpose/wrapper/wrapperStructFace.hpp | 9 ++-- include/openpose/wrapper/wrapperStructGui.hpp | 48 +++++++++++++++++++ .../openpose/wrapper/wrapperStructHand.hpp | 11 ++--- .../openpose/wrapper/wrapperStructInput.hpp | 17 ++++--- .../openpose/wrapper/wrapperStructOutput.hpp | 45 ++++------------- .../openpose/wrapper/wrapperStructPose.hpp | 25 +++++----- src/openpose/pose/poseExtractorCaffe.cpp | 2 +- src/openpose/pose/poseParameters.cpp | 21 +------- src/openpose/wrapper/CMakeLists.txt | 1 + src/openpose/wrapper/wrapperAuxiliary.cpp | 5 +- src/openpose/wrapper/wrapperStructGui.cpp | 12 +++++ src/openpose/wrapper/wrapperStructOutput.cpp | 4 -- 32 files changed, 221 insertions(+), 282 deletions(-) delete mode 100755 examples/tests/pose_accuracy_coco_val_2014.sh delete mode 100755 examples/tests/pose_accuracy_coco_val_server.sh delete mode 100755 examples/tests/pose_accuracy_coco_val_server_2014.sh create mode 100644 include/openpose/wrapper/wrapperStructGui.hpp create mode 100644 src/openpose/wrapper/wrapperStructGui.cpp diff --git a/doc/release_notes.md b/doc/release_notes.md index d05d1d7a..788d4503 100644 --- a/doc/release_notes.md +++ b/doc/release_notes.md @@ -294,6 +294,8 @@ OpenPose Library - Release Notes 3. WrapperT.configure() changed from 1 function that requries all arguments to individual functions that take 1 argument each. 4. Added `Forward` to all net classes that automatically selects between CUDA, OpenCL, or CPU-only version depending on the defines. 5. Previously hardcoded `COCO_CHALLENGE` variable turned into user configurable flag `--maximize_positives`. + 6. Removed old COCO 2014 validation scripts. + 7. WrapperStructOutput split into WrapperStructOutput and WrapperStructGui. 3. Main bugs fixed: 1. CMake-GUI was forcing to Release mode, allowed Debug modes too. 2. NMS returns in index 0 the number of found peaks. However, while the number of peaks was truncated to a maximum of 127, this index 0 was saving the real number instead of the truncated one. diff --git a/examples/openpose/openpose.cpp b/examples/openpose/openpose.cpp index 478dccf4..26c10d7a 100755 --- a/examples/openpose/openpose.cpp +++ b/examples/openpose/openpose.cpp @@ -96,14 +96,17 @@ int openPoseDemo() cameraSize, FLAGS_camera_fps, FLAGS_camera_parameter_folder, !FLAGS_frame_keep_distortion, (unsigned int) FLAGS_3d_views}; opWrapper.configure(wrapperStructInput); - // Consumer (comment or use default argument to disable any output) + // Output (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, op::stringToDataFormat(FLAGS_write_keypoint_format), FLAGS_write_json, FLAGS_write_coco_json, FLAGS_write_coco_foot_json, FLAGS_write_coco_json_variant, 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); + // GUI (comment or use default argument to disable any visual output) + const op::WrapperStructGui wrapperStructGui{ + op::flagsToDisplayMode(FLAGS_display, FLAGS_3d), !FLAGS_no_gui_verbose, FLAGS_fullscreen}; + opWrapper.configure(wrapperStructGui); // Set to single-thread (for sequential processing and/or debugging and/or reducing latency) if (FLAGS_disable_multi_thread) opWrapper.disableMultiThreading(); diff --git a/examples/tests/pose_accuracy_coco_test_dev.sh b/examples/tests/pose_accuracy_coco_test_dev.sh index b4330494..2cf25451 100755 --- a/examples/tests/pose_accuracy_coco_test_dev.sh +++ b/examples/tests/pose_accuracy_coco_test_dev.sh @@ -2,13 +2,13 @@ +# USAGE EXAMPLE +# clear && clear && make all -j`nproc` && bash ./examples/tests/pose_accuracy_coco_test_dev.sh + # Script for internal use. We might completely change it continuously and we will not answer questions about it. clear && clear -# USAGE EXAMPLE -# See ./examples/tests/pose_accuracy_coco_test.sh - # Parameters IMAGE_FOLDER=/media/posefs3b/Users/gines/openpose_train/dataset/COCO/cocoapi/images/test2017_dev/ JSON_FOLDER=../evaluation/coco_val_jsons/ @@ -16,6 +16,8 @@ OP_BIN=./build/examples/openpose/openpose.bin # # 1 scale # $OP_BIN --image_dir $IMAGE_FOLDER --write_coco_json ${JSON_FOLDER}1_test.json --display 0 --render_pose 0 +# $OP_BIN --image_dir $IMAGE_FOLDER --write_coco_json ${JSON_FOLDER}1_test_max.json --display 0 --render_pose 0 --maximize_positives # 4 scales -$OP_BIN --image_dir $IMAGE_FOLDER --write_coco_json ${JSON_FOLDER}1_4_test.json --display 0 --render_pose 0 --scale_number 4 --scale_gap 0.25 --net_resolution "1312x736" +# $OP_BIN --image_dir $IMAGE_FOLDER --write_coco_json ${JSON_FOLDER}1_4_test.json --display 0 --render_pose 0 --scale_number 4 --scale_gap 0.25 --net_resolution "1312x736" +$OP_BIN --image_dir $IMAGE_FOLDER --write_coco_json ${JSON_FOLDER}1_4_test_max.json --display 0 --render_pose 0 --scale_number 4 --scale_gap 0.25 --net_resolution "1312x736" --maximize_positives diff --git a/examples/tests/pose_accuracy_coco_val.sh b/examples/tests/pose_accuracy_coco_val.sh index 72ca1ce4..6c4ba4b8 100755 --- a/examples/tests/pose_accuracy_coco_val.sh +++ b/examples/tests/pose_accuracy_coco_val.sh @@ -2,24 +2,15 @@ +# USAGE EXAMPLE +# clear && clear && make all -j`nproc` && bash ./examples/tests/pose_accuracy_coco_val.sh + # Script for internal use. We might completely change it continuously and we will not answer questions about it. clear && clear -# USAGE EXAMPLE -# clear && clear && make all -j`nproc` && bash ./examples/tests/pose_accuracy_coco_test.sh - -# # Go back to main folder -# cd ../../ - - -# Write COCO-format JSON -# Last id: - # ID 20671 <--> #frames = 1471 --> ~ 1.5 min at 15fps - # ID 50006 <--> #frames = 3559 --> ~ 4 min at 15fps - # Parameters -IMAGE_FOLDER=/home/gines/devel/images/val2017/ +IMAGE_FOLDER=~/devel/images/val2017/ JSON_FOLDER=../evaluation/coco_val_jsons/ OP_BIN=./build/examples/openpose/openpose.bin diff --git a/examples/tests/pose_accuracy_coco_val_2014.sh b/examples/tests/pose_accuracy_coco_val_2014.sh deleted file mode 100755 index 560bc414..00000000 --- a/examples/tests/pose_accuracy_coco_val_2014.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/bash - - - -# Script for internal use. We might completely change it continuously and we will not answer questions about it. - -clear && clear - -# USAGE EXAMPLE -# clear && clear && make all -j`nproc` && bash ./examples/tests/pose_accuracy_coco_test.sh - -# # Go back to main folder -# cd ../../ - - -# Write COCO-format JSON -# Note: `--frame_last 3558` --> total = 3559 frames -# Last id: - # ID 20671 <--> #frames = 1471 --> ~ 1.5 min at 15fps - # ID 50006 <--> #frames = 3559 --> ~ 4 min at 15fps - -# Parameters -IMAGE_FOLDER=/home/gines/devel/images/val2014/ -JSON_FOLDER=../evaluation/coco_val_jsons/ -OP_BIN=./build/examples/openpose/openpose.bin - - # 1 scale -$OP_BIN --image_dir $IMAGE_FOLDER --write_coco_json ${JSON_FOLDER}1.json --display 0 --render_pose 0 --frame_last 3558 - - # 1 scale - Debugging -# $OP_BIN --image_dir $IMAGE_FOLDER --write_coco_json ${JSON_FOLDER}1.json --display 0 --frame_last 3558 --write_images ~/Desktop/CppValidation/ - -# # 3 scales -# $OP_BIN --image_dir $IMAGE_FOLDER --write_coco_json ${JSON_FOLDER}1_3.json --display 0 --render_pose 0 --scale_number 3 --scale_gap 0.25 --frame_last 3558 - -# # 4 scales -# $OP_BIN --num_gpu 1 --image_dir $IMAGE_FOLDER --write_coco_json ${JSON_FOLDER}1_4.json --display 0 --render_pose 0 --scale_number 4 --scale_gap 0.25 --net_resolution "1312x736" --frame_last 3558 - -# # Debugging - Rendered frames saved -# $OP_BIN --image_dir $IMAGE_FOLDER --write_images ${JSON_FOLDER}frameOutput --display 0 diff --git a/examples/tests/pose_accuracy_coco_val_server.sh b/examples/tests/pose_accuracy_coco_val_server.sh deleted file mode 100755 index 107b1ec3..00000000 --- a/examples/tests/pose_accuracy_coco_val_server.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash - - - -# Script for internal use. We might completely change it continuously and we will not answer questions about it. - -clear && clear - -# USAGE EXAMPLE -# See ./examples/tests/pose_accuracy_coco_test.sh - -# Parameters -IMAGE_FOLDER=/home/gines/devel/images/val2017/ -JSON_FOLDER=../evaluation/coco_val_jsons/ -OP_BIN=./build/examples/openpose/openpose.bin - - # 1 scale -$OP_BIN --image_dir $IMAGE_FOLDER --write_coco_json ${JSON_FOLDER}1.json --display 0 --render_pose 0 - - # 3 scales -$OP_BIN --image_dir $IMAGE_FOLDER --write_coco_json ${JSON_FOLDER}1_3.json --display 0 --render_pose 0 --scale_number 3 --scale_gap 0.25 - - # 4 scales -$OP_BIN --image_dir $IMAGE_FOLDER --write_coco_json ${JSON_FOLDER}1_4.json --display 0 --render_pose 0 --scale_number 4 --scale_gap 0.25 --net_resolution "1312x736" diff --git a/examples/tests/pose_accuracy_coco_val_server_2014.sh b/examples/tests/pose_accuracy_coco_val_server_2014.sh deleted file mode 100755 index cfab7bf9..00000000 --- a/examples/tests/pose_accuracy_coco_val_server_2014.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash - - - -# Script for internal use. We might completely change it continuously and we will not answer questions about it. - -clear && clear - -# USAGE EXAMPLE -# See ./examples/tests/pose_accuracy_coco_test.sh - -# Parameters -IMAGE_FOLDER=/home/gines/devel/images/val2014/ -JSON_FOLDER=../evaluation/coco_val_jsons/ -OP_BIN=./build/examples/openpose/openpose.bin - - # 1 scale -$OP_BIN --image_dir $IMAGE_FOLDER --write_coco_json ${JSON_FOLDER}1.json --display 0 --render_pose 0 --frame_last 3558 - - # 3 scales -$OP_BIN --image_dir $IMAGE_FOLDER --write_coco_json ${JSON_FOLDER}1_3.json --display 0 --render_pose 0 --scale_number 3 --scale_gap 0.25 --frame_last 3558 - - # 4 scales -$OP_BIN --image_dir $IMAGE_FOLDER --write_coco_json ${JSON_FOLDER}1_4.json --display 0 --render_pose 0 --scale_number 4 --scale_gap 0.25 --net_resolution "1312x736" --frame_last 3558 diff --git a/examples/tutorial_add_module/1_custom_post_processing.cpp b/examples/tutorial_add_module/1_custom_post_processing.cpp index 45e605f7..96276d34 100644 --- a/examples/tutorial_add_module/1_custom_post_processing.cpp +++ b/examples/tutorial_add_module/1_custom_post_processing.cpp @@ -109,14 +109,17 @@ int tutorialAddModule1() cameraSize, FLAGS_camera_fps, FLAGS_camera_parameter_folder, !FLAGS_frame_keep_distortion, (unsigned int) FLAGS_3d_views}; opWrapperT.configure(wrapperStructInput); - // Consumer (comment or use default argument to disable any output) + // Output (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, op::stringToDataFormat(FLAGS_write_keypoint_format), FLAGS_write_json, FLAGS_write_coco_json, FLAGS_write_coco_foot_json, FLAGS_write_coco_json_variant, 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}; opWrapperT.configure(wrapperStructOutput); + // GUI (comment or use default argument to disable any visual output) + const op::WrapperStructGui wrapperStructGui{ + op::flagsToDisplayMode(FLAGS_display, FLAGS_3d), !FLAGS_no_gui_verbose, FLAGS_fullscreen}; + opWrapperT.configure(wrapperStructGui); // Custom post-processing auto userPostProcessing = std::make_shared(/* Your class arguments here */); diff --git a/examples/tutorial_api_cpp/3_keypoints_from_image_configurable.cpp b/examples/tutorial_api_cpp/3_keypoints_from_image_configurable.cpp index e183b224..b29598bf 100644 --- a/examples/tutorial_api_cpp/3_keypoints_from_image_configurable.cpp +++ b/examples/tutorial_api_cpp/3_keypoints_from_image_configurable.cpp @@ -108,17 +108,14 @@ int tutorialApiCpp3() 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; + // Output (comment or use default argument to disable any output) 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_coco_json_variant, 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}; + FLAGS_write_keypoint, op::stringToDataFormat(FLAGS_write_keypoint_format), FLAGS_write_json, + FLAGS_write_coco_json, FLAGS_write_coco_foot_json, FLAGS_write_coco_json_variant, 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); + // No GUI. Equivalent to: opWrapper.configure(op::WrapperStructGui{}); // Set to single-thread (for sequential processing and/or debugging and/or reducing latency) if (FLAGS_disable_multi_thread) opWrapper.disableMultiThreading(); diff --git a/examples/tutorial_api_cpp/4_asynchronous_loop_custom_input_and_output.cpp b/examples/tutorial_api_cpp/4_asynchronous_loop_custom_input_and_output.cpp index dd3f554a..bc4f3e1c 100644 --- a/examples/tutorial_api_cpp/4_asynchronous_loop_custom_input_and_output.cpp +++ b/examples/tutorial_api_cpp/4_asynchronous_loop_custom_input_and_output.cpp @@ -241,17 +241,14 @@ int tutorialApiCpp4() 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; - const bool fullScreen = false; + // Output (comment or use default argument to disable any output) 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_coco_json_variant, 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}; + FLAGS_write_keypoint, op::stringToDataFormat(FLAGS_write_keypoint_format), FLAGS_write_json, + FLAGS_write_coco_json, FLAGS_write_coco_foot_json, FLAGS_write_coco_json_variant, 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}; opWrapperT.configure(wrapperStructOutput); + // No GUI. Equivalent to: opWrapper.configure(op::WrapperStructGui{}); // Set to single-thread (for sequential processing and/or debugging and/or reducing latency) if (FLAGS_disable_multi_thread) opWrapperT.disableMultiThreading(); diff --git a/examples/tutorial_api_cpp/5_asynchronous_loop_custom_output.cpp b/examples/tutorial_api_cpp/5_asynchronous_loop_custom_output.cpp index 2e4b42ac..3e4711c6 100644 --- a/examples/tutorial_api_cpp/5_asynchronous_loop_custom_output.cpp +++ b/examples/tutorial_api_cpp/5_asynchronous_loop_custom_output.cpp @@ -191,17 +191,14 @@ int tutorialApiCpp5() cameraSize, FLAGS_camera_fps, FLAGS_camera_parameter_folder, !FLAGS_frame_keep_distortion, (unsigned int) FLAGS_3d_views}; opWrapperT.configure(wrapperStructInput); - // Consumer (comment or use default argument to disable any output) - const auto displayMode = op::DisplayMode::NoDisplay; - const bool guiVerbose = false; - const bool fullScreen = false; + // Output (comment or use default argument to disable any output) 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_coco_json_variant, 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}; + FLAGS_write_keypoint, op::stringToDataFormat(FLAGS_write_keypoint_format), FLAGS_write_json, + FLAGS_write_coco_json, FLAGS_write_coco_foot_json, FLAGS_write_coco_json_variant, 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}; opWrapperT.configure(wrapperStructOutput); + // No GUI. Equivalent to: opWrapper.configure(op::WrapperStructGui{}); // Set to single-thread (for sequential processing and/or debugging and/or reducing latency) if (FLAGS_disable_multi_thread) opWrapperT.disableMultiThreading(); diff --git a/examples/tutorial_api_cpp/6_synchronous_custom_postprocessing.cpp b/examples/tutorial_api_cpp/6_synchronous_custom_postprocessing.cpp index eadda936..88a92c0d 100644 --- a/examples/tutorial_api_cpp/6_synchronous_custom_postprocessing.cpp +++ b/examples/tutorial_api_cpp/6_synchronous_custom_postprocessing.cpp @@ -159,14 +159,17 @@ int tutorialApiCpp6() cameraSize, FLAGS_camera_fps, FLAGS_camera_parameter_folder, !FLAGS_frame_keep_distortion, (unsigned int) FLAGS_3d_views}; opWrapperT.configure(wrapperStructInput); - // Consumer (comment or use default argument to disable any output) + // Output (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, op::stringToDataFormat(FLAGS_write_keypoint_format), FLAGS_write_json, FLAGS_write_coco_json, FLAGS_write_coco_foot_json, FLAGS_write_coco_json_variant, 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}; opWrapperT.configure(wrapperStructOutput); + // GUI (comment or use default argument to disable any visual output) + const op::WrapperStructGui wrapperStructGui{ + op::flagsToDisplayMode(FLAGS_display, FLAGS_3d), !FLAGS_no_gui_verbose, FLAGS_fullscreen}; + opWrapperT.configure(wrapperStructGui); // Set to single-thread (for sequential processing and/or debugging and/or reducing latency) if (FLAGS_disable_multi_thread) opWrapperT.disableMultiThreading(); diff --git a/examples/tutorial_api_cpp/7_synchronous_custom_input.cpp b/examples/tutorial_api_cpp/7_synchronous_custom_input.cpp index 13b0f053..16eee7ec 100644 --- a/examples/tutorial_api_cpp/7_synchronous_custom_input.cpp +++ b/examples/tutorial_api_cpp/7_synchronous_custom_input.cpp @@ -192,14 +192,17 @@ int tutorialApiCpp7() 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) + // Output (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, op::stringToDataFormat(FLAGS_write_keypoint_format), FLAGS_write_json, FLAGS_write_coco_json, FLAGS_write_coco_foot_json, FLAGS_write_coco_json_variant, 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}; opWrapperT.configure(wrapperStructOutput); + // GUI (comment or use default argument to disable any visual output) + const op::WrapperStructGui wrapperStructGui{ + op::flagsToDisplayMode(FLAGS_display, FLAGS_3d), !FLAGS_no_gui_verbose, FLAGS_fullscreen}; + opWrapperT.configure(wrapperStructGui); // Set to single-thread (for sequential processing and/or debugging and/or reducing latency) if (FLAGS_disable_multi_thread) opWrapperT.disableMultiThreading(); diff --git a/examples/tutorial_api_cpp/8_synchronous_custom_output.cpp b/examples/tutorial_api_cpp/8_synchronous_custom_output.cpp index 6ed1567f..f03722ec 100644 --- a/examples/tutorial_api_cpp/8_synchronous_custom_output.cpp +++ b/examples/tutorial_api_cpp/8_synchronous_custom_output.cpp @@ -206,17 +206,14 @@ int tutorialApiCpp8() cameraSize, FLAGS_camera_fps, FLAGS_camera_parameter_folder, !FLAGS_frame_keep_distortion, (unsigned int) FLAGS_3d_views}; opWrapperT.configure(wrapperStructInput); - // Consumer (comment or use default argument to disable any output) - const auto displayMode = op::DisplayMode::NoDisplay; - const bool guiVerbose = false; - const bool fullScreen = false; + // Output (comment or use default argument to disable any output) 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_coco_json_variant, 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}; + FLAGS_write_keypoint, op::stringToDataFormat(FLAGS_write_keypoint_format), FLAGS_write_json, + FLAGS_write_coco_json, FLAGS_write_coco_foot_json, FLAGS_write_coco_json_variant, 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}; opWrapperT.configure(wrapperStructOutput); + // No GUI. Equivalent to: opWrapper.configure(op::WrapperStructGui{}); // Set to single-thread (for sequential processing and/or debugging and/or reducing latency) if (FLAGS_disable_multi_thread) opWrapperT.disableMultiThreading(); diff --git a/examples/tutorial_api_cpp/9_synchronous_custom_all.cpp b/examples/tutorial_api_cpp/9_synchronous_custom_all.cpp index 8ca50da5..4e7b8e17 100644 --- a/examples/tutorial_api_cpp/9_synchronous_custom_all.cpp +++ b/examples/tutorial_api_cpp/9_synchronous_custom_all.cpp @@ -298,17 +298,14 @@ int tutorialApiCpp9() 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; - const bool fullScreen = false; + // Output (comment or use default argument to disable any output) 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_coco_json_variant, 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}; + FLAGS_write_keypoint, op::stringToDataFormat(FLAGS_write_keypoint_format), FLAGS_write_json, + FLAGS_write_coco_json, FLAGS_write_coco_foot_json, FLAGS_write_coco_json_variant, 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}; opWrapperT.configure(wrapperStructOutput); + // No GUI. Equivalent to: opWrapper.configure(op::WrapperStructGui{}); // Set to single-thread (for sequential processing and/or debugging and/or reducing latency) if (FLAGS_disable_multi_thread) opWrapperT.disableMultiThreading(); diff --git a/include/openpose/pose/poseParameters.hpp b/include/openpose/pose/poseParameters.hpp index 5780adc3..c2b7e497 100644 --- a/include/openpose/pose/poseParameters.hpp +++ b/include/openpose/pose/poseParameters.hpp @@ -20,7 +20,7 @@ namespace op OP_API unsigned int getPoseNumberBodyParts(const PoseModel poseModel); OP_API const std::vector& getPosePartPairs(const PoseModel poseModel); OP_API const std::vector& getPoseMapIndex(const PoseModel poseModel); - OP_API unsigned int getPoseMaxPeaks(const PoseModel poseModel); + OP_API unsigned int getPoseMaxPeaks(); OP_API float getPoseNetDecreaseFactor(const PoseModel poseModel); OP_API unsigned int poseBodyPartMapStringToKey(const PoseModel poseModel, const std::string& string); OP_API unsigned int poseBodyPartMapStringToKey(const PoseModel poseModel, const std::vector& strings); diff --git a/include/openpose/wrapper/headers.hpp b/include/openpose/wrapper/headers.hpp index 15a99e39..1a49b898 100644 --- a/include/openpose/wrapper/headers.hpp +++ b/include/openpose/wrapper/headers.hpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include diff --git a/include/openpose/wrapper/wrapper.hpp b/include/openpose/wrapper/wrapper.hpp index 2640a306..ff50dc8c 100644 --- a/include/openpose/wrapper/wrapper.hpp +++ b/include/openpose/wrapper/wrapper.hpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -71,30 +72,35 @@ namespace op void configure(const WrapperStructPose& wrapperStructPose); /** - * Analogous to configure() but applied to only pose (WrapperStructFace) + * Analogous to configure(WrapperStructPose) but applied to face (WrapperStructFace) */ void configure(const WrapperStructFace& wrapperStructFace); /** - * Analogous to configure() but applied to only pose (WrapperStructHand) + * Analogous to configure() but applied to hand (WrapperStructHand) */ void configure(const WrapperStructHand& wrapperStructHand); /** - * Analogous to configure() but applied to only pose (WrapperStructExtra) + * Analogous to configure() but applied to the extra options (WrapperStructExtra) */ void configure(const WrapperStructExtra& wrapperStructExtra); /** - * Analogous to configure() but applied to only pose (WrapperStructInput) + * Analogous to configure() but applied to the input (WrapperStructInput) */ void configure(const WrapperStructInput& wrapperStructInput); /** - * Analogous to configure() but applied to only pose (WrapperStructInput) + * Analogous to configure() but applied to the output (WrapperStructOutput) */ void configure(const WrapperStructOutput& wrapperStructOutput); + /** + * Analogous to configure() but applied to the GUI (WrapperStructGui) + */ + void configure(const WrapperStructGui& wrapperStructGui); + /** * Function to start multi-threading. * Similar to start(), but exec() blocks the thread that calls the function (it saves 1 thread). Use exec() @@ -201,6 +207,7 @@ namespace op WrapperStructExtra mWrapperStructExtra; WrapperStructInput mWrapperStructInput; WrapperStructOutput mWrapperStructOutput; + WrapperStructGui mWrapperStructGui; // User configurable workers std::array mUserWsOnNewThread; std::array, int(WorkerType::Size)> mUserWs; @@ -357,6 +364,19 @@ namespace op } } + template + void WrapperT::configure(const WrapperStructGui& wrapperStructGui) + { + try + { + mWrapperStructGui = wrapperStructGui; + } + catch (const std::exception& e) + { + error(e.what(), __LINE__, __FUNCTION__, __FILE__); + } + } + template void WrapperT::exec() { @@ -364,7 +384,7 @@ namespace op { configureThreadManager( mThreadManager, mMultiThreadEnabled, mThreadManagerMode, mWrapperStructPose, mWrapperStructFace, - mWrapperStructHand, mWrapperStructExtra, mWrapperStructInput, mWrapperStructOutput, + mWrapperStructHand, mWrapperStructExtra, mWrapperStructInput, mWrapperStructOutput, mWrapperStructGui, mUserWs, mUserWsOnNewThread); log("", Priority::Low, __LINE__, __FUNCTION__, __FILE__); mThreadManager.exec(); @@ -382,7 +402,7 @@ namespace op { configureThreadManager( mThreadManager, mMultiThreadEnabled, mThreadManagerMode, mWrapperStructPose, mWrapperStructFace, - mWrapperStructHand, mWrapperStructExtra, mWrapperStructInput, mWrapperStructOutput, + mWrapperStructHand, mWrapperStructExtra, mWrapperStructInput, mWrapperStructOutput, mWrapperStructGui, mUserWs, mUserWsOnNewThread); log("", Priority::Low, __LINE__, __FUNCTION__, __FILE__); mThreadManager.start(); diff --git a/include/openpose/wrapper/wrapperAuxiliary.hpp b/include/openpose/wrapper/wrapperAuxiliary.hpp index 27639b27..d33217b7 100644 --- a/include/openpose/wrapper/wrapperAuxiliary.hpp +++ b/include/openpose/wrapper/wrapperAuxiliary.hpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -29,8 +30,8 @@ namespace op WrapperStructPose& wrapperStructPose, const WrapperStructFace& wrapperStructFace, const WrapperStructHand& wrapperStructHand, const WrapperStructExtra& wrapperStructExtra, const WrapperStructInput& wrapperStructInput, const WrapperStructOutput& wrapperStructOutput, - const bool renderOutput, const bool userOutputWsEmpty, const std::shared_ptr& producerSharedPtr, - const ThreadManagerMode threadManagerMode); + const WrapperStructGui& wrapperStructGui, const bool renderOutput, const bool userOutputWsEmpty, + const std::shared_ptr& producerSharedPtr, const ThreadManagerMode threadManagerMode); /** * Thread ID increase (private internal function). @@ -56,7 +57,7 @@ namespace op const ThreadManagerMode threadManagerMode, const WrapperStructPose& wrapperStructPose, const WrapperStructFace& wrapperStructFace, const WrapperStructHand& wrapperStructHand, const WrapperStructExtra& wrapperStructExtra, const WrapperStructInput& wrapperStructInput, - const WrapperStructOutput& wrapperStructOutput, + const WrapperStructOutput& wrapperStructOutput, const WrapperStructGui& wrapperStructGui, const std::array, int(WorkerType::Size)>& userWs, const std::array& userWsOnNewThread); } @@ -86,7 +87,7 @@ namespace op const ThreadManagerMode threadManagerMode, const WrapperStructPose& wrapperStructPoseTemp, const WrapperStructFace& wrapperStructFace, const WrapperStructHand& wrapperStructHand, const WrapperStructExtra& wrapperStructExtra, const WrapperStructInput& wrapperStructInput, - const WrapperStructOutput& wrapperStructOutput, + const WrapperStructOutput& wrapperStructOutput, const WrapperStructGui& wrapperStructGui, const std::array, int(WorkerType::Size)>& userWs, const std::array& userWsOnNewThread) { @@ -146,7 +147,8 @@ namespace op const auto userOutputWsEmpty = userOutputWs.empty(); wrapperConfigureSanityChecks( wrapperStructPose, wrapperStructFace, wrapperStructHand, wrapperStructExtra, wrapperStructInput, - wrapperStructOutput, renderOutput, userOutputWsEmpty, producerSharedPtr, threadManagerMode); + wrapperStructOutput, wrapperStructGui, renderOutput, userOutputWsEmpty, producerSharedPtr, + threadManagerMode); // Get number threads auto numberThreads = wrapperStructPose.gpuNumber; @@ -562,8 +564,8 @@ namespace op } // IK/Adam - const auto displayAdam = wrapperStructOutput.displayMode == DisplayMode::DisplayAdam - || (wrapperStructOutput.displayMode == DisplayMode::DisplayAll + const auto displayAdam = wrapperStructGui.displayMode == DisplayMode::DisplayAdam + || (wrapperStructGui.displayMode == DisplayMode::DisplayAll && wrapperStructExtra.ikThreads > 0); jointAngleEstimationsWs.clear(); #ifdef USE_3D_ADAM_MODEL @@ -676,12 +678,12 @@ namespace op outputWs.emplace_back(std::make_shared>(heatMapSaver)); } // Add frame information for GUI - const bool guiEnabled = (wrapperStructOutput.displayMode != DisplayMode::NoDisplay); + const bool guiEnabled = (wrapperStructGui.displayMode != DisplayMode::NoDisplay); // If this WGuiInfoAdder instance is placed before the WImageSaver or WVideoSaver, then the resulting // recorded frames will look exactly as the final displayed image by the GUI - if (wrapperStructOutput.guiVerbose && (guiEnabled || !userOutputWs.empty() - || threadManagerMode == ThreadManagerMode::Asynchronous - || threadManagerMode == ThreadManagerMode::AsynchronousOut)) + if (wrapperStructGui.guiVerbose && (guiEnabled || !userOutputWs.empty() + || threadManagerMode == ThreadManagerMode::Asynchronous + || threadManagerMode == ThreadManagerMode::AsynchronousOut)) { const auto guiInfoAdder = std::make_shared(numberThreads, guiEnabled); outputWs.emplace_back(std::make_shared>(guiInfoAdder)); @@ -704,9 +706,9 @@ namespace op #ifdef USE_3D_ADAM_MODEL // Gui const auto gui = std::make_shared( - finalOutputSize, wrapperStructOutput.fullScreen, threadManager.getIsRunningSharedPtr(), + finalOutputSize, wrapperStructGui.fullScreen, threadManager.getIsRunningSharedPtr(), spVideoSeek, poseExtractorNets, faceExtractorNets, handExtractorNets, renderers, - wrapperStructOutput.displayMode, JointAngleEstimation::getTotalModel(), + wrapperStructGui.displayMode, JointAngleEstimation::getTotalModel(), wrapperStructOutput.writeVideoAdam ); // WGui @@ -714,24 +716,24 @@ namespace op #endif } // 3-D (+2-D) display - else if (wrapperStructOutput.displayMode == DisplayMode::Display3D - || wrapperStructOutput.displayMode == DisplayMode::DisplayAll) + else if (wrapperStructGui.displayMode == DisplayMode::Display3D + || wrapperStructGui.displayMode == DisplayMode::DisplayAll) { // Gui const auto gui = std::make_shared( - finalOutputSize, wrapperStructOutput.fullScreen, threadManager.getIsRunningSharedPtr(), + finalOutputSize, wrapperStructGui.fullScreen, threadManager.getIsRunningSharedPtr(), spVideoSeek, poseExtractorNets, faceExtractorNets, handExtractorNets, renderers, - wrapperStructPose.poseModel, wrapperStructOutput.displayMode + wrapperStructPose.poseModel, wrapperStructGui.displayMode ); // WGui guiW = {std::make_shared>(gui)}; } // 2-D display - else if (wrapperStructOutput.displayMode == DisplayMode::Display2D) + else if (wrapperStructGui.displayMode == DisplayMode::Display2D) { // Gui const auto gui = std::make_shared( - finalOutputSize, wrapperStructOutput.fullScreen, threadManager.getIsRunningSharedPtr(), + finalOutputSize, wrapperStructGui.fullScreen, threadManager.getIsRunningSharedPtr(), spVideoSeek, poseExtractorNets, faceExtractorNets, handExtractorNets, renderers ); // WGui diff --git a/include/openpose/wrapper/wrapperStructExtra.hpp b/include/openpose/wrapper/wrapperStructExtra.hpp index b8a0f802..32aa3311 100644 --- a/include/openpose/wrapper/wrapperStructExtra.hpp +++ b/include/openpose/wrapper/wrapperStructExtra.hpp @@ -50,9 +50,9 @@ namespace op * It has the recommended and default values we recommend for each element of the struct. * Since all the elements of the struct are public, they can also be manually filled. */ - WrapperStructExtra(const bool reconstruct3d = false, const int minViews3d = -1, - const bool identification = false, const int tracking = -1, - const int ikThreads = 0); + WrapperStructExtra( + const bool reconstruct3d = false, const int minViews3d = -1, const bool identification = false, + const int tracking = -1, const int ikThreads = 0); }; } diff --git a/include/openpose/wrapper/wrapperStructFace.hpp b/include/openpose/wrapper/wrapperStructFace.hpp index 68cc739c..3969dbf0 100644 --- a/include/openpose/wrapper/wrapperStructFace.hpp +++ b/include/openpose/wrapper/wrapperStructFace.hpp @@ -58,11 +58,10 @@ namespace op * It has the recommended and default values we recommend for each element of the struct. * Since all the elements of the struct are public, they can also be manually filled. */ - WrapperStructFace(const bool enable = false, const Point& netInputSize = Point{368, 368}, - const RenderMode renderMode = RenderMode::Gpu, - const float alphaKeypoint = FACE_DEFAULT_ALPHA_KEYPOINT, - const float alphaHeatMap = FACE_DEFAULT_ALPHA_HEAT_MAP, - const float renderThreshold = 0.4f); + WrapperStructFace( + const bool enable = false, const Point& netInputSize = Point{368, 368}, + const RenderMode renderMode = RenderMode::Gpu, const float alphaKeypoint = FACE_DEFAULT_ALPHA_KEYPOINT, + const float alphaHeatMap = FACE_DEFAULT_ALPHA_HEAT_MAP, const float renderThreshold = 0.4f); }; } diff --git a/include/openpose/wrapper/wrapperStructGui.hpp b/include/openpose/wrapper/wrapperStructGui.hpp new file mode 100644 index 00000000..2c86e8e1 --- /dev/null +++ b/include/openpose/wrapper/wrapperStructGui.hpp @@ -0,0 +1,48 @@ +#ifndef OPENPOSE_WRAPPER_WRAPPER_STRUCT_GUI_HPP +#define OPENPOSE_WRAPPER_WRAPPER_STRUCT_GUI_HPP + +#include +#include + +namespace op +{ + /** + * WrapperStructGui: It controls a small GUI for quick visualization. + */ + struct OP_API WrapperStructGui + { + /** + * Display mode + * a) -1 for automatic selection. + * b) 0 for no display. Useful if there is no X server and/or to slightly speed up the processing if visual + * output is not required. + * c) 2 for 2-D display in the OpenPose small integrated GUI. + * d) 3 for 3-D display, if `--3d` was enabled. + * e) 1 for both 2-D and 3-D display. + */ + DisplayMode displayMode; + + /** + * Whether to add some information to the frame (number of frame, number people detected, etc.) after it is + * saved on disk and before it is displayed and/or returned to the user. + */ + bool guiVerbose; + + /** + * Whether to display the OpenPose small integrated GUI on fullscreen mode. It can be changed by interacting + * with the GUI itself. + */ + bool fullScreen; + + /** + * Constructor of the struct. + * It has the recommended and default values we recommend for each element of the struct. + * Since all the elements of the struct are public, they can also be manually filled. + */ + WrapperStructGui( + const DisplayMode displayMode = DisplayMode::NoDisplay, const bool guiVerbose = false, + const bool fullScreen = false); + }; +} + +#endif // OPENPOSE_WRAPPER_WRAPPER_STRUCT_GUI_HPP diff --git a/include/openpose/wrapper/wrapperStructHand.hpp b/include/openpose/wrapper/wrapperStructHand.hpp index 918eb47a..4f14727b 100644 --- a/include/openpose/wrapper/wrapperStructHand.hpp +++ b/include/openpose/wrapper/wrapperStructHand.hpp @@ -80,12 +80,11 @@ namespace op * It has the recommended and default values we recommend for each element of the struct. * Since all the elements of the struct are public, they can also be manually filled. */ - WrapperStructHand(const bool enable = false, const Point& netInputSize = Point{368, 368}, - const int scalesNumber = 1, const float scaleRange = 0.4f, - const bool tracking = false, const RenderMode renderMode = RenderMode::Gpu, - const float alphaKeypoint = HAND_DEFAULT_ALPHA_KEYPOINT, - const float alphaHeatMap = HAND_DEFAULT_ALPHA_HEAT_MAP, - const float renderThreshold = 0.2f); + WrapperStructHand( + const bool enable = false, const Point& netInputSize = Point{368, 368}, + const int scalesNumber = 1, const float scaleRange = 0.4f, const bool tracking = false, + const RenderMode renderMode = RenderMode::Gpu, const float alphaKeypoint = HAND_DEFAULT_ALPHA_KEYPOINT, + const float alphaHeatMap = HAND_DEFAULT_ALPHA_HEAT_MAP, const float renderThreshold = 0.2f); }; } diff --git a/include/openpose/wrapper/wrapperStructInput.hpp b/include/openpose/wrapper/wrapperStructInput.hpp index fc1737d3..681b610b 100644 --- a/include/openpose/wrapper/wrapperStructInput.hpp +++ b/include/openpose/wrapper/wrapperStructInput.hpp @@ -96,15 +96,14 @@ namespace op * It has the recommended and default values we recommend for each element of the struct. * Since all the elements of the struct are public, they can also be manually filled. */ - WrapperStructInput(const ProducerType producerType = ProducerType::None, - const std::string& producerString = "", const unsigned long long frameFirst = 0, - const unsigned long long frameStep = 1, - const unsigned long long frameLast = std::numeric_limits::max(), - const bool realTimeProcessing = false, const bool frameFlip = false, - const int frameRotate = 0, const bool framesRepeat = false, - const Point& cameraResolution = Point{-1,-1}, const double webcamFps = 30., - const std::string& cameraParameterPath = "models/cameraParameters/", - const bool undistortImage = true, const unsigned int imageDirectoryStereo = 1); + WrapperStructInput( + const ProducerType producerType = ProducerType::None, const std::string& producerString = "", + const unsigned long long frameFirst = 0, const unsigned long long frameStep = 1, + const unsigned long long frameLast = std::numeric_limits::max(), + const bool realTimeProcessing = false, const bool frameFlip = false, const int frameRotate = 0, + const bool framesRepeat = false, const Point& cameraResolution = Point{-1,-1}, + const double webcamFps = 30., const std::string& cameraParameterPath = "models/cameraParameters/", + const bool undistortImage = true, const unsigned int imageDirectoryStereo = 1); }; } diff --git a/include/openpose/wrapper/wrapperStructOutput.hpp b/include/openpose/wrapper/wrapperStructOutput.hpp index 119cf691..5c5cac2f 100644 --- a/include/openpose/wrapper/wrapperStructOutput.hpp +++ b/include/openpose/wrapper/wrapperStructOutput.hpp @@ -8,34 +8,10 @@ namespace op { /** - * WrapperStructOutput: Output (small GUI, writing rendered results and/or pose data, etc.) configuration struct. - * WrapperStructOutput allows the user to set up the input frames generator. + * WrapperStructOutput: Output ( writing rendered results and/or pose data, etc.) configuration struct. */ struct OP_API WrapperStructOutput { - /** - * Display mode - * a) -1 for automatic selection. - * b) 0 for no display. Useful if there is no X server and/or to slightly speed up the processing if visual - * output is not required. - * c) 2 for 2-D display in the OpenPose small integrated GUI. - * d) 3 for 3-D display, if `--3d` was enabled. - * e) 1 for both 2-D and 3-D display. - */ - DisplayMode displayMode; - - /** - * Whether to add some information to the frame (number of frame, number people detected, etc.) after it is - * saved on disk and before it is displayed and/or returned to the user. - */ - bool guiVerbose; - - /** - * Whether to display the OpenPose small integrated GUI on fullscreen mode. It can be changed by interacting - * with the GUI itself. - */ - bool fullScreen; - /** * Pose (x, y, score) locations saving folder location. * If it is empty (default), it is disabled. @@ -145,16 +121,15 @@ namespace op * It has the recommended and default values we recommend for each element of the struct. * Since all the elements of the struct are public, they can also be manually filled. */ - WrapperStructOutput(const DisplayMode displayMode = DisplayMode::NoDisplay, const bool guiVerbose = false, - const bool fullScreen = false, const std::string& writeKeypoint = "", - const DataFormat writeKeypointFormat = DataFormat::Xml, - const std::string& writeJson = "", const std::string& writeCocoJson = "", - const std::string& writeCocoFootJson = "", const int writeCocoJsonVariant = 1, - const std::string& writeImages = "", const std::string& writeImagesFormat = "", - const std::string& writeVideo = "", const double writeVideoFps = 30., - const std::string& writeHeatMaps = "", const std::string& writeHeatMapsFormat = "", - const std::string& writeVideoAdam = "", const std::string& writeBvh = "", - const std::string& udpHost = "", const std::string& udpPort = ""); + WrapperStructOutput( + const std::string& writeKeypoint = "", const DataFormat writeKeypointFormat = DataFormat::Xml, + const std::string& writeJson = "", const std::string& writeCocoJson = "", + const std::string& writeCocoFootJson = "", const int writeCocoJsonVariant = 1, + const std::string& writeImages = "", const std::string& writeImagesFormat = "", + const std::string& writeVideo = "", const double writeVideoFps = 30., + const std::string& writeHeatMaps = "", const std::string& writeHeatMapsFormat = "", + const std::string& writeVideoAdam = "", const std::string& writeBvh = "", + const std::string& udpHost = "", const std::string& udpPort = ""); }; } diff --git a/include/openpose/wrapper/wrapperStructPose.hpp b/include/openpose/wrapper/wrapperStructPose.hpp index b7c4d382..1327038f 100644 --- a/include/openpose/wrapper/wrapperStructPose.hpp +++ b/include/openpose/wrapper/wrapperStructPose.hpp @@ -179,19 +179,18 @@ namespace op * It has the recommended and default values we recommend for each element of the struct. * Since all the elements of the struct are public, they can also be manually filled. */ - WrapperStructPose(const bool enable = true, const Point& netInputSize = Point{656, 368}, - const Point& outputSize = Point{-1, -1}, - const ScaleMode keypointScale = ScaleMode::InputResolution, - const int gpuNumber = -1, const int gpuNumberStart = 0, const int scalesNumber = 1, - const float scaleGap = 0.15f, const RenderMode renderMode = RenderMode::Gpu, - const PoseModel poseModel = PoseModel::BODY_25, const bool blendOriginalFrame = true, - const float alphaKeypoint = POSE_DEFAULT_ALPHA_KEYPOINT, - const float alphaHeatMap = POSE_DEFAULT_ALPHA_HEAT_MAP, - const int defaultPartToRender = 0, const std::string& modelFolder = "models/", - const std::vector& heatMapTypes = {}, - const ScaleMode heatMapScale = ScaleMode::ZeroToOne, const bool addPartCandidates = false, - const float renderThreshold = 0.05f, const int numberPeopleMax = -1, - const bool maximizePositives = false, const bool enableGoogleLogging = true); + WrapperStructPose( + const bool enable = true, const Point& netInputSize = Point{656, 368}, + const Point& outputSize = Point{-1, -1}, + const ScaleMode keypointScale = ScaleMode::InputResolution, const int gpuNumber = -1, + const int gpuNumberStart = 0, const int scalesNumber = 1, const float scaleGap = 0.15f, + const RenderMode renderMode = RenderMode::Gpu, const PoseModel poseModel = PoseModel::BODY_25, + const bool blendOriginalFrame = true, const float alphaKeypoint = POSE_DEFAULT_ALPHA_KEYPOINT, + const float alphaHeatMap = POSE_DEFAULT_ALPHA_HEAT_MAP, const int defaultPartToRender = 0, + const std::string& modelFolder = "models/", const std::vector& heatMapTypes = {}, + const ScaleMode heatMapScale = ScaleMode::ZeroToOne, const bool addPartCandidates = false, + const float renderThreshold = 0.05f, const int numberPeopleMax = -1, const bool maximizePositives = false, + const bool enableGoogleLogging = true); }; } diff --git a/src/openpose/pose/poseExtractorCaffe.cpp b/src/openpose/pose/poseExtractorCaffe.cpp index cf85b841..0e1d9c5e 100644 --- a/src/openpose/pose/poseExtractorCaffe.cpp +++ b/src/openpose/pose/poseExtractorCaffe.cpp @@ -98,7 +98,7 @@ namespace op getPoseNetDecreaseFactor(poseModel), 1.f/scaleInputToNetInput, true, gpuID); // Pose extractor blob and layer - nmsCaffe->Reshape({heatMapsBlob.get()}, {peaksBlob.get()}, getPoseMaxPeaks(poseModel), + nmsCaffe->Reshape({heatMapsBlob.get()}, {peaksBlob.get()}, getPoseMaxPeaks(), getPoseNumberBodyParts(poseModel), gpuID); // Pose extractor blob and layer bodyPartConnectorCaffe->Reshape({heatMapsBlob.get(), peaksBlob.get()}); diff --git a/src/openpose/pose/poseParameters.cpp b/src/openpose/pose/poseParameters.cpp index f88ee37b..fc0d154d 100644 --- a/src/openpose/pose/poseParameters.cpp +++ b/src/openpose/pose/poseParameters.cpp @@ -448,23 +448,6 @@ namespace op 16,18,17,18,16,19,17,19, 0,7,3,17,6,12,16,14, 6,21,7,20,3,21,20,14 }, }; - const std::array POSE_MAX_PEAKS{ - POSE_MAX_PEOPLE, // BODY_25 - POSE_MAX_PEOPLE, // COCO - POSE_MAX_PEOPLE, // MPI_15 - POSE_MAX_PEOPLE, // MPI_15_4 - POSE_MAX_PEOPLE, // BODY_19 - POSE_MAX_PEOPLE, // BODY_19_X2 - POSE_MAX_PEOPLE, // BODY_59 - POSE_MAX_PEOPLE, // BODY_19N - POSE_MAX_PEOPLE, // BODY_25E - POSE_MAX_PEOPLE, // BODY_25_19 - POSE_MAX_PEOPLE, // BODY_65 - POSE_MAX_PEOPLE, // CAR_12 - POSE_MAX_PEOPLE, // BODY_25D - POSE_MAX_PEOPLE, // BODY_23 - POSE_MAX_PEOPLE, // CAR_22 - }; const std::array POSE_CCN_DECREASE_FACTOR{ 8.f, // BODY_25 8.f, // COCO @@ -561,11 +544,11 @@ namespace op } } - unsigned int getPoseMaxPeaks(const PoseModel poseModel) + unsigned int getPoseMaxPeaks() { try { - return POSE_MAX_PEAKS.at((int)poseModel); + return POSE_MAX_PEOPLE; } catch (const std::exception& e) { diff --git a/src/openpose/wrapper/CMakeLists.txt b/src/openpose/wrapper/CMakeLists.txt index b53c1475..73c3cc48 100644 --- a/src/openpose/wrapper/CMakeLists.txt +++ b/src/openpose/wrapper/CMakeLists.txt @@ -3,6 +3,7 @@ set(SOURCES_OP_WRAPPER wrapperAuxiliary.cpp wrapperStructExtra.cpp wrapperStructFace.cpp + wrapperStructGui.cpp wrapperStructHand.cpp wrapperStructInput.cpp wrapperStructOutput.cpp diff --git a/src/openpose/wrapper/wrapperAuxiliary.cpp b/src/openpose/wrapper/wrapperAuxiliary.cpp index b36f953e..13403ff3 100644 --- a/src/openpose/wrapper/wrapperAuxiliary.cpp +++ b/src/openpose/wrapper/wrapperAuxiliary.cpp @@ -10,6 +10,7 @@ namespace op const WrapperStructExtra& wrapperStructExtra, const WrapperStructInput& wrapperStructInput, const WrapperStructOutput& wrapperStructOutput, + const WrapperStructGui& wrapperStructGui, const bool renderOutput, const bool userOutputWsEmpty, const std::shared_ptr& producerSharedPtr, @@ -66,7 +67,7 @@ namespace op const auto savingCvOutput = ( !wrapperStructOutput.writeImages.empty() || !wrapperStructOutput.writeVideo.empty() ); - const bool guiEnabled = (wrapperStructOutput.displayMode != DisplayMode::NoDisplay); + const bool guiEnabled = (wrapperStructGui.displayMode != DisplayMode::NoDisplay); if (!guiEnabled && !savingCvOutput && renderOutput) { const auto message = "GUI is not enabled and you are not saving the output frames. You should then" @@ -89,7 +90,7 @@ namespace op error(message, __LINE__, __FUNCTION__, __FILE__); } // Warnings - if (guiEnabled && wrapperStructOutput.guiVerbose && !renderOutput) + if (guiEnabled && wrapperStructGui.guiVerbose && !renderOutput) { const auto message = "No render is enabled (e.g., `--render_pose 0`), so you might also want to" " remove the display (set `--display 0` or `--no_gui_verbose`). If you" diff --git a/src/openpose/wrapper/wrapperStructGui.cpp b/src/openpose/wrapper/wrapperStructGui.cpp new file mode 100644 index 00000000..eb2089dd --- /dev/null +++ b/src/openpose/wrapper/wrapperStructGui.cpp @@ -0,0 +1,12 @@ +#include + +namespace op +{ + WrapperStructGui::WrapperStructGui( + const DisplayMode displayMode_, const bool guiVerbose_, const bool fullScreen_) : + displayMode{displayMode_}, + guiVerbose{guiVerbose_}, + fullScreen{fullScreen_} + { + } +} diff --git a/src/openpose/wrapper/wrapperStructOutput.cpp b/src/openpose/wrapper/wrapperStructOutput.cpp index c06120d7..30fd47e8 100644 --- a/src/openpose/wrapper/wrapperStructOutput.cpp +++ b/src/openpose/wrapper/wrapperStructOutput.cpp @@ -3,16 +3,12 @@ namespace op { WrapperStructOutput::WrapperStructOutput( - const DisplayMode displayMode_, const bool guiVerbose_, const bool fullScreen_, const std::string& writeKeypoint_, const DataFormat writeKeypointFormat_, const std::string& writeJson_, const std::string& writeCocoJson_, const std::string& writeCocoFootJson_, const int writeCocoJsonVariant_, const std::string& writeImages_, const std::string& writeImagesFormat_, const std::string& writeVideo_, const double writeVideoFps_, const std::string& writeHeatMaps_, const std::string& writeHeatMapsFormat_, const std::string& writeVideoAdam_, const std::string& writeBvh_, const std::string& udpHost_, const std::string& udpPort_) : - displayMode{displayMode_}, - guiVerbose{guiVerbose_}, - fullScreen{fullScreen_}, writeKeypoint{writeKeypoint_}, writeKeypointFormat{writeKeypointFormat_}, writeJson{writeJson_},