diff --git a/doc/demo_overview.md b/doc/demo_overview.md index de95bdc30b98d57349e27a4cb1ac310c47893f2a..ea9e616e85e020af7c4c0179ea46204dbba90e57 100644 --- a/doc/demo_overview.md +++ b/doc/demo_overview.md @@ -142,7 +142,7 @@ Each flag is divided into flag name, default value, and description. 4. OpenPose Body Pose - DEFINE_string(model_pose, "COCO", "Model to be used. E.g. `COCO` (18 keypoints), `MPI` (15 keypoints, ~10% faster), `MPI_4_layers` (15 keypoints, even faster but less accurate)."); -- DEFINE_string(net_resolution, "656x368", "Multiples of 16. If it is increased, the accuracy usually increases. If it is decreased, the speed increases. For maximum speed-accuracy balance, it should keep the closest aspect ratio possible to the images or videos to be processed. E.g. the default `656x368` is optimal for 16:9 videos, e.g. full HD (1980x1080) and HD (1280x720) videos."); +- DEFINE_string(net_resolution, "656x368", "Multiples of 16. If it is increased, the accuracy potentially increases. If it is decreased, the speed increases. For maximum speed-accuracy balance, it should keep the closest aspect ratio possible to the images or videos to be processed. Using `-1` in any of the dimensions, OP will choose the optimal resolution depending on the other value introduced by the user. E.g. the default `-1x368` is equivalent to `656x368` in 16:9 videos, e.g. full HD (1980x1080) and HD (1280x720) resolutions."); - DEFINE_int32(scale_number, 1, "Number of scales to average."); - DEFINE_double(scale_gap, 0.3, "Scale gap between scales. No effect unless scale_number > 1. Initial scale is always 1. If you want to change the initial scale, you actually want to multiply the `net_resolution` by your desired initial scale."); - DEFINE_bool(heatmaps_add_parts, false, "If true, it will add the body part heatmaps to the final op::Datum::poseHeatMaps array (program speed will decrease). Not required for our library, enable it only if you intend to process this information later. If more than one `add_heatmaps_X` flag is enabled, it will place then in sequential memory order: body parts + bkg + PAFs. It will follow the order on POSE_BODY_PART_MAPPING in `include/openpose/pose/poseParameters.hpp`."); diff --git a/doc/release_notes.md b/doc/release_notes.md index 8dfec4a47ae3038c84b1ebdadc3f5a980f2c037c..b2740b2e1e93f80bf36197d8d9117850f207b5e8 100644 --- a/doc/release_notes.md +++ b/doc/release_notes.md @@ -117,3 +117,4 @@ OpenPose Library - Release Notes 1. Main improvements: 1. COCO JSON file outputs 0 as score for non-detected keypoints. 2. Added example for OpenPose for user asynchronous output and cleaned all `tutorial_wrapper/` examples. + 3. Added `-1` option for `net_resolution` in order to auto-select the best possible aspect ratio given the user input. diff --git a/examples/openpose/openpose.cpp b/examples/openpose/openpose.cpp index aaa76bfa3d932d3774a53ed809e542270748241d..b6a87b7e7b1fd740a9a71b63a08b4e4f665c8bad 100755 --- a/examples/openpose/openpose.cpp +++ b/examples/openpose/openpose.cpp @@ -65,10 +65,12 @@ DEFINE_int32(keypoint_scale, 0, "Scaling of the (x,y) co // OpenPose Body Pose DEFINE_string(model_pose, "COCO", "Model to be used. E.g. `COCO` (18 keypoints), `MPI` (15 keypoints, ~10% faster), " "`MPI_4_layers` (15 keypoints, even faster but less accurate)."); -DEFINE_string(net_resolution, "656x368", "Multiples of 16. If it is increased, the accuracy potentially increases. If it is decreased," - " the speed increases. For maximum speed-accuracy balance, it should keep the closest aspect" - " ratio possible to the images or videos to be processed. E.g. the default `656x368` is" - " optimal for 16:9 videos, e.g. full HD (1980x1080) and HD (1280x720) videos."); +DEFINE_string(net_resolution, "656x368", "Multiples of 16. If it is increased, the accuracy potentially increases. If it is" + " decreased, the speed increases. For maximum speed-accuracy balance, it should keep the" + " closest aspect ratio possible to the images or videos to be processed. Using `-1` in" + " any of the dimensions, OP will choose the optimal aspect ratio depending on the user's" + " input value. E.g. the default `-1x368` is equivalent to `656x368` in 16:9 resolutions," + " e.g. full HD (1980x1080) and HD (1280x720) resolutions."); DEFINE_int32(scale_number, 1, "Number of scales to average."); DEFINE_double(scale_gap, 0.3, "Scale gap between scales. No effect unless scale_number > 1. Initial scale is always 1." " If you want to change the initial scale, you actually want to multiply the" @@ -172,7 +174,7 @@ int openPoseDemo() // outputSize const auto outputSize = op::flagsToPoint(FLAGS_resolution, "1280x720"); // netInputSize - const auto netInputSize = op::flagsToPoint(FLAGS_net_resolution, "656x368"); + const auto netInputSize = op::flagsToPoint(FLAGS_net_resolution, "-1x368"); // faceNetInputSize const auto faceNetInputSize = op::flagsToPoint(FLAGS_face_net_resolution, "368x368 (multiples of 16)"); // handNetInputSize diff --git a/examples/openpose/openposeBasicDemo.cpp b/examples/openpose/openposeBasicDemo.cpp new file mode 100644 index 0000000000000000000000000000000000000000..8c4965b85e377182d21f580b2ce56ebb7c06c3c7 --- /dev/null +++ b/examples/openpose/openposeBasicDemo.cpp @@ -0,0 +1,79 @@ +// ------------------------- OpenPose Library Tutorial - Real Time Pose Estimation ------------------------- +// C++ std library dependencies +#include // `std::chrono::` functions and classes, e.g. std::chrono::milliseconds +#include // std::this_thread +// Other 3rdparty dependencies +#include // DEFINE_bool, DEFINE_int32, DEFINE_int64, DEFINE_uint64, DEFINE_double, DEFINE_string +#include // google::InitGoogleLogging + +// OpenPose dependencies +#include + +// See all the available parameter options withe the `--help` flag. E.g. `./build/examples/openpose/openpose.bin --help`. +// Note: This command will show you flags for other unnecessary 3rdparty files. Check only the flags for the OpenPose +// executable. E.g. for `openpose.bin`, look for `Flags from examples/openpose/openpose.cpp:`. +// Producer +DEFINE_int32(camera, -1, "The camera index for cv::VideoCapture. Integer in the range [0, 9]. Select a negative" + " number (by default), to auto-detect and open the first available camera."); +DEFINE_string(camera_resolution, "1280x720", "Size of the camera frames to ask for."); +DEFINE_double(camera_fps, 30.0, "Frame rate for the webcam (only used when saving video from webcam). Set this value to the" + " minimum value between the OpenPose displayed speed and the webcam real frame rate."); +DEFINE_string(video, "", "Use a video file instead of the camera. Use `examples/media/video.avi` for our default" + " example video."); +DEFINE_string(image_dir, "", "Process a directory of images. Use `examples/media/` for our default example folder with 20" + " images. Read all standard formats (jpg, png, bmp, etc.)."); +// Display +DEFINE_bool(no_gui_verbose, false, "Do not write text on output images on GUI (e.g. number of current frame and people). It" + " does not affect the pose rendering."); +DEFINE_bool(no_display, false, "Do not open a display window. Useful if there is no X server and/or to slightly speed up" + " the processing if visual output is not required."); + +int openPoseDemo() +{ + op::log("Starting pose estimation demo.", op::Priority::High); + const auto timerBegin = std::chrono::high_resolution_clock::now(); + + // Applying user defined configuration - Google flags to program variables + const auto producerSharedPtr = op::flagsToProducer(FLAGS_image_dir, FLAGS_video, FLAGS_camera, FLAGS_camera_resolution, FLAGS_camera_fps); + op::log("", op::Priority::Low, __LINE__, __FUNCTION__, __FILE__); + + // OpenPose wrapper + op::log("Configuring OpenPose wrapper.", op::Priority::Low, __LINE__, __FUNCTION__, __FILE__); + op::Wrapper> opWrapper; + // Pose configuration (use WrapperStructPose{} for default and recommended configuration) + op::WrapperStructPose wrapperStructPose{}; + wrapperStructPose.renderMode = op::RenderMode::Gpu; + // Producer (use default to disable any input) + const op::WrapperStructInput wrapperStructInput{producerSharedPtr}; + // Consumer (comment or use default argument to disable any output) + const op::WrapperStructOutput wrapperStructOutput{!FLAGS_no_display, !FLAGS_no_gui_verbose}; + // Configure wrapper + opWrapper.configure(wrapperStructPose, wrapperStructInput, wrapperStructOutput); + // Set to single-thread running (e.g. for debugging purposes) + // opWrapper.disableMultiThreading(); + + // Start processing + // Two different ways of running the program on multithread environment + op::log("Starting thread(s)", op::Priority::High); + opWrapper.exec(); // It blocks this thread until all threads have finished + + // Measuring total time + const auto now = std::chrono::high_resolution_clock::now(); + const auto totalTimeSec = (double)std::chrono::duration_cast(now-timerBegin).count() * 1e-9; + const auto message = "Real-time pose estimation demo successfully finished. Total time: " + std::to_string(totalTimeSec) + " seconds."; + op::log(message, op::Priority::High); + + return 0; +} + +int main(int argc, char *argv[]) +{ + // Initializing google logging (Caffe uses it for logging) + google::InitGoogleLogging("openPoseDemo"); + + // Parsing command line flags + gflags::ParseCommandLineFlags(&argc, &argv, true); + + // Running openPoseDemo + return openPoseDemo(); +} diff --git a/examples/tutorial_pose/1_extract_from_image.cpp b/examples/tutorial_pose/1_extract_from_image.cpp index e4c0ffa7743f85426bcfd543ceae87fd6f2cf399..7fd048ce82971f7ee81b9a31705fc0a78b83ba6a 100644 --- a/examples/tutorial_pose/1_extract_from_image.cpp +++ b/examples/tutorial_pose/1_extract_from_image.cpp @@ -31,10 +31,12 @@ DEFINE_string(image_path, "examples/media/COCO_val2014_00000000019 DEFINE_string(model_pose, "COCO", "Model to be used. E.g. `COCO` (18 keypoints), `MPI` (15 keypoints, ~10% faster), " "`MPI_4_layers` (15 keypoints, even faster but less accurate)."); DEFINE_string(model_folder, "models/", "Folder path (absolute or relative) where the models (pose, face, ...) are located."); -DEFINE_string(net_resolution, "656x368", "Multiples of 16. If it is increased, the accuracy potentially increases. If it is decreased," - " the speed increases. For maximum speed-accuracy balance, it should keep the closest aspect" - " ratio possible to the images or videos to be processed. E.g. the default `656x368` is" - " optimal for 16:9 videos, e.g. full HD (1980x1080) and HD (1280x720) videos."); +DEFINE_string(net_resolution, "656x368", "Multiples of 16. If it is increased, the accuracy potentially increases. If it is" + " decreased, the speed increases. For maximum speed-accuracy balance, it should keep the" + " closest aspect ratio possible to the images or videos to be processed. Using `-1` in" + " any of the dimensions, OP will choose the optimal aspect ratio depending on the user's" + " input value. E.g. the default `-1x368` is equivalent to `656x368` in 16:9 resolutions," + " e.g. full HD (1980x1080) and HD (1280x720) resolutions."); DEFINE_string(resolution, "1280x720", "The image resolution (display and output). Use \"-1x-1\" to force the program to use the" " default images resolution."); DEFINE_int32(num_gpu_start, 0, "GPU device start number."); @@ -67,7 +69,7 @@ int openPoseTutorialPose1() // outputSize const auto outputSize = op::flagsToPoint(FLAGS_resolution, "1280x720"); // netInputSize - const auto netInputSize = op::flagsToPoint(FLAGS_net_resolution, "656x368"); + const auto netInputSize = op::flagsToPoint(FLAGS_net_resolution, "-1x368"); // netOutputSize const auto netOutputSize = netInputSize; // poseModel diff --git a/examples/tutorial_pose/2_extract_pose_or_heatmat_from_image.cpp b/examples/tutorial_pose/2_extract_pose_or_heatmat_from_image.cpp index f834d68e855fbbb7f783b398d8858f2eb9e640e0..2eb6ea3019ad97b99df8dad8a2cea127b8bd9779 100644 --- a/examples/tutorial_pose/2_extract_pose_or_heatmat_from_image.cpp +++ b/examples/tutorial_pose/2_extract_pose_or_heatmat_from_image.cpp @@ -31,10 +31,12 @@ DEFINE_string(image_path, "examples/media/COCO_val2014_00000000019 DEFINE_string(model_pose, "COCO", "Model to be used. E.g. `COCO` (18 keypoints), `MPI` (15 keypoints, ~10% faster), " "`MPI_4_layers` (15 keypoints, even faster but less accurate)."); DEFINE_string(model_folder, "models/", "Folder path (absolute or relative) where the models (pose, face, ...) are located."); -DEFINE_string(net_resolution, "656x368", "Multiples of 16. If it is increased, the accuracy potentially increases. If it is decreased," - " the speed increases. For maximum speed-accuracy balance, it should keep the closest aspect" - " ratio possible to the images or videos to be processed. E.g. the default `656x368` is" - " optimal for 16:9 videos, e.g. full HD (1980x1080) and HD (1280x720) videos."); +DEFINE_string(net_resolution, "656x368", "Multiples of 16. If it is increased, the accuracy potentially increases. If it is" + " decreased, the speed increases. For maximum speed-accuracy balance, it should keep the" + " closest aspect ratio possible to the images or videos to be processed. Using `-1` in" + " any of the dimensions, OP will choose the optimal aspect ratio depending on the user's" + " input value. E.g. the default `-1x368` is equivalent to `656x368` in 16:9 resolutions," + " e.g. full HD (1980x1080) and HD (1280x720) resolutions."); DEFINE_string(resolution, "1280x720", "The image resolution (display and output). Use \"-1x-1\" to force the program to use the" " default images resolution."); DEFINE_int32(num_gpu_start, 0, "GPU device start number."); @@ -72,7 +74,7 @@ int openPoseTutorialPose2() // outputSize const auto outputSize = op::flagsToPoint(FLAGS_resolution, "1280x720"); // netInputSize - const auto netInputSize = op::flagsToPoint(FLAGS_net_resolution, "656x368"); + const auto netInputSize = op::flagsToPoint(FLAGS_net_resolution, "-1x368"); // netOutputSize const auto netOutputSize = netInputSize; // poseModel diff --git a/examples/tutorial_wrapper/1_user_asynchronous_output.cpp b/examples/tutorial_wrapper/1_user_asynchronous_output.cpp index 43d8ebdac0a2664ddebe90fb515174abd768fdf5..5f5c4d04a9faa833b15a84de7f23a54ff3982598 100644 --- a/examples/tutorial_wrapper/1_user_asynchronous_output.cpp +++ b/examples/tutorial_wrapper/1_user_asynchronous_output.cpp @@ -65,10 +65,12 @@ DEFINE_int32(keypoint_scale, 0, "Scaling of the (x,y) co // OpenPose Body Pose DEFINE_string(model_pose, "COCO", "Model to be used. E.g. `COCO` (18 keypoints), `MPI` (15 keypoints, ~10% faster), " "`MPI_4_layers` (15 keypoints, even faster but less accurate)."); -DEFINE_string(net_resolution, "656x368", "Multiples of 16. If it is increased, the accuracy potentially increases. If it is decreased," - " the speed increases. For maximum speed-accuracy balance, it should keep the closest aspect" - " ratio possible to the images or videos to be processed. E.g. the default `656x368` is" - " optimal for 16:9 videos, e.g. full HD (1980x1080) and HD (1280x720) videos."); +DEFINE_string(net_resolution, "656x368", "Multiples of 16. If it is increased, the accuracy potentially increases. If it is" + " decreased, the speed increases. For maximum speed-accuracy balance, it should keep the" + " closest aspect ratio possible to the images or videos to be processed. Using `-1` in" + " any of the dimensions, OP will choose the optimal aspect ratio depending on the user's" + " input value. E.g. the default `-1x368` is equivalent to `656x368` in 16:9 resolutions," + " e.g. full HD (1980x1080) and HD (1280x720) resolutions."); DEFINE_int32(scale_number, 1, "Number of scales to average."); DEFINE_double(scale_gap, 0.3, "Scale gap between scales. No effect unless scale_number > 1. Initial scale is always 1." " If you want to change the initial scale, you actually want to multiply the" @@ -239,7 +241,7 @@ int openPoseTutorialWrapper3() // outputSize const auto outputSize = op::flagsToPoint(FLAGS_resolution, "1280x720"); // netInputSize - const auto netInputSize = op::flagsToPoint(FLAGS_net_resolution, "656x368"); + const auto netInputSize = op::flagsToPoint(FLAGS_net_resolution, "-1x368"); // faceNetInputSize const auto faceNetInputSize = op::flagsToPoint(FLAGS_face_net_resolution, "368x368 (multiples of 16)"); // handNetInputSize diff --git a/examples/tutorial_wrapper/2_user_synchronous.cpp b/examples/tutorial_wrapper/2_user_synchronous.cpp index 251ea50c6b17f83a4c031b8fc6e402e1d2c9e37c..acf6b01ff3381ca7f1d3c7dccb9147bbb24d4059 100644 --- a/examples/tutorial_wrapper/2_user_synchronous.cpp +++ b/examples/tutorial_wrapper/2_user_synchronous.cpp @@ -49,10 +49,12 @@ DEFINE_int32(keypoint_scale, 0, "Scaling of the (x,y) co // OpenPose Body Pose DEFINE_string(model_pose, "COCO", "Model to be used. E.g. `COCO` (18 keypoints), `MPI` (15 keypoints, ~10% faster), " "`MPI_4_layers` (15 keypoints, even faster but less accurate)."); -DEFINE_string(net_resolution, "656x368", "Multiples of 16. If it is increased, the accuracy potentially increases. If it is decreased," - " the speed increases. For maximum speed-accuracy balance, it should keep the closest aspect" - " ratio possible to the images or videos to be processed. E.g. the default `656x368` is" - " optimal for 16:9 videos, e.g. full HD (1980x1080) and HD (1280x720) videos."); +DEFINE_string(net_resolution, "656x368", "Multiples of 16. If it is increased, the accuracy potentially increases. If it is" + " decreased, the speed increases. For maximum speed-accuracy balance, it should keep the" + " closest aspect ratio possible to the images or videos to be processed. Using `-1` in" + " any of the dimensions, OP will choose the optimal aspect ratio depending on the user's" + " input value. E.g. the default `-1x368` is equivalent to `656x368` in 16:9 resolutions," + " e.g. full HD (1980x1080) and HD (1280x720) resolutions."); DEFINE_int32(scale_number, 1, "Number of scales to average."); DEFINE_double(scale_gap, 0.3, "Scale gap between scales. No effect unless scale_number > 1. Initial scale is always 1." " If you want to change the initial scale, you actually want to multiply the" @@ -319,7 +321,7 @@ int openPoseTutorialWrapper2() // outputSize const auto outputSize = op::flagsToPoint(FLAGS_resolution, "1280x720"); // netInputSize - const auto netInputSize = op::flagsToPoint(FLAGS_net_resolution, "656x368"); + const auto netInputSize = op::flagsToPoint(FLAGS_net_resolution, "-1x368"); // faceNetInputSize const auto faceNetInputSize = op::flagsToPoint(FLAGS_face_net_resolution, "368x368 (multiples of 16)"); // handNetInputSize diff --git a/examples/tutorial_wrapper/3_user_asynchronous.cpp b/examples/tutorial_wrapper/3_user_asynchronous.cpp index cc90aaee8efecae1e23cfb91f010dab1fd839a7b..c4827431643480e764ee70aead0e41221e789ce0 100644 --- a/examples/tutorial_wrapper/3_user_asynchronous.cpp +++ b/examples/tutorial_wrapper/3_user_asynchronous.cpp @@ -49,10 +49,12 @@ DEFINE_int32(keypoint_scale, 0, "Scaling of the (x,y) co // OpenPose Body Pose DEFINE_string(model_pose, "COCO", "Model to be used. E.g. `COCO` (18 keypoints), `MPI` (15 keypoints, ~10% faster), " "`MPI_4_layers` (15 keypoints, even faster but less accurate)."); -DEFINE_string(net_resolution, "656x368", "Multiples of 16. If it is increased, the accuracy potentially increases. If it is decreased," - " the speed increases. For maximum speed-accuracy balance, it should keep the closest aspect" - " ratio possible to the images or videos to be processed. E.g. the default `656x368` is" - " optimal for 16:9 videos, e.g. full HD (1980x1080) and HD (1280x720) videos."); +DEFINE_string(net_resolution, "656x368", "Multiples of 16. If it is increased, the accuracy potentially increases. If it is" + " decreased, the speed increases. For maximum speed-accuracy balance, it should keep the" + " closest aspect ratio possible to the images or videos to be processed. Using `-1` in" + " any of the dimensions, OP will choose the optimal aspect ratio depending on the user's" + " input value. E.g. the default `-1x368` is equivalent to `656x368` in 16:9 resolutions," + " e.g. full HD (1980x1080) and HD (1280x720) resolutions."); DEFINE_int32(scale_number, 1, "Number of scales to average."); DEFINE_double(scale_gap, 0.3, "Scale gap between scales. No effect unless scale_number > 1. Initial scale is always 1." " If you want to change the initial scale, you actually want to multiply the" @@ -278,7 +280,7 @@ int openPoseTutorialWrapper1() // outputSize const auto outputSize = op::flagsToPoint(FLAGS_resolution, "1280x720"); // netInputSize - const auto netInputSize = op::flagsToPoint(FLAGS_net_resolution, "656x368"); + const auto netInputSize = op::flagsToPoint(FLAGS_net_resolution, "-1x368"); // faceNetInputSize const auto faceNetInputSize = op::flagsToPoint(FLAGS_face_net_resolution, "368x368 (multiples of 16)"); // handNetInputSize diff --git a/examples_beta/openpose3d/openpose3d.cpp b/examples_beta/openpose3d/openpose3d.cpp index 39e5fa4d97d0551cc17eccf6aaa181e6810cb7ea..5825bec0483da61cc5587687f7db7fe88ae2c04e 100644 --- a/examples_beta/openpose3d/openpose3d.cpp +++ b/examples_beta/openpose3d/openpose3d.cpp @@ -49,10 +49,12 @@ DEFINE_int32(keypoint_scale, 0, "Scaling of the (x,y) co // OpenPose Body Pose DEFINE_string(model_pose, "COCO", "Model to be used. E.g. `COCO` (18 keypoints), `MPI` (15 keypoints, ~10% faster), " "`MPI_4_layers` (15 keypoints, even faster but less accurate)."); -DEFINE_string(net_resolution, "656x368", "Multiples of 16. If it is increased, the accuracy potentially increases. If it is decreased," - " the speed increases. For maximum speed-accuracy balance, it should keep the closest aspect" - " ratio possible to the images or videos to be processed. E.g. the default `656x368` is" - " optimal for 16:9 videos, e.g. full HD (1980x1080) and HD (1280x720) videos."); +DEFINE_string(net_resolution, "656x368", "Multiples of 16. If it is increased, the accuracy potentially increases. If it is" + " decreased, the speed increases. For maximum speed-accuracy balance, it should keep the" + " closest aspect ratio possible to the images or videos to be processed. Using `-1` in" + " any of the dimensions, OP will choose the optimal aspect ratio depending on the user's" + " input value. E.g. the default `-1x368` is equivalent to `656x368` in 16:9 resolutions," + " e.g. full HD (1980x1080) and HD (1280x720) resolutions."); DEFINE_int32(scale_number, 1, "Number of scales to average."); DEFINE_double(scale_gap, 0.3, "Scale gap between scales. No effect unless scale_number > 1. Initial scale is always 1." " If you want to change the initial scale, you actually want to multiply the" @@ -153,7 +155,7 @@ int openpose3d() // outputSize const auto outputSize = op::flagsToPoint(FLAGS_resolution, "1280x720"); // netInputSize - const auto netInputSize = op::flagsToPoint(FLAGS_net_resolution, "656x368"); + const auto netInputSize = op::flagsToPoint(FLAGS_net_resolution, "-1x368"); // faceNetInputSize const auto faceNetInputSize = op::flagsToPoint(FLAGS_face_net_resolution, "368x368 (multiples of 16)"); // handNetInputSize diff --git a/include/openpose/wrapper/wrapper.hpp b/include/openpose/wrapper/wrapper.hpp index 0344c25f996e3c0cbaec48ed1afb6eff4ae5849a..175914dfc32beca794b7a558a8b2a73f22133ebb 100644 --- a/include/openpose/wrapper/wrapper.hpp +++ b/include/openpose/wrapper/wrapper.hpp @@ -548,12 +548,27 @@ namespace op error(message, __LINE__, __FUNCTION__, __FILE__); } } + } else if (finalOutputSize.x == -1 || finalOutputSize.y == -1) { const auto message = "Output resolution cannot be (-1 x -1) unless wrapperStructInput.producerSharedPtr is also set."; error(message, __LINE__, __FUNCTION__, __FILE__); } + // Set poseNetInputSize if -1 used + Point poseNetInputSize = wrapperStructPose.netInputSize; + if (poseNetInputSize.x == -1 || poseNetInputSize.y == -1) + { + if (producerSize.area() <= 0) + { + const auto message = "Net resolution cannot be -1 for image_dir, only for video and webcam."; + error(message, __LINE__, __FUNCTION__, __FILE__); + } + else if (poseNetInputSize.x == -1) + poseNetInputSize.x = 16 * intRound(poseNetInputSize.y * producerSize.x / (float) producerSize.y / 16.f); + else // if (poseNetInputSize.y == -1) + poseNetInputSize.y = 16 * intRound(poseNetInputSize.x * producerSize.y / (float) producerSize.x / 16.f); + } // Producer if (wrapperStructInput.producerSharedPtr != nullptr) @@ -567,11 +582,11 @@ namespace op wDatumProducer = nullptr; // Pose estimators - const Point& poseNetOutputSize = wrapperStructPose.netInputSize; + const Point& poseNetOutputSize = poseNetInputSize; std::vector> poseExtractors; for (auto gpuId = 0; gpuId < gpuNumber; gpuId++) poseExtractors.emplace_back(std::make_shared( - wrapperStructPose.netInputSize, poseNetOutputSize, finalOutputSize, wrapperStructPose.scalesNumber, + poseNetInputSize, poseNetOutputSize, finalOutputSize, wrapperStructPose.scalesNumber, wrapperStructPose.poseModel, wrapperStructPose.modelFolder, gpuId + gpuNumberStart, wrapperStructPose.heatMapTypes, wrapperStructPose.heatMapScale )); @@ -613,7 +628,7 @@ namespace op // Input cvMat to OpenPose format const auto cvMatToOpInput = std::make_shared( - wrapperStructPose.netInputSize, wrapperStructPose.scalesNumber, wrapperStructPose.scaleGap + poseNetInputSize, wrapperStructPose.scalesNumber, wrapperStructPose.scaleGap ); spWCvMatToOpInput = std::make_shared>(cvMatToOpInput); const auto cvMatToOpOutput = std::make_shared(finalOutputSize, renderOutput);