31#ifndef __BTK_FEATUREDMARKER_H__
32#define __BTK_FEATUREDMARKER_H__
36#include "opencv2/features2d/features2d.hpp"
37#include "cameraparameters.h"
40#include <boost/thread.hpp>
64 int ratioTest(std::vector<std::vector<cv::DMatch> > &matches);
67 void symmetryTest(
const std::vector<std::vector<cv::DMatch> >& matches1,
const std::vector<std::vector<cv::DMatch> >& matches2, std::vector<cv::DMatch>& symMatches);
70 void robustMatch(
const cv::Mat& frame, std::vector<cv::DMatch>& good_matches, std::vector<cv::KeyPoint>& keypoints_frame,
const cv::Mat& descriptors_model,
const cv::Mat& mask);
73 void fastRobustMatch(
const cv::Mat& frame, std::vector<cv::DMatch>& good_matches, std::vector<cv::KeyPoint>& keypoints_frame,
const cv::Mat& mask);
75 bool addTrainData(
const cv::Mat& frame, std::vector<cv::KeyPoint> &marker_keypoints);
79 cv::Ptr<cv::FeatureDetector> traindetector_;
81 cv::Ptr<cv::FeatureDetector> detector_;
83 cv::Ptr<cv::DescriptorMatcher> matcher_;
118 ArFeaturedMarker(std::string filePath,
unsigned int nid,
float size,
unsigned int maxFeatures = 600);
122 ArFeaturedMarker(cv::Mat tpl,
unsigned int nid,
float size,
unsigned int maxFeatures = 600);
146 bool detectFeatured(cv::Mat &frame, cv::Mat &color, cv::Size camsize);
148 void Update(cv::Mat frame, cv::Mat color, aruco::CameraParameters& camparam,
bool reverse);
150 boost::mutex m_mutex;
152 unsigned int m_maxFeatures;
155 unsigned int m_minMatches;
156 double m_HomographyThreshold;
158 std::vector<cv::Point2f> m_prevTrainPoints;
159 std::vector<cv::Point2f> m_pcorners;
160 cv::Size m_lastFrameSize;
162 cv::Ptr<cv::FeatureDetector> m_detector;
163 cv::Ptr<cv::DescriptorMatcher> m_matcher;
166 std::vector<cv::KeyPoint> m_trainKeypoints;
167 bool m_registerNextFrame;
179 bool initTrackingPicture();
183 void CommonConstructor();
188 bool GetPointsFromMatches(
const std::vector<cv::KeyPoint> &querykeypoints,
const std::vector<cv::KeyPoint> &trainKeypoints, std::vector<cv::DMatch> matches, std::vector<cv::Point2f> &trainPoints, std::vector<cv::Point2f> &framePoints);
192 bool GetHomography(std::vector<cv::Point2f> &trainPoints, std::vector<cv::Point2f> &framePoints, cv::Mat &HMatrix);
196 bool detectMotionFlow(cv::Mat &frame, cv::Mat &color,
const std::vector<cv::Point2f> &trainPoints,
const std::vector<cv::Point2f> &framePoints, std::vector<cv::Point2f> >rainPoints, std::vector<cv::Point2f> &gframePoints);
This class represents a marker. It is a vector of the fours corners ot the marker.
std::vector< cv::Point2f > m_lastCorner
void Update(cv::Mat frame, cv::Mat color, aruco::CameraParameters &camparam, bool reverse)
void calculateFeaturedExtrinsics(float markerSize, aruco::CameraParameters &camParams, bool setYPerpendicular=true)
void RegisterNextFrame(cv::Point point, cv::Size size)
virtual ~ArFeaturedMarker()
bool detectFeatured(cv::Mat &frame, cv::Mat &color, cv::Size camsize)
bool GetWarpedMarker(cv::Mat &image)
void SetTrackedImage(cv::Mat tpl)
std::vector< cv::Mat > m_prevPyr
std::vector< cv::Point2f > m_prevFramePoints
std::vector< cv::Mat > m_nextPyr
std::vector< cv::Point2f > GetCorners()
void setDescriptorMatcher(const cv::Ptr< cv::DescriptorMatcher > &match)
void setFeatureDetector(const cv::Ptr< cv::FeatureDetector > &detect)
bool addTrainData(const cv::Mat &frame, std::vector< cv::KeyPoint > &marker_keypoints)
void fastRobustMatch(const cv::Mat &frame, std::vector< cv::DMatch > &good_matches, std::vector< cv::KeyPoint > &keypoints_frame, const cv::Mat &mask)
int ratioTest(std::vector< std::vector< cv::DMatch > > &matches)
void setTrainFeatureDetector(const cv::Ptr< cv::FeatureDetector > &detect)
void robustMatch(const cv::Mat &frame, std::vector< cv::DMatch > &good_matches, std::vector< cv::KeyPoint > &keypoints_frame, const cv::Mat &descriptors_model, const cv::Mat &mask)
void symmetryTest(const std::vector< std::vector< cv::DMatch > > &matches1, const std::vector< std::vector< cv::DMatch > > &matches2, std::vector< cv::DMatch > &symMatches)