提交 babd8900 编写于 作者: G gineshidalgo99

Fixed #1069 and #1071

上级 de117486
...@@ -52,6 +52,11 @@ matrix: ...@@ -52,6 +52,11 @@ matrix:
dist: xenial dist: xenial
env: NAME="U16-python-cmake-cpu-debug" WITH_PYTHON=true WITH_CUDA=false WITH_DEBUG=true env: NAME="U16-python-cmake-cpu-debug" WITH_PYTHON=true WITH_CUDA=false WITH_DEBUG=true
sudo: required sudo: required
# Ubuntu 16.04 - Python - CMake - CPU - Unity
- os: linux
dist: xenial
env: NAME="U16-python-cmake-cpu-unity" WITH_PYTHON=true WITH_UNITY=true WITH_CUDA=false
sudo: required
# Mac OSX # Mac OSX
# Mac OSX - Python - CMake - CPU # Mac OSX - Python - CMake - CPU
...@@ -67,7 +72,12 @@ matrix: ...@@ -67,7 +72,12 @@ matrix:
# Mac OSX - Python - CMake - CPU - Debug # Mac OSX - Python - CMake - CPU - Debug
- os: osx - os: osx
osx_image: xcode9.4 # xcode10.1 does not work with Python # Versions: https://docs.travis-ci.com/user/languages/objective-c#supported-xcode-versions osx_image: xcode9.4 # xcode10.1 does not work with Python # Versions: https://docs.travis-ci.com/user/languages/objective-c#supported-xcode-versions
env: NAME="OSX-python-cmake-cpu" WITH_CUDA=false WITH_PYTHON=true WITH_DEBUG=true env: NAME="OSX-python-cmake-cpu-debug" WITH_CUDA=false WITH_PYTHON=true WITH_DEBUG=true
sudo: required
# Mac OSX - Python - CMake - CPU - Unity
- os: osx
osx_image: xcode9.4 # xcode10.1 does not work with Python # Versions: https://docs.travis-ci.com/user/languages/objective-c#supported-xcode-versions
env: NAME="OSX-python-cmake-cpu-unity" WITH_CUDA=false WITH_PYTHON=true WITH_UNITY=true
sudo: required sudo: required
# # TO-DO: To be implemented # # TO-DO: To be implemented
......
...@@ -273,9 +273,7 @@ if (WIN32) ...@@ -273,9 +273,7 @@ if (WIN32)
endif (WIN32) endif (WIN32)
# Unity # Unity
if (WIN32) option(BUILD_UNITY_SUPPORT "Build OpenPose as a Unity plugin." OFF)
option(BUILD_UNITY_SUPPORT "Build OpenPose as a Unity plugin." OFF)
endif (WIN32)
# Build as shared library # Build as shared library
option(BUILD_SHARED_LIBS "Build as shared lib." ON) option(BUILD_SHARED_LIBS "Build as shared lib." ON)
......
...@@ -4,10 +4,10 @@ ...@@ -4,10 +4,10 @@
----------------- -----------------
| | `Python (CUDA GPU)` | `Python (CPU)` | `CUDA GPU` | `CPU` | `Debug mode` | | |`Python (CUDA)`| `Python (CPU)`| `CUDA` | `CPU` | `Debug` | `Unity` |
| :---: | :---: | :---: | :---: |:---: | :---: | | :---: | :---: | :---: | :---: | :---: | :---: | :---: |
| **`Linux`** | [![Status](https://travis-matrix-badges.herokuapp.com/repos/CMU-Perceptual-Computing-Lab/openpose/branches/master/1)](https://travis-ci.org/CMU-Perceptual-Computing-Lab/openpose) | [![Status](https://travis-matrix-badges.herokuapp.com/repos/CMU-Perceptual-Computing-Lab/openpose/branches/master/2)](https://travis-ci.org/CMU-Perceptual-Computing-Lab/openpose) | [![Status](https://travis-matrix-badges.herokuapp.com/repos/CMU-Perceptual-Computing-Lab/openpose/branches/master/3)](https://travis-ci.org/CMU-Perceptual-Computing-Lab/openpose) | [![Status](https://travis-matrix-badges.herokuapp.com/repos/CMU-Perceptual-Computing-Lab/openpose/branches/master/4)](https://travis-ci.org/CMU-Perceptual-Computing-Lab/openpose) | [![Status](https://travis-matrix-badges.herokuapp.com/repos/CMU-Perceptual-Computing-Lab/openpose/branches/master/5)](https://travis-ci.org/CMU-Perceptual-Computing-Lab/openpose) | | **`Linux`** | [![Status](https://travis-matrix-badges.herokuapp.com/repos/CMU-Perceptual-Computing-Lab/openpose/branches/master/1)](https://travis-ci.org/CMU-Perceptual-Computing-Lab/openpose) | [![Status](https://travis-matrix-badges.herokuapp.com/repos/CMU-Perceptual-Computing-Lab/openpose/branches/master/2)](https://travis-ci.org/CMU-Perceptual-Computing-Lab/openpose) | [![Status](https://travis-matrix-badges.herokuapp.com/repos/CMU-Perceptual-Computing-Lab/openpose/branches/master/3)](https://travis-ci.org/CMU-Perceptual-Computing-Lab/openpose) | [![Status](https://travis-matrix-badges.herokuapp.com/repos/CMU-Perceptual-Computing-Lab/openpose/branches/master/4)](https://travis-ci.org/CMU-Perceptual-Computing-Lab/openpose) | [![Status](https://travis-matrix-badges.herokuapp.com/repos/CMU-Perceptual-Computing-Lab/openpose/branches/master/5)](https://travis-ci.org/CMU-Perceptual-Computing-Lab/openpose) | [![Status](https://travis-matrix-badges.herokuapp.com/repos/CMU-Perceptual-Computing-Lab/openpose/branches/master/6)](https://travis-ci.org/CMU-Perceptual-Computing-Lab/openpose) |
| **`MacOS`** | | [![Status](https://travis-matrix-badges.herokuapp.com/repos/CMU-Perceptual-Computing-Lab/openpose/branches/master/6)](https://travis-ci.org/CMU-Perceptual-Computing-Lab/openpose) | | [![Status](https://travis-matrix-badges.herokuapp.com/repos/CMU-Perceptual-Computing-Lab/openpose/branches/master/7)](https://travis-ci.org/CMU-Perceptual-Computing-Lab/openpose) | [![Status](https://travis-matrix-badges.herokuapp.com/repos/CMU-Perceptual-Computing-Lab/openpose/branches/master/8)](https://travis-ci.org/CMU-Perceptual-Computing-Lab/openpose) | | **`MacOS`** | | [![Status](https://travis-matrix-badges.herokuapp.com/repos/CMU-Perceptual-Computing-Lab/openpose/branches/master/7)](https://travis-ci.org/CMU-Perceptual-Computing-Lab/openpose) | | [![Status](https://travis-matrix-badges.herokuapp.com/repos/CMU-Perceptual-Computing-Lab/openpose/branches/master/8)](https://travis-ci.org/CMU-Perceptual-Computing-Lab/openpose) | [![Status](https://travis-matrix-badges.herokuapp.com/repos/CMU-Perceptual-Computing-Lab/openpose/branches/master/9)](https://travis-ci.org/CMU-Perceptual-Computing-Lab/openpose) | [![Status](https://travis-matrix-badges.herokuapp.com/repos/CMU-Perceptual-Computing-Lab/openpose/branches/master/10)](https://travis-ci.org/CMU-Perceptual-Computing-Lab/openpose) |
<!-- | **`Windows`** | | | | | | --> <!-- | **`Windows`** | | | | | | -->
<!-- <!--
Note: Currently using [travis-matrix-badges](https://github.com/bjfish/travis-matrix-badges) vs. traditional [![Build Status](https://travis-ci.org/CMU-Perceptual-Computing-Lab/openpose.svg?branch=master)](https://travis-ci.org/CMU-Perceptual-Computing-Lab/openpose) Note: Currently using [travis-matrix-badges](https://github.com/bjfish/travis-matrix-badges) vs. traditional [![Build Status](https://travis-ci.org/CMU-Perceptual-Computing-Lab/openpose.svg?branch=master)](https://travis-ci.org/CMU-Perceptual-Computing-Lab/openpose)
......
...@@ -68,7 +68,7 @@ namespace op ...@@ -68,7 +68,7 @@ namespace op
const T* cpu_data() const; const T* cpu_data() const;
void set_cpu_data(T* data); void set_cpu_data(T* data);
const int* gpu_shape() const; // const int* gpu_shape() const; // Disabled because it produces compiler errors for some users
const T* gpu_data() const; const T* gpu_data() const;
void set_gpu_data(T* data); void set_gpu_data(T* data);
const T* cpu_diff() const; const T* cpu_diff() const;
......
...@@ -50,6 +50,11 @@ else ...@@ -50,6 +50,11 @@ else
ARGS="$ARGS -DUSE_CUDNN=Off" ARGS="$ARGS -DUSE_CUDNN=Off"
fi fi
echo "WITH_UNITY = ${WITH_UNITY}."
if [[ $WITH_UNITY == true ]] ; then
ARGS="$ARGS -DBUILD_UNITY_SUPPORT=On"
fi
echo "WITH_DEBUG = ${WITH_DEBUG}." echo "WITH_DEBUG = ${WITH_DEBUG}."
if [[ $WITH_DEBUG == true ]] ; then if [[ $WITH_DEBUG == true ]] ; then
ARGS="$ARGS -DCMAKE_BUILD_TYPE=Debug" ARGS="$ARGS -DCMAKE_BUILD_TYPE=Debug"
......
...@@ -8,11 +8,12 @@ WITH_CUDA=${WITH_CUDA:-true} ...@@ -8,11 +8,12 @@ WITH_CUDA=${WITH_CUDA:-true}
WITH_CUDNN=${WITH_CUDNN:-true} WITH_CUDNN=${WITH_CUDNN:-true}
WITH_OPEN_CL=${WITH_OPEN_CL:-false} WITH_OPEN_CL=${WITH_OPEN_CL:-false}
WITH_MKL=${WITH_MKL:-false} WITH_MKL=${WITH_MKL:-false}
WITH_UNITY=${WITH_UNITY:-false}
WITH_DEBUG=${WITH_DEBUG:-false} WITH_DEBUG=${WITH_DEBUG:-false}
# Examples should be run (Travis not compatible with GPU code) # Examples should be run (Travis not compatible with GPU code)
# if [[ $WITH_CMAKE == true ]] && [[ $WITH_PYTHON == true ]] && [[ $WITH_CUDA == false ]] && [[ $WITH_OPEN_CL == false ]] && [[ $WITH_MKL == false ]]; then # if [[ $WITH_CMAKE == true ]] && [[ $WITH_PYTHON == true ]] && [[ $WITH_CUDA == false ]] && [[ $WITH_OPEN_CL == false ]] && [[ $WITH_MKL == false ]]; then
if [[ $WITH_CUDA == false ]] && [[ $WITH_OPEN_CL == false ]]; then if [[ $WITH_CUDA == false ]] && [[ $WITH_OPEN_CL == false ]] && [[ $WITH_UNITY == false ]]; then
RUN_EXAMPLES=true RUN_EXAMPLES=true
else else
RUN_EXAMPLES=false RUN_EXAMPLES=false
...@@ -21,7 +22,7 @@ echo "RUN_EXAMPLES = ${RUN_EXAMPLES}." ...@@ -21,7 +22,7 @@ echo "RUN_EXAMPLES = ${RUN_EXAMPLES}."
# Makefile configuration compatible # Makefile configuration compatible
# if [[ $WITH_PYTHON == false ]] ; then # if [[ $WITH_PYTHON == false ]] ; then
if [[ $WITH_PYTHON == false ]] && [[ $WITH_DEBUG == false ]]; then if [[ $WITH_PYTHON == false ]] && [[ $WITH_DEBUG == false ]] && [[ $WITH_UNITY == false ]]; then
MAKE_CONFIG_COMPATIBLE=true MAKE_CONFIG_COMPATIBLE=true
else else
MAKE_CONFIG_COMPATIBLE=false MAKE_CONFIG_COMPATIBLE=false
......
...@@ -578,23 +578,23 @@ namespace op ...@@ -578,23 +578,23 @@ namespace op
} }
} }
template<typename T> // template<typename T>
const int* ArrayCpuGpu<T>::gpu_shape() const // const int* ArrayCpuGpu<T>::gpu_shape() const
{ // {
try // try
{ // {
#ifdef USE_CAFFE // #ifdef USE_CAFFE
return spImpl->pCaffeBlobT->gpu_shape(); // return spImpl->pCaffeBlobT->gpu_shape();
#else // #else
return nullptr; // return nullptr;
#endif // #endif
} // }
catch (const std::exception& e) // catch (const std::exception& e)
{ // {
error(e.what(), __LINE__, __FUNCTION__, __FILE__); // error(e.what(), __LINE__, __FUNCTION__, __FILE__);
return nullptr; // return nullptr;
} // }
} // }
template<typename T> template<typename T>
const T* ArrayCpuGpu<T>::gpu_data() const const T* ArrayCpuGpu<T>::gpu_data() const
......
...@@ -292,8 +292,9 @@ namespace op ...@@ -292,8 +292,9 @@ namespace op
{ {
// Sanity check // Sanity check
if (inputNetData.size() != 1u) if (inputNetData.size() != 1u)
error("Size(inputNetData) must be provided heatmaps (" + std::to_string(inputNetData.size()) error("Size(inputNetData) must match the provided heatmaps batch size ("
+ " vs. " + std::to_string(1) + ").", __LINE__, __FUNCTION__, __FILE__); + std::to_string(inputNetData.size()) + " vs. " + std::to_string(1) + ").",
__LINE__, __FUNCTION__, __FILE__);
// Copy heatmap information // Copy heatmap information
upImpl->spCaffeNetOutputBlobs.clear(); upImpl->spCaffeNetOutputBlobs.clear();
const bool copyFromGpu = false; const bool copyFromGpu = false;
......
...@@ -6,11 +6,15 @@ ...@@ -6,11 +6,15 @@
namespace op namespace op
{ {
#ifdef _WIN32
// Output callback register in Unity // Output callback register in Unity
typedef void(__stdcall * OutputCallback) (void * ptrs, int ptrSize, int * sizes, int sizeSize, uchar outputType); typedef void(__stdcall * OutputCallback) (void * ptrs, int ptrSize, int * sizes, int sizeSize,
uchar outputType);
// Global output callback // Global output callback
OutputCallback sUnityOutputCallback; OutputCallback sUnityOutputCallback;
#endif
// Other global parameters
bool sMultiThreadEnabled = true; bool sMultiThreadEnabled = true;
bool sUnityOutputEnabled = true; bool sUnityOutputEnabled = true;
bool sImageOutput = false; bool sImageOutput = false;
...@@ -84,11 +88,29 @@ namespace op ...@@ -84,11 +88,29 @@ namespace op
template<class T> template<class T>
void outputValue(T ** ptrs, int ptrSize, int * sizes, int sizeSize, OutputType outputType) void outputValue(T ** ptrs, int ptrSize, int * sizes, int sizeSize, OutputType outputType)
{ {
try
{
#ifdef _WIN32
if (sUnityOutputCallback) if (sUnityOutputCallback)
sUnityOutputCallback(static_cast<void*>(ptrs), ptrSize, sizes, sizeSize, (uchar)outputType); sUnityOutputCallback(static_cast<void*>(ptrs), ptrSize, sizes, sizeSize, (uchar)outputType);
#else
UNUSED(ptrs);
UNUSED(ptrSize);
UNUSED(sizes);
UNUSED(sizeSize);
UNUSED(outputType);
error("Function only available on Windows.", __LINE__, __FUNCTION__, __FILE__);
#endif
}
catch (const std::exception& e)
{
log(e.what(), Priority::Max, __LINE__, __FUNCTION__, __FILE__);
}
} }
void sendDatumsInfoAndName(const std::shared_ptr<std::vector<std::shared_ptr<Datum>>>& datumsPtr) void sendDatumsInfoAndName(const std::shared_ptr<std::vector<std::shared_ptr<Datum>>>& datumsPtr)
{
try
{ {
auto& datum = datumsPtr->at(0); auto& datum = datumsPtr->at(0);
int sizes[] = { 1 }; int sizes[] = { 1 };
...@@ -100,8 +122,15 @@ namespace op ...@@ -100,8 +122,15 @@ namespace op
char const *a[] = { datum->name.c_str() }; char const *a[] = { datum->name.c_str() };
outputValue(&a[0], 1, &sizes[0], sizeSize, OutputType::Name); outputValue(&a[0], 1, &sizes[0], sizeSize, OutputType::Name);
} }
catch (const std::exception& e)
{
log(e.what(), Priority::Max, __LINE__, __FUNCTION__, __FILE__);
}
}
void sendPoseKeypoints(const std::shared_ptr<std::vector<std::shared_ptr<Datum>>>& datumsPtr) void sendPoseKeypoints(const std::shared_ptr<std::vector<std::shared_ptr<Datum>>>& datumsPtr)
{
try
{ {
auto& data = datumsPtr->at(0)->poseKeypoints; // Array<float> auto& data = datumsPtr->at(0)->poseKeypoints; // Array<float>
if (!data.empty()) if (!data.empty())
...@@ -113,8 +142,15 @@ namespace op ...@@ -113,8 +142,15 @@ namespace op
outputValue(&val, 1, sizes, sizeSize, OutputType::PoseKeypoints); outputValue(&val, 1, sizes, sizeSize, OutputType::PoseKeypoints);
} }
} }
catch (const std::exception& e)
{
log(e.what(), Priority::Max, __LINE__, __FUNCTION__, __FILE__);
}
}
void sendPoseIds(const std::shared_ptr<std::vector<std::shared_ptr<Datum>>>& datumsPtr) void sendPoseIds(const std::shared_ptr<std::vector<std::shared_ptr<Datum>>>& datumsPtr)
{
try
{ {
auto& data = datumsPtr->at(0)->poseIds; // Array<long long> auto& data = datumsPtr->at(0)->poseIds; // Array<long long>
if (!data.empty()) if (!data.empty())
...@@ -126,8 +162,15 @@ namespace op ...@@ -126,8 +162,15 @@ namespace op
outputValue(&val, 1, sizes, sizeSize, OutputType::PoseIds); outputValue(&val, 1, sizes, sizeSize, OutputType::PoseIds);
} }
} }
catch (const std::exception& e)
{
log(e.what(), Priority::Max, __LINE__, __FUNCTION__, __FILE__);
}
}
void sendPoseScores(const std::shared_ptr<std::vector<std::shared_ptr<Datum>>>& datumsPtr) void sendPoseScores(const std::shared_ptr<std::vector<std::shared_ptr<Datum>>>& datumsPtr)
{
try
{ {
auto& data = datumsPtr->at(0)->poseScores; // Array<float> auto& data = datumsPtr->at(0)->poseScores; // Array<float>
if (!data.empty()) if (!data.empty())
...@@ -139,8 +182,15 @@ namespace op ...@@ -139,8 +182,15 @@ namespace op
outputValue(&val, 1, sizes, sizeSize, OutputType::PoseScores); outputValue(&val, 1, sizes, sizeSize, OutputType::PoseScores);
} }
} }
catch (const std::exception& e)
{
log(e.what(), Priority::Max, __LINE__, __FUNCTION__, __FILE__);
}
}
void sendPoseHeatMaps(const std::shared_ptr<std::vector<std::shared_ptr<Datum>>>& datumsPtr) void sendPoseHeatMaps(const std::shared_ptr<std::vector<std::shared_ptr<Datum>>>& datumsPtr)
{
try
{ {
auto& data = datumsPtr->at(0)->poseHeatMaps; // Array<float> auto& data = datumsPtr->at(0)->poseHeatMaps; // Array<float>
if (!data.empty()) if (!data.empty())
...@@ -152,8 +202,15 @@ namespace op ...@@ -152,8 +202,15 @@ namespace op
outputValue(&val, 1, sizes, sizeSize, OutputType::PoseHeatMaps); outputValue(&val, 1, sizes, sizeSize, OutputType::PoseHeatMaps);
} }
} }
catch (const std::exception& e)
{
log(e.what(), Priority::Max, __LINE__, __FUNCTION__, __FILE__);
}
}
void sendPoseCandidates(const std::shared_ptr<std::vector<std::shared_ptr<Datum>>>& datumsPtr) void sendPoseCandidates(const std::shared_ptr<std::vector<std::shared_ptr<Datum>>>& datumsPtr)
{
try
{ {
auto& data = datumsPtr->at(0)->poseCandidates; // std::vector<std::vector<std::array<float, 3>>> auto& data = datumsPtr->at(0)->poseCandidates; // std::vector<std::vector<std::array<float, 3>>>
if (!data.empty()) if (!data.empty())
...@@ -167,15 +224,22 @@ namespace op ...@@ -167,15 +224,22 @@ namespace op
outputValue(&val, 1, sizes, sizeSize, OutputType::PoseIds);*/ outputValue(&val, 1, sizes, sizeSize, OutputType::PoseIds);*/
} }
} }
catch (const std::exception& e)
{
log(e.what(), Priority::Max, __LINE__, __FUNCTION__, __FILE__);
}
}
void sendFaceRectangles(const std::shared_ptr<std::vector<std::shared_ptr<Datum>>>& datumsPtr) void sendFaceRectangles(const std::shared_ptr<std::vector<std::shared_ptr<Datum>>>& datumsPtr)
{
try
{ {
auto& data = datumsPtr->at(0)->faceRectangles; // std::vector<Rectangle<float>> auto& data = datumsPtr->at(0)->faceRectangles; // std::vector<Rectangle<float>>
if (data.size() > 0) if (data.size() > 0)
{ {
int sizes[] = { data.size(), 4 }; int sizes[] = { (int)data.size(), 4 };
std::vector<float> vals(data.size() * 4); std::vector<float> vals(data.size() * 4);
for (int i = 0; i < data.size(); i++) for (auto i = 0u; i < data.size(); i++)
{ {
vals[4 * i + 0] = data[i].x; vals[4 * i + 0] = data[i].x;
vals[4 * i + 1] = data[i].y; vals[4 * i + 1] = data[i].y;
...@@ -186,8 +250,15 @@ namespace op ...@@ -186,8 +250,15 @@ namespace op
outputValue(&val, 1, sizes, 2, OutputType::FaceRectangles); outputValue(&val, 1, sizes, 2, OutputType::FaceRectangles);
} }
} }
catch (const std::exception& e)
{
log(e.what(), Priority::Max, __LINE__, __FUNCTION__, __FILE__);
}
}
void sendFaceKeypoints(const std::shared_ptr<std::vector<std::shared_ptr<Datum>>>& datumsPtr) void sendFaceKeypoints(const std::shared_ptr<std::vector<std::shared_ptr<Datum>>>& datumsPtr)
{
try
{ {
auto& data = datumsPtr->at(0)->faceKeypoints; // Array<float> auto& data = datumsPtr->at(0)->faceKeypoints; // Array<float>
if (!data.empty()) if (!data.empty())
...@@ -199,8 +270,15 @@ namespace op ...@@ -199,8 +270,15 @@ namespace op
outputValue(&val, 1, sizes, sizeSize, OutputType::FaceKeypoints); outputValue(&val, 1, sizes, sizeSize, OutputType::FaceKeypoints);
} }
} }
catch (const std::exception& e)
{
log(e.what(), Priority::Max, __LINE__, __FUNCTION__, __FILE__);
}
}
void sendFaceHeatMaps(const std::shared_ptr<std::vector<std::shared_ptr<Datum>>>& datumsPtr) void sendFaceHeatMaps(const std::shared_ptr<std::vector<std::shared_ptr<Datum>>>& datumsPtr)
{
try
{ {
auto& data = datumsPtr->at(0)->faceHeatMaps; // Array<float> auto& data = datumsPtr->at(0)->faceHeatMaps; // Array<float>
if (!data.empty()) if (!data.empty())
...@@ -212,17 +290,24 @@ namespace op ...@@ -212,17 +290,24 @@ namespace op
outputValue(&val, 1, sizes, sizeSize, OutputType::FaceHeatMaps); outputValue(&val, 1, sizes, sizeSize, OutputType::FaceHeatMaps);
} }
} }
catch (const std::exception& e)
{
log(e.what(), Priority::Max, __LINE__, __FUNCTION__, __FILE__);
}
}
void sendHandRectangles(const std::shared_ptr<std::vector<std::shared_ptr<Datum>>>& datumsPtr) void sendHandRectangles(const std::shared_ptr<std::vector<std::shared_ptr<Datum>>>& datumsPtr)
{
try
{ {
auto& data = datumsPtr->at(0)->handRectangles; // std::vector<std::array<Rectangle<float>, 2>> auto& data = datumsPtr->at(0)->handRectangles; // std::vector<std::array<Rectangle<float>, 2>>
if (!data.empty()) if (!data.empty())
{ {
std::vector<float*> valPtrs; std::vector<float*> valPtrs;
for (int i = 0; i < data.size(); i++) for (auto i = 0u; i < data.size(); i++)
{ {
float vals[8]; float vals[8];
for (int j = 0; j < 2; j++) for (auto j = 0; j < 2; j++)
{ {
vals[4 * j + 0] = data[i][j].x; vals[4 * j + 0] = data[i][j].x;
vals[4 * j + 1] = data[i][j].y; vals[4 * j + 1] = data[i][j].y;
...@@ -236,8 +321,15 @@ namespace op ...@@ -236,8 +321,15 @@ namespace op
outputValue(valPtrs.data(), valPtrs.size(), sizes, sizeSize, OutputType::HandRectangles); outputValue(valPtrs.data(), valPtrs.size(), sizes, sizeSize, OutputType::HandRectangles);
} }
} }
catch (const std::exception& e)
{
log(e.what(), Priority::Max, __LINE__, __FUNCTION__, __FILE__);
}
}
void sendHandKeypoints(const std::shared_ptr<std::vector<std::shared_ptr<Datum>>>& datumsPtr) void sendHandKeypoints(const std::shared_ptr<std::vector<std::shared_ptr<Datum>>>& datumsPtr)
{
try
{ {
auto& data = datumsPtr->at(0)->handKeypoints; // std::array<Array<float>, 2> auto& data = datumsPtr->at(0)->handKeypoints; // std::array<Array<float>, 2>
if (data.size() == 2 && !data[0].empty()) if (data.size() == 2 && !data[0].empty())
...@@ -249,8 +341,15 @@ namespace op ...@@ -249,8 +341,15 @@ namespace op
outputValue(ptrs, 2, sizes, sizeSize, OutputType::HandKeypoints); outputValue(ptrs, 2, sizes, sizeSize, OutputType::HandKeypoints);
} }
} }
catch (const std::exception& e)
{
log(e.what(), Priority::Max, __LINE__, __FUNCTION__, __FILE__);
}
}
void sendHandHeatMaps(const std::shared_ptr<std::vector<std::shared_ptr<Datum>>>& datumsPtr) void sendHandHeatMaps(const std::shared_ptr<std::vector<std::shared_ptr<Datum>>>& datumsPtr)
{
try
{ {
auto& data = datumsPtr->at(0)->handHeatMaps; // std::array<Array<float>, 2> auto& data = datumsPtr->at(0)->handHeatMaps; // std::array<Array<float>, 2>
if (data.size() == 2 && !data[0].empty()) if (data.size() == 2 && !data[0].empty())
...@@ -262,8 +361,15 @@ namespace op ...@@ -262,8 +361,15 @@ namespace op
outputValue(ptrs, 2, sizes, sizeSize, OutputType::HandHeightMaps); outputValue(ptrs, 2, sizes, sizeSize, OutputType::HandHeightMaps);
} }
} }
catch (const std::exception& e)
{
log(e.what(), Priority::Max, __LINE__, __FUNCTION__, __FILE__);
}
}
void sendImage(const std::shared_ptr<std::vector<std::shared_ptr<Datum>>>& datumsPtr) void sendImage(const std::shared_ptr<std::vector<std::shared_ptr<Datum>>>& datumsPtr)
{
try
{ {
auto& data = datumsPtr->at(0)->cvInputData; // cv::Mat auto& data = datumsPtr->at(0)->cvInputData; // cv::Mat
if (!data.empty()) if (!data.empty())
...@@ -274,11 +380,23 @@ namespace op ...@@ -274,11 +380,23 @@ namespace op
outputValue(&valPtr, 1, sizeVector, sizeSize, OutputType::Image); outputValue(&valPtr, 1, sizeVector, sizeSize, OutputType::Image);
} }
} }
catch (const std::exception& e)
{
log(e.what(), Priority::Max, __LINE__, __FUNCTION__, __FILE__);
}
}
void sendEndOfFrame() void sendEndOfFrame()
{
try
{ {
outputValue((void**)nullptr, 0, nullptr, 0, OutputType::None); outputValue((void**)nullptr, 0, nullptr, 0, OutputType::None);
} }
catch (const std::exception& e)
{
log(e.what(), Priority::Max, __LINE__, __FUNCTION__, __FILE__);
}
}
}; };
// Global user output // Global user output
...@@ -334,7 +452,7 @@ namespace op ...@@ -334,7 +452,7 @@ namespace op
{ {
log(e.what(), Priority::Max, __LINE__, __FUNCTION__, __FILE__); log(e.what(), Priority::Max, __LINE__, __FUNCTION__, __FILE__);
} }
}; }
// Functions called from Unity // Functions called from Unity
extern "C" { extern "C" {
...@@ -369,6 +487,7 @@ namespace op ...@@ -369,6 +487,7 @@ namespace op
} }
// Register Unity output callback function // Register Unity output callback function
#ifdef _WIN32
OP_API void _OPRegisterOutputCallback(OutputCallback callback) OP_API void _OPRegisterOutputCallback(OutputCallback callback)
{ {
try try
...@@ -380,6 +499,7 @@ namespace op ...@@ -380,6 +499,7 @@ namespace op
log(e.what(), Priority::Max, __LINE__, __FUNCTION__, __FILE__); log(e.what(), Priority::Max, __LINE__, __FUNCTION__, __FILE__);
} }
} }
#endif
// Enable/disable multi-threading // Enable/disable multi-threading
OP_API void _OPSetMultiThreadEnable(bool enable) OP_API void _OPSetMultiThreadEnable(bool enable)
...@@ -422,7 +542,7 @@ namespace op ...@@ -422,7 +542,7 @@ namespace op
// Configs // Configs
OP_API void _OPConfigurePose( OP_API void _OPConfigurePose(
bool enable, uchar poseMode,
int netInputSizeX, int netInputSizeY, // Point int netInputSizeX, int netInputSizeY, // Point
int outputSizeX, int outputSizeY, // Point int outputSizeX, int outputSizeY, // Point
uchar keypointScaleMode, // ScaleMode uchar keypointScaleMode, // ScaleMode
...@@ -434,19 +554,19 @@ namespace op ...@@ -434,19 +554,19 @@ namespace op
bool heatMapAddPAFs, // HeatMapType // uchar heatmap_type, bool heatMapAddPAFs, // HeatMapType // uchar heatmap_type,
uchar heatMapScaleMode, // ScaleMode uchar heatMapScaleMode, // ScaleMode
bool addPartCandidates, float renderThreshold, int numberPeopleMax, bool addPartCandidates, float renderThreshold, int numberPeopleMax,
bool maximizePositives, double fpsMax, char* protoTxtPath, char* caffeModelPath) bool maximizePositives, double fpsMax, char* protoTxtPath, float upsamplingRatio, char* caffeModelPath)
{ {
try try
{ {
spWrapperStructPose = std::make_shared<WrapperStructPose>( spWrapperStructPose = std::make_shared<WrapperStructPose>(
enable, Point<int>{netInputSizeX, netInputSizeY}, Point<int>{outputSizeX, outputSizeY}, (PoseMode)poseMode, Point<int>{netInputSizeX, netInputSizeY}, Point<int>{outputSizeX, outputSizeY},
(ScaleMode) keypointScaleMode, gpuNumber, gpuNumberStart, scalesNumber, scaleGap, (ScaleMode) keypointScaleMode, gpuNumber, gpuNumberStart, scalesNumber, scaleGap,
(RenderMode) renderMode, (PoseModel) poseModel, blendOriginalFrame, alphaKeypoint, alphaHeatMap, (RenderMode) renderMode, (PoseModel) poseModel, blendOriginalFrame, alphaKeypoint, alphaHeatMap,
defaultPartToRender, modelFolder, defaultPartToRender, modelFolder,
// HeatMapType // (HeatMapType) heatmap_type, // HeatMapType // (HeatMapType) heatmap_type,
flagsToHeatMaps(heatMapAddParts, heatMapAddBkg, heatMapAddPAFs), flagsToHeatMaps(heatMapAddParts, heatMapAddBkg, heatMapAddPAFs),
(ScaleMode) heatMapScaleMode, addPartCandidates, renderThreshold, numberPeopleMax, (ScaleMode) heatMapScaleMode, addPartCandidates, renderThreshold, numberPeopleMax,
maximizePositives, fpsMax, protoTxtPath, caffeModelPath, true maximizePositives, fpsMax, protoTxtPath, caffeModelPath, upsamplingRatio, true
); );
} }
catch (const std::exception& e) catch (const std::exception& e)
...@@ -481,8 +601,8 @@ namespace op ...@@ -481,8 +601,8 @@ namespace op
try try
{ {
spWrapperStructFace = std::make_shared<WrapperStructFace>( spWrapperStructFace = std::make_shared<WrapperStructFace>(
enable, (Detector) detector, Point<int>{ netInputSizeX, netInputSizeY }, (RenderMode) renderMode, alphaKeypoint, enable, (Detector) detector, Point<int>{ netInputSizeX, netInputSizeY }, (RenderMode) renderMode,
alphaHeatMap, renderThreshold alphaKeypoint, alphaHeatMap, renderThreshold
); );
} }
catch (const std::exception& e) catch (const std::exception& e)
...@@ -530,9 +650,9 @@ namespace op ...@@ -530,9 +650,9 @@ namespace op
OP_API void _OPConfigureOutput( OP_API void _OPConfigureOutput(
double verbose, char* writeKeypoint, uchar writeKeypointFormat, // DataFormat double verbose, char* writeKeypoint, uchar writeKeypointFormat, // DataFormat
char* writeJson, char* writeCocoJson, char* writeCocoFootJson, int writeCocoJsonVariant, char* writeImages, char* writeJson, char* writeCocoJson, char* writeCocoFootJson, int writeCocoJsonVariant, char* writeImages,
char* writeImagesFormat, char* writeVideo, double writeVideoFps, bool writeVideoWithAudio, char* writeHeatMaps, char* writeImagesFormat, char* writeVideo, double writeVideoFps, bool writeVideoWithAudio,
char* writeHeatMapsFormat, char* writeVideo3D, char* writeVideoAdam, char* writeBvh, char* udpHost, char* writeHeatMaps, char* writeHeatMapsFormat, char* writeVideo3D, char* writeVideoAdam, char* writeBvh,
char* udpPort) char* udpHost, char* udpPort)
{ {
try try
{ {
......
...@@ -9,21 +9,36 @@ namespace op ...@@ -9,21 +9,36 @@ namespace op
#ifdef USE_UNITY_SUPPORT #ifdef USE_UNITY_SUPPORT
namespace UnityDebugger namespace UnityDebugger
{ {
#ifdef _WIN32
typedef void(__stdcall * DebugCallback) (const char* const str, int type); typedef void(__stdcall * DebugCallback) (const char* const str, int type);
DebugCallback unityDebugCallback; DebugCallback unityDebugCallback;
#endif
bool unityDebugEnabled = true; bool unityDebugEnabled = true;
extern "C" void OP_API _OPRegisterDebugCallback(DebugCallback debugCallback) { #ifdef _WIN32
extern "C" void OP_API _OPRegisterDebugCallback(DebugCallback debugCallback)
{
if (debugCallback) if (debugCallback)
unityDebugCallback = debugCallback; unityDebugCallback = debugCallback;
} }
extern "C" void OP_API _OPSetDebugEnable(bool enable) { extern "C" void OP_API _OPSetDebugEnable(bool enable)
{
unityDebugEnabled = enable; unityDebugEnabled = enable;
} }
#endif
void DebugInUnity(const std::string& message, const int type) { void DebugInUnity(const std::string& message, const int type)
if (unityDebugEnabled) if (unityDebugCallback) unityDebugCallback(message.c_str(), type); {
#ifdef _WIN32
if (unityDebugEnabled)
if (unityDebugCallback)
unityDebugCallback(message.c_str(), type);
#else
UNUSED(message);
UNUSED(type);
error("Unity plugin only available on Windows.", __LINE__, __FUNCTION__, __FILE__);
#endif
} }
void log(const std::string& message) { DebugInUnity(message, 0); } void log(const std::string& message) { DebugInUnity(message, 0); }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册