Skip to content

Commit

Permalink
Alpha Unity plugin version (CMU-Perceptual-Computing-Lab#805)
Browse files Browse the repository at this point in the history
  • Loading branch information
ZiuTinyat authored and gineshidalgo99 committed Sep 16, 2018
1 parent d9ea678 commit a602f93
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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();

Expand Down
1 change: 0 additions & 1 deletion examples/tutorial_wrapper/2_user_synchronous_input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
3 changes: 1 addition & 2 deletions examples/tutorial_wrapper/3_user_synchronous_output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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();

Expand Down
1 change: 0 additions & 1 deletion examples/tutorial_wrapper/4_user_synchronous_all.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
34 changes: 34 additions & 0 deletions src/openpose/utilities/errorAndLog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -147,6 +179,7 @@ namespace op

// Unity logError
#ifdef USE_UNITY_SUPPORT
UnityDebugger::logError(errorMessageToPrint);
#endif

// std::runtime_error
Expand All @@ -171,6 +204,7 @@ namespace op

// Unity log
#ifdef USE_UNITY_SUPPORT
UnityDebugger::log(infoMessage);
#endif
}
}
Expand Down

0 comments on commit a602f93

Please sign in to comment.