From a602f93fa424f0d6f41136ae2c68366b17357cad Mon Sep 17 00:00:00 2001 From: Tianyi Zhao Date: Sat, 15 Sep 2018 21:12:34 -0400 Subject: [PATCH] Alpha Unity plugin version (#805) --- .../1_user_synchronous_postprocessing.cpp | 3 +- .../2_user_synchronous_input.cpp | 1 - .../3_user_synchronous_output.cpp | 3 +- .../4_user_synchronous_all.cpp | 1 - src/openpose/utilities/errorAndLog.cpp | 34 +++++++++++++++++++ 5 files changed, 36 insertions(+), 6 deletions(-) diff --git a/examples/tutorial_wrapper/1_user_synchronous_postprocessing.cpp b/examples/tutorial_wrapper/1_user_synchronous_postprocessing.cpp index 93fa71d7..f2f3acba 100644 --- a/examples/tutorial_wrapper/1_user_synchronous_postprocessing.cpp +++ b/examples/tutorial_wrapper/1_user_synchronous_postprocessing.cpp @@ -366,7 +366,7 @@ int openPoseDemo() (float)FLAGS_hand_alpha_heatmap, (float)FLAGS_hand_render_threshold}; // 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, + 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{ @@ -388,7 +388,6 @@ int openPoseDemo() // Start processing // Two different ways of running the program on multithread environment op::log("Starting thread(s)...", op::Priority::High); - // Option a) Recommended - Also using the main thread (this thread) for processing (it saves 1 thread) // Start, run & stop threads - it blocks this thread until all others have finished opWrapper.exec(); diff --git a/examples/tutorial_wrapper/2_user_synchronous_input.cpp b/examples/tutorial_wrapper/2_user_synchronous_input.cpp index 60c64e81..d58760cf 100644 --- a/examples/tutorial_wrapper/2_user_synchronous_input.cpp +++ b/examples/tutorial_wrapper/2_user_synchronous_input.cpp @@ -425,7 +425,6 @@ int openPoseDemo() // Start processing // Two different ways of running the program on multithread environment op::log("Starting thread(s)...", op::Priority::High); - // Option a) Recommended - Also using the main thread (this thread) for processing (it saves 1 thread) // Start, run & stop threads - it blocks this thread until all others have finished opWrapper.exec(); diff --git a/examples/tutorial_wrapper/3_user_synchronous_output.cpp b/examples/tutorial_wrapper/3_user_synchronous_output.cpp index ded2f992..f334a206 100644 --- a/examples/tutorial_wrapper/3_user_synchronous_output.cpp +++ b/examples/tutorial_wrapper/3_user_synchronous_output.cpp @@ -416,7 +416,7 @@ int openPoseDemo() 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, + producerSharedPtr, FLAGS_frame_first, FLAGS_frame_last, FLAGS_process_real_time, FLAGS_frame_flip, FLAGS_frame_rotate, FLAGS_frames_repeat}; // Consumer (comment or use default argument to disable any output) // const op::WrapperStructOutput wrapperStructOutput{op::flagsToDisplayMode(FLAGS_display, FLAGS_3d), @@ -440,7 +440,6 @@ int openPoseDemo() // Start processing // Two different ways of running the program on multithread environment op::log("Starting thread(s)...", op::Priority::High); - // Option a) Recommended - Also using the main thread (this thread) for processing (it saves 1 thread) // Start, run & stop threads - it blocks this thread until all others have finished opWrapper.exec(); diff --git a/examples/tutorial_wrapper/4_user_synchronous_all.cpp b/examples/tutorial_wrapper/4_user_synchronous_all.cpp index e1cb5e2a..e1547194 100644 --- a/examples/tutorial_wrapper/4_user_synchronous_all.cpp +++ b/examples/tutorial_wrapper/4_user_synchronous_all.cpp @@ -492,7 +492,6 @@ int openPoseTutorialWrapper2() op::log("Starting thread(s)...", op::Priority::High); // Two different ways of running the program on multithread environment - // Option a) Recommended - Also using the main thread (this thread) for processing (it saves 1 thread) // Start, run & stop threads - it blocks this thread until all others have finished opWrapper.exec(); diff --git a/src/openpose/utilities/errorAndLog.cpp b/src/openpose/utilities/errorAndLog.cpp index af4a54a7..0cc2f8ec 100644 --- a/src/openpose/utilities/errorAndLog.cpp +++ b/src/openpose/utilities/errorAndLog.cpp @@ -7,6 +7,38 @@ namespace op { #ifdef USE_UNITY_SUPPORT + namespace UnityDebugger + { + typedef void(__stdcall * DebugCallback) (const char* const str, int type); + DebugCallback gDebugCallback; + + extern "C" void OP_API OP_RegisterDebugCallback(DebugCallback& debugCallback) + { + if (debugCallback) + gDebugCallback = debugCallback; + } + + void DebugInUnity(const std::string& message, const int type) + { + if (gDebugCallback) + gDebugCallback(message.c_str(), type); + } + + void log(const std::string& message) + { + DebugInUnity(message, 0); + } + + void logWarning(const std::string& message) + { + DebugInUnity(message, 1); + } + + void logError(const std::string& message) + { + DebugInUnity(message, -1); + } + } #endif // Private auxiliar functions @@ -147,6 +179,7 @@ namespace op // Unity logError #ifdef USE_UNITY_SUPPORT + UnityDebugger::logError(errorMessageToPrint); #endif // std::runtime_error @@ -171,6 +204,7 @@ namespace op // Unity log #ifdef USE_UNITY_SUPPORT + UnityDebugger::log(infoMessage); #endif } } -- GitLab