All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
personTracker.hpp
Go to the documentation of this file.
#ifndef OPENPOSE_TRACKING_PERSON_TRACKER_HPP
#define OPENPOSE_TRACKING_PERSON_TRACKER_HPP
#include <atomic>
#include <unordered_map>
#include <openpose/core/common.hpp>
namespace op
{
struct PersonTrackerEntry
{
std::vector<cv::Point2f> keypoints;
std::vector<cv::Point2f> lastKeypoints;
std::vector<char> status;
std::vector<cv::Point2f> getPredicted() const
{
std::vector<cv::Point2f> predictedKeypoints(keypoints);
if (!lastKeypoints.size())
return predictedKeypoints;
for (size_t i=0; i<keypoints.size(); i++)
{
predictedKeypoints[i] = cv::Point2f{predictedKeypoints[i].x + (keypoints[i].x-lastKeypoints[i].x),
predictedKeypoints[i].y + (keypoints[i].y-lastKeypoints[i].y)};
}
return predictedKeypoints;
}
};
class OP_API PersonTracker
{
public:
PersonTracker(const bool mergeResults, const int levels = 3, const int patchSize = 31,
const float confidenceThreshold = 0.05f, const bool trackVelocity = false,
const bool scaleVarying = false, const float rescale = 640);
virtual ~PersonTracker();
void track(Array<float>& poseKeypoints, Array<long long>& poseIds, const cv::Mat& cvMatInput);
void trackLockThread(Array<float>& poseKeypoints, Array<long long>& poseIds, const cv::Mat& cvMatInput,
const long long frameId);
bool getMergeResults() const;
private:
const bool mMergeResults;
const int mLevels;
const int mPatchSize;
const bool mTrackVelocity;
const float mConfidenceThreshold;
const bool mScaleVarying;
const float mRescale;
cv::Mat mImagePrevious;
std::vector<cv::Mat> mPyramidImagesPrevious;
std::unordered_map<int, PersonTrackerEntry> mPersonEntries;
Array<long long> mLastPoseIds;
// Thread-safe variables
std::atomic<long long> mLastFrameId;
DELETE_COPY(PersonTracker);
};
}
#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