From a35999f51a0dc547a4fa5312d8b78fb0d970dd5f Mon Sep 17 00:00:00 2001 From: gineshidalgo99 Date: Wed, 21 Nov 2018 20:17:55 -0500 Subject: [PATCH] Flag renamed: camera_fps into write_video_fps --- doc/demo_overview.md | 6 +- doc/quick_start.md | 2 +- doc/release_notes.md | 7 ++- examples/calibration/calibration.cpp | 1 - examples/openpose/openpose.cpp | 9 ++- .../1_custom_post_processing.cpp | 9 ++- .../tutorial_api_cpp/1_body_from_image.cpp | 55 +++++++++------- .../2_whole_body_from_image.cpp | 61 ++++++++++-------- .../3_keypoints_from_image_configurable.cpp | 6 +- ...nchronous_loop_custom_input_and_output.cpp | 6 +- .../5_asynchronous_loop_custom_output.cpp | 9 ++- .../6_synchronous_custom_postprocessing.cpp | 9 ++- .../7_synchronous_custom_input.cpp | 11 +--- .../8_synchronous_custom_output.cpp | 9 ++- .../9_synchronous_custom_all.cpp | 6 +- .../thread_1_openpose_read_and_display.cpp | 6 +- .../thread_2_user_processing_function.cpp | 6 +- include/openpose/flags.hpp | 12 ++-- include/openpose/producer/producer.hpp | 2 +- include/openpose/producer/webcamReader.hpp | 6 +- include/openpose/wrapper/wrapperAuxiliary.hpp | 63 ++++++++++--------- .../openpose/wrapper/wrapperStructInput.hpp | 7 +-- .../openpose/wrapper/wrapperStructOutput.hpp | 6 +- src/openpose/producer/producer.cpp | 6 +- src/openpose/producer/webcamReader.cpp | 10 +-- src/openpose/wrapper/wrapperAuxiliary.cpp | 4 -- src/openpose/wrapper/wrapperStructInput.cpp | 3 +- 27 files changed, 166 insertions(+), 171 deletions(-) diff --git a/doc/demo_overview.md b/doc/demo_overview.md index 7eb085ff..3472d990 100644 --- a/doc/demo_overview.md +++ b/doc/demo_overview.md @@ -138,7 +138,6 @@ Each flag is divided into flag name, default value, and description. 2. 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, "-1x-1", "Set the camera resolution (either `--camera` or `--flir_camera`). `-1x-1` will use the default 1280x720 for `--camera`, or the maximum flir camera resolution available for `--flir_camera`"); -- DEFINE_double(camera_fps, 30.0, "Frame rate for the webcam (also used when saving video). 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.)."); - DEFINE_bool(flir_camera, false, "Whether to use FLIR (Point-Grey) stereo camera."); @@ -231,7 +230,8 @@ Each flag is divided into flag name, default value, and description. 16. Result Saving - DEFINE_string(write_images, "", "Directory to write rendered frames in `write_images_format` image format."); - DEFINE_string(write_images_format, "png", "File extension and format for `write_images`, e.g., png, jpg or bmp. Check the OpenCV function cv::imwrite for all compatible extensions."); -- DEFINE_string(write_video, "", "Full file path to write rendered frames in motion JPEG video format. It might fail if the final path does not finish in `.avi`. It internally uses cv::VideoWriter. Flag `camera_fps` controls FPS."); +- DEFINE_string(write_video, "", "Full file path to write rendered frames in motion JPEG video format. It might fail if the final path does not finish in `.avi`. It internally uses cv::VideoWriter. Flag `write_video_fps` controls FPS."); +- DEFINE_double(write_video_fps, -1., "Frame rate for the recorded video. By default, it will try to get the input frames producer frame rate (e.g., input video or webcam frame rate). If the input frames producer does not have a set FPS (e.g., image_dir or webcam if OpenCV not compiled with its support), set this value accordingly (e.g., to the frame rate displayed by the OpenPose GUI)."); - DEFINE_string(write_json, "", "Directory to write OpenPose output in JSON format. It includes body, hand, and face pose keypoints (2-D and 3-D), as well as pose candidates (if `--part_candidates` enabled)."); - DEFINE_string(write_coco_json, "", "Full file path to write people pose data with JSON COCO validation format."); - DEFINE_string(write_coco_foot_json, "", "Full file path to write people foot pose data with JSON COCO validation format."); @@ -242,7 +242,7 @@ Each flag is divided into flag name, default value, and description. - DEFINE_string(write_keypoint_format, "yml", "(Deprecated, use `write_json`) File extension and format for `write_keypoint`: json, xml, yaml & yml. Json not available for OpenCV < 3.0, use `write_json` instead."); 17. Result Saving - Extra Algorithms -- DEFINE_string(write_video_adam, "", "Experimental, not available yet. E.g., `~/Desktop/adamResult.avi`. Flag `camera_fps` controls FPS."); +- DEFINE_string(write_video_adam, "", "Experimental, not available yet. E.g., `~/Desktop/adamResult.avi`. Flag `write_video_fps` controls FPS."); - DEFINE_string(write_bvh, "", "Experimental, not available yet. E.g., `~/Desktop/mocapResult.bvh`."); 18. UDP Communication diff --git a/doc/quick_start.md b/doc/quick_start.md index 417eecb4..3a28150f 100644 --- a/doc/quick_start.md +++ b/doc/quick_start.md @@ -141,7 +141,7 @@ build\x64\Release\OpenPoseDemo.exe --flir_camera --3d --number_people_max 1 --fa # Ubuntu and Mac (same flags for Windows version) # Saving video # Note: saving in PNG rather than JPG will improve image quality, but slow down FPS (depending on hard disk writing speed and camera number) -./build/examples/openpose/openpose.bin --flir_camera --num_gpu 0 --write_video output_folder_path/video.avi --camera_fps 5 +./build/examples/openpose/openpose.bin --flir_camera --num_gpu 0 --write_video output_folder_path/video.avi --write_video_fps 5 # Saving images # Note: saving in PNG rather than JPG will improve image quality, but slow down FPS (depending on hard disk writing speed and camera number) ./build/examples/openpose/openpose.bin --flir_camera --num_gpu 0 --write_images output_folder_path/ --write_images_format jpg diff --git a/doc/release_notes.md b/doc/release_notes.md index a9199917..cb445efd 100644 --- a/doc/release_notes.md +++ b/doc/release_notes.md @@ -55,7 +55,7 @@ OpenPose Library - Release Notes 7. Rendering threshold for pose, face and hands becomes user-configurable. 8. Check() functions give more feedback. 9. WCocoJsonSaver finished and removed its 3599-image limit. - 10. Added `--camera_fps` so generated video will use that frame rate. + 10. Added `--camera_fps` so generated video (`--write_video`) will use that frame rate. 11. Reduced the number of printed information messages. Default logging priority threshold increased to Priority::Max. 12. GFlags to OpenPose configuration parameters reader moved from each demo to utilities/flagsToOpenPose. 13. Nms classes do not use `numberParts` for `Reshape`, they deduce the value. @@ -195,8 +195,7 @@ OpenPose Library - Release Notes 23. OpenPose small GUI shows the frame number w.r.t. the original producer, rather than the frame id. E.g., if video is started at frame 30, OpenPose will display 30 rather than 0 in the first frame. 24. OpenPose GUI: 'l' and 'k' functionality swapped. 25. 3-D reconstruction module: Added flag `--3d_min_views` to select minimum number of cameras required for 3-D reconstruction. - 26. Flag `--camera_fps` also applies to recorded video (`--write_video`). - 27. Flir camera producer `n` times faster for `n` cameras (multi-threaded). If the number of cameras is greater than the number of the computer threads, the speed up might not be exactly `n` times. + 26. Flir camera producer `n` times faster for `n` cameras (multi-threaded). If the number of cameras is greater than the number of the computer threads, the speed up might not be exactly `n` times. 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. @@ -290,6 +289,7 @@ OpenPose Library - Release Notes 19. All bash scripts incorporate `#!/bin/bash` to tell the terminal that they are bash scripts. 20. Added flag `--verbose` to plot the progress. 21. Added find_package(Protobuf) to allow specific versions of Protobuf. + 22. Examples do not end in core dumped if an OpenPose exception occurred, but it is rather closed returning -1. 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. @@ -298,6 +298,7 @@ OpenPose Library - Release Notes 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. + 8. Replaced `--camera_fps` flag by `--write_video_fps`, given that it was a confusing name: It did not affect the webcam FPS, but only the FPS of the output video. In addition, default value changed from 30 to -1. 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/calibration/calibration.cpp b/examples/calibration/calibration.cpp index 4c0b935a..71600d1e 100644 --- a/examples/calibration/calibration.cpp +++ b/examples/calibration/calibration.cpp @@ -112,7 +112,6 @@ int openPoseDemo() } catch (const std::exception& e) { - op::error(e.what(), __LINE__, __FUNCTION__, __FILE__); return -1; } } diff --git a/examples/openpose/openpose.cpp b/examples/openpose/openpose.cpp index 329ad312..91a66a4c 100755 --- a/examples/openpose/openpose.cpp +++ b/examples/openpose/openpose.cpp @@ -93,15 +93,15 @@ int openPoseDemo() const op::WrapperStructInput wrapperStructInput{ producerType, producerString, FLAGS_frame_first, FLAGS_frame_step, FLAGS_frame_last, FLAGS_process_real_time, FLAGS_frame_flip, FLAGS_frame_rotate, FLAGS_frames_repeat, - cameraSize, FLAGS_camera_fps, FLAGS_camera_parameter_folder, !FLAGS_frame_keep_distortion, - (unsigned int) FLAGS_3d_views}; + cameraSize, FLAGS_camera_parameter_folder, !FLAGS_frame_keep_distortion, (unsigned int) FLAGS_3d_views}; opWrapper.configure(wrapperStructInput); // Output (comment or use default argument to disable any output) const op::WrapperStructOutput wrapperStructOutput{ FLAGS_cli_verbose, 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_images, FLAGS_write_images_format, FLAGS_write_video, FLAGS_write_video_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{ @@ -128,7 +128,6 @@ int openPoseDemo() } catch (const std::exception& e) { - op::error(e.what(), __LINE__, __FUNCTION__, __FILE__); return -1; } } diff --git a/examples/tutorial_add_module/1_custom_post_processing.cpp b/examples/tutorial_add_module/1_custom_post_processing.cpp index f6fca022..4c227ffd 100644 --- a/examples/tutorial_add_module/1_custom_post_processing.cpp +++ b/examples/tutorial_add_module/1_custom_post_processing.cpp @@ -106,15 +106,15 @@ int tutorialAddModule1() const op::WrapperStructInput wrapperStructInput{ producerType, producerString, FLAGS_frame_first, FLAGS_frame_step, FLAGS_frame_last, FLAGS_process_real_time, FLAGS_frame_flip, FLAGS_frame_rotate, FLAGS_frames_repeat, - cameraSize, FLAGS_camera_fps, FLAGS_camera_parameter_folder, !FLAGS_frame_keep_distortion, - (unsigned int) FLAGS_3d_views}; + cameraSize, FLAGS_camera_parameter_folder, !FLAGS_frame_keep_distortion, (unsigned int) FLAGS_3d_views}; opWrapperT.configure(wrapperStructInput); // Output (comment or use default argument to disable any output) const op::WrapperStructOutput wrapperStructOutput{ FLAGS_cli_verbose, 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_images, FLAGS_write_images_format, FLAGS_write_video, FLAGS_write_video_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{ @@ -151,7 +151,6 @@ int tutorialAddModule1() } catch (const std::exception& e) { - op::error(e.what(), __LINE__, __FUNCTION__, __FILE__); return -1; } } diff --git a/examples/tutorial_api_cpp/1_body_from_image.cpp b/examples/tutorial_api_cpp/1_body_from_image.cpp index 3e8e542e..d74ae171 100644 --- a/examples/tutorial_api_cpp/1_body_from_image.cpp +++ b/examples/tutorial_api_cpp/1_body_from_image.cpp @@ -65,32 +65,39 @@ void printKeypoints(const std::shared_ptr>& datumsPtr) int tutorialApiCpp1() { - op::log("Starting OpenPose demo...", op::Priority::High); - - // Configuring OpenPose - op::log("Configuring OpenPose...", op::Priority::High); - op::Wrapper opWrapper{op::ThreadManagerMode::Asynchronous}; - // Set to single-thread (for sequential processing and/or debugging and/or reducing latency) - if (FLAGS_disable_multi_thread) - opWrapper.disableMultiThreading(); - // Starting OpenPose - op::log("Starting thread(s)...", op::Priority::High); - opWrapper.start(); - - // Process and display image - const auto imageToProcess = cv::imread(FLAGS_image_path); - auto datumProcessed = opWrapper.emplaceAndPop(imageToProcess); - if (datumProcessed != nullptr) + try { - printKeypoints(datumProcessed); - display(datumProcessed); - } - else - op::log("Image could not be processed.", op::Priority::High); + op::log("Starting OpenPose demo...", op::Priority::High); - // Return successful message - op::log("Stopping OpenPose...", op::Priority::High); - return 0; + // Configuring OpenPose + op::log("Configuring OpenPose...", op::Priority::High); + op::Wrapper opWrapper{op::ThreadManagerMode::Asynchronous}; + // Set to single-thread (for sequential processing and/or debugging and/or reducing latency) + if (FLAGS_disable_multi_thread) + opWrapper.disableMultiThreading(); + // Starting OpenPose + op::log("Starting thread(s)...", op::Priority::High); + opWrapper.start(); + + // Process and display image + const auto imageToProcess = cv::imread(FLAGS_image_path); + auto datumProcessed = opWrapper.emplaceAndPop(imageToProcess); + if (datumProcessed != nullptr) + { + printKeypoints(datumProcessed); + display(datumProcessed); + } + else + op::log("Image could not be processed.", op::Priority::High); + + // Return successful message + op::log("Stopping OpenPose...", op::Priority::High); + return 0; + } + catch (const std::exception& e) + { + return -1; + } } int main(int argc, char *argv[]) diff --git a/examples/tutorial_api_cpp/2_whole_body_from_image.cpp b/examples/tutorial_api_cpp/2_whole_body_from_image.cpp index 1f6b0d18..61746322 100644 --- a/examples/tutorial_api_cpp/2_whole_body_from_image.cpp +++ b/examples/tutorial_api_cpp/2_whole_body_from_image.cpp @@ -44,35 +44,42 @@ void printKeypoints(const std::shared_ptr>& datumsPtr) int tutorialApiCpp2() { - op::log("Starting OpenPose demo...", op::Priority::High); - - // Configuring OpenPose - op::log("Configuring OpenPose...", op::Priority::High); - op::Wrapper opWrapper{op::ThreadManagerMode::Asynchronous}; - // Add hand and face - opWrapper.configure(op::WrapperStructFace{true}); - opWrapper.configure(op::WrapperStructHand{true}); - // Set to single-thread (for sequential processing and/or debugging and/or reducing latency) - if (FLAGS_disable_multi_thread) - opWrapper.disableMultiThreading(); - // Starting OpenPose - op::log("Starting thread(s)...", op::Priority::High); - opWrapper.start(); - - // Process and display image - const auto imageToProcess = cv::imread(FLAGS_image_path); - auto datumProcessed = opWrapper.emplaceAndPop(imageToProcess); - if (datumProcessed != nullptr) + try { - printKeypoints(datumProcessed); - display(datumProcessed); - } - else - op::log("Image could not be processed.", op::Priority::High); + op::log("Starting OpenPose demo...", op::Priority::High); - // Return successful message - op::log("Stopping OpenPose...", op::Priority::High); - return 0; + // Configuring OpenPose + op::log("Configuring OpenPose...", op::Priority::High); + op::Wrapper opWrapper{op::ThreadManagerMode::Asynchronous}; + // Add hand and face + opWrapper.configure(op::WrapperStructFace{true}); + opWrapper.configure(op::WrapperStructHand{true}); + // Set to single-thread (for sequential processing and/or debugging and/or reducing latency) + if (FLAGS_disable_multi_thread) + opWrapper.disableMultiThreading(); + // Starting OpenPose + op::log("Starting thread(s)...", op::Priority::High); + opWrapper.start(); + + // Process and display image + const auto imageToProcess = cv::imread(FLAGS_image_path); + auto datumProcessed = opWrapper.emplaceAndPop(imageToProcess); + if (datumProcessed != nullptr) + { + printKeypoints(datumProcessed); + display(datumProcessed); + } + else + op::log("Image could not be processed.", op::Priority::High); + + // Return successful message + op::log("Stopping OpenPose...", op::Priority::High); + return 0; + } + catch (const std::exception& e) + { + return -1; + } } int main(int argc, char *argv[]) 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 ad44d6e7..7299a967 100644 --- a/examples/tutorial_api_cpp/3_keypoints_from_image_configurable.cpp +++ b/examples/tutorial_api_cpp/3_keypoints_from_image_configurable.cpp @@ -112,8 +112,9 @@ int tutorialApiCpp3() const op::WrapperStructOutput wrapperStructOutput{ FLAGS_cli_verbose, 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_images, FLAGS_write_images_format, FLAGS_write_video, FLAGS_write_video_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) @@ -140,7 +141,6 @@ int tutorialApiCpp3() } catch (const std::exception& e) { - op::error(e.what(), __LINE__, __FUNCTION__, __FILE__); return -1; } } 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 6c8ff418..fce642d5 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 @@ -245,8 +245,9 @@ int tutorialApiCpp4() const op::WrapperStructOutput wrapperStructOutput{ FLAGS_cli_verbose, 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_images, FLAGS_write_images_format, FLAGS_write_video, FLAGS_write_video_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) @@ -297,7 +298,6 @@ int tutorialApiCpp4() } catch (const std::exception& e) { - op::error(e.what(), __LINE__, __FUNCTION__, __FILE__); return -1; } } 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 c6d8ef3d..3b12621d 100644 --- a/examples/tutorial_api_cpp/5_asynchronous_loop_custom_output.cpp +++ b/examples/tutorial_api_cpp/5_asynchronous_loop_custom_output.cpp @@ -188,15 +188,15 @@ int tutorialApiCpp5() const op::WrapperStructInput wrapperStructInput{ producerType, producerString, FLAGS_frame_first, FLAGS_frame_step, FLAGS_frame_last, FLAGS_process_real_time, FLAGS_frame_flip, FLAGS_frame_rotate, FLAGS_frames_repeat, - cameraSize, FLAGS_camera_fps, FLAGS_camera_parameter_folder, !FLAGS_frame_keep_distortion, - (unsigned int) FLAGS_3d_views}; + cameraSize, FLAGS_camera_parameter_folder, !FLAGS_frame_keep_distortion, (unsigned int) FLAGS_3d_views}; opWrapperT.configure(wrapperStructInput); // Output (comment or use default argument to disable any output) const op::WrapperStructOutput wrapperStructOutput{ FLAGS_cli_verbose, 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_images, FLAGS_write_images_format, FLAGS_write_video, FLAGS_write_video_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) @@ -239,7 +239,6 @@ int tutorialApiCpp5() } catch (const std::exception& e) { - op::error(e.what(), __LINE__, __FUNCTION__, __FILE__); return -1; } } diff --git a/examples/tutorial_api_cpp/6_synchronous_custom_postprocessing.cpp b/examples/tutorial_api_cpp/6_synchronous_custom_postprocessing.cpp index 80bc0b6c..d799cd6f 100644 --- a/examples/tutorial_api_cpp/6_synchronous_custom_postprocessing.cpp +++ b/examples/tutorial_api_cpp/6_synchronous_custom_postprocessing.cpp @@ -156,15 +156,15 @@ int tutorialApiCpp6() const op::WrapperStructInput wrapperStructInput{ producerType, producerString, FLAGS_frame_first, FLAGS_frame_step, FLAGS_frame_last, FLAGS_process_real_time, FLAGS_frame_flip, FLAGS_frame_rotate, FLAGS_frames_repeat, - cameraSize, FLAGS_camera_fps, FLAGS_camera_parameter_folder, !FLAGS_frame_keep_distortion, - (unsigned int) FLAGS_3d_views}; + cameraSize, FLAGS_camera_parameter_folder, !FLAGS_frame_keep_distortion, (unsigned int) FLAGS_3d_views}; opWrapperT.configure(wrapperStructInput); // Output (comment or use default argument to disable any output) const op::WrapperStructOutput wrapperStructOutput{ FLAGS_cli_verbose, 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_images, FLAGS_write_images_format, FLAGS_write_video, FLAGS_write_video_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{ @@ -191,7 +191,6 @@ int tutorialApiCpp6() } catch (const std::exception& e) { - op::error(e.what(), __LINE__, __FUNCTION__, __FILE__); return -1; } } diff --git a/examples/tutorial_api_cpp/7_synchronous_custom_input.cpp b/examples/tutorial_api_cpp/7_synchronous_custom_input.cpp index 3135cac8..38faba10 100644 --- a/examples/tutorial_api_cpp/7_synchronous_custom_input.cpp +++ b/examples/tutorial_api_cpp/7_synchronous_custom_input.cpp @@ -135,11 +135,6 @@ int tutorialApiCpp7() const auto faceNetInputSize = op::flagsToPoint(FLAGS_face_net_resolution, "368x368 (multiples of 16)"); // handNetInputSize const auto handNetInputSize = op::flagsToPoint(FLAGS_hand_net_resolution, "368x368 (multiples of 16)"); - // // producerType - // const auto producerSharedPtr = op::flagsToProducer(FLAGS_image_dir, FLAGS_video, FLAGS_ip_camera, FLAGS_camera, - // FLAGS_flir_camera, FLAGS_camera_resolution, FLAGS_camera_fps, - // FLAGS_camera_parameter_folder, !FLAGS_frame_keep_distortion, - // (unsigned int) FLAGS_3d_views, FLAGS_flir_camera_index); // poseModel const auto poseModel = op::flagsToPoseModel(FLAGS_model_pose); // JSON saving @@ -196,8 +191,9 @@ int tutorialApiCpp7() const op::WrapperStructOutput wrapperStructOutput{ FLAGS_cli_verbose, 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_images, FLAGS_write_images_format, FLAGS_write_video, FLAGS_write_video_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{ @@ -224,7 +220,6 @@ int tutorialApiCpp7() } catch (const std::exception& e) { - op::error(e.what(), __LINE__, __FUNCTION__, __FILE__); return -1; } } diff --git a/examples/tutorial_api_cpp/8_synchronous_custom_output.cpp b/examples/tutorial_api_cpp/8_synchronous_custom_output.cpp index 863967cf..7d57d55a 100644 --- a/examples/tutorial_api_cpp/8_synchronous_custom_output.cpp +++ b/examples/tutorial_api_cpp/8_synchronous_custom_output.cpp @@ -203,15 +203,15 @@ int tutorialApiCpp8() const op::WrapperStructInput wrapperStructInput{ producerType, producerString, FLAGS_frame_first, FLAGS_frame_step, FLAGS_frame_last, FLAGS_process_real_time, FLAGS_frame_flip, FLAGS_frame_rotate, FLAGS_frames_repeat, - cameraSize, FLAGS_camera_fps, FLAGS_camera_parameter_folder, !FLAGS_frame_keep_distortion, - (unsigned int) FLAGS_3d_views}; + cameraSize, FLAGS_camera_parameter_folder, !FLAGS_frame_keep_distortion, (unsigned int) FLAGS_3d_views}; opWrapperT.configure(wrapperStructInput); // Output (comment or use default argument to disable any output) const op::WrapperStructOutput wrapperStructOutput{ FLAGS_cli_verbose, 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_images, FLAGS_write_images_format, FLAGS_write_video, FLAGS_write_video_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) @@ -235,7 +235,6 @@ int tutorialApiCpp8() } catch (const std::exception& e) { - op::error(e.what(), __LINE__, __FUNCTION__, __FILE__); return -1; } } diff --git a/examples/tutorial_api_cpp/9_synchronous_custom_all.cpp b/examples/tutorial_api_cpp/9_synchronous_custom_all.cpp index 4ae631ad..2ee381e2 100644 --- a/examples/tutorial_api_cpp/9_synchronous_custom_all.cpp +++ b/examples/tutorial_api_cpp/9_synchronous_custom_all.cpp @@ -302,8 +302,9 @@ int tutorialApiCpp9() const op::WrapperStructOutput wrapperStructOutput{ FLAGS_cli_verbose, 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_images, FLAGS_write_images_format, FLAGS_write_video, FLAGS_write_video_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) @@ -327,7 +328,6 @@ int tutorialApiCpp9() } catch (const std::exception& e) { - op::error(e.what(), __LINE__, __FUNCTION__, __FILE__); return -1; } } diff --git a/examples/tutorial_developer/thread_1_openpose_read_and_display.cpp b/examples/tutorial_developer/thread_1_openpose_read_and_display.cpp index 2865d29c..b6ada02d 100644 --- a/examples/tutorial_developer/thread_1_openpose_read_and_display.cpp +++ b/examples/tutorial_developer/thread_1_openpose_read_and_display.cpp @@ -34,8 +34,6 @@ DEFINE_int32(camera, -1, "The camera index for cv DEFINE_string(camera_resolution, "-1x-1", "Set the camera resolution (either `--camera` or `--flir_camera`). `-1x-1` will use the" " default 1280x720 for `--camera`, or the maximum flir camera resolution available for" " `--flir_camera`"); -DEFINE_double(camera_fps, 30.0, "Frame rate for the webcam (also used when saving video). 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" @@ -88,8 +86,8 @@ int tutorialDeveloperThread1() const auto displayProducerFpsMode = (FLAGS_process_real_time ? op::ProducerFpsMode::OriginalFps : op::ProducerFpsMode::RetrievalFps); auto producerSharedPtr = createProducer( - producerType, producerString, cameraSize, FLAGS_camera_fps, FLAGS_camera_parameter_folder, - !FLAGS_frame_keep_distortion, (unsigned int) FLAGS_3d_views); + producerType, producerString, cameraSize, FLAGS_camera_parameter_folder, !FLAGS_frame_keep_distortion, + (unsigned int) FLAGS_3d_views); producerSharedPtr->setProducerFpsMode(displayProducerFpsMode); op::log("", op::Priority::Low, __LINE__, __FUNCTION__, __FILE__); // Step 3 - Setting producer diff --git a/examples/tutorial_developer/thread_2_user_processing_function.cpp b/examples/tutorial_developer/thread_2_user_processing_function.cpp index 27d278cf..32786506 100644 --- a/examples/tutorial_developer/thread_2_user_processing_function.cpp +++ b/examples/tutorial_developer/thread_2_user_processing_function.cpp @@ -35,8 +35,6 @@ DEFINE_int32(camera, -1, "The camera index for cv DEFINE_string(camera_resolution, "-1x-1", "Set the camera resolution (either `--camera` or `--flir_camera`). `-1x-1` will use the" " default 1280x720 for `--camera`, or the maximum flir camera resolution available for" " `--flir_camera`"); -DEFINE_double(camera_fps, 30.0, "Frame rate for the webcam (also used when saving video). 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" @@ -122,8 +120,8 @@ int tutorialDeveloperThread2() const auto displayProducerFpsMode = (FLAGS_process_real_time ? op::ProducerFpsMode::OriginalFps : op::ProducerFpsMode::RetrievalFps); auto producerSharedPtr = createProducer( - producerType, producerString, cameraSize, FLAGS_camera_fps, FLAGS_camera_parameter_folder, - !FLAGS_frame_keep_distortion, (unsigned int) FLAGS_3d_views); + producerType, producerString, cameraSize, FLAGS_camera_parameter_folder, !FLAGS_frame_keep_distortion, + (unsigned int) FLAGS_3d_views); producerSharedPtr->setProducerFpsMode(displayProducerFpsMode); op::log("", op::Priority::Low, __LINE__, __FUNCTION__, __FILE__); // Step 3 - Setting producer diff --git a/include/openpose/flags.hpp b/include/openpose/flags.hpp index 8ccda40d..ec9aef0e 100644 --- a/include/openpose/flags.hpp +++ b/include/openpose/flags.hpp @@ -33,10 +33,6 @@ DEFINE_int32(camera, -1, "The camera index for cv DEFINE_string(camera_resolution, "-1x-1", "Set the camera resolution (either `--camera` or `--flir_camera`). `-1x-1` will use the" " default 1280x720 for `--camera`, or the maximum flir camera resolution available for" " `--flir_camera`"); -#endif // OPENPOSE_FLAGS_DISABLE_PRODUCER -DEFINE_double(camera_fps, 30.0, "Frame rate for the webcam (also used when saving video). Set this value to the minimum" - " value between the OpenPose displayed speed and the webcam real frame rate."); -#ifndef OPENPOSE_FLAGS_DISABLE_PRODUCER 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" @@ -214,7 +210,11 @@ DEFINE_string(write_images_format, "png", "File extension and form " function cv::imwrite for all compatible extensions."); DEFINE_string(write_video, "", "Full file path to write rendered frames in motion JPEG video format. It might fail if the" " final path does not finish in `.avi`. It internally uses cv::VideoWriter. Flag" - " `camera_fps` controls FPS."); + " `write_video_fps` controls FPS."); +DEFINE_double(write_video_fps, -1., "Frame rate for the recorded video. By default, it will try to get the input frames producer" + " frame rate (e.g., input video or webcam frame rate). If the input frames producer does not" + " have a set FPS (e.g., image_dir or webcam if OpenCV not compiled with its support), set" + " this value accordingly (e.g., to the frame rate displayed by the OpenPose GUI)."); DEFINE_string(write_json, "", "Directory to write OpenPose output in JSON format. It includes body, hand, and face pose" " keypoints (2-D and 3-D), as well as pose candidates (if `--part_candidates` enabled)."); DEFINE_string(write_coco_json, "", "Full file path to write people pose data with JSON COCO validation format."); @@ -231,7 +231,7 @@ DEFINE_string(write_keypoint, "", "(Deprecated, use `write DEFINE_string(write_keypoint_format, "yml", "(Deprecated, use `write_json`) File extension and format for `write_keypoint`: json, xml," " yaml & yml. Json not available for OpenCV < 3.0, use `write_json` instead."); // Result Saving - Extra Algorithms -DEFINE_string(write_video_adam, "", "Experimental, not available yet. E.g., `~/Desktop/adamResult.avi`. Flag `camera_fps`" +DEFINE_string(write_video_adam, "", "Experimental, not available yet. E.g., `~/Desktop/adamResult.avi`. Flag `write_video_fps`" " controls FPS."); DEFINE_string(write_bvh, "", "Experimental, not available yet. E.g., `~/Desktop/mocapResult.bvh`."); // UDP Communication diff --git a/include/openpose/producer/producer.hpp b/include/openpose/producer/producer.hpp index e3926dcf..5a96a1b0 100644 --- a/include/openpose/producer/producer.hpp +++ b/include/openpose/producer/producer.hpp @@ -184,7 +184,7 @@ namespace op */ OP_API std::shared_ptr createProducer( const ProducerType producerType = ProducerType::None, const std::string& producerString = "", - const Point& cameraResolution = Point{-1,-1}, const double webcamFps = 30., + const Point& cameraResolution = Point{-1,-1}, const std::string& cameraParameterPath = "models/cameraParameters/", const bool undistortImage = true, const unsigned int imageDirectoryStereo = -1); } diff --git a/include/openpose/producer/webcamReader.hpp b/include/openpose/producer/webcamReader.hpp index 6569eefb..2bcb18a8 100644 --- a/include/openpose/producer/webcamReader.hpp +++ b/include/openpose/producer/webcamReader.hpp @@ -21,10 +21,11 @@ namespace op * @param webcamIndex const int indicating the camera source (see the OpenCV documentation about * cv::VideoCapture for more details), in the range [0, 9]. * @param webcamResolution const Point parameter which specifies the desired camera resolution. - * @param fps Double parameter which specifies the desired camera frame rate. + * @param throwExceptionIfNoOpened Bool parameter which specifies whether to throw an exception if the camera + * cannot be opened. */ explicit WebcamReader(const int webcamIndex = 0, const Point& webcamResolution = Point{}, - const double fps = 30., const bool throwExceptionIfNoOpened = true); + const bool throwExceptionIfNoOpened = true); virtual ~WebcamReader(); @@ -44,7 +45,6 @@ namespace op private: const int mIndex; - double mFps; long long mFrameNameCounter; bool mThreadOpened; cv::Mat mBuffer; diff --git a/include/openpose/wrapper/wrapperAuxiliary.hpp b/include/openpose/wrapper/wrapperAuxiliary.hpp index d8ea9edb..80545d8a 100644 --- a/include/openpose/wrapper/wrapperAuxiliary.hpp +++ b/include/openpose/wrapper/wrapperAuxiliary.hpp @@ -98,9 +98,8 @@ namespace op // Create producer auto producerSharedPtr = createProducer( wrapperStructInput.producerType, wrapperStructInput.producerString, - wrapperStructInput.cameraResolution, wrapperStructInput.webcamFps, - wrapperStructInput.cameraParameterPath, wrapperStructInput.undistortImage, - wrapperStructInput.imageDirectoryStereo); + wrapperStructInput.cameraResolution, wrapperStructInput.cameraParameterPath, + wrapperStructInput.undistortImage, wrapperStructInput.imageDirectoryStereo); // Editable arguments auto wrapperStructPose = wrapperStructPoseTemp; @@ -649,35 +648,43 @@ namespace op outputWs.emplace_back(std::make_shared>(imageSaver)); } // Write frames as *.avi video on hard disk - const auto producerFps = (producerSharedPtr == nullptr ? - 0. : producerSharedPtr->get(CV_CAP_PROP_FPS)); - const auto originalVideoFps = (wrapperStructOutput.writeVideoFps > 0 ? - wrapperStructOutput.writeVideoFps - : producerFps); - if (!wrapperStructOutput.writeVideo.empty()) + if (!wrapperStructOutput.writeVideo.empty() || !wrapperStructOutput.writeBvh.empty()) { - if (!oPProducer) - error("Video file can only be recorded inside `wrapper/wrapper.hpp` if the producer" - " is one of the default ones (e.g., video, webcam, ...).", + if (wrapperStructOutput.writeVideoFps <= 0 + && (producerSharedPtr == nullptr || producerSharedPtr->get(CV_CAP_PROP_FPS) <= 0)) + error("The frame rate of the frames producer is unknown. Set `--write_video_fps` to your desired" + " FPS if you wanna record video (`--write_video`). E.g., if it is a folder of images, you" + " will have to know or guess the frame rate; if it is a webcam, you should use the OpenPose" + " displayed FPS as desired value. If you do not care, simply add `--write_video_fps 30`.", __LINE__, __FUNCTION__, __FILE__); - if (finalOutputSize.x <= 0 || finalOutputSize.y <= 0) - error("Video can only be recorded if outputSize is fixed (e.g., video, webcam, IP camera)," - "but not for a image directory.", __LINE__, __FUNCTION__, __FILE__); - const auto videoSaver = std::make_shared( - wrapperStructOutput.writeVideo, CV_FOURCC('M','J','P','G'), originalVideoFps, finalOutputSize - ); - outputWs.emplace_back(std::make_shared>(videoSaver)); - } - // Write joint angles as *.bvh file on hard disk + const auto originalVideoFps = ( + wrapperStructOutput.writeVideoFps > 0 ? + wrapperStructOutput.writeVideoFps : producerSharedPtr->get(CV_CAP_PROP_FPS)); + if (!wrapperStructOutput.writeVideo.empty()) + { + if (!oPProducer) + error("Video file can only be recorded inside `wrapper/wrapper.hpp` if the producer" + " is one of the default ones (e.g., video, webcam, ...).", + __LINE__, __FUNCTION__, __FILE__); + if (finalOutputSize.x <= 0 || finalOutputSize.y <= 0) + error("Video can only be recorded if outputSize is fixed (e.g., video, webcam, IP camera)," + " but not for a image directory.", __LINE__, __FUNCTION__, __FILE__); + const auto videoSaver = std::make_shared( + wrapperStructOutput.writeVideo, CV_FOURCC('M','J','P','G'), originalVideoFps, finalOutputSize + ); + outputWs.emplace_back(std::make_shared>(videoSaver)); + } + // Write joint angles as *.bvh file on hard disk #ifdef USE_3D_ADAM_MODEL - if (!wrapperStructOutput.writeBvh.empty()) - { - const auto bvhSaver = std::make_shared( - wrapperStructOutput.writeBvh, JointAngleEstimation::getTotalModel(), originalVideoFps - ); - outputWs.emplace_back(std::make_shared>(bvhSaver)); - } + if (!wrapperStructOutput.writeBvh.empty()) + { + const auto bvhSaver = std::make_shared( + wrapperStructOutput.writeBvh, JointAngleEstimation::getTotalModel(), originalVideoFps + ); + outputWs.emplace_back(std::make_shared>(bvhSaver)); + } #endif + } // Write heat maps as desired image format on hard disk if (!writeHeatMapsCleaned.empty()) { diff --git a/include/openpose/wrapper/wrapperStructInput.hpp b/include/openpose/wrapper/wrapperStructInput.hpp index 681b610b..72b6f910 100644 --- a/include/openpose/wrapper/wrapperStructInput.hpp +++ b/include/openpose/wrapper/wrapperStructInput.hpp @@ -71,11 +71,6 @@ namespace op */ Point cameraResolution; - /** - * Frame rate of the camera (only for some producers). - */ - double webcamFps; - /** * Directory path for the camera parameters (intrinsic and extrinsic parameters). */ @@ -102,7 +97,7 @@ namespace op 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 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 d7fa2042..30d5762c 100644 --- a/include/openpose/wrapper/wrapperStructOutput.hpp +++ b/include/openpose/wrapper/wrapperStructOutput.hpp @@ -97,6 +97,10 @@ namespace op /** * Frame rate of the recorded video. + * By default (-1.), it will try to get the input frames producer frame rate (e.g., input video or webcam frame + * rate). If the input frames producer does not have a set FPS (e.g., image_dir or webcam if OpenCV not + * compiled with its support), set this value accordingly (e.g., to the frame rate displayed by the OpenPose + * GUI). */ double writeVideoFps; @@ -135,7 +139,7 @@ namespace op 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 double writeVideoFps = -1., 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/src/openpose/producer/producer.cpp b/src/openpose/producer/producer.cpp index 475da23a..23122d3e 100644 --- a/src/openpose/producer/producer.cpp +++ b/src/openpose/producer/producer.cpp @@ -352,7 +352,7 @@ namespace op } std::shared_ptr createProducer(const ProducerType producerType, const std::string& producerString, - const Point& cameraResolution, const double webcamFps, + const Point& cameraResolution, const std::string& cameraParameterPath, const bool undistortImage, const unsigned int imageDirectoryStereo) { @@ -386,7 +386,7 @@ namespace op { const auto throwExceptionIfNoOpened = true; return std::make_shared( - webcamIndex, cameraResolutionFinal, webcamFps, throwExceptionIfNoOpened); + webcamIndex, cameraResolutionFinal, throwExceptionIfNoOpened); } else { @@ -395,7 +395,7 @@ namespace op for (auto index = 0 ; index < 10 ; index++) { webcamReader = std::make_shared( - index, cameraResolutionFinal, webcamFps, throwExceptionIfNoOpened); + index, cameraResolutionFinal, throwExceptionIfNoOpened); if (webcamReader->isOpened()) { log("Auto-detecting camera index... Detected and opened camera " + std::to_string(index) diff --git a/src/openpose/producer/webcamReader.cpp b/src/openpose/producer/webcamReader.cpp index 00cad5da..06c4ab3b 100644 --- a/src/openpose/producer/webcamReader.cpp +++ b/src/openpose/producer/webcamReader.cpp @@ -5,11 +5,10 @@ namespace op { - WebcamReader::WebcamReader(const int webcamIndex, const Point& webcamResolution, const double fps, + WebcamReader::WebcamReader(const int webcamIndex, const Point& webcamResolution, const bool throwExceptionIfNoOpened) : VideoCaptureReader{webcamIndex, throwExceptionIfNoOpened}, mIndex{webcamIndex}, - mFps{fps}, mFrameNameCounter{-1}, mThreadOpened{std::atomic{false}}, mResolution{webcamResolution} @@ -137,8 +136,6 @@ namespace op { if (capProperty == CV_CAP_PROP_POS_FRAMES) return (double)mFrameNameCounter; - else if (capProperty == CV_CAP_PROP_FPS) - return mFps; else return VideoCaptureReader::get(capProperty); } @@ -153,10 +150,7 @@ namespace op { try { - if (capProperty == CV_CAP_PROP_FPS) - mFps = value; - else - VideoCaptureReader::set(capProperty, value); + VideoCaptureReader::set(capProperty, value); } catch (const std::exception& e) { diff --git a/src/openpose/wrapper/wrapperAuxiliary.cpp b/src/openpose/wrapper/wrapperAuxiliary.cpp index 13403ff3..9864cb92 100644 --- a/src/openpose/wrapper/wrapperAuxiliary.cpp +++ b/src/openpose/wrapper/wrapperAuxiliary.cpp @@ -137,10 +137,6 @@ namespace op + std::to_string(wrapperStructPose.outputSize.x) + "x" + std::to_string(wrapperStructPose.outputSize.y) + ").", __LINE__, __FUNCTION__, __FILE__); - if (wrapperStructOutput.writeVideoFps <= 0 - && producerSharedPtr->get(CV_CAP_PROP_FPS) > 0) - error("Set `--camera_fps` for this producer, as its frame rate is unknown.", - __LINE__, __FUNCTION__, __FILE__); #ifdef USE_CPU_ONLY if (wrapperStructPose.scalesNumber > 1) error("Temporarily, the number of scales (`--scale_number`) cannot be greater than 1 for" diff --git a/src/openpose/wrapper/wrapperStructInput.cpp b/src/openpose/wrapper/wrapperStructInput.cpp index f202b806..e81a58fd 100644 --- a/src/openpose/wrapper/wrapperStructInput.cpp +++ b/src/openpose/wrapper/wrapperStructInput.cpp @@ -6,7 +6,7 @@ namespace op 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 std::string& cameraParameterPath_, const bool undistortImage_, const unsigned int imageDirectoryStereo_) : producerType{producerType_}, producerString{producerString_}, @@ -18,7 +18,6 @@ namespace op frameRotate{frameRotate_}, framesRepeat{framesRepeat_}, cameraResolution{cameraResolution_}, - webcamFps{webcamFps_}, cameraParameterPath{cameraParameterPath_}, undistortImage{undistortImage_}, imageDirectoryStereo{imageDirectoryStereo_}