From f7ea3b901354658f86d17e943c80b3e35016e1a7 Mon Sep 17 00:00:00 2001 From: Gines Hidalgo Date: Sat, 13 Apr 2019 18:27:54 -0400 Subject: [PATCH] Added doc about cli tools --- CMakeLists.txt | 86 ++++++++++++++++---------- doc/demo_overview.md | 5 +- doc/quick_start.md | 2 +- src/openpose/pose/poseExtractorNet.cpp | 61 ++++++++++-------- src/openpose/utilities/errorAndLog.cpp | 2 +- 5 files changed, 93 insertions(+), 63 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 099b05e0..22e7a964 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -104,24 +104,61 @@ endif (WIN32) # C++ additional flags if (CMAKE_COMPILER_IS_GNUCXX) + message(STATUS "GCC detected, adding compile flags") + # set(OP_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp -Wpedantic -Wall -Wextra -Wfatal-errors") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp") + set(OP_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wpedantic -Wall -Wextra -Wfatal-errors") + # set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} -Wpedantic -Wall -Wextra -Wfatal-errors") +endif (CMAKE_COMPILER_IS_GNUCXX) - # Select the Enhanced Instruction Set - set(INSTRUCTION_SET NONE CACHE STRING "Enable Enhanced Instruction Set") - set_property(CACHE INSTRUCTION_SET PROPERTY STRINGS NONE SSE4 AVX) - - if (${INSTRUCTION_SET} MATCHES "SSE4") - add_definitions("-DWITH_SSE4") - set(SIMD_FLAGS "${SIMD_FLAGS} -msse4.1") - endif (${INSTRUCTION_SET} MATCHES "SSE4") - - if (${INSTRUCTION_SET} MATCHES "AVX") - add_definitions("-DWITH_AVX") +# Select the Enhanced Instruction Set +set(INSTRUCTION_SET NONE CACHE STRING "Enable Enhanced Instruction Set") +set_property(CACHE INSTRUCTION_SET PROPERTY STRINGS NONE AVX2) +if (${INSTRUCTION_SET} MATCHES "AVX2") + add_definitions("-DWITH_AVX") +endif (${INSTRUCTION_SET} MATCHES "AVX2") +# Windows +if (WIN32) + # Suboptions for Enhanced Instruction Set + if (${INSTRUCTION_SET} MATCHES "AVX2") + add_definitions("/arch:AVX2") + endif (${INSTRUCTION_SET} MATCHES "AVX2") +# Ubuntu +else (WIN32) # if (CMAKE_COMPILER_IS_GNUCXX) + if (${INSTRUCTION_SET} MATCHES "AVX2") set(SIMD_FLAGS "${SIMD_FLAGS} -mavx") - endif (${INSTRUCTION_SET} MATCHES "AVX") - + endif (${INSTRUCTION_SET} MATCHES "AVX2") message(STATUS "GCC detected, adding compile flags") - set(OP_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SIMD_FLAGS} -fopenmp -Wpedantic -Wall -Wextra -Wfatal-errors") -endif (CMAKE_COMPILER_IS_GNUCXX) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SIMD_FLAGS}") +endif (WIN32) +# if (CMAKE_COMPILER_IS_GNUCXX) +# set_property(CACHE INSTRUCTION_SET PROPERTY STRINGS NONE SSE4 AVX) +# if (${INSTRUCTION_SET} MATCHES "SSE4") +# add_definitions("-DWITH_SSE4") +# set(SIMD_FLAGS "${SIMD_FLAGS} -msse4.1") +# endif (${INSTRUCTION_SET} MATCHES "SSE4") +# if (${INSTRUCTION_SET} MATCHES "AVX2") +# add_definitions("-DWITH_AVX") +# set(SIMD_FLAGS "${SIMD_FLAGS} -mavx") +# endif (${INSTRUCTION_SET} MATCHES "AVX") +# message(STATUS "GCC detected, adding compile flags") +# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SIMD_FLAGS}") +# endif (CMAKE_COMPILER_IS_GNUCXX) +# if (WIN32) +# # set_property(CACHE INSTRUCTION_SET PROPERTY STRINGS NONE SSE SSE2 AVX AVX2 IA32) +# # Suboptions for Enhanced Instruction Set +# if (${INSTRUCTION_SET} MATCHES "SSE") +# add_definitions("/arch:SSE") +# elseif (${INSTRUCTION_SET} MATCHES "SSE2") +# add_definitions("/arch:SSE2") +# elseif (${INSTRUCTION_SET} MATCHES "AVX") +# add_definitions("/arch:AVX") +# elseif (${INSTRUCTION_SET} MATCHES "AVX2") +# add_definitions("/arch:AVX2") +# elseif (${INSTRUCTION_SET} MATCHES "IA32") +# add_definitions("/arch:IA32") +# endif (${INSTRUCTION_SET} MATCHES "SSE") +# endif (WIN32) ### PROJECT OPTIONS @@ -139,25 +176,6 @@ if (${DL_FRAMEWORK} MATCHES "CAFFE") add_definitions(-DUSE_CAFFE) endif (${DL_FRAMEWORK} MATCHES "CAFFE") -if (WIN32) - # Select the Enhanced Instruction Set - set(INSTRUCTION_SET NONE CACHE STRING "Enable Enhanced Instruction Set") - set_property(CACHE INSTRUCTION_SET PROPERTY STRINGS NONE SSE SSE2 AVX AVX2 IA32) - - # Suboptions for Enhanced Instruction Set - if (${INSTRUCTION_SET} MATCHES "SSE") - add_definitions("/arch:SSE") - elseif (${INSTRUCTION_SET} MATCHES "SSE2") - add_definitions("/arch:SSE2") - elseif (${INSTRUCTION_SET} MATCHES "AVX") - add_definitions("/arch:AVX") - elseif (${INSTRUCTION_SET} MATCHES "AVX2") - add_definitions("/arch:AVX2") - elseif (${INSTRUCTION_SET} MATCHES "IA32") - add_definitions("/arch:IA32") - endif (${INSTRUCTION_SET} MATCHES "SSE") -endif (WIN32) - # Set the acceleration library if (APPLE) set(GPU_MODE CPU_ONLY CACHE STRING "Select the acceleration GPU library or CPU otherwise.") diff --git a/doc/demo_overview.md b/doc/demo_overview.md index 413b740c..41606f5e 100644 --- a/doc/demo_overview.md +++ b/doc/demo_overview.md @@ -3,7 +3,10 @@ OpenPose Demo - Overview Forget about the OpenPose library code, just compile the library and use the demo `./build/examples/openpose/openpose.bin`. -In order to learn how to use it, run `./build/examples/openpose/openpose.bin --help` in your bash and read all the available flags (check only the flags for `examples/openpose/openpose.cpp` itself, i.e., the section `Flags from examples/openpose/openpose.cpp:`). We detail some of them in the following sections. +In order to learn how to use it, run `./build/examples/openpose/openpose.bin --help` in your favorite command-line interface tool and read all the available flags (check only the flags for `examples/openpose/openpose.cpp` itself, i.e., the section `Flags from examples/openpose/openpose.cpp:`). We detail some of them in the following sections. + +In Ubuntu, Mac, and other Unix systems, use any command-line interface, such as `Terminal` or `Terminator`. In Windows, open the `PowerShell` (recommended) or Windows Command Prompt (CMD). They can be open by pressing the Windows button + X, and then A. Feel free to watch any Youtube video tutorial if you are not familiar with these non-GUI tools. Make sure that you are in the **root directory of the project** (i.e., in the OpenPose folder, not inside `build/` nor `windows/` nor `bin/`). + diff --git a/doc/quick_start.md b/doc/quick_start.md index 08956a16..a6227804 100644 --- a/doc/quick_start.md +++ b/doc/quick_start.md @@ -14,7 +14,7 @@ OpenPose - Quick Start ## Quick Start -Check that the library is working properly by running any of the following commands. Make sure that you are in the **root directory of the project** (i.e., in the OpenPose folder, not inside `build/` nor `windows/` nor `bin/`). In addition, `examples/media/video.avi` and `examples/media` do exist, no need to change the paths. +Check that the library is working properly by running any of the following commands on any command-line interface program. In Ubuntu, Mac, and other Unix systems, use any command-line interface, such as `Terminal` or `Terminator`. In Windows, open the `PowerShell` (recommended) or Windows Command Prompt (CMD). They can be open by pressing the Windows button + X, and then A. Feel free to watch any Youtube video tutorial if you are not familiar with these non-GUI tools. Make sure that you are in the **root directory of the project** (i.e., in the OpenPose folder, not inside `build/` nor `windows/` nor `bin/`). In addition, `examples/media/video.avi` and `examples/media` do exist, no need to change the paths. ### Running on Video ``` diff --git a/src/openpose/pose/poseExtractorNet.cpp b/src/openpose/pose/poseExtractorNet.cpp index 5d1998c8..98194970 100644 --- a/src/openpose/pose/poseExtractorNet.cpp +++ b/src/openpose/pose/poseExtractorNet.cpp @@ -152,31 +152,40 @@ namespace op // Background if (heatMapTypesHas(mHeatMapTypes, HeatMapType::Background)) { - auto* heatMapsPtr = heatMaps.getPtr() + totalOffset; - #ifdef USE_CUDA - cudaMemcpy(heatMapsPtr, getHeatMapGpuConstPtr() + volumeBodyParts, - channelOffset * sizeof(float), cudaMemcpyDeviceToHost); - #else - const auto* heatMapCpuPtr = getHeatMapCpuConstPtr(); - std::copy(heatMapCpuPtr + volumeBodyParts, heatMapCpuPtr + volumeBodyParts + channelOffset, - heatMapsPtr); - #endif - if (mHeatMapScaleMode != ScaleMode::NoScale) + if (addBkgChannel(mPoseModel)) { - // Change from [0,1] to [-1,1] - if (mHeatMapScaleMode == ScaleMode::PlusMinusOne) - for (auto i = 0u ; i < channelOffset ; i++) - heatMapsPtr[i] = fastTruncate(heatMapsPtr[i]) * 2.f - 1.f; - // [0, 255] - else if (mHeatMapScaleMode == ScaleMode::UnsignedChar) - for (auto i = 0u ; i < channelOffset ; i++) - heatMapsPtr[i] = (float)positiveIntRound(fastTruncate(heatMapsPtr[i]) * 255.f); - // Avoid values outside original range - else - for (auto i = 0u ; i < channelOffset ; i++) - heatMapsPtr[i] = fastTruncate(heatMapsPtr[i]); + auto* heatMapsPtr = heatMaps.getPtr() + totalOffset; + #ifdef USE_CUDA + cudaMemcpy(heatMapsPtr, getHeatMapGpuConstPtr() + volumeBodyParts, + channelOffset * sizeof(float), cudaMemcpyDeviceToHost); + #else + const auto* heatMapCpuPtr = getHeatMapCpuConstPtr(); + std::copy( + heatMapCpuPtr + volumeBodyParts, heatMapCpuPtr + volumeBodyParts + channelOffset, + heatMapsPtr); + #endif + if (mHeatMapScaleMode != ScaleMode::NoScale) + { + // Change from [0,1] to [-1,1] + if (mHeatMapScaleMode == ScaleMode::PlusMinusOne) + for (auto i = 0u ; i < channelOffset ; i++) + heatMapsPtr[i] = fastTruncate(heatMapsPtr[i]) * 2.f - 1.f; + // [0, 255] + else if (mHeatMapScaleMode == ScaleMode::UnsignedChar) + for (auto i = 0u ; i < channelOffset ; i++) + heatMapsPtr[i] = (float)positiveIntRound(fastTruncate(heatMapsPtr[i]) * 255.f); + // Avoid values outside original range + else + for (auto i = 0u ; i < channelOffset ; i++) + heatMapsPtr[i] = fastTruncate(heatMapsPtr[i]); + } + totalOffset += (unsigned int)channelOffset; + } + else + { + error("You enabled `--heatmaps_add_bkg` for a model that does not contain one. Please," + " remove this flag for this model.", __LINE__, __FUNCTION__, __FILE__); } - totalOffset += (unsigned int)channelOffset; } // PAFs if (heatMapTypesHas(mHeatMapTypes, HeatMapType::PAFs)) @@ -184,12 +193,12 @@ namespace op auto* heatMapsPtr = heatMaps.getPtr() + totalOffset; #ifdef USE_CUDA cudaMemcpy(heatMapsPtr, - getHeatMapGpuConstPtr() + volumeBodyParts + channelOffset, + getHeatMapGpuConstPtr() + volumeBodyParts + (addBkgChannel(mPoseModel) ? channelOffset : 0), volumePAFs * sizeof(float), cudaMemcpyDeviceToHost); #else const auto* heatMapCpuPtr = getHeatMapCpuConstPtr(); - std::copy(heatMapCpuPtr + volumeBodyParts + channelOffset, - heatMapCpuPtr + volumeBodyParts + channelOffset + volumePAFs, + std::copy(heatMapCpuPtr + volumeBodyParts + (addBkgChannel(mPoseModel) ? channelOffset : 0), + heatMapCpuPtr + volumeBodyParts + (addBkgChannel(mPoseModel) ? channelOffset : 0) + volumePAFs, heatMapsPtr); #endif if (mHeatMapScaleMode != ScaleMode::NoScale) diff --git a/src/openpose/utilities/errorAndLog.cpp b/src/openpose/utilities/errorAndLog.cpp index 7281ce79..326cab4e 100644 --- a/src/openpose/utilities/errorAndLog.cpp +++ b/src/openpose/utilities/errorAndLog.cpp @@ -196,7 +196,7 @@ namespace op if (errorMode == 1) { errorMessageToPropagate = errorInitBase + " occurred on a thread. OpenPose closed all its" - " threads and then propagated the error to the main thread:\n" + " threads and then propagated the error to the main thread. Error description:\n\n" + errorMessageToPropagate.substr(errorInit.size(), errorMessageToPropagate.size()-1); } if (errorMode == 2) -- GitLab