Skip to content

Commit 665b23e

Browse files
Removed boost and caffe deps from headers
1 parent ee10cec commit 665b23e

30 files changed

+943
-233
lines changed

.github/issue_template.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ You might select multiple topics, delete the rest:
4848
3. **General configuration**:
4949
- **Installation mode**: CMake, sh script, manual Makefile installation, ... (Ubuntu); CMake, ... (Windows); ...?
5050
- **Operating system** (`lsb_release -a` in Ubuntu):
51+
- **Operating system version** (e.g., Ubuntu 16, Windows 10, ...):
5152
- **Release or Debug mode**? (by default: release):
5253
- Compiler (`gcc --version` in Ubuntu or VS version in Windows): 5.4.0, ... (Ubuntu); VS2015 Enterprise Update 3, VS2017 community, ... (Windows); ...?
5354

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
-----------------
66

7-
| | `Python (CUDA GPU)` | `Python (CPU)` | `CUDA GPU` | `CPU` | `Debug mode` |
8-
| :---: | :---: | :---: | :---: |:---: | :---: |
7+
| | `Python (CUDA GPU)` | `Python (CPU)` | `CUDA GPU` | `CPU` | `Debug mode` |
8+
| :---: | :---: | :---: | :---: |:---: | :---: |
99
| **`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) |
1010
| **`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) |
1111
<!-- | **`Windows`** | | | | | | -->
@@ -46,7 +46,7 @@ It is **authored by [Gines Hidalgo](https://www.gineshidalgo.com), [Zhe Cao](htt
4646
- Available: command-line demo, C++ wrapper, and C++ API.
4747
- [**Python API**](doc/modules/python_module.md).
4848
- [**Unity Plugin**](https://github.com/CMU-Perceptual-Computing-Lab/openpose_unity_plugin).
49-
- CUDA (Nvidia GPU), OpenCL (AMD GPU), and CPU versions.
49+
- CUDA (Nvidia GPU), OpenCL (AMD GPU), and CPU-only (no GPU) versions.
5050
- Training code included in the [**original CVPR 2017 GitHub repository**](https://github.com/ZheC/Multi-Person-Pose-Estimation).
5151

5252

doc/installation.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,14 @@ This installation section is only intended if you plan to modify the OpenPose co
4848

4949
## Requirements and Dependencies
5050
- **Requirements** for the default configuration (you might need more resources with a greater `--net_resolution` and/or `scale_number` or less resources by reducing the net resolution and/or using the MPI and MPI_4 models):
51-
- Nvidia GPU version:
51+
- CUDA (Nvidia GPU) version:
5252
- NVIDIA graphics card with at least 1.6 GB available (the `nvidia-smi` command checks the available GPU memory in Ubuntu).
5353
- At least 2.5 GB of free RAM memory for BODY_25 model or 2 GB for COCO model (assuming cuDNN installed).
5454
- Highly recommended: cuDNN.
55-
- AMD GPU version:
55+
- OpenCL (AMD GPU) version:
5656
- Vega series graphics card
5757
- At least 2 GB of free RAM memory.
58-
- CPU version:
58+
- CPU-only (no GPU) version:
5959
- Around 8GB of free RAM memory.
6060
- Highly recommended: a CPU with at least 8 cores.
6161
- **Dependencies**:

doc/modules/python_module.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ This module exposes a Python API for OpenPose. It is effectively a wrapper that
1818
## Compatibility
1919
The OpenPose Python module is compatible with both Python 2 and Python 3 (default and recommended). In addition, it will also run in all OpenPose compatible operating systems. It uses [Pybind11](https://github.com/pybind/pybind11) for mapping between C++ and Python datatypes.
2020

21-
To compile, enable `BUILD_PYTHON` in CMake-gui. In Windows, make sure you compile the whole solution (clicking the green play button does not compile the whole solution!). You can do that by right-click on the OpenPose project solution, and clicking in `Build solution`.
21+
To compile, enable `BUILD_PYTHON` in CMake-gui. In Windows, make sure you compile the whole solution (clicking the green play button does not compile the whole solution!). You can do that by right-click on the OpenPose project solution, and clicking in `Build Solution` (or individually building the PyOpenPose module).
2222

2323
Pybind selects the latest version of Python by default (Python 3). To use Python 2, change `PYTHON_EXECUTABLE` and `PYTHON_LIBRARY` flags in CMake-gui to your desired Python version.
2424

doc/release_notes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,7 @@ OpenPose Library - Release Notes
316316
33. Added the flags `--face_detector` and `--hand_detector`, that enable the user to select the face/hand rectangle detector that is used for the later face/hand keypoint detection. It includes OpenCV (for face), and also allows the user to provide its own input. Flag `--hand_tracking` is removed and integrated into this flag too.
317317
34. Maximum queue size per OpenPose thread is configurable through the Wrapper class.
318318
35. Added pre-processing capabilities to Wrapper (WorkerType::PreProcessing), which will be run right after the image has been read.
319+
36. Removed boost::shared_ptr and caffe::Blob dependencies from the headers. No 3rdparty dependencies left on headers (except dim3 for CUDA).
319320
2. Functions or parameters renamed:
320321
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.
321322
2. WrapperStructPose default parameters changed to match those of the OpenPose demo binary.

doc/released_features.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
OpenPose Library - All Released Features
22
====================================
33

4-
- Jan 2018: [**Unity plugin released**](https://github.com/CMU-Perceptual-Computing-Lab/openpose_unity_plugin)!
5-
- Jan 2018: [**Improved Python API**](doc/modules/python_module.md) released! Including body, face, hands, and all the functionality of the C++ API!
4+
- Jan 2019: [**Unity plugin released**](https://github.com/CMU-Perceptual-Computing-Lab/openpose_unity_plugin)!
5+
- Jan 2019: [**Improved Python API**](doc/modules/python_module.md) released! Including body, face, hands, and all the functionality of the C++ API!
66
- Dec 2018: [**Foot dataset**](https://cmu-perceptual-computing-lab.github.io/foot_keypoint_dataset) and [**new paper released**](https://arxiv.org/abs/1812.08008)!
77
- Sep 2018: [**Experimental tracker**](./quick_start.md#tracking)!
88
- Jun 2018: [**Combined body-foot model released! 40% faster and 5% more accurate**](./installation.md)!

examples/tests/clTest.cpp

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
#include <openpose/flags.hpp>
66
// OpenPose dependencies
77
#include <openpose/headers.hpp>
8+
// Caffe dependencies
9+
#ifdef USE_CAFFE
10+
#include <caffe/blob.hpp>
11+
#endif
812
// OpenCL dependencies
913
#ifdef USE_OPENCL
1014
#include <openpose/gpu/opencl.hcl>
@@ -72,7 +76,8 @@ DEFINE_string(image_path, "examples/media/COCO_val2014_00000000019
7276

7377
typedef cl::KernelFunctor<cl::Buffer, int, int, float> ScaleFunctor;
7478
const std::string scaleKernelString = MULTI_LINE_STRING(
75-
__kernel void scaleKernel(__global float* targetPtr, const int targetWidth, const int targetHeight, const float scale)
79+
__kernel void scaleKernel(__global float* targetPtr, const int targetWidth, const int targetHeight,
80+
const float scale)
7681
{
7782
int x = get_global_id(0);
7883
int y = get_global_id(1);
@@ -111,7 +116,8 @@ int clTest()
111116
std::unique_ptr<caffe::Net<float>> upCaffeNet;
112117
caffe::Caffe::set_mode(caffe::Caffe::GPU);
113118
caffe::Caffe::SelectDevice(0, true);
114-
upCaffeNet.reset(new caffe::Net<float>{"models/pose/coco/pose_deploy_linevec.prototxt", caffe::TEST, caffe::Caffe::GetDefaultDevice()});
119+
upCaffeNet.reset(new caffe::Net<float>{
120+
"models/pose/coco/pose_deploy_linevec.prototxt", caffe::TEST, caffe::Caffe::GetDefaultDevice()});
115121
upCaffeNet->CopyTrainedLayersFrom("models/pose/coco/pose_iter_440000.caffemodel");
116122
op::OpenCL::getInstance(0, CL_DEVICE_TYPE_GPU, true);
117123

@@ -125,19 +131,16 @@ int clTest()
125131
blob_proto.set_height(imgResize.size().width);
126132
blob_proto.set_width(imgResize.size().height);
127133
blob_proto.clear_data();
128-
for (int c = 0; c < 3; ++c) {
129-
for (int h = 0; h < imgResize.size().height; ++h) {
130-
for (int w = 0; w < imgResize.size().width; ++w) {
134+
for (int c = 0; c < 3; ++c)
135+
for (int h = 0; h < imgResize.size().height; ++h)
136+
for (int w = 0; w < imgResize.size().width; ++w)
131137
blob_proto.add_data(imgResize.at<cv::Vec3f>(h, w)[c]);
132-
}
133-
}
134-
}
135138
blob_proto.set_num(1);
136139
caffe::Blob<float>* input_layer = upCaffeNet->input_blobs()[0];
137140
input_layer->FromProto(blob_proto);
138141
upCaffeNet->Forward(0);
139142

140-
boost::shared_ptr<caffe::Blob<float> > output_blob = upCaffeNet->blob_by_name("net_output");
143+
boost::shared_ptr<caffe::Blob<float>> output_blob = upCaffeNet->blob_by_name("net_output");
141144

142145
// Test
143146
cl::Device& device = op::OpenCL::getInstance(0)->getDevice();
@@ -156,8 +159,9 @@ int clTest()
156159
// Read it
157160
// Read back image to GPU
158161
float* heatmaps = new float[output_blob->shape()[1] * output_blob->shape()[2] * output_blob->shape()[3]];
159-
op::OpenCL::getInstance(0)->getQueue().enqueueReadBuffer(outputBuffer, CL_TRUE, 0,
160-
output_blob->shape()[1] * output_blob->shape()[2] * output_blob->shape()[3] * sizeof(float), heatmaps);
162+
op::OpenCL::getInstance(0)->getQueue().enqueueReadBuffer(
163+
outputBuffer, CL_TRUE, 0,
164+
output_blob->shape()[1] * output_blob->shape()[2] * output_blob->shape()[3] * sizeof(float), heatmaps);
161165

162166
int heatmapChannels = output_blob->shape()[1];
163167
int shape = output_blob->shape()[2] * output_blob->shape()[3];
@@ -172,11 +176,11 @@ int clTest()
172176
}
173177
}
174178
#if defined(USE_OPENCL) && defined(CL_HPP_ENABLE_EXCEPTIONS)
175-
catch (const cl::Error& e)
176-
{
177-
op::error(std::string(e.what()) + " : " + op::OpenCL::clErrorToString(e.err()) + " ID: " +
178-
std::to_string(0), __LINE__, __FUNCTION__, __FILE__);
179-
}
179+
catch (const cl::Error& e)
180+
{
181+
op::error(std::string(e.what()) + " : " + op::OpenCL::clErrorToString(e.err()) + " ID: " +
182+
std::to_string(0), __LINE__, __FUNCTION__, __FILE__);
183+
}
180184
#endif
181185
catch (const std::exception& e)
182186
{
@@ -223,6 +227,6 @@ int main()
223227
#else
224228
op::error("OpenPose must be compiled with the `USE_CAFFE` & `USE_OPENCL` macro definitions in order to run"
225229
" this functionality.", __LINE__, __FUNCTION__, __FILE__);
226-
return 0;
230+
return -1;
227231
#endif
228232
}

examples/tests/resizeTest.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
cv::Mat gpuResize(cv::Mat& img, const cv::Size& newSize)
1717
{
18-
#ifdef USE_CUDA
18+
#if defined USE_CAFFE && defined USE_CUDA
1919
// Upload to Source to GPU
2020
float* cpuPtr = &img.at<float>(0);
2121
float* gpuPtr;
@@ -49,6 +49,7 @@
4949
UNUSED(newSize);
5050
op::error("OpenPose must be compiled with the `USE_CAFFE` & `USE_CUDA` macro definitions in order to run"
5151
" this functionality.", __LINE__, __FUNCTION__, __FILE__);
52+
return cv::Mat();
5253
#endif
5354
}
5455

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
#ifndef OPENPOSE_CORE_ARRAY_CPU_GPU_HPP
2+
#define OPENPOSE_CORE_ARRAY_CPU_GPU_HPP
3+
4+
#include <memory> // std::shared_ptr
5+
#include <vector>
6+
#include <openpose/core/macros.hpp>
7+
8+
namespace op
9+
{
10+
/**
11+
* ArrayCpuGpu<T>: Bind of caffe::Blob<T> to avoid Caffe as dependency in the headers.
12+
*/
13+
template<typename T>
14+
class ArrayCpuGpu
15+
{
16+
public:
17+
ArrayCpuGpu();
18+
explicit ArrayCpuGpu(const void* caffeBlobTPtr);
19+
explicit ArrayCpuGpu(const int num, const int channels, const int height, const int width);
20+
// explicit ArrayCpuGpu(const std::vector<int>& shape);
21+
22+
void Reshape(const int num, const int channels, const int height, const int width);
23+
void Reshape(const std::vector<int>& shape);
24+
// // void Reshape(const BlobShape& shape);
25+
// // void ReshapeLike(const Blob& other);
26+
// void ReshapeLike(const ArrayCpuGpu& other);
27+
std::string shape_string() const;
28+
const std::vector<int>& shape() const;
29+
int shape(const int index) const;
30+
int num_axes() const;
31+
int count() const;
32+
int count(const int start_axis, const int end_axis) const;
33+
int count(const int start_axis) const;
34+
35+
int CanonicalAxisIndex(const int axis_index) const;
36+
37+
// int num() const;
38+
// int channels() const;
39+
// int height() const;
40+
// int width() const;
41+
// int LegacyShape(const int index) const;
42+
43+
// int offset(const int n, const int c = 0, const int h = 0, const int w = 0) const;
44+
// int offset(const std::vector<int>& indices) const;
45+
46+
// // void CopyFrom(const Blob<T>& source, bool copy_diff = false, bool reshape = false);
47+
// void CopyFrom(const ArrayCpuGpu<T>& source, bool copy_diff = false, bool reshape = false);
48+
49+
T data_at(const int n, const int c, const int h, const int w) const;
50+
T diff_at(const int n, const int c, const int h, const int w) const;
51+
// T data_at(const std::vector<int>& index) const; // Caffe warning
52+
// T diff_at(const std::vector<int>& index) const;
53+
54+
// // const boost::shared_ptr<SyncedMemory>& data() const;
55+
// // const boost::shared_ptr<SyncedMemory>& diff() const;
56+
57+
const T* cpu_data() const;
58+
void set_cpu_data(T* data);
59+
const int* gpu_shape() const;
60+
const T* gpu_data() const;
61+
void set_gpu_data(T* data);
62+
const T* cpu_diff() const;
63+
const T* gpu_diff() const;
64+
T* mutable_cpu_data();
65+
T* mutable_gpu_data();
66+
T* mutable_cpu_diff();
67+
T* mutable_gpu_diff();
68+
void Update();
69+
// void FromProto(const BlobProto& proto, bool reshape = true);
70+
// void ToProto(BlobProto* proto, bool write_diff = false) const;
71+
72+
// T asum_data() const;
73+
// T asum_diff() const;
74+
// T sumsq_data() const;
75+
// T sumsq_diff() const;
76+
77+
// void scale_data(T scale_factor);
78+
// void scale_diff(T scale_factor);
79+
80+
// // void ShareData(const Blob& other);
81+
// // void ShareDiff(const Blob& other);
82+
83+
// // bool ShapeEquals(const BlobProto& other);
84+
85+
private:
86+
// PIMPL idiom
87+
// http://www.cppsamples.com/common-tasks/pimpl.html
88+
struct ImplArrayCpuGpu;
89+
std::shared_ptr<ImplArrayCpuGpu> spImpl;
90+
91+
// PIMP requires DELETE_COPY & destructor, or extra code
92+
// http://oliora.github.io/2015/12/29/pimpl-and-rule-of-zero.html
93+
DELETE_COPY(ArrayCpuGpu);
94+
};
95+
96+
// // Static methods
97+
// OVERLOAD_C_OUT(ArrayCpuGpu)
98+
}
99+
100+
#endif // OPENPOSE_CORE_ARRAY_CPU_GPU_HPP

include/openpose/core/common.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <vector>
99
// OpenPose most used classes
1010
#include <openpose/core/array.hpp>
11+
#include <openpose/core/arrayCpuGpu.hpp>
1112
#include <openpose/core/macros.hpp>
1213
#include <openpose/core/point.hpp>
1314
#include <openpose/core/rectangle.hpp>

0 commit comments

Comments
 (0)