#ifndef OPENPOSE_POSE_BODY_PART_CONNECTOR_CAFFE_HPP #define OPENPOSE_POSE_BODY_PART_CONNECTOR_CAFFE_HPP #include #include namespace op { // It mostly follows the Caffe::layer implementation, so Caffe users can easily use it. However, in order to keep // the compatibility with any generic Caffe version, we keep this 'layer' inside our library rather than in the // Caffe code. template class BodyPartConnectorCaffe { public: explicit BodyPartConnectorCaffe(); virtual ~BodyPartConnectorCaffe(); virtual void Reshape(const std::vector*>& bottom, const int gpuID = 0); virtual inline const char* type() const { return "BodyPartConnector"; } void setPoseModel(const PoseModel poseModel); void setMaximizePositives(const bool maximizePositives); void setDefaultNmsThreshold(const T defaultNmsThreshold); void setInterMinAboveThreshold(const T interMinAboveThreshold); void setInterThreshold(const T interThreshold); void setMinSubsetCnt(const int minSubsetCnt); void setMinSubsetScore(const T minSubsetScore); void setScaleNetToOutput(const T scaleNetToOutput); virtual void Forward(const std::vector*>& bottom, Array& poseKeypoints, Array& poseScores); virtual void Forward_cpu(const std::vector*>& bottom, Array& poseKeypoints, Array& poseScores); virtual void Forward_gpu(const std::vector*>& bottom, Array& poseKeypoints, Array& poseScores); virtual void Forward_ocl(const std::vector*>& bottom, Array& poseKeypoints, Array& poseScores); virtual void Backward_cpu(const std::vector*>& top, const std::vector& propagate_down, const std::vector*>& bottom); virtual void Backward_gpu(const std::vector*>& top, const std::vector& propagate_down, const std::vector*>& bottom); private: PoseModel mPoseModel; bool mMaximizePositives; T mDefaultNmsThreshold; T mInterMinAboveThreshold; T mInterThreshold; int mMinSubsetCnt; T mMinSubsetScore; T mScaleNetToOutput; std::array mHeatMapsSize; std::array mPeaksSize; std::array mTopSize; // GPU auxiliary unsigned int* pBodyPartPairsGpuPtr; unsigned int* pMapIdxGpuPtr; Array mFinalOutputCpu; T* pFinalOutputGpuPtr; int mGpuID; DELETE_COPY(BodyPartConnectorCaffe); }; } #endif // OPENPOSE_POSE_BODY_PART_CONNECTOR_CAFFE_HPP