JeVoisBase  1.22
JeVois Smart Embedded Machine Vision Toolkit Base Modules
Share this page:
Loading...
Searching...
No Matches
ObjectMatcher Class Reference

Object matching using OpenCV keypoint detection and matching. More...

#include <jevoisbase/Components/ObjectMatcher/ObjectMatcher.H>

Inheritance diagram for ObjectMatcher:
Collaboration diagram for ObjectMatcher:

Classes

struct  TrainData
 Training data structure for ObjectMatcher. More...
 

Public Member Functions

 ~ObjectMatcher ()
 Destructor.
 
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 object.
 
double process (cv::Mat const &img, size_t &trainidx)
 Process a greyscale image, returns match score, object index.
 
void postInit () override
 Load training images and compute keypoints and descriptors.
 
size_t numtrain () const
 Get number of training images.
 
void detect (cv::Mat const &img, std::vector< cv::KeyPoint > &keypoints)
 Detect keypoints.
 
void compute (cv::Mat const &img, std::vector< cv::KeyPoint > &keypoints, cv::Mat &descriptors)
 Compute descriptors for given keypoints.
 
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.
 
double match (std::vector< cv::KeyPoint > const &keypoints, cv::Mat const &descriptors, size_t &trainidx)
 Match given descriptors against those of our training images, return best match distance.
 
TrainData const & traindata (size_t idx) const
 Get the training data for a given index.
 
- Public Member Functions inherited from jevois::Component
 Component (std::string const &instance)
 
virtual ~Component ()
 
std::shared_ptr< Comp > addSubComponent (std::string const &instance, Args &&...args)
 
void removeSubComponent (std::shared_ptr< Comp > &component)
 
void removeSubComponent (std::string const &instance, bool warnIfNotFound=true)
 
std::shared_ptr< Comp > getSubComponent (std::string const &instance) const
 
bool isTopLevel () const
 
bool initialized () const
 
std::string const & className () const
 
std::string const & instanceName () const
 
std::vector< std::string > setParamVal (std::string const &paramdescriptor, T const &val)
 
void setParamValUnique (std::string const &paramdescriptor, T const &val)
 
std::vector< std::pair< std::string, T > > getParamVal (std::string const &paramdescriptor) const
 
getParamValUnique (std::string const &paramdescriptor) const
 
std::vector< std::string > setParamString (std::string const &paramdescriptor, std::string const &val)
 
void setParamStringUnique (std::string const &paramdescriptor, std::string const &val)
 
std::vector< std::pair< std::string, std::string > > getParamString (std::string const &paramdescriptor) const
 
std::string getParamStringUnique (std::string const &paramdescriptor) const
 
void freezeParam (std::string const &paramdescriptor, bool doit)
 
void freezeAllParams (bool doit)
 
std::string descriptor () const
 
void setParamsFromFile (std::string const &filename)
 
std::istream & setParamsFromStream (std::istream &is, std::string const &absfile)
 
virtual void paramInfo (std::shared_ptr< UserInterface > s, std::map< std::string, std::string > &categs, bool skipFrozen, std::string const &cname="", std::string const &pfx="")
 
void foreachParam (std::function< void(std::string const &compname, ParameterBase *p)> func, std::string const &cname="")
 
std::shared_ptr< DynamicParameter< T > > addDynamicParameter (std::string const &name, std::string const &description, T const &defaultValue, ParameterCategory const &category)
 
std::shared_ptr< DynamicParameter< T > > addDynamicParameter (std::string const &name, std::string const &description, T const &defaultValue, ValidValuesSpec< T > const &validValuesSpec, ParameterCategory const &category)
 
void setDynamicParameterCallback (std::string const &name, std::function< void(T const &)> cb, bool callnow=true)
 
void removeDynamicParameter (std::string const &name, bool throw_if_not_found=true)
 
void setPath (std::string const &path)
 
std::filesystem::path absolutePath (std::filesystem::path const &path="")
 
std::shared_ptr< Comp > addSubComponent (std::string const &instance, Args &&...args)
 
void removeSubComponent (std::shared_ptr< Comp > &component)
 
void removeSubComponent (std::string const &instance, bool warnIfNotFound=true)
 
std::shared_ptr< Comp > getSubComponent (std::string const &instance) const
 
bool isTopLevel () const
 
bool initialized () const
 
std::string const & className () const
 
std::string const & instanceName () const
 
std::vector< std::string > setParamVal (std::string const &paramdescriptor, T const &val)
 
void setParamValUnique (std::string const &paramdescriptor, T const &val)
 
std::vector< std::pair< std::string, T > > getParamVal (std::string const &paramdescriptor) const
 
getParamValUnique (std::string const &paramdescriptor) const
 
std::vector< std::string > setParamString (std::string const &paramdescriptor, std::string const &val)
 
void setParamStringUnique (std::string const &paramdescriptor, std::string const &val)
 
std::vector< std::pair< std::string, std::string > > getParamString (std::string const &paramdescriptor) const
 
std::string getParamStringUnique (std::string const &paramdescriptor) const
 
void freezeParam (std::string const &paramdescriptor, bool doit)
 
void freezeAllParams (bool doit)
 
std::string descriptor () const
 
void setParamsFromFile (std::string const &filename)
 
std::istream & setParamsFromStream (std::istream &is, std::string const &absfile)
 
virtual void paramInfo (std::shared_ptr< UserInterface > s, std::map< std::string, std::string > &categs, bool skipFrozen, std::string const &cname="", std::string const &pfx="")
 
void foreachParam (std::function< void(std::string const &compname, ParameterBase *p)> func, std::string const &cname="")
 
std::shared_ptr< DynamicParameter< T > > addDynamicParameter (std::string const &name, std::string const &description, T const &defaultValue, ParameterCategory const &category)
 
