21#include <opencv2/core/core.hpp>
22#include <opencv2/features2d.hpp>
47 public jevois::Parameter<objectmatcher::hessian, objectmatcher::traindir,
48 objectmatcher::goodpts, objectmatcher::distthresh>
60 double process(cv::Mat
const & img,
size_t & trainidx, std::vector<cv::Point2f> & corners);
65 double process(cv::Mat
const & img,
size_t & trainidx);
74 void detect(cv::Mat
const & img, std::vector<cv::KeyPoint> & keypoints);
78 void compute(cv::Mat
const & img, std::vector<cv::KeyPoint> & keypoints, cv::Mat & descriptors);
81 double match(std::vector<cv::KeyPoint>
const & keypoints, cv::Mat
const & descriptors,
82 size_t & trainidx, std::vector<cv::Point2f> & corners);
85 double match(std::vector<cv::KeyPoint>
const & keypoints, cv::Mat
const & descriptors,
size_t & trainidx);
105 std::vector<cv::Point2f> corners;
108 MatchData matchcore(
size_t corenum, std::vector<cv::KeyPoint>
const & keypoints, cv::Mat
const & descriptors,
109 size_t minidx,
size_t maxidx,
bool do_corners);
111 cv::Ptr<cv::Feature2D> itsFeatureDetector;
112 std::vector<cv::Ptr<cv::DescriptorMatcher> > itsMatcher;
113 std::vector<TrainData> itsTrainData;
Object matching using OpenCV keypoint detection and matching.
size_t numtrain() const
Get number of training images.
double process(cv::Mat const &img, size_t &trainidx, std::vector< cv::Point2f > &corners)
Process a greyscale image, returns match score, object index, and bounding box corners for best match...
JEVOIS_DECLARE_PARAMETER(hessian, double, "Hessian threshold", 800.0, ParamCateg)
Parameter.
~ObjectMatcher()
Destructor.
TrainData const & traindata(size_t idx) const
Get the training data for a given index.
void postInit() override
Load training images and compute keypoints and descriptors.
JEVOIS_DECLARE_PARAMETER(goodpts, jevois::Range< size_t >, "Number range of good matches considered", jevois::Range< size_t >(15, 100), ParamCateg)
Parameter.
void compute(cv::Mat const &img, std::vector< cv::KeyPoint > &keypoints, cv::Mat &descriptors)
Compute descriptors for given keypoints.
JEVOIS_DECLARE_PARAMETER(distthresh, double, "Maximum distance for a match to be considered good", 0.2, ParamCateg)
Parameter.
double match(std::vector< cv::KeyPoint > const &keypoints, cv::Mat const &descriptors, size_t &trainidx, std::vector< cv::Point2f > &corners)
Match given descriptors against those of our training images, return best match distance.
JEVOIS_DECLARE_PARAMETER(traindir, std::string, "Directory where training images are", "images", ParamCateg)
Parameter.
void detect(cv::Mat const &img, std::vector< cv::KeyPoint > &keypoints)
Detect keypoints.
friend friend class Component
Training data structure for ObjectMatcher.
std::vector< cv::KeyPoint > keypoints