From 49939503ac8e92ac408bfc13fb690b25bd2148bd Mon Sep 17 00:00:00 2001 From: gineshidalgo99 Date: Tue, 27 Feb 2018 15:33:29 -0500 Subject: [PATCH] Fixed webcam resolution bug --- doc/release_notes.md | 1 + examples/openpose/openpose.cpp | 2 +- examples/tutorial_add_module/1_custom_post_processing.cpp | 6 +++--- examples/tutorial_wrapper/1_user_asynchronous_output.cpp | 6 +++--- examples/tutorial_wrapper/2_user_synchronous.cpp | 6 +++--- examples/tutorial_wrapper/3_user_asynchronous.cpp | 6 +++--- src/openpose/utilities/flagsToOpenPose.cpp | 8 +++++--- 7 files changed, 19 insertions(+), 16 deletions(-) diff --git a/doc/release_notes.md b/doc/release_notes.md index 7ca25168..06a0b289 100644 --- a/doc/release_notes.md +++ b/doc/release_notes.md @@ -188,6 +188,7 @@ OpenPose Library - Release Notes 16. 3-D reconstruction module can be implemented with different camera brands or custom image sources. 17. Flag `--write_json` includes 3-D keypoints. 18. Flag `--image_dir_stereo` added to allow `--image_dir` to load stereo images. + 19. Flag `--camera_resolution` applicable to `--flir_camera`. 2. Functions or parameters renamed: 1. Flag `no_display` renamed as `display`, able to select between `NoDisplay`, `Display2D`, `Display3D`, and `DisplayAll`. 2. 3-D reconstruction demo is now inside the OpenPose demo binary. diff --git a/examples/openpose/openpose.cpp b/examples/openpose/openpose.cpp index 93861e3d..81006cda 100755 --- a/examples/openpose/openpose.cpp +++ b/examples/openpose/openpose.cpp @@ -269,7 +269,7 @@ int openPoseDemo() const op::WrapperStructPose wrapperStructPose{!FLAGS_body_disable, netInputSize, outputSize, keypointScale, FLAGS_num_gpu, FLAGS_num_gpu_start, FLAGS_scale_number, (float)FLAGS_scale_gap, - op::flagsToRenderMode(FLAGS_render_pose, FLAGS_3d, FLAGS_render_pose), + op::flagsToRenderMode(FLAGS_render_pose, FLAGS_3d), poseModel, !FLAGS_disable_blending, (float)FLAGS_alpha_pose, (float)FLAGS_alpha_heatmap, FLAGS_part_to_show, FLAGS_model_folder, heatMapTypes, heatMapScale, FLAGS_part_candidates, diff --git a/examples/tutorial_add_module/1_custom_post_processing.cpp b/examples/tutorial_add_module/1_custom_post_processing.cpp index 887d3641..ae06a168 100644 --- a/examples/tutorial_add_module/1_custom_post_processing.cpp +++ b/examples/tutorial_add_module/1_custom_post_processing.cpp @@ -270,7 +270,7 @@ int openPoseTutorialWrapper4() // Pose configuration (use WrapperStructPose{} for default and recommended configuration) const op::WrapperStructPose wrapperStructPose{!FLAGS_body_disable, netInputSize, outputSize, keypointScale, FLAGS_num_gpu, FLAGS_num_gpu_start, FLAGS_scale_number, - (float)FLAGS_scale_gap, op::flagsToRenderMode(FLAGS_render_pose), + (float)FLAGS_scale_gap, op::flagsToRenderMode(FLAGS_render_pose, FLAGS_3d), poseModel, !FLAGS_disable_blending, (float)FLAGS_alpha_pose, (float)FLAGS_alpha_heatmap, FLAGS_part_to_show, FLAGS_model_folder, heatMapTypes, heatMapScale, FLAGS_part_candidates, @@ -278,13 +278,13 @@ int openPoseTutorialWrapper4() enableGoogleLogging, FLAGS_3d}; // Face configuration (use op::WrapperStructFace{} to disable it) const op::WrapperStructFace wrapperStructFace{FLAGS_face, faceNetInputSize, - op::flagsToRenderMode(FLAGS_face_render, FLAGS_render_pose), + op::flagsToRenderMode(FLAGS_face_render, FLAGS_3d, FLAGS_render_pose), (float)FLAGS_face_alpha_pose, (float)FLAGS_face_alpha_heatmap, (float)FLAGS_face_render_threshold}; // Hand configuration (use op::WrapperStructHand{} to disable it) const op::WrapperStructHand wrapperStructHand{FLAGS_hand, handNetInputSize, FLAGS_hand_scale_number, (float)FLAGS_hand_scale_range, FLAGS_hand_tracking, - op::flagsToRenderMode(FLAGS_hand_render, FLAGS_render_pose), + op::flagsToRenderMode(FLAGS_hand_render, FLAGS_3d, FLAGS_render_pose), (float)FLAGS_hand_alpha_pose, (float)FLAGS_hand_alpha_heatmap, (float)FLAGS_hand_render_threshold}; // Producer (use default to disable any input) diff --git a/examples/tutorial_wrapper/1_user_asynchronous_output.cpp b/examples/tutorial_wrapper/1_user_asynchronous_output.cpp index 64830ec6..3fb46806 100644 --- a/examples/tutorial_wrapper/1_user_asynchronous_output.cpp +++ b/examples/tutorial_wrapper/1_user_asynchronous_output.cpp @@ -345,7 +345,7 @@ int openPoseTutorialWrapper1() // Pose configuration (use WrapperStructPose{} for default and recommended configuration) const op::WrapperStructPose wrapperStructPose{!FLAGS_body_disable, netInputSize, outputSize, keypointScale, FLAGS_num_gpu, FLAGS_num_gpu_start, FLAGS_scale_number, - (float)FLAGS_scale_gap, op::flagsToRenderMode(FLAGS_render_pose), + (float)FLAGS_scale_gap, op::flagsToRenderMode(FLAGS_render_pose, FLAGS_3d), poseModel, !FLAGS_disable_blending, (float)FLAGS_alpha_pose, (float)FLAGS_alpha_heatmap, FLAGS_part_to_show, FLAGS_model_folder, heatMapTypes, heatMapScale, FLAGS_part_candidates, @@ -353,13 +353,13 @@ int openPoseTutorialWrapper1() enableGoogleLogging, FLAGS_3d}; // Face configuration (use op::WrapperStructFace{} to disable it) const op::WrapperStructFace wrapperStructFace{FLAGS_face, faceNetInputSize, - op::flagsToRenderMode(FLAGS_face_render, FLAGS_render_pose), + op::flagsToRenderMode(FLAGS_face_render, FLAGS_3d, FLAGS_render_pose), (float)FLAGS_face_alpha_pose, (float)FLAGS_face_alpha_heatmap, (float)FLAGS_face_render_threshold}; // Hand configuration (use op::WrapperStructHand{} to disable it) const op::WrapperStructHand wrapperStructHand{FLAGS_hand, handNetInputSize, FLAGS_hand_scale_number, (float)FLAGS_hand_scale_range, FLAGS_hand_tracking, - op::flagsToRenderMode(FLAGS_hand_render, FLAGS_render_pose), + op::flagsToRenderMode(FLAGS_hand_render, FLAGS_3d, FLAGS_render_pose), (float)FLAGS_hand_alpha_pose, (float)FLAGS_hand_alpha_heatmap, (float)FLAGS_hand_render_threshold}; // Producer (use default to disable any input) diff --git a/examples/tutorial_wrapper/2_user_synchronous.cpp b/examples/tutorial_wrapper/2_user_synchronous.cpp index a7ed5e48..46f320a0 100644 --- a/examples/tutorial_wrapper/2_user_synchronous.cpp +++ b/examples/tutorial_wrapper/2_user_synchronous.cpp @@ -431,7 +431,7 @@ int openPoseTutorialWrapper2() op::log("Configuring OpenPose wrapper.", op::Priority::Low, __LINE__, __FUNCTION__, __FILE__); const op::WrapperStructPose wrapperStructPose{!FLAGS_body_disable, netInputSize, outputSize, keypointScale, FLAGS_num_gpu, FLAGS_num_gpu_start, FLAGS_scale_number, - (float)FLAGS_scale_gap, op::flagsToRenderMode(FLAGS_render_pose), + (float)FLAGS_scale_gap, op::flagsToRenderMode(FLAGS_render_pose, FLAGS_3d), poseModel, !FLAGS_disable_blending, (float)FLAGS_alpha_pose, (float)FLAGS_alpha_heatmap, FLAGS_part_to_show, FLAGS_model_folder, heatMapTypes, heatMapScale, FLAGS_part_candidates, @@ -439,13 +439,13 @@ int openPoseTutorialWrapper2() enableGoogleLogging, FLAGS_3d}; // Face configuration (use op::WrapperStructFace{} to disable it) const op::WrapperStructFace wrapperStructFace{FLAGS_face, faceNetInputSize, - op::flagsToRenderMode(FLAGS_face_render, FLAGS_render_pose), + op::flagsToRenderMode(FLAGS_face_render, FLAGS_3d, FLAGS_render_pose), (float)FLAGS_face_alpha_pose, (float)FLAGS_face_alpha_heatmap, (float)FLAGS_face_render_threshold}; // Hand configuration (use op::WrapperStructHand{} to disable it) const op::WrapperStructHand wrapperStructHand{FLAGS_hand, handNetInputSize, FLAGS_hand_scale_number, (float)FLAGS_hand_scale_range, FLAGS_hand_tracking, - op::flagsToRenderMode(FLAGS_hand_render, FLAGS_render_pose), + op::flagsToRenderMode(FLAGS_hand_render, FLAGS_3d, FLAGS_render_pose), (float)FLAGS_hand_alpha_pose, (float)FLAGS_hand_alpha_heatmap, (float)FLAGS_hand_render_threshold}; // Consumer (comment or use default argument to disable any output) diff --git a/examples/tutorial_wrapper/3_user_asynchronous.cpp b/examples/tutorial_wrapper/3_user_asynchronous.cpp index f1f825cd..985bc744 100644 --- a/examples/tutorial_wrapper/3_user_asynchronous.cpp +++ b/examples/tutorial_wrapper/3_user_asynchronous.cpp @@ -372,7 +372,7 @@ int openPoseTutorialWrapper3() // Pose configuration (use WrapperStructPose{} for default and recommended configuration) const op::WrapperStructPose wrapperStructPose{!FLAGS_body_disable, netInputSize, outputSize, keypointScale, FLAGS_num_gpu, FLAGS_num_gpu_start, FLAGS_scale_number, - (float)FLAGS_scale_gap, op::flagsToRenderMode(FLAGS_render_pose), + (float)FLAGS_scale_gap, op::flagsToRenderMode(FLAGS_render_pose, FLAGS_3d), poseModel, !FLAGS_disable_blending, (float)FLAGS_alpha_pose, (float)FLAGS_alpha_heatmap, FLAGS_part_to_show, FLAGS_model_folder, heatMapTypes, heatMapScale, FLAGS_part_candidates, @@ -380,13 +380,13 @@ int openPoseTutorialWrapper3() enableGoogleLogging, FLAGS_3d}; // Face configuration (use op::WrapperStructFace{} to disable it) const op::WrapperStructFace wrapperStructFace{FLAGS_face, faceNetInputSize, - op::flagsToRenderMode(FLAGS_face_render, FLAGS_render_pose), + op::flagsToRenderMode(FLAGS_face_render, FLAGS_3d, FLAGS_render_pose), (float)FLAGS_face_alpha_pose, (float)FLAGS_face_alpha_heatmap, (float)FLAGS_face_render_threshold}; // Hand configuration (use op::WrapperStructHand{} to disable it) const op::WrapperStructHand wrapperStructHand{FLAGS_hand, handNetInputSize, FLAGS_hand_scale_number, (float)FLAGS_hand_scale_range, FLAGS_hand_tracking, - op::flagsToRenderMode(FLAGS_hand_render, FLAGS_render_pose), + op::flagsToRenderMode(FLAGS_hand_render, FLAGS_3d, FLAGS_render_pose), (float)FLAGS_hand_alpha_pose, (float)FLAGS_hand_alpha_heatmap, (float)FLAGS_hand_render_threshold}; // Consumer (comment or use default argument to disable any output) diff --git a/src/openpose/utilities/flagsToOpenPose.cpp b/src/openpose/utilities/flagsToOpenPose.cpp index db687708..ab6fc3ea 100644 --- a/src/openpose/utilities/flagsToOpenPose.cpp +++ b/src/openpose/utilities/flagsToOpenPose.cpp @@ -156,14 +156,16 @@ namespace op if (type == ProducerType::FlirCamera) { // cameraFrameSize - const auto cameraFrameSize = op::flagsToPoint(cameraResolution, "-1x-1"); + const auto cameraFrameSize = flagsToPoint(cameraResolution, "-1x-1"); return std::make_shared(cameraParameterPath, cameraFrameSize); } // Webcam if (type == ProducerType::Webcam) { // cameraFrameSize - const auto cameraFrameSize = op::flagsToPoint(cameraResolution, "1280x720"); + auto cameraFrameSize = flagsToPoint(cameraResolution, "1280x720"); + if (cameraFrameSize.x < 0 || cameraFrameSize.y < 0) + cameraFrameSize = Point{1280,720}; if (webcamIndex >= 0) { const auto throwExceptionIfNoOpened = true; @@ -235,7 +237,7 @@ namespace op } // Face and hand: to pick same than body else if (renderFlag == -1 && renderPoseFlag != -2) - return flagsToRenderMode(renderPoseFlag, -2); + return flagsToRenderMode(renderPoseFlag, gpuBuggy, -2); // No render else if (renderFlag == 0) return RenderMode::None;