std::shared_ptr< DynamicParameter< T > > addDynamicParameter (std::string const &name, std::string const &description, T const &defaultValue, ValidValuesSpec< T > const &validValuesSpec, ParameterCategory const &category)
 
void setDynamicParameterCallback (std::string const &name, std::function< void(T const &)> cb, bool callnow=true)
 
void removeDynamicParameter (std::string const &name, bool throw_if_not_found=true)
 
void setPath (std::string const &path)
 
std::filesystem::path absolutePath (std::filesystem::path const &path="")
 
- Public Member Functions inherited from jevois::ParameterRegistry
virtual ~ParameterRegistry ()
 

Related Symbols

(Note that these are not member symbols.)

 JEVOIS_DECLARE_PARAMETER (hessian, double, "Hessian threshold", 800.0, ParamCateg)
 Parameter.
 
 JEVOIS_DECLARE_PARAMETER (traindir, std::string, "Directory where training images are", "images", ParamCateg)
 Parameter.
 
 JEVOIS_DECLARE_PARAMETER (goodpts, jevois::Range< size_t >, "Number range of good matches considered", jevois::Range< size_t >(15, 100), ParamCateg)
 Parameter.
 
 JEVOIS_DECLARE_PARAMETER (distthresh, double, "Maximum distance for a match to be considered good", 0.2, ParamCateg)
 Parameter.
 

Additional Inherited Members

- Protected Member Functions inherited from jevois::Component
virtual void preInit ()
 
virtual void preUninit ()
 
virtual void postUninit ()
 
virtual void preInit ()
 
virtual void preUninit ()
 
virtual void postUninit ()
 
- Protected Member Functions inherited from jevois::ParameterRegistry
void addParameter (ParameterBase *const param)
 
void removeParameter (ParameterBase *const param)
 
void callbackInitCall ()
 

Detailed Description

Object matching using OpenCV keypoint detection and matching.

See tutorial at http://docs.opencv.org/3.0-beta/doc/py_tutorials/py_feature2d/py_surf_intro/py_surf_intro.html

Definition at line 46 of file ObjectMatcher.H.

Constructor & Destructor Documentation

◆ ~ObjectMatcher()

ObjectMatcher::~ObjectMatcher ( )

Destructor.

Definition at line 35 of file ObjectMatcher.C.

Member Function Documentation

◆ compute()

void ObjectMatcher::compute ( cv::Mat const &  img,
std::vector< cv::KeyPoint > &  keypoints,
cv::Mat &  descriptors 
)

Compute descriptors for given keypoints.

Note
keypoints is an input argument but opencv wants a non-const ref to it for some reason.

Definition at line 117 of file ObjectMatcher.C.

Referenced by process(), and process().

◆ detect()

void ObjectMatcher::detect ( cv::Mat const &  img,
std::vector< cv::KeyPoint > &  keypoints 
)

◆ match() [1/2]

double ObjectMatcher::match ( std::vector< cv::KeyPoint > const &  keypoints,
cv::Mat const &  descriptors,
size_t &  trainidx 
)

Match given descriptors against those of our training images, return best match distance.

Definition at line 164 of file ObjectMatcher.C.

References jevois::async(), and LFATAL.

◆ match() [2/2]

double ObjectMatcher::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.

Definition at line 123 of file ObjectMatcher.C.

References jevois::async(), and LFATAL.

Referenced by process(), and process().

◆ numtrain()

size_t ObjectMatcher::numtrain ( ) const

Get number of training images.

Definition at line 304 of file ObjectMatcher.C.

◆ postInit()

void ObjectMatcher::postInit ( )
overridevirtual

◆ process() [1/2]

double ObjectMatcher::process ( cv::Mat const &  img,
size_t &  trainidx 
)

Process a greyscale image, returns match score, object index.

If return value is 1.0e30, then no good object match was found. This runs detect(), then compute() and then match(). One may also want to run those separately in some cases.

Definition at line 99 of file ObjectMatcher.C.

References compute(), detect(), and match().

◆ process() [2/2]

double ObjectMatcher::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 object.

If return value is 1.0e30, then no good object match was found. This runs detect(), then compute() and then match(). One may also want to run those separately in some cases.

Definition at line 87 of file ObjectMatcher.C.

References compute(), detect(), and match().

◆ traindata()

ObjectMatcher::TrainData const & ObjectMatcher::traindata ( size_t  idx) const

Get the training data for a given index.

Definition at line 297 of file ObjectMatcher.C.

References LFATAL.

Friends And Related Symbol Documentation

◆ JEVOIS_DECLARE_PARAMETER() [1/4]

JEVOIS_DECLARE_PARAMETER ( distthresh  ,
double  ,
"Maximum distance for a match to be considered good"  ,
0.  2,
ParamCateg   
)
related

Parameter.

◆ JEVOIS_DECLARE_PARAMETER() [2/4]

JEVOIS_DECLARE_PARAMETER ( goodpts  ,
jevois::Range< size_t >  ,
"Number range of good matches considered"  ,
jevois::Range< size_t >  15, 100,
ParamCateg   
)
related

Parameter.

◆ JEVOIS_DECLARE_PARAMETER() [3/4]

JEVOIS_DECLARE_PARAMETER ( hessian  ,
double  ,
"Hessian threshold"  ,
800.  0,
ParamCateg   
)
related

Parameter.

◆ JEVOIS_DECLARE_PARAMETER() [4/4]

JEVOIS_DECLARE_PARAMETER ( traindir  ,
std::string  ,
"Directory where training images are"  ,
"images"  ,
ParamCateg   
)
related

Parameter.


The documentation for this class was generated from the following files: