OpenPose  1.7.0
The first real-time multi-person system to jointly detect human body, hand, facial, and foot keypoints
nmsCaffe.hpp
Go to the documentation of this file.
1 #ifndef OPENPOSE_NET_NMS_CAFFE_HPP
2 #define OPENPOSE_NET_NMS_CAFFE_HPP
3 
5 
6 namespace op
7 {
8  // It mostly follows the Caffe::layer implementation, so Caffe users can easily use it. However, in order to keep
9  // the compatibility with any generic Caffe version, we keep this 'layer' inside our library rather than in the
10  // Caffe code.
11  template <typename T>
12  class NmsCaffe
13  {
14  public:
15  explicit NmsCaffe();
16 
17  virtual ~NmsCaffe();
18 
19  virtual void LayerSetUp(const std::vector<ArrayCpuGpu<T>*>& bottom, const std::vector<ArrayCpuGpu<T>*>& top);
20 
21  virtual void Reshape(const std::vector<ArrayCpuGpu<T>*>& bottom, const std::vector<ArrayCpuGpu<T>*>& top,
22  const int maxPeaks, const int outputChannels = -1, const int gpuID = 0);
23 
24  virtual inline const char* type() const { return "Nms"; }
25 
26  void setThreshold(const T threshold);
27 
28  // Empirically gives better results (copied from Matlab original code)
29  void setOffset(const Point<T>& offset);
30 
31  virtual void Forward(const std::vector<ArrayCpuGpu<T>*>& bottom, const std::vector<ArrayCpuGpu<T>*>& top);
32 
33  virtual void Forward_cpu(const std::vector<ArrayCpuGpu<T>*>& bottom, const std::vector<ArrayCpuGpu<T>*>& top);
34 
35  virtual void Forward_gpu(const std::vector<ArrayCpuGpu<T>*>& bottom, const std::vector<ArrayCpuGpu<T>*>& top);
36 
37  virtual void Forward_ocl(const std::vector<ArrayCpuGpu<T>*>& bottom, const std::vector<ArrayCpuGpu<T>*>& top);
38 
39  virtual void Backward_cpu(const std::vector<ArrayCpuGpu<T>*>& top, const std::vector<bool>& propagate_down,
40  const std::vector<ArrayCpuGpu<T>*>& bottom);
41 
42  virtual void Backward_gpu(const std::vector<ArrayCpuGpu<T>*>& top, const std::vector<bool>& propagate_down,
43  const std::vector<ArrayCpuGpu<T>*>& bottom);
44 
45  private:
46  T mThreshold;
47  Point<T> mOffset;
48  int mGpuID;
49 
50  // PIMPL idiom
51  // http://www.cppsamples.com/common-tasks/pimpl.html
52  struct ImplNmsCaffe;
53  std::unique_ptr<ImplNmsCaffe> upImpl;
54 
55  // PIMP requires DELETE_COPY & destructor, or extra code
56  // http://oliora.github.io/2015/12/29/pimpl-and-rule-of-zero.html
58  };
59 }
60 
61 #endif // OPENPOSE_NET_NMS_CAFFE_HPP
virtual ~NmsCaffe()
void setOffset(const Point< T > &offset)
virtual void Forward(const std::vector< ArrayCpuGpu< T > * > &bottom, const std::vector< ArrayCpuGpu< T > * > &top)
virtual void Backward_gpu(const std::vector< ArrayCpuGpu< T > * > &top, const std::vector< bool > &propagate_down, const std::vector< ArrayCpuGpu< T > * > &bottom)
void setThreshold(const T threshold)
virtual void Forward_cpu(const std::vector< ArrayCpuGpu< T > * > &bottom, const std::vector< ArrayCpuGpu< T > * > &top)
virtual void Forward_gpu(const std::vector< ArrayCpuGpu< T > * > &bottom, const std::vector< ArrayCpuGpu< T > * > &top)
virtual void LayerSetUp(const std::vector< ArrayCpuGpu< T > * > &bottom, const std::vector< ArrayCpuGpu< T > * > &top)
virtual void Backward_cpu(const std::vector< ArrayCpuGpu< T > * > &top, const std::vector< bool > &propagate_down, const std::vector< ArrayCpuGpu< T > * > &bottom)
virtual void Reshape(const std::vector< ArrayCpuGpu< T > * > &bottom, const std::vector< ArrayCpuGpu< T > * > &top, const int maxPeaks, const int outputChannels=-1, const int gpuID=0)
virtual void Forward_ocl(const std::vector< ArrayCpuGpu< T > * > &bottom, const std::vector< ArrayCpuGpu< T > * > &top)
virtual const char * type() const
Definition: nmsCaffe.hpp:24
#define DELETE_COPY(className)
Definition: macros.hpp:32