From d2dc99634e5f497fd97faf150228dd62a27c58cd Mon Sep 17 00:00:00 2001 From: gineshidalgo99 Date: Thu, 15 Nov 2018 12:35:26 -0500 Subject: [PATCH] Added flag maximize_positives --- CMakeLists.txt | 4 +- doc/demo_overview.md | 1 + doc/release_notes.md | 3 + examples/openpose/openpose.cpp | 2 +- examples/tests/drawProtoTxt.sh | 4 ++ examples/tests/handFromJsonTest.cpp | 2 +- examples/tests/hand_accuracy_test.sh | 4 ++ examples/tests/pose_accuracy_car_val.sh | 4 ++ examples/tests/pose_accuracy_coco_test_dev.sh | 4 ++ examples/tests/pose_accuracy_coco_val.sh | 9 ++- examples/tests/pose_accuracy_coco_val_2014.sh | 4 ++ examples/tests/pose_accuracy_coco_val_foot.sh | 4 ++ .../tests/pose_accuracy_coco_val_server.sh | 4 ++ .../pose_accuracy_coco_val_server_2014.sh | 4 ++ examples/tests/pose_time_Caffe_layers.sh | 4 ++ examples/tests/pose_time_visual_GUI.sh | 4 ++ examples/tests/speed_test.sh | 4 ++ .../1_custom_post_processing.cpp | 2 +- .../3_keypoints_from_image_configurable.cpp | 2 +- ...nchronous_loop_custom_input_and_output.cpp | 2 +- .../5_asynchronous_loop_custom_output.cpp | 2 +- .../6_synchronous_custom_postprocessing.cpp | 2 +- .../7_synchronous_custom_input.cpp | 2 +- .../8_synchronous_custom_output.cpp | 2 +- .../9_synchronous_custom_all.cpp | 2 +- include/openpose/flags.hpp | 2 + .../openpose/net/bodyPartConnectorBase.hpp | 7 ++- .../openpose/net/bodyPartConnectorCaffe.hpp | 3 + include/openpose/pose/poseExtractorCaffe.hpp | 1 + include/openpose/pose/poseExtractorNet.hpp | 3 +- include/openpose/pose/poseParameters.hpp | 13 ++--- include/openpose/wrapper/wrapperAuxiliary.hpp | 3 +- .../openpose/wrapper/wrapperStructPose.hpp | 9 ++- src/openpose/net/bodyPartConnectorBase.cpp | 18 +++--- src/openpose/net/bodyPartConnectorBase.cu | 16 ++--- src/openpose/net/bodyPartConnectorCaffe.cpp | 30 +++++++--- src/openpose/pose/poseExtractorCaffe.cpp | 5 +- src/openpose/pose/poseExtractorNet.cpp | 18 +++--- src/openpose/pose/poseParameters.cpp | 58 ++++++++----------- src/openpose/wrapper/wrapperStructExtra.cpp | 6 +- src/openpose/wrapper/wrapperStructFace.cpp | 6 +- src/openpose/wrapper/wrapperStructHand.cpp | 8 +-- src/openpose/wrapper/wrapperStructInput.cpp | 13 ++--- src/openpose/wrapper/wrapperStructOutput.cpp | 18 +++--- src/openpose/wrapper/wrapperStructPose.cpp | 21 +++---- ubuntu_deprecated/Makefile.example | 3 +- 46 files changed, 206 insertions(+), 136 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b0986a0e..9cb034fc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -802,10 +802,10 @@ if (WITH_CERES) include_directories(${CERES_INCLUDE_DIRS}) endif (WITH_CERES) if (WITH_FLIR_CAMERA) - include_directories(${SPINNAKER_INCLUDE_DIRS}) + include_directories(SYSTEM ${SPINNAKER_INCLUDE_DIRS}) # To remove its warnings, equiv. to -isystem endif (WITH_FLIR_CAMERA) if (WITH_3D_ADAM_MODEL) - include_directories(include/adam) # TEMPORARY - TO BE REMOVED IN THE FUTURE + include_directories(include/adam) # TODO: TEMPORARY - TO BE REMOVED IN THE FUTURE include_directories(${CERES_INCLUDE_DIRS}) include_directories(${EIGEN3_INCLUDE_DIRS}) include_directories(${IGL_INCLUDE_DIRS}) diff --git a/doc/demo_overview.md b/doc/demo_overview.md index cfd2ee63..81cb61ac 100644 --- a/doc/demo_overview.md +++ b/doc/demo_overview.md @@ -161,6 +161,7 @@ Each flag is divided into flag name, default value, and description. - DEFINE_int32(num_gpu_start, 0, "GPU device start number."); - DEFINE_int32(keypoint_scale, 0, "Scaling of the (x,y) coordinates of the final pose data array, i.e., the scale of the (x,y) coordinates that will be saved with the `write_json` & `write_keypoint` flags. Select `0` to scale it to the original source resolution; `1`to scale it to the net output size (set with `net_resolution`); `2` to scale it to the final output size (set with `resolution`); `3` to scale it in the range [0,1], where (0,0) would be the top-left corner of the image, and (1,1) the bottom-right one; and 4 for range [-1,1], where (-1,-1) would be the top-left corner of the image, and (1,1) the bottom-right one. Non related with `scale_number` and `scale_gap`."); - DEFINE_int32(number_people_max, -1, "This parameter will limit the maximum number of people detected, by keeping the people with top scores. The score is based in person area over the image, body part score, as well as joint score (between each pair of connected body parts). Useful if you know the exact number of people in the scene, so it can remove false positives (if all the people have been detected. However, it might also include false negatives by removing very small or highly occluded people. -1 will keep them all."); +- DEFINE_bool(maximize_positives, false, "It reduces the thresholds to accept a person candidate. It highly increases both false and true positives. I.e., it maximizes average recall but could harm average precision."); 4. OpenPose Body Pose - DEFINE_bool(body_disable, false, "Disable body keypoint detection. Option only possible for faster (but less accurate) face keypoint detection."); diff --git a/doc/release_notes.md b/doc/release_notes.md index 024bc36e..d05d1d7a 100644 --- a/doc/release_notes.md +++ b/doc/release_notes.md @@ -286,11 +286,14 @@ OpenPose Library - Release Notes 15. Function `resizeFixedAspectRatio` can take already allocated memory (e.g., faster if target is an Array object, no intermediate cv::Mat required). 16. Added compatibility for OpenCV 4.0, while preserving 2.4.X and 3.X compatibility. 17. Improved and added several functions to `utilities/keypoints.hpp` and Array to simplify keypoint post-processing. + 18. Removed warnings from Spinnaker SDK at compiling time. + 19. All bash scripts incorporate `#!/bin/bash` to tell the terminal that they are bash scripts. 2. Functions or parameters renamed: 1. By default, python example `tutorial_developer/python_2_pose_from_heatmaps.py` was using 2 scales starting at -1x736, changed to 1 scale at -1x368. 2. WrapperStructPose default parameters changed to match those of the OpenPose demo binary. 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`. 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 f66e8116..478dccf4 100755 --- a/examples/openpose/openpose.cpp +++ b/examples/openpose/openpose.cpp @@ -72,7 +72,7 @@ int openPoseDemo() 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}; + (float)FLAGS_render_threshold, FLAGS_number_people_max, FLAGS_maximize_positives, enableGoogleLogging}; opWrapper.configure(wrapperStructPose); // Face configuration (use op::WrapperStructFace{} to disable it) const op::WrapperStructFace wrapperStructFace{ diff --git a/examples/tests/drawProtoTxt.sh b/examples/tests/drawProtoTxt.sh index 382f1547..e9696b85 100755 --- a/examples/tests/drawProtoTxt.sh +++ b/examples/tests/drawProtoTxt.sh @@ -1,3 +1,7 @@ +#!/bin/bash + + + # Script for internal use. We might completely change it continuously and we will not answer questions about it. # Required diff --git a/examples/tests/handFromJsonTest.cpp b/examples/tests/handFromJsonTest.cpp index da39d01a..a17db9c1 100644 --- a/examples/tests/handFromJsonTest.cpp +++ b/examples/tests/handFromJsonTest.cpp @@ -55,7 +55,7 @@ int handFromJsonTest() op::ScaleMode::InputResolution, FLAGS_num_gpu, FLAGS_num_gpu_start, 1, 0.15f, op::RenderMode::None, op::PoseModel::BODY_25, true, 0.f, 0.f, 0, "models/", {}, op::ScaleMode::ZeroToOne, false, - 0.05f, -1, enableGoogleLogging}; + 0.05f, -1, false, enableGoogleLogging}; wrapperStructPose.modelFolder = FLAGS_model_folder; // Hand configuration (use op::WrapperStructHand{} to disable it) const op::WrapperStructHand wrapperStructHand{FLAGS_hand, handNetInputSize, FLAGS_hand_scale_number, diff --git a/examples/tests/hand_accuracy_test.sh b/examples/tests/hand_accuracy_test.sh index 7bed49e3..d5d89029 100755 --- a/examples/tests/hand_accuracy_test.sh +++ b/examples/tests/hand_accuracy_test.sh @@ -1,3 +1,7 @@ +#!/bin/bash + + + # Disclaimer: # Script for internal use. We might make continuous changess on it and we will not answer questions about it. diff --git a/examples/tests/pose_accuracy_car_val.sh b/examples/tests/pose_accuracy_car_val.sh index ce197199..82c7dd5b 100644 --- a/examples/tests/pose_accuracy_car_val.sh +++ b/examples/tests/pose_accuracy_car_val.sh @@ -1,3 +1,7 @@ +#!/bin/bash + + + # Script for internal use. We might completely change it continuously and we will not answer questions about it. clear && clear diff --git a/examples/tests/pose_accuracy_coco_test_dev.sh b/examples/tests/pose_accuracy_coco_test_dev.sh index 5dc489e6..b4330494 100755 --- a/examples/tests/pose_accuracy_coco_test_dev.sh +++ b/examples/tests/pose_accuracy_coco_test_dev.sh @@ -1,3 +1,7 @@ +#!/bin/bash + + + # Script for internal use. We might completely change it continuously and we will not answer questions about it. clear && clear diff --git a/examples/tests/pose_accuracy_coco_val.sh b/examples/tests/pose_accuracy_coco_val.sh index e0ae642a..72ca1ce4 100755 --- a/examples/tests/pose_accuracy_coco_val.sh +++ b/examples/tests/pose_accuracy_coco_val.sh @@ -1,3 +1,7 @@ +#!/bin/bash + + + # Script for internal use. We might completely change it continuously and we will not answer questions about it. clear && clear @@ -21,6 +25,7 @@ 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 +# $OP_BIN --image_dir $IMAGE_FOLDER --write_coco_json ${JSON_FOLDER}1_max.json --display 0 --render_pose 0 --maximize_positives --model_pose BODY_25E # 1 scale - Debugging # $OP_BIN --image_dir $IMAGE_FOLDER --write_coco_json ${JSON_FOLDER}1.json --display 0 --write_images ~/Desktop/CppValidation/ @@ -30,6 +35,4 @@ $OP_BIN --image_dir $IMAGE_FOLDER --write_coco_json ${JSON_FOLDER}1.json --displ # # 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" - -# # Debugging - Rendered frames saved -# $OP_BIN --image_dir $IMAGE_FOLDER --write_images ${JSON_FOLDER}frameOutput --display 0 +# $OP_BIN --image_dir $IMAGE_FOLDER --write_coco_json ${JSON_FOLDER}1_4_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_2014.sh b/examples/tests/pose_accuracy_coco_val_2014.sh index 0c775fc3..560bc414 100755 --- a/examples/tests/pose_accuracy_coco_val_2014.sh +++ b/examples/tests/pose_accuracy_coco_val_2014.sh @@ -1,3 +1,7 @@ +#!/bin/bash + + + # Script for internal use. We might completely change it continuously and we will not answer questions about it. clear && clear diff --git a/examples/tests/pose_accuracy_coco_val_foot.sh b/examples/tests/pose_accuracy_coco_val_foot.sh index a7c2fc2b..1d58a5cd 100644 --- a/examples/tests/pose_accuracy_coco_val_foot.sh +++ b/examples/tests/pose_accuracy_coco_val_foot.sh @@ -1,3 +1,7 @@ +#!/bin/bash + + + # Script for internal use. We might completely change it continuously and we will not answer questions about it. clear && clear diff --git a/examples/tests/pose_accuracy_coco_val_server.sh b/examples/tests/pose_accuracy_coco_val_server.sh index 678681ff..107b1ec3 100755 --- a/examples/tests/pose_accuracy_coco_val_server.sh +++ b/examples/tests/pose_accuracy_coco_val_server.sh @@ -1,3 +1,7 @@ +#!/bin/bash + + + # Script for internal use. We might completely change it continuously and we will not answer questions about it. clear && clear diff --git a/examples/tests/pose_accuracy_coco_val_server_2014.sh b/examples/tests/pose_accuracy_coco_val_server_2014.sh index 0526dc33..cfab7bf9 100755 --- a/examples/tests/pose_accuracy_coco_val_server_2014.sh +++ b/examples/tests/pose_accuracy_coco_val_server_2014.sh @@ -1,3 +1,7 @@ +#!/bin/bash + + + # Script for internal use. We might completely change it continuously and we will not answer questions about it. clear && clear diff --git a/examples/tests/pose_time_Caffe_layers.sh b/examples/tests/pose_time_Caffe_layers.sh index e213a117..77d720d3 100755 --- a/examples/tests/pose_time_Caffe_layers.sh +++ b/examples/tests/pose_time_Caffe_layers.sh @@ -1,3 +1,7 @@ +#!/bin/bash + + + # Script for internal use. We might completely change it continuously and we will not answer questions about it. # # Go back to main folder diff --git a/examples/tests/pose_time_visual_GUI.sh b/examples/tests/pose_time_visual_GUI.sh index 48e115a4..54e33e08 100755 --- a/examples/tests/pose_time_visual_GUI.sh +++ b/examples/tests/pose_time_visual_GUI.sh @@ -1,3 +1,7 @@ +#!/bin/bash + + + # Script for internal use. We might completely change it continuously and we will not answer questions about it. # # Go back to main folder diff --git a/examples/tests/speed_test.sh b/examples/tests/speed_test.sh index bb09195d..5eb5fe4a 100755 --- a/examples/tests/speed_test.sh +++ b/examples/tests/speed_test.sh @@ -1,3 +1,7 @@ +#!/bin/bash + + + # Script for internal use. We might completely change it continuously and we will not answer questions about it. # USAGE EXAMPLE diff --git a/examples/tutorial_add_module/1_custom_post_processing.cpp b/examples/tutorial_add_module/1_custom_post_processing.cpp index 52977049..45e605f7 100644 --- a/examples/tutorial_add_module/1_custom_post_processing.cpp +++ b/examples/tutorial_add_module/1_custom_post_processing.cpp @@ -85,7 +85,7 @@ int tutorialAddModule1() 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}; + (float)FLAGS_render_threshold, FLAGS_number_people_max, FLAGS_maximize_positives, enableGoogleLogging}; opWrapperT.configure(wrapperStructPose); // Face configuration (use op::WrapperStructFace{} to disable it) const op::WrapperStructFace wrapperStructFace{ 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 a719643f..e183b224 100644 --- a/examples/tutorial_api_cpp/3_keypoints_from_image_configurable.cpp +++ b/examples/tutorial_api_cpp/3_keypoints_from_image_configurable.cpp @@ -91,7 +91,7 @@ int tutorialApiCpp3() 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}; + (float)FLAGS_render_threshold, FLAGS_number_people_max, FLAGS_maximize_positives, enableGoogleLogging}; opWrapper.configure(wrapperStructPose); // Face configuration (use op::WrapperStructFace{} to disable it) const op::WrapperStructFace wrapperStructFace{ 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 45062d4b..dd3f554a 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 @@ -224,7 +224,7 @@ int tutorialApiCpp4() 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}; + (float)FLAGS_render_threshold, FLAGS_number_people_max, FLAGS_maximize_positives, enableGoogleLogging}; opWrapperT.configure(wrapperStructPose); // Face configuration (use op::WrapperStructFace{} to disable it) const op::WrapperStructFace wrapperStructFace{ 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 e8491a06..2e4b42ac 100644 --- a/examples/tutorial_api_cpp/5_asynchronous_loop_custom_output.cpp +++ b/examples/tutorial_api_cpp/5_asynchronous_loop_custom_output.cpp @@ -167,7 +167,7 @@ int tutorialApiCpp5() 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}; + (float)FLAGS_render_threshold, FLAGS_number_people_max, FLAGS_maximize_positives, enableGoogleLogging}; opWrapperT.configure(wrapperStructPose); // Face configuration (use op::WrapperStructFace{} to disable it) const op::WrapperStructFace wrapperStructFace{ diff --git a/examples/tutorial_api_cpp/6_synchronous_custom_postprocessing.cpp b/examples/tutorial_api_cpp/6_synchronous_custom_postprocessing.cpp index 3040f07b..eadda936 100644 --- a/examples/tutorial_api_cpp/6_synchronous_custom_postprocessing.cpp +++ b/examples/tutorial_api_cpp/6_synchronous_custom_postprocessing.cpp @@ -135,7 +135,7 @@ int tutorialApiCpp6() 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}; + (float)FLAGS_render_threshold, FLAGS_number_people_max, FLAGS_maximize_positives, enableGoogleLogging}; opWrapperT.configure(wrapperStructPose); // Face configuration (use op::WrapperStructFace{} to disable it) const op::WrapperStructFace wrapperStructFace{ diff --git a/examples/tutorial_api_cpp/7_synchronous_custom_input.cpp b/examples/tutorial_api_cpp/7_synchronous_custom_input.cpp index cf36caea..13b0f053 100644 --- a/examples/tutorial_api_cpp/7_synchronous_custom_input.cpp +++ b/examples/tutorial_api_cpp/7_synchronous_custom_input.cpp @@ -175,7 +175,7 @@ int tutorialApiCpp7() 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}; + (float)FLAGS_render_threshold, FLAGS_number_people_max, FLAGS_maximize_positives, enableGoogleLogging}; opWrapperT.configure(wrapperStructPose); // Face configuration (use op::WrapperStructFace{} to disable it) const op::WrapperStructFace wrapperStructFace{ diff --git a/examples/tutorial_api_cpp/8_synchronous_custom_output.cpp b/examples/tutorial_api_cpp/8_synchronous_custom_output.cpp index bcda556a..6ed1567f 100644 --- a/examples/tutorial_api_cpp/8_synchronous_custom_output.cpp +++ b/examples/tutorial_api_cpp/8_synchronous_custom_output.cpp @@ -182,7 +182,7 @@ int tutorialApiCpp8() 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}; + (float)FLAGS_render_threshold, FLAGS_number_people_max, FLAGS_maximize_positives, enableGoogleLogging}; opWrapperT.configure(wrapperStructPose); // Face configuration (use op::WrapperStructFace{} to disable it) const op::WrapperStructFace wrapperStructFace{ diff --git a/examples/tutorial_api_cpp/9_synchronous_custom_all.cpp b/examples/tutorial_api_cpp/9_synchronous_custom_all.cpp index 8d3111d4..8ca50da5 100644 --- a/examples/tutorial_api_cpp/9_synchronous_custom_all.cpp +++ b/examples/tutorial_api_cpp/9_synchronous_custom_all.cpp @@ -281,7 +281,7 @@ int tutorialApiCpp9() 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}; + (float)FLAGS_render_threshold, FLAGS_number_people_max, FLAGS_maximize_positives, enableGoogleLogging}; opWrapperT.configure(wrapperStructPose); // Face configuration (use op::WrapperStructFace{} to disable it) const op::WrapperStructFace wrapperStructFace{ diff --git a/include/openpose/flags.hpp b/include/openpose/flags.hpp index 44b5622e..1083a4e9 100644 --- a/include/openpose/flags.hpp +++ b/include/openpose/flags.hpp @@ -82,6 +82,8 @@ DEFINE_int32(number_people_max, -1, "This parameter will lim " number of people in the scene, so it can remove false positives (if all the people have" " been detected. However, it might also include false negatives by removing very small or" " highly occluded people. -1 will keep them all."); +DEFINE_bool(maximize_positives, false, "It reduces the thresholds to accept a person candidate. It highly increases both false and" + " true positives. I.e., it maximizes average recall but could harm average precision."); // OpenPose Body Pose DEFINE_bool(body_disable, false, "Disable body keypoint detection. Option only possible for faster (but less accurate) face" " keypoint detection."); diff --git a/include/openpose/net/bodyPartConnectorBase.hpp b/include/openpose/net/bodyPartConnectorBase.hpp index 4cbc1038..1a1f9431 100644 --- a/include/openpose/net/bodyPartConnectorBase.hpp +++ b/include/openpose/net/bodyPartConnectorBase.hpp @@ -10,7 +10,8 @@ namespace op void connectBodyPartsCpu( Array& poseKeypoints, Array& poseScores, const T* const heatMapPtr, const T* const peaksPtr, const PoseModel poseModel, const Point& heatMapSize, const int maxPeaks, const T interMinAboveThreshold, - const T interThreshold, const int minSubsetCnt, const T minSubsetScore, const T scaleFactor = 1.f); + const T interThreshold, const int minSubsetCnt, const T minSubsetScore, const T scaleFactor = 1.f, + const bool maximizePositives = false); // Windows: Cuda functions do not include OP_API template @@ -18,7 +19,7 @@ namespace op Array& poseKeypoints, Array& poseScores, const T* const heatMapGpuPtr, const T* const peaksPtr, const PoseModel poseModel, const Point& heatMapSize, const int maxPeaks, const T interMinAboveThreshold, const T interThreshold, const int minSubsetCnt, const T minSubsetScore, const T scaleFactor = 1.f, - Array pairScoresCpu = Array{}, T* pairScoresGpuPtr = nullptr, + const bool maximizePositives = false, Array pairScoresCpu = Array{}, T* pairScoresGpuPtr = nullptr, const unsigned int* const bodyPartPairsGpuPtr = nullptr, const unsigned int* const mapIdxGpuPtr = nullptr, const T* const peaksGpuPtr = nullptr); @@ -34,7 +35,7 @@ namespace op void removePeopleBelowThresholds(std::vector& validSubsetIndexes, int& numberPeople, const std::vector, T>>& subsets, const unsigned int numberBodyParts, const int minSubsetCnt, - const T minSubsetScore, const int maxPeaks); + const T minSubsetScore, const int maxPeaks, const bool maximizePositives); template void peopleVectorToPeopleArray(Array& poseKeypoints, Array& poseScores, const T scaleFactor, diff --git a/include/openpose/net/bodyPartConnectorCaffe.hpp b/include/openpose/net/bodyPartConnectorCaffe.hpp index 4fd625ed..f83284fc 100644 --- a/include/openpose/net/bodyPartConnectorCaffe.hpp +++ b/include/openpose/net/bodyPartConnectorCaffe.hpp @@ -23,6 +23,8 @@ namespace op void setPoseModel(const PoseModel poseModel); + void setMaximizePositives(const bool maximizePositives); + void setInterMinAboveThreshold(const T interMinAboveThreshold); void setInterThreshold(const T interThreshold); @@ -50,6 +52,7 @@ namespace op private: PoseModel mPoseModel; + bool mMaximizePositives; T mInterMinAboveThreshold; T mInterThreshold; int mMinSubsetCnt; diff --git a/include/openpose/pose/poseExtractorCaffe.hpp b/include/openpose/pose/poseExtractorCaffe.hpp index bdb9df25..091764c9 100644 --- a/include/openpose/pose/poseExtractorCaffe.hpp +++ b/include/openpose/pose/poseExtractorCaffe.hpp @@ -14,6 +14,7 @@ namespace op const std::vector& heatMapTypes = {}, const ScaleMode heatMapScale = ScaleMode::ZeroToOne, const bool addPartCandidates = false, + const bool maximizePositives = false, const bool enableGoogleLogging = true); virtual ~PoseExtractorCaffe(); diff --git a/include/openpose/pose/poseExtractorNet.hpp b/include/openpose/pose/poseExtractorNet.hpp index 8758b87f..327c5bb4 100644 --- a/include/openpose/pose/poseExtractorNet.hpp +++ b/include/openpose/pose/poseExtractorNet.hpp @@ -14,7 +14,8 @@ namespace op PoseExtractorNet(const PoseModel poseModel, const std::vector& heatMapTypes = {}, const ScaleMode heatMapScale = ScaleMode::ZeroToOne, - const bool addPartCandidates = false); + const bool addPartCandidates = false, + const bool maximizePositives = false); virtual ~PoseExtractorNet(); diff --git a/include/openpose/pose/poseParameters.hpp b/include/openpose/pose/poseParameters.hpp index 37dd9f1d..5780adc3 100644 --- a/include/openpose/pose/poseParameters.hpp +++ b/include/openpose/pose/poseParameters.hpp @@ -26,14 +26,11 @@ namespace op OP_API unsigned int poseBodyPartMapStringToKey(const PoseModel poseModel, const std::vector& strings); // Default NSM and body connector parameters - OP_API float getPoseDefaultNmsThreshold(const PoseModel poseModel); - OP_API float getPoseDefaultConnectInterMinAboveThreshold(const PoseModel poseModel); - OP_API float getPoseDefaultConnectInterThreshold(const PoseModel poseModel); - OP_API unsigned int getPoseDefaultMinSubsetCnt(const PoseModel poseModel); - OP_API float getPoseDefaultConnectMinSubsetScore(const PoseModel poseModel); - - // const bool COCO_CHALLENGE = true; - const bool COCO_CHALLENGE = false; + OP_API float getPoseDefaultNmsThreshold(const PoseModel poseModel, const bool maximizePositives = false); + OP_API float getPoseDefaultConnectInterMinAboveThreshold(const bool maximizePositives = false); + OP_API float getPoseDefaultConnectInterThreshold(const PoseModel poseModel, const bool maximizePositives = false); + OP_API unsigned int getPoseDefaultMinSubsetCnt(const bool maximizePositives = false); + OP_API float getPoseDefaultConnectMinSubsetScore(const bool maximizePositives = false); } #endif // OPENPOSE_POSE_POSE_PARAMETERS_HPP diff --git a/include/openpose/wrapper/wrapperAuxiliary.hpp b/include/openpose/wrapper/wrapperAuxiliary.hpp index 5aee5547..27639b27 100644 --- a/include/openpose/wrapper/wrapperAuxiliary.hpp +++ b/include/openpose/wrapper/wrapperAuxiliary.hpp @@ -263,7 +263,8 @@ namespace op poseExtractorNets.emplace_back(std::make_shared( wrapperStructPose.poseModel, modelFolder, gpuId + gpuNumberStart, wrapperStructPose.heatMapTypes, wrapperStructPose.heatMapScale, - wrapperStructPose.addPartCandidates, wrapperStructPose.enableGoogleLogging + wrapperStructPose.addPartCandidates, wrapperStructPose.maximizePositives, + wrapperStructPose.enableGoogleLogging )); // Pose renderers diff --git a/include/openpose/wrapper/wrapperStructPose.hpp b/include/openpose/wrapper/wrapperStructPose.hpp index 8f22118a..b7c4d382 100644 --- a/include/openpose/wrapper/wrapperStructPose.hpp +++ b/include/openpose/wrapper/wrapperStructPose.hpp @@ -158,6 +158,13 @@ namespace op */ int numberPeopleMax; + /** + * Whether to maximize the number of positives. + * It reduces the thresholds to accept a person candidate. It highly increases both false and true positives. + * I.e., it maximizes average recall but could harm average precision. + */ + bool maximizePositives; + /** * Whether to internally enable Google Logging. * This option is only applicable if Caffe is used. @@ -184,7 +191,7 @@ namespace op const std::vector& heatMapTypes = {}, const ScaleMode heatMapScale = ScaleMode::ZeroToOne, const bool addPartCandidates = false, const float renderThreshold = 0.05f, const int numberPeopleMax = -1, - const bool enableGoogleLogging = true); + const bool maximizePositives = false, const bool enableGoogleLogging = true); }; } diff --git a/src/openpose/net/bodyPartConnectorBase.cpp b/src/openpose/net/bodyPartConnectorBase.cpp index 9e0a4228..0d66177d 100644 --- a/src/openpose/net/bodyPartConnectorBase.cpp +++ b/src/openpose/net/bodyPartConnectorBase.cpp @@ -617,7 +617,8 @@ namespace op void removePeopleBelowThresholds(std::vector& validSubsetIndexes, int& numberPeople, const std::vector, T>>& peopleVector, const unsigned int numberBodyParts, const int minSubsetCnt, - const T minSubsetScore, const int maxPeaks) + const T minSubsetScore, const int maxPeaks, + const bool maximizePositives) { try { @@ -635,7 +636,7 @@ namespace op // same foot usually appears as both left and right keypoints) // Pros: Removed tons of false positives // Cons: Standalone leg will never be recorded - if (!COCO_CHALLENGE && numberBodyParts == 25) + if (!maximizePositives && numberBodyParts == 25) { // No consider foot keypoints for that for (auto i = 19 ; i < 25 ; i++) @@ -1097,7 +1098,8 @@ namespace op void connectBodyPartsCpu(Array& poseKeypoints, Array& poseScores, const T* const heatMapPtr, const T* const peaksPtr, const PoseModel poseModel, const Point& heatMapSize, const int maxPeaks, const T interMinAboveThreshold, const T interThreshold, - const int minSubsetCnt, const T minSubsetScore, const T scaleFactor) + const int minSubsetCnt, const T minSubsetScore, const T scaleFactor, + const bool maximizePositives) { try { @@ -1124,7 +1126,7 @@ namespace op std::vector validSubsetIndexes; validSubsetIndexes.reserve(fastMin((size_t)maxPeaks, peopleVector.size())); removePeopleBelowThresholds(validSubsetIndexes, numberPeople, peopleVector, numberBodyParts, minSubsetCnt, - minSubsetScore, maxPeaks); + minSubsetScore, maxPeaks, maximizePositives); // Fill and return poseKeypoints peopleVectorToPeopleArray(poseKeypoints, poseScores, scaleFactor, peopleVector, validSubsetIndexes, @@ -1148,12 +1150,12 @@ namespace op Array& poseKeypoints, Array& poseScores, const float* const heatMapPtr, const float* const peaksPtr, const PoseModel poseModel, const Point& heatMapSize, const int maxPeaks, const float interMinAboveThreshold, const float interThreshold, const int minSubsetCnt, - const float minSubsetScore, const float scaleFactor); + const float minSubsetScore, const float scaleFactor, const bool maximizePositives); template OP_API void connectBodyPartsCpu( Array& poseKeypoints, Array& poseScores, const double* const heatMapPtr, const double* const peaksPtr, const PoseModel poseModel, const Point& heatMapSize, const int maxPeaks, const double interMinAboveThreshold, const double interThreshold, const int minSubsetCnt, - const double minSubsetScore, const double scaleFactor); + const double minSubsetScore, const double scaleFactor, const bool maximizePositives); template OP_API std::vector, float>> createPeopleVector( const float* const heatMapPtr, const float* const peaksPtr, const PoseModel poseModel, @@ -1172,12 +1174,12 @@ namespace op std::vector& validSubsetIndexes, int& numberPeople, const std::vector, float>>& peopleVector, const unsigned int numberBodyParts, - const int minSubsetCnt, const float minSubsetScore, const int maxPeaks); + const int minSubsetCnt, const float minSubsetScore, const int maxPeaks, const bool maximizePositives); template OP_API void removePeopleBelowThresholds( std::vector& validSubsetIndexes, int& numberPeople, const std::vector, double>>& peopleVector, const unsigned int numberBodyParts, - const int minSubsetCnt, const double minSubsetScore, const int maxPeaks); + const int minSubsetCnt, const double minSubsetScore, const int maxPeaks, const bool maximizePositives); template OP_API void peopleVectorToPeopleArray( Array& poseKeypoints, Array& poseScores, const float scaleFactor, diff --git a/src/openpose/net/bodyPartConnectorBase.cu b/src/openpose/net/bodyPartConnectorBase.cu index 45029c6c..1aec262a 100644 --- a/src/openpose/net/bodyPartConnectorBase.cu +++ b/src/openpose/net/bodyPartConnectorBase.cu @@ -111,7 +111,7 @@ namespace op const T* const peaksPtr, const PoseModel poseModel, const Point& heatMapSize, const int maxPeaks, const T interMinAboveThreshold, const T interThreshold, const int minSubsetCnt, const T minSubsetScore, const T scaleFactor, - Array pairScoresCpu, T* pairScoresGpuPtr, + const bool maximizePositives, Array pairScoresCpu, T* pairScoresGpuPtr, const unsigned int* const bodyPartPairsGpuPtr, const unsigned int* const mapIdxGpuPtr, const T* const peaksGpuPtr) { @@ -169,7 +169,7 @@ namespace op std::vector validSubsetIndexes; validSubsetIndexes.reserve(fastMin((size_t)maxPeaks, peopleVector.size())); removePeopleBelowThresholds(validSubsetIndexes, numberPeople, peopleVector, numberBodyParts, minSubsetCnt, - minSubsetScore, maxPeaks); + minSubsetScore, maxPeaks, maximizePositives); // Fill and return poseKeypoints peopleVectorToPeopleArray(poseKeypoints, poseScores, scaleFactor, peopleVector, validSubsetIndexes, @@ -188,14 +188,14 @@ namespace op Array& poseKeypoints, Array& poseScores, const float* const heatMapGpuPtr, const float* const peaksPtr, const PoseModel poseModel, const Point& heatMapSize, const int maxPeaks, const float interMinAboveThreshold, const float interThreshold, const int minSubsetCnt, - const float minSubsetScore, const float scaleFactor, Array pairScoresCpu, float* pairScoresGpuPtr, - const unsigned int* const bodyPartPairsGpuPtr, const unsigned int* const mapIdxGpuPtr, - const float* const peaksGpuPtr); + const float minSubsetScore, const float scaleFactor, const bool maximizePositives, + Array pairScoresCpu, float* pairScoresGpuPtr, const unsigned int* const bodyPartPairsGpuPtr, + const unsigned int* const mapIdxGpuPtr, const float* const peaksGpuPtr); template void connectBodyPartsGpu( Array& poseKeypoints, Array& poseScores, const double* const heatMapGpuPtr, const double* const peaksPtr, const PoseModel poseModel, const Point& heatMapSize, const int maxPeaks, const double interMinAboveThreshold, const double interThreshold, const int minSubsetCnt, - const double minSubsetScore, const double scaleFactor, Array pairScoresCpu, double* pairScoresGpuPtr, - const unsigned int* const bodyPartPairsGpuPtr, const unsigned int* const mapIdxGpuPtr, - const double* const peaksGpuPtr); + const double minSubsetScore, const double scaleFactor, const bool maximizePositives, + Array pairScoresCpu, double* pairScoresGpuPtr, const unsigned int* const bodyPartPairsGpuPtr, + const unsigned int* const mapIdxGpuPtr, const double* const peaksGpuPtr); } diff --git a/src/openpose/net/bodyPartConnectorCaffe.cpp b/src/openpose/net/bodyPartConnectorCaffe.cpp index 3cd25137..7c9efa53 100644 --- a/src/openpose/net/bodyPartConnectorCaffe.cpp +++ b/src/openpose/net/bodyPartConnectorCaffe.cpp @@ -12,6 +12,8 @@ namespace op { template BodyPartConnectorCaffe::BodyPartConnectorCaffe() : + mPoseModel{PoseModel::Size}, + mMaximizePositives{false}, pBodyPartPairsGpuPtr{nullptr}, pMapIdxGpuPtr{nullptr}, pFinalOutputGpuPtr{nullptr} @@ -61,10 +63,10 @@ namespace op // Array sizes mTopSize = std::array{1, maxPeaks, numberBodyParts, 3}; - mHeatMapsSize = std::array{heatMapsBlob->shape(0), heatMapsBlob->shape(1), - heatMapsBlob->shape(2), heatMapsBlob->shape(3)}; - mPeaksSize = std::array{peaksBlob->shape(0), peaksBlob->shape(1), peaksBlob->shape(2), - peaksBlob->shape(3)}; + mHeatMapsSize = std::array{ + heatMapsBlob->shape(0), heatMapsBlob->shape(1), heatMapsBlob->shape(2), heatMapsBlob->shape(3)}; + mPeaksSize = std::array{ + peaksBlob->shape(0), peaksBlob->shape(1), peaksBlob->shape(2), peaksBlob->shape(3)}; #else UNUSED(bottom); #endif @@ -88,6 +90,19 @@ namespace op } } + template + void BodyPartConnectorCaffe::setMaximizePositives(const bool maximizePositives) + { + try + { + mMaximizePositives = {maximizePositives}; + } + catch (const std::exception& e) + { + error(e.what(), __LINE__, __FUNCTION__, __FILE__); + } + } + template void BodyPartConnectorCaffe::setInterMinAboveThreshold(const T interMinAboveThreshold) { @@ -187,7 +202,7 @@ namespace op connectBodyPartsCpu(poseKeypoints, poseScores, heatMapsPtr, peaksPtr, mPoseModel, Point{heatMapsBlob->shape(3), heatMapsBlob->shape(2)}, maxPeaks, mInterMinAboveThreshold, mInterThreshold, - mMinSubsetCnt, mMinSubsetScore, mScaleNetToOutput); + mMinSubsetCnt, mMinSubsetScore, mScaleNetToOutput, mMaximizePositives); #else UNUSED(bottom); UNUSED(poseKeypoints); @@ -256,8 +271,9 @@ namespace op connectBodyPartsGpu(poseKeypoints, poseScores, heatMapsGpuPtr, peaksPtr, mPoseModel, Point{heatMapsBlob->shape(3), heatMapsBlob->shape(2)}, maxPeaks, mInterMinAboveThreshold, mInterThreshold, - mMinSubsetCnt, mMinSubsetScore, mScaleNetToOutput, mFinalOutputCpu, - pFinalOutputGpuPtr, pBodyPartPairsGpuPtr, pMapIdxGpuPtr, peaksGpuPtr); + mMinSubsetCnt, mMinSubsetScore, mScaleNetToOutput, mMaximizePositives, + mFinalOutputCpu, pFinalOutputGpuPtr, pBodyPartPairsGpuPtr, pMapIdxGpuPtr, + peaksGpuPtr); #else UNUSED(bottom); UNUSED(poseKeypoints); diff --git a/src/openpose/pose/poseExtractorCaffe.cpp b/src/openpose/pose/poseExtractorCaffe.cpp index bc8ec758..cf85b841 100644 --- a/src/openpose/pose/poseExtractorCaffe.cpp +++ b/src/openpose/pose/poseExtractorCaffe.cpp @@ -156,8 +156,8 @@ namespace op PoseExtractorCaffe::PoseExtractorCaffe(const PoseModel poseModel, const std::string& modelFolder, const int gpuId, const std::vector& heatMapTypes, const ScaleMode heatMapScale, const bool addPartCandidates, - const bool enableGoogleLogging) : - PoseExtractorNet{poseModel, heatMapTypes, heatMapScale, addPartCandidates} + const bool maximizePositives, const bool enableGoogleLogging) : + PoseExtractorNet{poseModel, heatMapTypes, heatMapScale, addPartCandidates, maximizePositives} #ifdef USE_CAFFE , upImpl{new ImplPoseExtractorCaffe{poseModel, gpuId, modelFolder, enableGoogleLogging}} #endif @@ -167,6 +167,7 @@ namespace op #ifdef USE_CAFFE // Layers parameters upImpl->spBodyPartConnectorCaffe->setPoseModel(upImpl->mPoseModel); + upImpl->spBodyPartConnectorCaffe->setMaximizePositives(maximizePositives); #else UNUSED(poseModel); UNUSED(modelFolder); diff --git a/src/openpose/pose/poseExtractorNet.cpp b/src/openpose/pose/poseExtractorNet.cpp index 3a8df72d..a75c640c 100644 --- a/src/openpose/pose/poseExtractorNet.cpp +++ b/src/openpose/pose/poseExtractorNet.cpp @@ -45,7 +45,8 @@ namespace op } PoseExtractorNet::PoseExtractorNet(const PoseModel poseModel, const std::vector& heatMapTypes, - const ScaleMode heatMapScale, const bool addPartCandidates) : + const ScaleMode heatMapScale, const bool addPartCandidates, + const bool maximizePositives) : mPoseModel{poseModel}, mNetOutputSize{0,0}, mHeatMapTypes{heatMapTypes}, @@ -60,15 +61,18 @@ namespace op error("The ScaleMode heatMapScale must be ZeroToOne, PlusMinusOne, UnsignedChar, or NoScale.", __LINE__, __FUNCTION__, __FILE__); - // Properties + // Properties - Init to 0 for (auto& property : mProperties) property = 0.; - mProperties[(int)PoseProperty::NMSThreshold] = getPoseDefaultNmsThreshold(mPoseModel); + // Properties - Fill default values + mProperties[(int)PoseProperty::NMSThreshold] = getPoseDefaultNmsThreshold(mPoseModel, maximizePositives); mProperties[(int)PoseProperty::ConnectInterMinAboveThreshold] - = getPoseDefaultConnectInterMinAboveThreshold(mPoseModel); - mProperties[(int)PoseProperty::ConnectInterThreshold] = getPoseDefaultConnectInterThreshold(mPoseModel); - mProperties[(int)PoseProperty::ConnectMinSubsetCnt] = getPoseDefaultMinSubsetCnt(mPoseModel); - mProperties[(int)PoseProperty::ConnectMinSubsetScore] = getPoseDefaultConnectMinSubsetScore(mPoseModel); + = getPoseDefaultConnectInterMinAboveThreshold(maximizePositives); + mProperties[(int)PoseProperty::ConnectInterThreshold] = getPoseDefaultConnectInterThreshold( + mPoseModel, maximizePositives); + mProperties[(int)PoseProperty::ConnectMinSubsetCnt] = getPoseDefaultMinSubsetCnt(maximizePositives); + mProperties[(int)PoseProperty::ConnectMinSubsetScore] = getPoseDefaultConnectMinSubsetScore( + maximizePositives); } catch (const std::exception& e) { diff --git a/src/openpose/pose/poseParameters.cpp b/src/openpose/pose/poseParameters.cpp index 9586a202..f88ee37b 100644 --- a/src/openpose/pose/poseParameters.cpp +++ b/src/openpose/pose/poseParameters.cpp @@ -483,31 +483,6 @@ namespace op 8.f, // CAR_22 }; - // Default Model Parameters - // They might be modified on running time - const auto nmsT = (COCO_CHALLENGE ? 0.02f : 0.05f); - const std::array POSE_DEFAULT_NMS_THRESHOLD{ - nmsT, nmsT, 0.6f, 0.3f, nmsT, nmsT, nmsT, nmsT, nmsT, nmsT, nmsT, nmsT, nmsT, nmsT, nmsT - }; - const auto minAT = (COCO_CHALLENGE ? 0.75f : 0.95f); // Matlab version: 0.85f - const std::array POSE_DEFAULT_CONNECT_INTER_MIN_ABOVE_THRESHOLD{ - minAT, minAT, minAT, minAT, minAT, minAT, minAT, minAT, minAT, minAT, minAT, minAT, minAT, minAT, minAT - // 0.85f, 0.85f, 0.85f, 0.85f, 0.85f, 0.85f // Matlab version - }; - const auto conIT = (COCO_CHALLENGE ? 0.01f : 0.05f); - const std::array POSE_DEFAULT_CONNECT_INTER_THRESHOLD{ - conIT, conIT, 0.01f, 0.01f, conIT, conIT, conIT, conIT, conIT, conIT, conIT, conIT, conIT, conIT, conIT - }; - const auto minSC = (COCO_CHALLENGE ? 2 : 3); - const std::array POSE_DEFAULT_CONNECT_MIN_SUBSET_CNT{ - minSC, minSC, minSC, minSC, minSC, minSC, minSC, minSC, minSC, minSC, minSC, minSC, minSC, minSC, minSC - }; - const auto minSS = (COCO_CHALLENGE ? 0.05f : 0.4f); - const std::array POSE_DEFAULT_CONNECT_MIN_SUBSET_SCORE{ - minSS, minSS, minSS, minSS, minSS, minSS, minSS, minSS, minSS, minSS, minSS, minSS, minSS, minSS, minSS - // 0.2f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f // Matlab version - }; - const std::map& getPoseBodyPartMapping(const PoseModel poseModel) { try @@ -645,11 +620,19 @@ namespace op } // Default Model Parameters - float getPoseDefaultNmsThreshold(const PoseModel poseModel) + // They might be modified on running time + float getPoseDefaultNmsThreshold(const PoseModel poseModel, const bool maximizePositives) { try { - return POSE_DEFAULT_NMS_THRESHOLD.at((int)poseModel); + // MPI models + if (poseModel == PoseModel::MPI_15) + return 0.6f; + else if (poseModel == PoseModel::MPI_15_4) + return 0.3f; + // Non-MPI models + else + return (maximizePositives ? 0.02f : 0.05f); } catch (const std::exception& e) { @@ -658,11 +641,11 @@ namespace op } } - float getPoseDefaultConnectInterMinAboveThreshold(const PoseModel poseModel) + float getPoseDefaultConnectInterMinAboveThreshold(const bool maximizePositives) { try { - return POSE_DEFAULT_CONNECT_INTER_MIN_ABOVE_THRESHOLD.at((int)poseModel); + return (maximizePositives ? 0.75f : 0.95f); } catch (const std::exception& e) { @@ -671,11 +654,16 @@ namespace op } } - float getPoseDefaultConnectInterThreshold(const PoseModel poseModel) + float getPoseDefaultConnectInterThreshold(const PoseModel poseModel, const bool maximizePositives) { try { - return POSE_DEFAULT_CONNECT_INTER_THRESHOLD.at((int)poseModel); + // MPI models + if (poseModel == PoseModel::MPI_15 || poseModel == PoseModel::MPI_15_4) + return 0.01f; + // Non-MPI models + else + return (maximizePositives ? 0.01f : 0.05f); } catch (const std::exception& e) { @@ -684,11 +672,11 @@ namespace op } } - unsigned int getPoseDefaultMinSubsetCnt(const PoseModel poseModel) + unsigned int getPoseDefaultMinSubsetCnt(const bool maximizePositives) { try { - return POSE_DEFAULT_CONNECT_MIN_SUBSET_CNT.at((int)poseModel); + return (maximizePositives ? 2u : 3u); } catch (const std::exception& e) { @@ -697,11 +685,11 @@ namespace op } } - float getPoseDefaultConnectMinSubsetScore(const PoseModel poseModel) + float getPoseDefaultConnectMinSubsetScore(const bool maximizePositives) { try { - return POSE_DEFAULT_CONNECT_MIN_SUBSET_SCORE.at((int)poseModel); + return (maximizePositives ? 0.05f : 0.4f); } catch (const std::exception& e) { diff --git a/src/openpose/wrapper/wrapperStructExtra.cpp b/src/openpose/wrapper/wrapperStructExtra.cpp index 0d1fd08c..be538896 100644 --- a/src/openpose/wrapper/wrapperStructExtra.cpp +++ b/src/openpose/wrapper/wrapperStructExtra.cpp @@ -2,9 +2,9 @@ namespace op { - WrapperStructExtra::WrapperStructExtra(const bool reconstruct3d_, const int minViews3d_, - const bool identification_, const int tracking_, - const int ikThreads_) : + WrapperStructExtra::WrapperStructExtra( + const bool reconstruct3d_, const int minViews3d_, const bool identification_, const int tracking_, + const int ikThreads_) : reconstruct3d{reconstruct3d_}, minViews3d{minViews3d_}, identification{identification_}, diff --git a/src/openpose/wrapper/wrapperStructFace.cpp b/src/openpose/wrapper/wrapperStructFace.cpp index 44100bde..224ef20e 100644 --- a/src/openpose/wrapper/wrapperStructFace.cpp +++ b/src/openpose/wrapper/wrapperStructFace.cpp @@ -2,9 +2,9 @@ namespace op { - WrapperStructFace::WrapperStructFace(const bool enable_, const Point& netInputSize_, const RenderMode renderMode_, - const float alphaKeypoint_, const float alphaHeatMap_, - const float renderThreshold_) : + WrapperStructFace::WrapperStructFace( + const bool enable_, const Point& netInputSize_, const RenderMode renderMode_, const float alphaKeypoint_, + const float alphaHeatMap_, const float renderThreshold_) : enable{enable_}, netInputSize{netInputSize_}, renderMode{renderMode_}, diff --git a/src/openpose/wrapper/wrapperStructHand.cpp b/src/openpose/wrapper/wrapperStructHand.cpp index cc44109b..bb3a0bca 100644 --- a/src/openpose/wrapper/wrapperStructHand.cpp +++ b/src/openpose/wrapper/wrapperStructHand.cpp @@ -2,10 +2,10 @@ namespace op { - WrapperStructHand::WrapperStructHand(const bool enable_, const Point& netInputSize_, const int scalesNumber_, - const float scaleRange_, const bool tracking_, const RenderMode renderMode_, - const float alphaKeypoint_, const float alphaHeatMap_, - const float renderThreshold_) : + WrapperStructHand::WrapperStructHand( + const bool enable_, const Point& netInputSize_, const int scalesNumber_, const float scaleRange_, + const bool tracking_, const RenderMode renderMode_, const float alphaKeypoint_, const float alphaHeatMap_, + const float renderThreshold_) : enable{enable_}, netInputSize{netInputSize_}, scalesNumber{scalesNumber_}, diff --git a/src/openpose/wrapper/wrapperStructInput.cpp b/src/openpose/wrapper/wrapperStructInput.cpp index b1e8fd6c..f202b806 100644 --- a/src/openpose/wrapper/wrapperStructInput.cpp +++ b/src/openpose/wrapper/wrapperStructInput.cpp @@ -2,13 +2,12 @@ namespace op { - WrapperStructInput::WrapperStructInput(const ProducerType producerType_, const std::string& producerString_, - const unsigned long long frameFirst_, const unsigned long long frameStep_, - const unsigned long long frameLast_, const bool realTimeProcessing_, - const bool frameFlip_, const int frameRotate_, const bool framesRepeat_, - const Point& cameraResolution_, const double webcamFps_, - const std::string& cameraParameterPath_, const bool undistortImage_, - const unsigned int imageDirectoryStereo_) : + WrapperStructInput::WrapperStructInput( + const ProducerType producerType_, const std::string& producerString_, const unsigned long long frameFirst_, + const unsigned long long frameStep_, const unsigned long long frameLast_, const bool realTimeProcessing_, + const bool frameFlip_, const int frameRotate_, const bool framesRepeat_, const Point& cameraResolution_, + const double webcamFps_, const std::string& cameraParameterPath_, const bool undistortImage_, + const unsigned int imageDirectoryStereo_) : producerType{producerType_}, producerString{producerString_}, frameFirst{frameFirst_}, diff --git a/src/openpose/wrapper/wrapperStructOutput.cpp b/src/openpose/wrapper/wrapperStructOutput.cpp index e07fbcf9..c06120d7 100644 --- a/src/openpose/wrapper/wrapperStructOutput.cpp +++ b/src/openpose/wrapper/wrapperStructOutput.cpp @@ -2,16 +2,14 @@ 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_) : + 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_}, diff --git a/src/openpose/wrapper/wrapperStructPose.cpp b/src/openpose/wrapper/wrapperStructPose.cpp index 1b626d8c..b2d10f5c 100644 --- a/src/openpose/wrapper/wrapperStructPose.cpp +++ b/src/openpose/wrapper/wrapperStructPose.cpp @@ -2,18 +2,14 @@ namespace op { - WrapperStructPose::WrapperStructPose(const bool enable_, const Point& netInputSize_, - const Point& outputSize_, const ScaleMode keypointScale_, - const int gpuNumber_, const int gpuNumberStart_, - const int scalesNumber_, const float scaleGap_, - const RenderMode renderMode_, const PoseModel poseModel_, - const bool blendOriginalFrame_, const float alphaKeypoint_, - const float alphaHeatMap_, const int defaultPartToRender_, - const std::string& modelFolder_, - const std::vector& heatMapTypes_, - const ScaleMode heatMapScale_, const bool addPartCandidates_, - const float renderThreshold_, const int numberPeopleMax_, - const bool enableGoogleLogging_) : + WrapperStructPose::WrapperStructPose( + const bool enable_, const Point& netInputSize_, const Point& outputSize_, + const ScaleMode keypointScale_, const int gpuNumber_, const int gpuNumberStart_, const int scalesNumber_, + const float scaleGap_, const RenderMode renderMode_, const PoseModel poseModel_, + const bool blendOriginalFrame_, const float alphaKeypoint_, const float alphaHeatMap_, + const int defaultPartToRender_, const std::string& modelFolder_, const std::vector& heatMapTypes_, + const ScaleMode heatMapScale_, const bool addPartCandidates_, const float renderThreshold_, + const int numberPeopleMax_, const bool maximizePositives_, const bool enableGoogleLogging_) : enable{enable_}, netInputSize{netInputSize_}, outputSize{outputSize_}, @@ -34,6 +30,7 @@ namespace op addPartCandidates{addPartCandidates_}, renderThreshold{renderThreshold_}, numberPeopleMax{numberPeopleMax_}, + maximizePositives{maximizePositives_}, enableGoogleLogging{enableGoogleLogging_} { } diff --git a/ubuntu_deprecated/Makefile.example b/ubuntu_deprecated/Makefile.example index 90e738c3..3762ea6d 100644 --- a/ubuntu_deprecated/Makefile.example +++ b/ubuntu_deprecated/Makefile.example @@ -108,7 +108,8 @@ ifneq ($(WITH_FLIR_CAMERA), 0) COMMON_FLAGS += -DUSE_FLIR_CAMERA # Spinnaker SDK LIBRARIES += Spinnaker - INCLUDE_DIRS += $(SPINNAKER_DIR) + # INCLUDE_DIRS += $(SPINNAKER_DIR) + COMMON_FLAGS += -isystem $(SPINNAKER_DIR) # Remove warnings from this library endif ##############################