OpenPose 1.0.0rc2 OpenPose: A Real-Time Multi-Person Key-Point Detection And Multi-Threading C++ Library

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
personTracker.hpp
Go to the documentation of this file.
1 #ifndef OPENPOSE_TRACKING_PERSON_TRACKER_HPP
2 #define OPENPOSE_TRACKING_PERSON_TRACKER_HPP
3
4 #include <atomic>
5 #include <unordered_map>
6 #include <openpose/core/common.hpp>
7
8 namespace op
9 {
10 struct PersonTrackerEntry
11 {
12 std::vector<cv::Point2f> keypoints;
13 std::vector<cv::Point2f> lastKeypoints;
14 std::vector<char> status;
15 std::vector<cv::Point2f> getPredicted() const
16 {
17 std::vector<cv::Point2f> predictedKeypoints(keypoints);
18 if (!lastKeypoints.size())
19 return predictedKeypoints;
20 for (size_t i=0; i<keypoints.size(); i++)
21 {
22 predictedKeypoints[i] = cv::Point2f{predictedKeypoints[i].x + (keypoints[i].x-lastKeypoints[i].x),
23 predictedKeypoints[i].y + (keypoints[i].y-lastKeypoints[i].y)};
24 }
25 return predictedKeypoints;
26 }
27 };
28
29 class OP_API PersonTracker
30 {
31
32 public:
33 PersonTracker(const bool mergeResults, const int levels = 3, const int patchSize = 31,
34 const float confidenceThreshold = 0.05f, const bool trackVelocity = false,
35 const bool scaleVarying = false, const float rescale = 640);
36
37 virtual ~PersonTracker();
38
39 void track(Array<float>& poseKeypoints, Array<long long>& poseIds, const cv::Mat& cvMatInput);
40
41 void trackLockThread(Array<float>& poseKeypoints, Array<long long>& poseIds, const cv::Mat& cvMatInput,
42 const long long frameId);
43
44 bool getMergeResults() const;
45
46 private:
47 const bool mMergeResults;
48 const int mLevels;
49 const int mPatchSize;
50 const bool mTrackVelocity;
51 const float mConfidenceThreshold;
52 const bool mScaleVarying;
53 const float mRescale;
54
55 cv::Mat mImagePrevious;
56 std::vector<cv::Mat> mPyramidImagesPrevious;
57 std::unordered_map<int, PersonTrackerEntry> mPersonEntries;
58 Array<long long> mLastPoseIds;
59
60 // Thread-safe variables
61 std::atomic<long long> mLastFrameId;
62
63 DELETE_COPY(PersonTracker);
64 };
65 }
66
67 #endif // OPENPOSE_TRACKING_PERSON_TRACKER_HPP
DELETE_COPY
#define DELETE_COPY(className)
Definition: macros.hpp:34
op::PersonTrackerEntry::keypoints
std::vector< cv::Point2f > keypoints
Definition: personTracker.hpp:12
op::PersonTrackerEntry::status
std::vector< char > status
Definition: personTracker.hpp:14
op::PersonTrackerEntry
Definition: personTracker.hpp:10
common.hpp
op::PersonTrackerEntry::getPredicted
std::vector< cv::Point2f > getPredicted() const
Definition: personTracker.hpp:15
op::Array< float >
op::PersonTracker
Definition: personTracker.hpp:29
OP_API
#define OP_API
Definition: macros.hpp:19
op::PersonTrackerEntry::lastKeypoints
std::vector< cv::Point2f > lastKeypoints
Definition: personTracker.hpp:13