diff --git a/doc/release_notes.md b/doc/release_notes.md index 1d1d7ff0..5c892b7b 100644 --- a/doc/release_notes.md +++ b/doc/release_notes.md @@ -274,6 +274,7 @@ OpenPose Library - Release Notes 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. 3. Main bugs fixed: 1. CMake-GUI was forcing to Release mode, allowed Debug modes too. diff --git a/examples/openpose/openpose.cpp b/examples/openpose/openpose.cpp index a2dbbcdf..5df23a08 100755 --- a/examples/openpose/openpose.cpp +++ b/examples/openpose/openpose.cpp @@ -1,20 +1,11 @@ -// ------------------------- OpenPose Library Tutorial - Real Time Pose Estimation ------------------------- -// If the user wants to learn to use the OpenPose library, we highly recommend to start with the -// examples in `examples/tutorial_api_cpp/`. -// This example summarizes all the functionality of the OpenPose library: - // 1. Read folder of images / video / webcam (`producer` module) - // 2. Extract and render body keypoint / heatmap / PAF of that image (`pose` module) - // 3. Extract and render face keypoint / heatmap / PAF of that image (`face` module) - // 4. Save the results on disk (`filestream` module) - // 5. Display the rendered pose (`gui` module) - // Everything in a multi-thread scenario (`thread` module) - // Points 2 to 5 are included in the `wrapper` module -// In addition to the previous OpenPose modules, we also need to use: - // 1. `core` module: - // For the Array class that the `pose` module needs - // For the Datum struct that the `thread` module sends between the queues - // 2. `utilities` module: for the error & logging functions, i.e. op::error & op::log respectively -// This file should only be used for the user to take specific examples. +// ------------------------------------------------ OpenPose C++ Demo ------------------------------------------------ +// This example summarizes all the functionality of the OpenPose library. It can... + // 1. Read a frames source (images, video, webcam, 3D stereo Flir cameras, etc.). + // 2. Extract and render body/hand/face/foot keypoint/heatmap/PAF of that image. + // 3. Save the results on disk. + // 4. Display the rendered pose. +// If the user wants to learn to use the OpenPose C++ library, we highly recommend to start with the examples in +// `examples/tutorial_api_cpp/`. // Command-line user intraface #include @@ -49,10 +40,10 @@ int openPoseDemo() // 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); + 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 @@ -69,11 +60,9 @@ int openPoseDemo() const auto multipleView = (FLAGS_3d || FLAGS_3d_views > 1 || FLAGS_flir_camera); // Enabling Google Logging const bool enableGoogleLogging = true; - // Logging - op::log("", op::Priority::Low, __LINE__, __FUNCTION__, __FILE__); - // OpenPose wrapper - op::log("Configuring OpenPose wrapper...", op::Priority::Low, __LINE__, __FUNCTION__, __FILE__); + // Configuring OpenPose + op::log("Configuring OpenPose...", op::Priority::High); op::Wrapper opWrapper; // Pose configuration (use WrapperStructPose{} for default and recommended configuration) const op::WrapperStructPose wrapperStructPose{ @@ -82,22 +71,27 @@ int openPoseDemo() 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}; + opWrapper.configure(wrapperStructPose); // Face configuration (use op::WrapperStructFace{} to disable it) const op::WrapperStructFace wrapperStructFace{ FLAGS_face, faceNetInputSize, op::flagsToRenderMode(FLAGS_face_render, multipleView, FLAGS_render_pose), (float)FLAGS_face_alpha_pose, (float)FLAGS_face_alpha_heatmap, (float)FLAGS_face_render_threshold}; + opWrapper.configure(wrapperStructFace); // 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, multipleView, FLAGS_render_pose), (float)FLAGS_hand_alpha_pose, (float)FLAGS_hand_alpha_heatmap, (float)FLAGS_hand_render_threshold}; + opWrapper.configure(wrapperStructHand); // Extra functionality configuration (use op::WrapperStructExtra{} to disable it) const op::WrapperStructExtra wrapperStructExtra{ FLAGS_3d, FLAGS_3d_min_views, FLAGS_identification, FLAGS_tracking, FLAGS_ik_threads}; + opWrapper.configure(wrapperStructExtra); // Producer (use default to disable any input) const op::WrapperStructInput wrapperStructInput{ producerSharedPtr, FLAGS_frame_first, FLAGS_frame_last, FLAGS_process_real_time, FLAGS_frame_flip, FLAGS_frame_rotate, FLAGS_frames_repeat}; + opWrapper.configure(wrapperStructInput); // Consumer (comment or use default argument to disable any output) const op::WrapperStructOutput wrapperStructOutput{ op::flagsToDisplayMode(FLAGS_display, FLAGS_3d), !FLAGS_no_gui_verbose, FLAGS_fullscreen, @@ -105,40 +99,15 @@ int openPoseDemo() FLAGS_write_coco_json, FLAGS_write_coco_foot_json, 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}; - // Configure wrapper - opWrapper.configure(wrapperStructPose, wrapperStructFace, wrapperStructHand, wrapperStructExtra, - wrapperStructInput, wrapperStructOutput); + opWrapper.configure(wrapperStructOutput); // Set to single-thread (for sequential processing and/or debugging and/or reducing latency) if (FLAGS_disable_multi_thread) opWrapper.disableMultiThreading(); - // Start processing - // Two different ways of running the program on multithread environment + // Start, run, and stop processing - exec() blocks this thread until OpenPose wrapper has finished op::log("Starting thread(s)...", op::Priority::High); - // Start, run & stop threads - it blocks this thread until all others have finished opWrapper.exec(); - // // Option b) Keeping this thread free in case you want to do something else meanwhile, e.g. profiling the GPU - // memory - // // VERY IMPORTANT NOTE: if OpenCV is compiled with Qt support, this option will not work. Qt needs the main - // // thread to plot visual results, so the final GUI (which uses OpenCV) would return an exception similar to: - // // `QMetaMethod::invoke: Unable to invoke methods with return values in queued connections` - // // Start threads - // opWrapper.start(); - // // Profile used GPU memory - // // 1: wait ~10sec so the memory has been totally loaded on GPU - // // 2: profile the GPU memory - // const auto sleepTimeMs = 10; - // for (auto i = 0 ; i < 10000/sleepTimeMs && opWrapper.isRunning() ; i++) - // std::this_thread::sleep_for(std::chrono::milliseconds{sleepTimeMs}); - // op::Profiler::profileGpuMemory(__LINE__, __FUNCTION__, __FILE__); - // // Keep program alive while running threads - // while (opWrapper.isRunning()) - // std::this_thread::sleep_for(std::chrono::milliseconds{sleepTimeMs}); - // // Stop and join threads - // op::log("Stopping thread(s)", op::Priority::High); - // opWrapper.stop(); - // Measuring total time const auto now = std::chrono::high_resolution_clock::now(); const auto totalTimeSec = (double)std::chrono::duration_cast(now-timerBegin).count() diff --git a/examples/tests/handFromJsonTest.cpp b/examples/tests/handFromJsonTest.cpp index c6f9e135..fa033683 100644 --- a/examples/tests/handFromJsonTest.cpp +++ b/examples/tests/handFromJsonTest.cpp @@ -1,4 +1,4 @@ -// ------------------------- OpenPose Library Tutorial - Hand Keypoint Detection from JSON Ground-Truth Data ------------------------- +// ----------------------- OpenPose Tests - Hand Keypoint Detection from JSON Ground-Truth Data ----------------------- // Example to test hands accuracy given ground-truth bounding boxes. // Command-line user intraface @@ -46,11 +46,9 @@ int handFromJsonTest() const auto producerSharedPtr = op::flagsToProducer(FLAGS_image_dir, "", "", 0); // Enabling Google Logging const bool enableGoogleLogging = true; - // Logging - op::log("", op::Priority::Low, __LINE__, __FUNCTION__, __FILE__); // OpenPose wrapper - op::log("Configuring OpenPose wrapper...", op::Priority::Low, __LINE__, __FUNCTION__, __FILE__); + op::log("Configuring OpenPose...", op::Priority::High); op::WrapperHandFromJsonTest> opWrapper; // Pose configuration (use WrapperStructPose{} for default and recommended configuration) op::WrapperStructPose wrapperStructPose{false, op::flagsToPoint("656x368"), op::flagsToPoint("1280x720"), diff --git a/examples/tutorial_add_module/1_custom_post_processing.cpp b/examples/tutorial_add_module/1_custom_post_processing.cpp index aac250fb..b967fd54 100644 --- a/examples/tutorial_add_module/1_custom_post_processing.cpp +++ b/examples/tutorial_add_module/1_custom_post_processing.cpp @@ -30,7 +30,7 @@ #include "userDatum.hpp" #include "wUserPostProcessing.hpp" -int openPoseTutorialWrapper4() +int tutorialAddModule1() { try { @@ -53,10 +53,10 @@ int openPoseTutorialWrapper4() // 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); + 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 @@ -73,12 +73,10 @@ int openPoseTutorialWrapper4() const auto multipleView = (FLAGS_3d || FLAGS_3d_views > 1 || FLAGS_flir_camera); // Enabling Google Logging const bool enableGoogleLogging = true; - // Logging - op::log("", op::Priority::Low, __LINE__, __FUNCTION__, __FILE__); // OpenPose wrapper - op::log("Configuring OpenPose wrapper...", op::Priority::Low, __LINE__, __FUNCTION__, __FILE__); - op::WrapperT> opWrapper; + op::log("Configuring OpenPose...", op::Priority::High); + op::WrapperT> opWrapperT; // 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, @@ -86,22 +84,27 @@ int openPoseTutorialWrapper4() 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}; + opWrapperT.configure(wrapperStructPose); // Face configuration (use op::WrapperStructFace{} to disable it) const op::WrapperStructFace wrapperStructFace{ FLAGS_face, faceNetInputSize, op::flagsToRenderMode(FLAGS_face_render, multipleView, FLAGS_render_pose), (float)FLAGS_face_alpha_pose, (float)FLAGS_face_alpha_heatmap, (float)FLAGS_face_render_threshold}; + opWrapperT.configure(wrapperStructFace); // 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, multipleView, FLAGS_render_pose), (float)FLAGS_hand_alpha_pose, (float)FLAGS_hand_alpha_heatmap, (float)FLAGS_hand_render_threshold}; + opWrapperT.configure(wrapperStructHand); // Extra functionality configuration (use op::WrapperStructExtra{} to disable it) const op::WrapperStructExtra wrapperStructExtra{ FLAGS_3d, FLAGS_3d_min_views, FLAGS_identification, FLAGS_tracking, FLAGS_ik_threads}; + opWrapperT.configure(wrapperStructExtra); // Producer (use default to disable any input) const op::WrapperStructInput wrapperStructInput{ producerSharedPtr, FLAGS_frame_first, FLAGS_frame_last, FLAGS_process_real_time, FLAGS_frame_flip, FLAGS_frame_rotate, FLAGS_frames_repeat}; + opWrapperT.configure(wrapperStructInput); // Consumer (comment or use default argument to disable any output) const op::WrapperStructOutput wrapperStructOutput{ op::flagsToDisplayMode(FLAGS_display, FLAGS_3d), !FLAGS_no_gui_verbose, FLAGS_fullscreen, @@ -109,6 +112,7 @@ int openPoseTutorialWrapper4() FLAGS_write_coco_json, FLAGS_write_coco_foot_json, FLAGS_write_images, FLAGS_write_images_format, FLAGS_write_video, FLAGS_camera_fps, FLAGS_write_heatmaps, FLAGS_write_heatmaps_format, FLAGS_write_video_adam, FLAGS_write_bvh, FLAGS_udp_host, FLAGS_udp_port}; + opWrapperT.configure(wrapperStructOutput); // Custom post-processing auto userPostProcessing = std::make_shared(/* Your class arguments here */); @@ -117,18 +121,15 @@ int openPoseTutorialWrapper4() ); // Add custom processing const auto workerProcessingOnNewThread = false; - opWrapper.setWorker(op::WorkerType::PostProcessing, wUserPostProcessing, workerProcessingOnNewThread); + opWrapperT.setWorker(op::WorkerType::PostProcessing, wUserPostProcessing, workerProcessingOnNewThread); - // Configure wrapper - opWrapper.configure(wrapperStructPose, wrapperStructFace, wrapperStructHand, wrapperStructExtra, - wrapperStructInput, wrapperStructOutput); // Set to single-thread (for sequential processing and/or debugging and/or reducing latency) if (FLAGS_disable_multi_thread) - opWrapper.disableMultiThreading(); + opWrapperT.disableMultiThreading(); op::log("Starting thread(s)...", op::Priority::High); // Start, run & stop threads - it blocks this thread until all others have finished - opWrapper.exec(); + opWrapperT.exec(); // Measuring total time const auto now = std::chrono::high_resolution_clock::now(); @@ -153,6 +154,6 @@ int main(int argc, char *argv[]) // Parsing command line flags gflags::ParseCommandLineFlags(&argc, &argv, true); - // Running openPoseTutorialWrapper4 - return openPoseTutorialWrapper4(); + // Running tutorialAddModule1 + return tutorialAddModule1(); } diff --git a/examples/tutorial_api_cpp/1_body_from_image.cpp b/examples/tutorial_api_cpp/1_body_from_image.cpp index 3aa24214..3e8e542e 100644 --- a/examples/tutorial_api_cpp/1_body_from_image.cpp +++ b/examples/tutorial_api_cpp/1_body_from_image.cpp @@ -63,7 +63,7 @@ void printKeypoints(const std::shared_ptr>& datumsPtr) op::log("Nullptr or empty datumsPtr found.", op::Priority::High); } -int bodyFromImage() +int tutorialApiCpp1() { op::log("Starting OpenPose demo...", op::Priority::High); @@ -98,6 +98,6 @@ int main(int argc, char *argv[]) // Parsing command line flags gflags::ParseCommandLineFlags(&argc, &argv, true); - // Running bodyFromImage - return bodyFromImage(); + // Running tutorialApiCpp1 + return tutorialApiCpp1(); } 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 82fcde61..1f6b0d18 100644 --- a/examples/tutorial_api_cpp/2_whole_body_from_image.cpp +++ b/examples/tutorial_api_cpp/2_whole_body_from_image.cpp @@ -42,7 +42,7 @@ void printKeypoints(const std::shared_ptr>& datumsPtr) op::log("Nullptr or empty datumsPtr found.", op::Priority::High); } -int wholeBodyFromImage() +int tutorialApiCpp2() { op::log("Starting OpenPose demo...", op::Priority::High); @@ -80,6 +80,6 @@ int main(int argc, char *argv[]) // Parsing command line flags gflags::ParseCommandLineFlags(&argc, &argv, true); - // Running wholeBodyFromImage - return wholeBodyFromImage(); + // Running tutorialApiCpp2 + return tutorialApiCpp2(); } 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 8b426709..dad00f90 100644 --- a/examples/tutorial_api_cpp/3_keypoints_from_image_configurable.cpp +++ b/examples/tutorial_api_cpp/3_keypoints_from_image_configurable.cpp @@ -44,100 +44,108 @@ void printKeypoints(const std::shared_ptr>& datumsPtr) op::log("Nullptr or empty datumsPtr found.", op::Priority::High); } -int wholeBodyFromImage() +int tutorialApiCpp3() { - op::log("Starting OpenPose demo...", op::Priority::High); - - // logging_level - op::check(0 <= FLAGS_logging_level && FLAGS_logging_level <= 255, "Wrong logging_level value.", - __LINE__, __FUNCTION__, __FILE__); - op::ConfigureLog::setPriorityThreshold((op::Priority)FLAGS_logging_level); - op::Profiler::setDefaultX(FLAGS_profile_speed); - - // Applying user defined configuration - GFlags to program variables - // outputSize - const auto outputSize = op::flagsToPoint(FLAGS_output_resolution, "-1x-1"); - // netInputSize - const auto netInputSize = op::flagsToPoint(FLAGS_net_resolution, "-1x368"); - // faceNetInputSize - 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)"); - // poseModel - const auto poseModel = op::flagsToPoseModel(FLAGS_model_pose); - // JSON saving - if (!FLAGS_write_keypoint.empty()) - op::log("Flag `write_keypoint` is deprecated and will eventually be removed." - " Please, use `write_json` instead.", op::Priority::Max); - // keypointScale - const auto keypointScale = op::flagsToScaleMode(FLAGS_keypoint_scale); - // heatmaps to add - const auto heatMapTypes = op::flagsToHeatMaps(FLAGS_heatmaps_add_parts, FLAGS_heatmaps_add_bkg, - FLAGS_heatmaps_add_PAFs); - const auto heatMapScale = op::flagsToHeatMapScaleMode(FLAGS_heatmaps_scale); - // >1 camera view? - const auto multipleView = (FLAGS_3d || FLAGS_3d_views > 1); - // Enabling Google Logging - const bool enableGoogleLogging = true; - // Logging - op::log("", op::Priority::Low, __LINE__, __FUNCTION__, __FILE__); - - // Configuring OpenPose - op::log("Configuring OpenPose...", op::Priority::High); - op::Wrapper opWrapper{op::ThreadManagerMode::Asynchronous}; - // 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, 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}; - // Face configuration (use op::WrapperStructFace{} to disable it) - const op::WrapperStructFace wrapperStructFace{ - FLAGS_face, faceNetInputSize, op::flagsToRenderMode(FLAGS_face_render, multipleView, 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, multipleView, FLAGS_render_pose), (float)FLAGS_hand_alpha_pose, - (float)FLAGS_hand_alpha_heatmap, (float)FLAGS_hand_render_threshold}; - // Extra functionality configuration (use op::WrapperStructExtra{} to disable it) - const op::WrapperStructExtra wrapperStructExtra{ - FLAGS_3d, FLAGS_3d_min_views, FLAGS_identification, FLAGS_tracking, FLAGS_ik_threads}; - // Consumer (comment or use default argument to disable any output) - const auto displayMode = op::DisplayMode::NoDisplay; - const bool guiVerbose = false; - const bool fullScreen = false; - const op::WrapperStructOutput wrapperStructOutput{ - displayMode, guiVerbose, fullScreen, FLAGS_write_keypoint, - op::stringToDataFormat(FLAGS_write_keypoint_format), FLAGS_write_json, FLAGS_write_coco_json, - FLAGS_write_coco_foot_json, FLAGS_write_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}; - // Configure wrapper - opWrapper.configure(wrapperStructPose, wrapperStructFace, wrapperStructHand, wrapperStructExtra, - op::WrapperStructInput{}, wrapperStructOutput); - // 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; + // logging_level + op::check(0 <= FLAGS_logging_level && FLAGS_logging_level <= 255, "Wrong logging_level value.", + __LINE__, __FUNCTION__, __FILE__); + op::ConfigureLog::setPriorityThreshold((op::Priority)FLAGS_logging_level); + op::Profiler::setDefaultX(FLAGS_profile_speed); + + // Applying user defined configuration - GFlags to program variables + // outputSize + const auto outputSize = op::flagsToPoint(FLAGS_output_resolution, "-1x-1"); + // netInputSize + const auto netInputSize = op::flagsToPoint(FLAGS_net_resolution, "-1x368"); + // faceNetInputSize + 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)"); + // poseModel + const auto poseModel = op::flagsToPoseModel(FLAGS_model_pose); + // JSON saving + if (!FLAGS_write_keypoint.empty()) + op::log("Flag `write_keypoint` is deprecated and will eventually be removed." + " Please, use `write_json` instead.", op::Priority::Max); + // keypointScale + const auto keypointScale = op::flagsToScaleMode(FLAGS_keypoint_scale); + // heatmaps to add + const auto heatMapTypes = op::flagsToHeatMaps(FLAGS_heatmaps_add_parts, FLAGS_heatmaps_add_bkg, + FLAGS_heatmaps_add_PAFs); + const auto heatMapScale = op::flagsToHeatMapScaleMode(FLAGS_heatmaps_scale); + // >1 camera view? + const auto multipleView = (FLAGS_3d || FLAGS_3d_views > 1); + // Enabling Google Logging + const bool enableGoogleLogging = true; + + // Configuring OpenPose + op::log("Configuring OpenPose...", op::Priority::High); + op::Wrapper opWrapper{op::ThreadManagerMode::Asynchronous}; + // 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, 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}; + opWrapper.configure(wrapperStructPose); + // Face configuration (use op::WrapperStructFace{} to disable it) + const op::WrapperStructFace wrapperStructFace{ + FLAGS_face, faceNetInputSize, op::flagsToRenderMode(FLAGS_face_render, multipleView, FLAGS_render_pose), + (float)FLAGS_face_alpha_pose, (float)FLAGS_face_alpha_heatmap, (float)FLAGS_face_render_threshold}; + opWrapper.configure(wrapperStructFace); + // 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, multipleView, FLAGS_render_pose), (float)FLAGS_hand_alpha_pose, + (float)FLAGS_hand_alpha_heatmap, (float)FLAGS_hand_render_threshold}; + opWrapper.configure(wrapperStructHand); + // Extra functionality configuration (use op::WrapperStructExtra{} to disable it) + const op::WrapperStructExtra wrapperStructExtra{ + FLAGS_3d, FLAGS_3d_min_views, FLAGS_identification, FLAGS_tracking, FLAGS_ik_threads}; + opWrapper.configure(wrapperStructExtra); + // Consumer (comment or use default argument to disable any output) + const auto displayMode = op::DisplayMode::NoDisplay; + const bool guiVerbose = false; + const bool fullScreen = false; + const op::WrapperStructOutput wrapperStructOutput{ + displayMode, guiVerbose, fullScreen, FLAGS_write_keypoint, + op::stringToDataFormat(FLAGS_write_keypoint_format), FLAGS_write_json, FLAGS_write_coco_json, + FLAGS_write_coco_foot_json, FLAGS_write_images, FLAGS_write_images_format, FLAGS_write_video, + FLAGS_camera_fps, FLAGS_write_heatmaps, FLAGS_write_heatmaps_format, FLAGS_write_video_adam, + FLAGS_write_bvh, FLAGS_udp_host, FLAGS_udp_port}; + opWrapper.configure(wrapperStructOutput); + // 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) + { + op::error(e.what(), __LINE__, __FUNCTION__, __FILE__); + return -1; + } } int main(int argc, char *argv[]) @@ -145,6 +153,6 @@ int main(int argc, char *argv[]) // Parsing command line flags gflags::ParseCommandLineFlags(&argc, &argv, true); - // Running wholeBodyFromImage - return wholeBodyFromImage(); + // Running tutorialApiCpp3 + return tutorialApiCpp3(); } 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 de84a6b5..2f8971ae 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 @@ -176,7 +176,7 @@ public: } }; -int example4() +int tutorialApiCpp4() { try { @@ -214,11 +214,9 @@ int example4() const auto multipleView = (FLAGS_3d || FLAGS_3d_views > 1); // Enabling Google Logging const bool enableGoogleLogging = true; - // Logging - op::log("", op::Priority::Low, __LINE__, __FUNCTION__, __FILE__); - // Configure OpenPose - op::log("Configuring OpenPose wrapper...", op::Priority::Low, __LINE__, __FUNCTION__, __FILE__); + // Configuring OpenPose + op::log("Configuring OpenPose...", op::Priority::High); op::WrapperT> opWrapperT{op::ThreadManagerMode::Asynchronous}; // Pose configuration (use WrapperStructPose{} for default and recommended configuration) const op::WrapperStructPose wrapperStructPose{ @@ -227,18 +225,22 @@ int example4() 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}; + opWrapperT.configure(wrapperStructPose); // Face configuration (use op::WrapperStructFace{} to disable it) const op::WrapperStructFace wrapperStructFace{ FLAGS_face, faceNetInputSize, op::flagsToRenderMode(FLAGS_face_render, multipleView, FLAGS_render_pose), (float)FLAGS_face_alpha_pose, (float)FLAGS_face_alpha_heatmap, (float)FLAGS_face_render_threshold}; + opWrapperT.configure(wrapperStructFace); // 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, multipleView, FLAGS_render_pose), (float)FLAGS_hand_alpha_pose, (float)FLAGS_hand_alpha_heatmap, (float)FLAGS_hand_render_threshold}; + opWrapperT.configure(wrapperStructHand); // Extra functionality configuration (use op::WrapperStructExtra{} to disable it) const op::WrapperStructExtra wrapperStructExtra{ FLAGS_3d, FLAGS_3d_min_views, FLAGS_identification, FLAGS_tracking, FLAGS_ik_threads}; + opWrapperT.configure(wrapperStructExtra); // Consumer (comment or use default argument to disable any output) const auto displayMode = op::DisplayMode::NoDisplay; const bool guiVerbose = false; @@ -249,13 +251,12 @@ int example4() FLAGS_write_coco_foot_json, 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}; - // Configure wrapper - opWrapperT.configure(wrapperStructPose, wrapperStructFace, wrapperStructHand, wrapperStructExtra, - op::WrapperStructInput{}, wrapperStructOutput); + opWrapperT.configure(wrapperStructOutput); // Set to single-thread (for sequential processing and/or debugging and/or reducing latency) if (FLAGS_disable_multi_thread) - opWrapperT.disableMultiThreading(); + opWrapperT.disableMultiThreading(); + // Start, run, and stop processing - exec() blocks this thread until OpenPose wrapper has finished op::log("Starting thread(s)...", op::Priority::High); opWrapperT.start(); @@ -309,6 +310,6 @@ int main(int argc, char *argv[]) // Parsing command line flags gflags::ParseCommandLineFlags(&argc, &argv, true); - // Running example4 - return example4(); + // Running tutorialApiCpp4 + return tutorialApiCpp4(); } 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 f574dfc5..a5382108 100644 --- a/examples/tutorial_api_cpp/5_asynchronous_loop_custom_output.cpp +++ b/examples/tutorial_api_cpp/5_asynchronous_loop_custom_output.cpp @@ -112,7 +112,7 @@ public: } }; -int openPoseTutorialWrapper1() +int tutorialApiCpp5() { try { @@ -135,10 +135,10 @@ int openPoseTutorialWrapper1() // 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); + 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 @@ -155,11 +155,9 @@ int openPoseTutorialWrapper1() const auto multipleView = (FLAGS_3d || FLAGS_3d_views > 1 || FLAGS_flir_camera); // Enabling Google Logging const bool enableGoogleLogging = true; - // Logging - op::log("", op::Priority::Low, __LINE__, __FUNCTION__, __FILE__); - // Configure OpenPose - op::log("Configuring OpenPose wrapper...", op::Priority::Low, __LINE__, __FUNCTION__, __FILE__); + // Configuring OpenPose + op::log("Configuring OpenPose...", op::Priority::High); op::WrapperT> opWrapperT{op::ThreadManagerMode::AsynchronousOut}; // Pose configuration (use WrapperStructPose{} for default and recommended configuration) const op::WrapperStructPose wrapperStructPose{ @@ -168,22 +166,27 @@ int openPoseTutorialWrapper1() 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}; + opWrapperT.configure(wrapperStructPose); // Face configuration (use op::WrapperStructFace{} to disable it) const op::WrapperStructFace wrapperStructFace{ FLAGS_face, faceNetInputSize, op::flagsToRenderMode(FLAGS_face_render, multipleView, FLAGS_render_pose), (float)FLAGS_face_alpha_pose, (float)FLAGS_face_alpha_heatmap, (float)FLAGS_face_render_threshold}; + opWrapperT.configure(wrapperStructFace); // 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, multipleView, FLAGS_render_pose), (float)FLAGS_hand_alpha_pose, (float)FLAGS_hand_alpha_heatmap, (float)FLAGS_hand_render_threshold}; + opWrapperT.configure(wrapperStructHand); // Extra functionality configuration (use op::WrapperStructExtra{} to disable it) const op::WrapperStructExtra wrapperStructExtra{ FLAGS_3d, FLAGS_3d_min_views, FLAGS_identification, FLAGS_tracking, FLAGS_ik_threads}; + opWrapperT.configure(wrapperStructExtra); // Producer (use default to disable any input) const op::WrapperStructInput wrapperStructInput{ producerSharedPtr, FLAGS_frame_first, FLAGS_frame_last, FLAGS_process_real_time, FLAGS_frame_flip, FLAGS_frame_rotate, FLAGS_frames_repeat}; + opWrapperT.configure(wrapperStructInput); // Consumer (comment or use default argument to disable any output) const auto displayMode = op::DisplayMode::NoDisplay; const bool guiVerbose = false; @@ -194,13 +197,12 @@ int openPoseTutorialWrapper1() FLAGS_write_coco_foot_json, 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}; - // Configure wrapper - opWrapperT.configure(wrapperStructPose, wrapperStructFace, wrapperStructHand, wrapperStructExtra, - wrapperStructInput, wrapperStructOutput); + opWrapperT.configure(wrapperStructOutput); // Set to single-thread (for sequential processing and/or debugging and/or reducing latency) if (FLAGS_disable_multi_thread) - opWrapperT.disableMultiThreading(); + opWrapperT.disableMultiThreading(); + // Start, run, and stop processing - exec() blocks this thread until OpenPose wrapper has finished op::log("Starting thread(s)...", op::Priority::High); opWrapperT.start(); @@ -246,6 +248,6 @@ int main(int argc, char *argv[]) // Parsing command line flags gflags::ParseCommandLineFlags(&argc, &argv, true); - // Running openPoseTutorialWrapper1 - return openPoseTutorialWrapper1(); + // Running tutorialApiCpp5 + return tutorialApiCpp5(); } diff --git a/examples/tutorial_api_cpp/6_synchronous_custom_postprocessing.cpp b/examples/tutorial_api_cpp/6_synchronous_custom_postprocessing.cpp index cc193eee..047003e1 100644 --- a/examples/tutorial_api_cpp/6_synchronous_custom_postprocessing.cpp +++ b/examples/tutorial_api_cpp/6_synchronous_custom_postprocessing.cpp @@ -67,7 +67,7 @@ public: } }; -int openPoseDemo() +int tutorialApiCpp6() { try { @@ -95,10 +95,10 @@ int openPoseDemo() // 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); + 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 @@ -115,19 +115,17 @@ int openPoseDemo() const auto multipleView = (FLAGS_3d || FLAGS_3d_views > 1 || FLAGS_flir_camera); // Enabling Google Logging const bool enableGoogleLogging = true; - // Logging - op::log("", op::Priority::Low, __LINE__, __FUNCTION__, __FILE__); // OpenPose wrapper - op::log("Configuring OpenPose wrapper...", op::Priority::Low, __LINE__, __FUNCTION__, __FILE__); - op::WrapperT> opWrapper; + op::log("Configuring OpenPose...", op::Priority::High); + op::WrapperT> opWrapperT; // Initializing the user custom classes // Processing auto wUserPostProcessing = std::make_shared(); // Add custom processing const auto workerProcessingOnNewThread = true; - opWrapper.setWorker(op::WorkerType::PostProcessing, wUserPostProcessing, workerProcessingOnNewThread); + opWrapperT.setWorker(op::WorkerType::PostProcessing, wUserPostProcessing, workerProcessingOnNewThread); // Pose configuration (use WrapperStructPose{} for default and recommended configuration) const op::WrapperStructPose wrapperStructPose{ @@ -136,22 +134,27 @@ int openPoseDemo() 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}; + opWrapperT.configure(wrapperStructPose); // Face configuration (use op::WrapperStructFace{} to disable it) const op::WrapperStructFace wrapperStructFace{ FLAGS_face, faceNetInputSize, op::flagsToRenderMode(FLAGS_face_render, multipleView, FLAGS_render_pose), (float)FLAGS_face_alpha_pose, (float)FLAGS_face_alpha_heatmap, (float)FLAGS_face_render_threshold}; + opWrapperT.configure(wrapperStructFace); // 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, multipleView, FLAGS_render_pose), (float)FLAGS_hand_alpha_pose, (float)FLAGS_hand_alpha_heatmap, (float)FLAGS_hand_render_threshold}; + opWrapperT.configure(wrapperStructHand); + // Extra functionality configuration (use op::WrapperStructExtra{} to disable it) + const op::WrapperStructExtra wrapperStructExtra{ + FLAGS_3d, FLAGS_3d_min_views, FLAGS_identification, FLAGS_tracking, FLAGS_ik_threads}; + opWrapperT.configure(wrapperStructExtra); // Producer (use default to disable any input) const op::WrapperStructInput wrapperStructInput{ producerSharedPtr, FLAGS_frame_first, FLAGS_frame_last, FLAGS_process_real_time, FLAGS_frame_flip, FLAGS_frame_rotate, FLAGS_frames_repeat}; - // Extra functionality configuration (use op::WrapperStructExtra{} to disable it) - const op::WrapperStructExtra wrapperStructExtra{ - FLAGS_3d, FLAGS_3d_min_views, FLAGS_identification, FLAGS_tracking, FLAGS_ik_threads}; + opWrapperT.configure(wrapperStructInput); // Consumer (comment or use default argument to disable any output) const op::WrapperStructOutput wrapperStructOutput{ op::flagsToDisplayMode(FLAGS_display, FLAGS_3d), !FLAGS_no_gui_verbose, FLAGS_fullscreen, @@ -159,39 +162,14 @@ int openPoseDemo() FLAGS_write_coco_json, FLAGS_write_coco_foot_json, 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}; - // Configure wrapper - opWrapper.configure(wrapperStructPose, wrapperStructFace, wrapperStructHand, wrapperStructExtra, - wrapperStructInput, wrapperStructOutput); + opWrapperT.configure(wrapperStructOutput); // Set to single-thread (for sequential processing and/or debugging and/or reducing latency) if (FLAGS_disable_multi_thread) - opWrapper.disableMultiThreading(); + opWrapperT.disableMultiThreading(); - // Start processing - // Two different ways of running the program on multithread environment + // Start, run, and stop processing - exec() blocks this thread until OpenPose wrapper has finished op::log("Starting thread(s)...", op::Priority::High); - // Start, run & stop threads - it blocks this thread until all others have finished - opWrapper.exec(); - - // // Option b) Keeping this thread free in case you want to do something else meanwhile, e.g. profiling the GPU - // memory - // // VERY IMPORTANT NOTE: if OpenCV is compiled with Qt support, this option will not work. Qt needs the main - // // thread to plot visual results, so the final GUI (which uses OpenCV) would return an exception similar to: - // // `QMetaMethod::invoke: Unable to invoke methods with return values in queued connections` - // // Start threads - // opWrapper.start(); - // // Profile used GPU memory - // // 1: wait ~10sec so the memory has been totally loaded on GPU - // // 2: profile the GPU memory - // const auto sleepTimeMs = 10; - // for (auto i = 0 ; i < 10000/sleepTimeMs && opWrapper.isRunning() ; i++) - // std::this_thread::sleep_for(std::chrono::milliseconds{sleepTimeMs}); - // op::Profiler::profileGpuMemory(__LINE__, __FUNCTION__, __FILE__); - // // Keep program alive while running threads - // while (opWrapper.isRunning()) - // std::this_thread::sleep_for(std::chrono::milliseconds{sleepTimeMs}); - // // Stop and join threads - // op::log("Stopping thread(s)", op::Priority::High); - // opWrapper.stop(); + opWrapperT.exec(); // Measuring total time const auto now = std::chrono::high_resolution_clock::now(); @@ -216,6 +194,6 @@ int main(int argc, char *argv[]) // Parsing command line flags gflags::ParseCommandLineFlags(&argc, &argv, true); - // Running openPoseDemo - return openPoseDemo(); + // Running tutorialApiCpp6 + return tutorialApiCpp6(); } diff --git a/examples/tutorial_api_cpp/7_synchronous_custom_input.cpp b/examples/tutorial_api_cpp/7_synchronous_custom_input.cpp index d2646f01..b575d362 100644 --- a/examples/tutorial_api_cpp/7_synchronous_custom_input.cpp +++ b/examples/tutorial_api_cpp/7_synchronous_custom_input.cpp @@ -108,7 +108,7 @@ private: unsigned long long mCounter; }; -int openPoseDemo() +int tutorialApiCpp7() { try { @@ -157,11 +157,9 @@ int openPoseDemo() const auto multipleView = false; // Enabling Google Logging const bool enableGoogleLogging = true; - // Logging - op::log("", op::Priority::Low, __LINE__, __FUNCTION__, __FILE__); // OpenPose wrapper - op::log("Configuring OpenPose wrapper...", op::Priority::Low, __LINE__, __FUNCTION__, __FILE__); + op::log("Configuring OpenPose...", op::Priority::High); op::WrapperT> opWrapperT; // Initializing the user custom classes @@ -178,23 +176,22 @@ int openPoseDemo() 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}; + opWrapperT.configure(wrapperStructPose); // Face configuration (use op::WrapperStructFace{} to disable it) const op::WrapperStructFace wrapperStructFace{ FLAGS_face, faceNetInputSize, op::flagsToRenderMode(FLAGS_face_render, multipleView, FLAGS_render_pose), (float)FLAGS_face_alpha_pose, (float)FLAGS_face_alpha_heatmap, (float)FLAGS_face_render_threshold}; + opWrapperT.configure(wrapperStructFace); // 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, multipleView, FLAGS_render_pose), (float)FLAGS_hand_alpha_pose, (float)FLAGS_hand_alpha_heatmap, (float)FLAGS_hand_render_threshold}; + opWrapperT.configure(wrapperStructHand); // Extra functionality configuration (use op::WrapperStructExtra{} to disable it) const op::WrapperStructExtra wrapperStructExtra{ FLAGS_3d, FLAGS_3d_min_views, FLAGS_identification, FLAGS_tracking, FLAGS_ik_threads}; - // Producer (use default to disable any input) - // const op::WrapperStructInput wrapperStructInput{producerSharedPtr, FLAGS_frame_first, FLAGS_frame_last, - // FLAGS_process_real_time, FLAGS_frame_flip, FLAGS_frame_rotate, - // FLAGS_frames_repeat}; - const op::WrapperStructInput wrapperStructInput; + opWrapperT.configure(wrapperStructExtra); // Consumer (comment or use default argument to disable any output) const op::WrapperStructOutput wrapperStructOutput{ op::flagsToDisplayMode(FLAGS_display, FLAGS_3d), !FLAGS_no_gui_verbose, FLAGS_fullscreen, @@ -202,41 +199,15 @@ int openPoseDemo() FLAGS_write_coco_json, FLAGS_write_coco_foot_json, 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}; - // Configure wrapper - - opWrapperT.configure(wrapperStructPose, wrapperStructFace, wrapperStructHand, wrapperStructExtra, - wrapperStructInput, wrapperStructOutput); + opWrapperT.configure(wrapperStructOutput); // Set to single-thread (for sequential processing and/or debugging and/or reducing latency) if (FLAGS_disable_multi_thread) opWrapperT.disableMultiThreading(); - // Start processing - // Two different ways of running the program on multithread environment + // Start, run, and stop processing - exec() blocks this thread until OpenPose wrapper has finished op::log("Starting thread(s)...", op::Priority::High); - // Start, run & stop threads - it blocks this thread until all others have finished opWrapperT.exec(); - // // Option b) Keeping this thread free in case you want to do something else meanwhile, e.g. profiling the GPU - // memory - // // VERY IMPORTANT NOTE: if OpenCV is compiled with Qt support, this option will not work. Qt needs the main - // // thread to plot visual results, so the final GUI (which uses OpenCV) would return an exception similar to: - // // `QMetaMethod::invoke: Unable to invoke methods with return values in queued connections` - // // Start threads - // opWrapperT.start(); - // // Profile used GPU memory - // // 1: wait ~10sec so the memory has been totally loaded on GPU - // // 2: profile the GPU memory - // const auto sleepTimeMs = 10; - // for (auto i = 0 ; i < 10000/sleepTimeMs && opWrapperT.isRunning() ; i++) - // std::this_thread::sleep_for(std::chrono::milliseconds{sleepTimeMs}); - // op::Profiler::profileGpuMemory(__LINE__, __FUNCTION__, __FILE__); - // // Keep program alive while running threads - // while (opWrapperT.isRunning()) - // std::this_thread::sleep_for(std::chrono::milliseconds{sleepTimeMs}); - // // Stop and join threads - // op::log("Stopping thread(s)", op::Priority::High); - // opWrapperT.stop(); - // Measuring total time const auto now = std::chrono::high_resolution_clock::now(); const auto totalTimeSec = (double)std::chrono::duration_cast(now-timerBegin).count() @@ -260,6 +231,6 @@ int main(int argc, char *argv[]) // Parsing command line flags gflags::ParseCommandLineFlags(&argc, &argv, true); - // Running openPoseDemo - return openPoseDemo(); + // Running tutorialApiCpp7 + return tutorialApiCpp7(); } diff --git a/examples/tutorial_api_cpp/8_synchronous_custom_output.cpp b/examples/tutorial_api_cpp/8_synchronous_custom_output.cpp index 4522c988..00e118e0 100644 --- a/examples/tutorial_api_cpp/8_synchronous_custom_output.cpp +++ b/examples/tutorial_api_cpp/8_synchronous_custom_output.cpp @@ -114,7 +114,7 @@ public: } }; -int openPoseDemo() +int tutorialApiCpp8() { try { @@ -142,10 +142,10 @@ int openPoseDemo() // 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); + 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 @@ -162,11 +162,9 @@ int openPoseDemo() const auto multipleView = (FLAGS_3d || FLAGS_3d_views > 1 || FLAGS_flir_camera); // Enabling Google Logging const bool enableGoogleLogging = true; - // Logging - op::log("", op::Priority::Low, __LINE__, __FUNCTION__, __FILE__); // OpenPose wrapper - op::log("Configuring OpenPose wrapper...", op::Priority::Low, __LINE__, __FUNCTION__, __FILE__); + op::log("Configuring OpenPose...", op::Priority::High); op::WrapperT> opWrapperT; // Initializing the user custom classes @@ -183,25 +181,28 @@ int openPoseDemo() 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}; + opWrapperT.configure(wrapperStructPose); // Face configuration (use op::WrapperStructFace{} to disable it) const op::WrapperStructFace wrapperStructFace{ FLAGS_face, faceNetInputSize, op::flagsToRenderMode(FLAGS_face_render, multipleView, FLAGS_render_pose), (float)FLAGS_face_alpha_pose, (float)FLAGS_face_alpha_heatmap, (float)FLAGS_face_render_threshold}; + opWrapperT.configure(wrapperStructFace); // 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, multipleView, FLAGS_render_pose), (float)FLAGS_hand_alpha_pose, (float)FLAGS_hand_alpha_heatmap, (float)FLAGS_hand_render_threshold}; + opWrapperT.configure(wrapperStructHand); // Extra functionality configuration (use op::WrapperStructExtra{} to disable it) const op::WrapperStructExtra wrapperStructExtra{ FLAGS_3d, FLAGS_3d_min_views, FLAGS_identification, FLAGS_tracking, FLAGS_ik_threads}; + opWrapperT.configure(wrapperStructExtra); // Producer (use default to disable any input) const op::WrapperStructInput wrapperStructInput{ producerSharedPtr, FLAGS_frame_first, FLAGS_frame_last, FLAGS_process_real_time, FLAGS_frame_flip, FLAGS_frame_rotate, FLAGS_frames_repeat}; + opWrapperT.configure(wrapperStructInput); // Consumer (comment or use default argument to disable any output) - // const op::WrapperStructOutput wrapperStructOutput{op::flagsToDisplayMode(FLAGS_display, FLAGS_3d), - // !FLAGS_no_gui_verbose, FLAGS_fullscreen, FLAGS_write_keypoint, const auto displayMode = op::DisplayMode::NoDisplay; const bool guiVerbose = false; const bool fullScreen = false; @@ -211,40 +212,15 @@ int openPoseDemo() FLAGS_write_coco_foot_json, 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}; - // Configure wrapper - opWrapperT.configure(wrapperStructPose, wrapperStructFace, wrapperStructHand, wrapperStructExtra, - wrapperStructInput, wrapperStructOutput); + opWrapperT.configure(wrapperStructOutput); // Set to single-thread (for sequential processing and/or debugging and/or reducing latency) if (FLAGS_disable_multi_thread) opWrapperT.disableMultiThreading(); - // Start processing - // Two different ways of running the program on multithread environment + // Start, run, and stop processing - exec() blocks this thread until OpenPose wrapper has finished op::log("Starting thread(s)...", op::Priority::High); - // Start, run & stop threads - it blocks this thread until all others have finished opWrapperT.exec(); - // // Option b) Keeping this thread free in case you want to do something else meanwhile, e.g. profiling the GPU - // memory - // // VERY IMPORTANT NOTE: if OpenCV is compiled with Qt support, this option will not work. Qt needs the main - // // thread to plot visual results, so the final GUI (which uses OpenCV) would return an exception similar to: - // // `QMetaMethod::invoke: Unable to invoke methods with return values in queued connections` - // // Start threads - // opWrapperT.start(); - // // Profile used GPU memory - // // 1: wait ~10sec so the memory has been totally loaded on GPU - // // 2: profile the GPU memory - // const auto sleepTimeMs = 10; - // for (auto i = 0 ; i < 10000/sleepTimeMs && opWrapperT.isRunning() ; i++) - // std::this_thread::sleep_for(std::chrono::milliseconds{sleepTimeMs}); - // op::Profiler::profileGpuMemory(__LINE__, __FUNCTION__, __FILE__); - // // Keep program alive while running threads - // while (opWrapperT.isRunning()) - // std::this_thread::sleep_for(std::chrono::milliseconds{sleepTimeMs}); - // // Stop and join threads - // op::log("Stopping thread(s)", op::Priority::High); - // opWrapperT.stop(); - // Measuring total time const auto now = std::chrono::high_resolution_clock::now(); const auto totalTimeSec = (double)std::chrono::duration_cast(now-timerBegin).count() @@ -268,6 +244,6 @@ int main(int argc, char *argv[]) // Parsing command line flags gflags::ParseCommandLineFlags(&argc, &argv, true); - // Running openPoseDemo - return openPoseDemo(); + // Running tutorialApiCpp8 + return tutorialApiCpp8(); } diff --git a/examples/tutorial_api_cpp/9_synchronous_custom_all.cpp b/examples/tutorial_api_cpp/9_synchronous_custom_all.cpp index 258f1961..fafe5280 100644 --- a/examples/tutorial_api_cpp/9_synchronous_custom_all.cpp +++ b/examples/tutorial_api_cpp/9_synchronous_custom_all.cpp @@ -215,7 +215,7 @@ public: } }; -int openPoseTutorialWrapper2() +int tutorialApiCpp9() { try { @@ -253,8 +253,6 @@ int openPoseTutorialWrapper2() const auto multipleView = (FLAGS_3d || FLAGS_3d_views > 1); // Enabling Google Logging const bool enableGoogleLogging = true; - // Logging - op::log("", op::Priority::Low, __LINE__, __FUNCTION__, __FILE__); // Initializing the user custom classes // Frames producer (e.g. video, webcam, ...) @@ -264,6 +262,8 @@ int openPoseTutorialWrapper2() // GUI (Display) auto wUserOutput = std::make_shared(); + // OpenPose wrapper + op::log("Configuring OpenPose...", op::Priority::High); op::WrapperT> opWrapperT; // Add custom input const auto workerInputOnNewThread = false; @@ -274,26 +274,30 @@ int openPoseTutorialWrapper2() // Add custom output const auto workerOutputOnNewThread = true; opWrapperT.setWorker(op::WorkerType::Output, wUserOutput, workerOutputOnNewThread); - // Configure OpenPose - op::log("Configuring OpenPose wrapper...", op::Priority::Low, __LINE__, __FUNCTION__, __FILE__); + + // 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, 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}; + opWrapperT.configure(wrapperStructPose); // Face configuration (use op::WrapperStructFace{} to disable it) const op::WrapperStructFace wrapperStructFace{ FLAGS_face, faceNetInputSize, op::flagsToRenderMode(FLAGS_face_render, multipleView, FLAGS_render_pose), (float)FLAGS_face_alpha_pose, (float)FLAGS_face_alpha_heatmap, (float)FLAGS_face_render_threshold}; + opWrapperT.configure(wrapperStructFace); // 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, multipleView, FLAGS_render_pose), (float)FLAGS_hand_alpha_pose, (float)FLAGS_hand_alpha_heatmap, (float)FLAGS_hand_render_threshold}; + opWrapperT.configure(wrapperStructHand); // Extra functionality configuration (use op::WrapperStructExtra{} to disable it) const op::WrapperStructExtra wrapperStructExtra{ FLAGS_3d, FLAGS_3d_min_views, FLAGS_identification, FLAGS_tracking, FLAGS_ik_threads}; + opWrapperT.configure(wrapperStructExtra); // Consumer (comment or use default argument to disable any output) const auto displayMode = op::DisplayMode::NoDisplay; const bool guiVerbose = false; @@ -304,36 +308,15 @@ int openPoseTutorialWrapper2() FLAGS_write_coco_foot_json, 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}; - // Configure wrapper - opWrapperT.configure(wrapperStructPose, wrapperStructFace, wrapperStructHand, wrapperStructExtra, - op::WrapperStructInput{}, wrapperStructOutput); + opWrapperT.configure(wrapperStructOutput); // Set to single-thread (for sequential processing and/or debugging and/or reducing latency) if (FLAGS_disable_multi_thread) opWrapperT.disableMultiThreading(); + // Start, run, and stop processing - exec() blocks this thread until OpenPose wrapper has finished op::log("Starting thread(s)...", op::Priority::High); - // Two different ways of running the program on multithread environment - // Start, run & stop threads - it blocks this thread until all others have finished opWrapperT.exec(); - // Option b) Keeping this thread free in case you want to do something else meanwhile, e.g. profiling the GPU memory - // // VERY IMPORTANT NOTE: if OpenCV is compiled with Qt support, this option will not work. Qt needs the main - // // thread to plot visual results, so the final GUI (which uses OpenCV) would return an exception similar to: - // // `QMetaMethod::invoke: Unable to invoke methods with return values in queued connections` - // // Start threads - // opWrapperT.start(); - // // Profile used GPU memory - // // 1: wait ~10sec so the memory has been totally loaded on GPU - // // 2: profile the GPU memory - // std::this_thread::sleep_for(std::chrono::milliseconds{1000}); - // op::log("Random task here...", op::Priority::High); - // // Keep program alive while running threads - // while (opWrapperT.isRunning()) - // std::this_thread::sleep_for(std::chrono::milliseconds{33}); - // // Stop and join threads - // op::log("Stopping thread(s)", op::Priority::High); - // opWrapperT.stop(); - // Measuring total time const auto now = std::chrono::high_resolution_clock::now(); const auto totalTimeSec = (double)std::chrono::duration_cast(now-timerBegin).count() @@ -357,6 +340,6 @@ int main(int argc, char *argv[]) // Parsing command line flags gflags::ParseCommandLineFlags(&argc, &argv, true); - // Running openPoseTutorialWrapper2 - return openPoseTutorialWrapper2(); + // Running tutorialApiCpp9 + return tutorialApiCpp9(); } diff --git a/examples/tutorial_developer/pose_1_extract_from_image.cpp b/examples/tutorial_developer/pose_1_extract_from_image.cpp index 1a93f030..62d67eff 100644 --- a/examples/tutorial_developer/pose_1_extract_from_image.cpp +++ b/examples/tutorial_developer/pose_1_extract_from_image.cpp @@ -59,7 +59,7 @@ DEFINE_double(render_threshold, 0.05, "Only estimated keypoint DEFINE_double(alpha_pose, 0.6, "Blending factor (range 0-1) for the body part rendering. 1 will show it completely, 0 will" " hide it. Only valid for GPU rendering."); -int openPoseTutorialPose1() +int tutorialDeveloperPose1() { try { @@ -87,8 +87,6 @@ int openPoseTutorialPose1() if (FLAGS_scale_gap <= 0. && FLAGS_scale_number > 1) op::error("Incompatible flag configuration: scale_gap must be greater than 0 or scale_number = 1.", __LINE__, __FUNCTION__, __FILE__); - // Logging - op::log("", op::Priority::Low, __LINE__, __FUNCTION__, __FILE__); // Step 3 - Initialize all required classes op::ScaleAndSizeExtractor scaleAndSizeExtractor(netInputSize, outputSize, FLAGS_scale_number, FLAGS_scale_gap); op::CvMatToOpInput cvMatToOpInput{poseModel}; @@ -152,6 +150,6 @@ int main(int argc, char *argv[]) // Parsing command line flags gflags::ParseCommandLineFlags(&argc, &argv, true); - // Running openPoseTutorialPose1 - return openPoseTutorialPose1(); + // Running tutorialDeveloperPose1 + return tutorialDeveloperPose1(); } diff --git a/examples/tutorial_developer/pose_2_extract_pose_or_heatmat_from_image.cpp b/examples/tutorial_developer/pose_2_extract_pose_or_heatmat_from_image.cpp index 0f87b746..dde4e00b 100644 --- a/examples/tutorial_developer/pose_2_extract_pose_or_heatmat_from_image.cpp +++ b/examples/tutorial_developer/pose_2_extract_pose_or_heatmat_from_image.cpp @@ -64,7 +64,7 @@ DEFINE_double(alpha_pose, 0.6, "Blending factor (range DEFINE_double(alpha_heatmap, 0.7, "Blending factor (range 0-1) between heatmap and original frame. 1 will only show the" " heatmap, 0 will only show the frame. Only valid for GPU rendering."); -int openPoseTutorialPose2() +int tutorialDeveloperPose2() { try { @@ -92,8 +92,6 @@ int openPoseTutorialPose2() if (FLAGS_scale_gap <= 0. && FLAGS_scale_number > 1) op::error("Incompatible flag configuration: scale_gap must be greater than 0 or scale_number = 1.", __LINE__, __FUNCTION__, __FILE__); - // Logging - op::log("", op::Priority::Low, __LINE__, __FUNCTION__, __FILE__); // Step 3 - Initialize all required classes op::ScaleAndSizeExtractor scaleAndSizeExtractor(netInputSize, outputSize, FLAGS_scale_number, FLAGS_scale_gap); op::CvMatToOpInput cvMatToOpInput{poseModel}; @@ -160,6 +158,6 @@ int main(int argc, char *argv[]) // Parsing command line flags gflags::ParseCommandLineFlags(&argc, &argv, true); - // Running openPoseTutorialPose2 - return openPoseTutorialPose2(); + // Running tutorialDeveloperPose2 + return tutorialDeveloperPose2(); } 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 8a6fc486..5a9746c2 100644 --- a/examples/tutorial_developer/thread_1_openpose_read_and_display.cpp +++ b/examples/tutorial_developer/thread_1_openpose_read_and_display.cpp @@ -61,7 +61,7 @@ DEFINE_int32(3d_views, 1, "Complementary option to // Consumer DEFINE_bool(fullscreen, false, "Run in full-screen mode (press f during runtime to toggle)."); -int openPoseTutorialThread1() +int tutorialDeveloperThread1() { try { @@ -79,10 +79,10 @@ int openPoseTutorialThread1() // outputSize const auto outputSize = op::flagsToPoint(FLAGS_output_resolution, "-1x-1"); // 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); + 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); const auto displayProducerFpsMode = (FLAGS_process_real_time ? op::ProducerFpsMode::OriginalFps : op::ProducerFpsMode::RetrievalFps); producerSharedPtr->setProducerFpsMode(displayProducerFpsMode); @@ -174,6 +174,6 @@ int main(int argc, char *argv[]) // Parsing command line flags gflags::ParseCommandLineFlags(&argc, &argv, true); - // Running openPoseTutorialThread1 - return openPoseTutorialThread1(); + // Running tutorialDeveloperThread1 + return tutorialDeveloperThread1(); } diff --git a/examples/tutorial_developer/thread_2_user_processing_function.cpp b/examples/tutorial_developer/thread_2_user_processing_function.cpp index 2d7a05e1..568eac41 100644 --- a/examples/tutorial_developer/thread_2_user_processing_function.cpp +++ b/examples/tutorial_developer/thread_2_user_processing_function.cpp @@ -95,7 +95,7 @@ public: } }; -int openPoseTutorialThread2() +int tutorialDeveloperThread2() { try { @@ -113,10 +113,10 @@ int openPoseTutorialThread2() // outputSize const auto outputSize = op::flagsToPoint(FLAGS_output_resolution, "-1x-1"); // 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); + 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); const auto displayProducerFpsMode = (FLAGS_process_real_time ? op::ProducerFpsMode::OriginalFps : op::ProducerFpsMode::RetrievalFps); producerSharedPtr->setProducerFpsMode(displayProducerFpsMode); @@ -215,6 +215,6 @@ int main(int argc, char *argv[]) // Parsing command line flags gflags::ParseCommandLineFlags(&argc, &argv, true); - // Running openPoseTutorialThread2 - return openPoseTutorialThread2(); + // Running tutorialDeveloperThread2 + return tutorialDeveloperThread2(); } diff --git a/include/openpose/wrapper/wrapper.hpp b/include/openpose/wrapper/wrapper.hpp index e9548153..ac0aff5a 100644 --- a/include/openpose/wrapper/wrapper.hpp +++ b/include/openpose/wrapper/wrapper.hpp @@ -65,24 +65,10 @@ namespace op */ void setWorker(const WorkerType workerType, const TWorker& worker, const bool workerOnNewThread = true); - // Configure class. Provide WrapperStruct structs to configure the wrapper, or call without arguments for - // default values - void configure(const WrapperStructPose& wrapperStructPose = WrapperStructPose{}, - // Face (use the default WrapperStructFace{} to disable any face detector) - const WrapperStructFace& wrapperStructFace = WrapperStructFace{}, - // Hand (use the default WrapperStructHand{} to disable any hand detector) - const WrapperStructHand& wrapperStructHand = WrapperStructHand{}, - // Hand (use the default WrapperStructExtra{} to disable any hand detector) - const WrapperStructExtra& wrapperStructExtra = WrapperStructExtra{}, - // Producer: set producerSharedPtr=nullptr or use default WrapperStructInput{} to disable input - const WrapperStructInput& wrapperStructInput = WrapperStructInput{}, - // Consumer (keep default values to disable any output) - const WrapperStructOutput& wrapperStructOutput = WrapperStructOutput{}); - - // /** - // * Analogous to configure() but applied to only pose (WrapperStructPose) - // */ - // void configure(const WrapperStructPose& wrapperStructPose); + /** + * It configures the pose parameters. Do not call for default values. + */ + void configure(const WrapperStructPose& wrapperStructPose); /** * Analogous to configure() but applied to only pose (WrapperStructFace) @@ -294,21 +280,11 @@ namespace op } template - void WrapperT::configure(const WrapperStructPose& wrapperStructPose, - const WrapperStructFace& wrapperStructFace, - const WrapperStructHand& wrapperStructHand, - const WrapperStructExtra& wrapperStructExtra, - const WrapperStructInput& wrapperStructInput, - const WrapperStructOutput& wrapperStructOutput) + void WrapperT::configure(const WrapperStructPose& wrapperStructPose) { try { mWrapperStructPose = wrapperStructPose; - mWrapperStructFace = wrapperStructFace; - mWrapperStructHand = wrapperStructHand; - mWrapperStructExtra = wrapperStructExtra; - mWrapperStructInput = wrapperStructInput; - mWrapperStructOutput = wrapperStructOutput; } catch (const std::exception& e) { @@ -316,19 +292,6 @@ namespace op } } - // template - // void WrapperT::configure(const WrapperStructPose& wrapperStructPose) - // { - // try - // { - // mWrapperStructPose = wrapperStructPose; - // } - // catch (const std::exception& e) - // { - // error(e.what(), __LINE__, __FUNCTION__, __FILE__); - // } - // } - template void WrapperT::configure(const WrapperStructFace& wrapperStructFace) { @@ -595,7 +558,7 @@ namespace op catch (const std::exception& e) { error(e.what(), __LINE__, __FUNCTION__, __FILE__); - return false; + return TDatumsSP{}; } } diff --git a/python/openpose/_openpose.cpp b/python/openpose/_openpose.cpp index 50e5be2b..26b60c47 100644 --- a/python/openpose/_openpose.cpp +++ b/python/openpose/_openpose.cpp @@ -11,9 +11,9 @@ #include #include +#include #include #include -#include #include #include #include @@ -105,8 +105,6 @@ public: if (FLAGS_scale_gap <= 0. && FLAGS_scale_number > 1) op::error("Incompatible flag configuration: scale_gap must be greater than 0 or scale_number = 1.", __LINE__, __FUNCTION__, __FILE__); - // Logging - op::log("", op::Priority::Low, __LINE__, __FUNCTION__, __FILE__); // Step 3 - Initialize all required classes scaleAndSizeExtractor = std::unique_ptr(new op::ScaleAndSizeExtractor(netInputSize, outputSize, FLAGS_scale_number, FLAGS_scale_gap));