File size: 2,485 Bytes
f5bb0c0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#ifndef OPENPOSE_POSE_POSE_EXTRACTOR_NET_HPP
#define OPENPOSE_POSE_POSE_EXTRACTOR_NET_HPP

#include <atomic>
#include <openpose/core/common.hpp>
#include <openpose/core/enumClasses.hpp>
#include <openpose/pose/poseParameters.hpp>

namespace op
{
    class OP_API PoseExtractorNet
    {
    public:
        PoseExtractorNet(const PoseModel poseModel,
                         const std::vector<HeatMapType>& heatMapTypes = {},
                         const ScaleMode heatMapScaleMode = ScaleMode::ZeroToOneFixedAspect,
                         const bool addPartCandidates = false,
                         const bool maximizePositives = false);

        virtual ~PoseExtractorNet();

        void initializationOnThread();

        virtual void forwardPass(
            const std::vector<Array<float>>& inputNetData, const Point<int>& inputDataSize,
            const std::vector<double>& scaleRatios = {1.f}, const Array<float>& poseNetOutput = Array<float>{}) = 0;

        virtual const float* getCandidatesCpuConstPtr() const = 0;

        virtual const float* getCandidatesGpuConstPtr() const = 0;

        virtual const float* getHeatMapCpuConstPtr() const = 0;

        virtual const float* getHeatMapGpuConstPtr() const = 0;

        virtual std::vector<int> getHeatMapSize() const = 0;

        Array<float> getHeatMapsCopy() const;

        std::vector<std::vector<std::array<float,3>>> getCandidatesCopy() const;

        virtual const float* getPoseGpuConstPtr() const = 0;

        Array<float> getPoseKeypoints() const;

        Array<float> getPoseScores() const;

        float getScaleNetToOutput() const;

        double get(const PoseProperty property) const;

        void set(const PoseProperty property, const double value);

        void increase(const PoseProperty property, const double value);

        void clear();

    protected:
        const PoseModel mPoseModel;
        Point<int> mNetOutputSize;
        Array<float> mPoseKeypoints;
        Array<float> mPoseScores;
        float mScaleNetToOutput;

        void checkThread() const;

        virtual void netInitializationOnThread() = 0;

    private:
        const std::vector<HeatMapType> mHeatMapTypes;
        const ScaleMode mHeatMapScaleMode;
        const bool mAddPartCandidates;
        std::array<std::atomic<double>, (int)PoseProperty::Size> mProperties;
        std::thread::id mThreadId;

        DELETE_COPY(PoseExtractorNet);
    };
}

#endif // OPENPOSE_POSE_POSE_EXTRACTOR_NET_HPP