JeVoisBase
1.22
JeVois Smart Embedded Machine Vision Toolkit Base Modules
|
|
Object matching using OpenCV keypoint detection and matching. More...
#include <jevoisbase/Components/ObjectMatcher/ObjectMatcher.H>
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 ¶mdescriptor, T const &val) |
void | setParamValUnique (std::string const ¶mdescriptor, T const &val) |
std::vector< std::pair< std::string, T > > | getParamVal (std::string const ¶mdescriptor) const |
T | getParamValUnique (std::string const ¶mdescriptor) const |
std::vector< std::string > | setParamString (std::string const ¶mdescriptor, std::string const &val) |
void | setParamStringUnique (std::string const ¶mdescriptor, std::string const &val) |
std::vector< std::pair< std::string, std::string > > | getParamString (std::string const ¶mdescriptor) const |
std::string | getParamStringUnique (std::string const ¶mdescriptor) const |
void | freezeParam (std::string const ¶mdescriptor, 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 ¶mdescriptor, T const &val) |
void | setParamValUnique (std::string const ¶mdescriptor, T const &val) |
std::vector< std::pair< std::string, T > > | getParamVal (std::string const ¶mdescriptor) const |
T | getParamValUnique (std::string const ¶mdescriptor) const |
std::vector< std::string > | setParamString (std::string const ¶mdescriptor, std::string const &val) |
void | setParamStringUnique (std::string const ¶mdescriptor, std::string const &val) |
std::vector< std::pair< std::string, std::string > > | getParamString (std::string const ¶mdescriptor) const |
std::string | getParamStringUnique (std::string const ¶mdescriptor) const |
void | freezeParam (std::string const ¶mdescriptor, 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 () |
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.
ObjectMatcher::~ObjectMatcher | ( | ) |
Destructor.
Definition at line 35 of file ObjectMatcher.C.
void ObjectMatcher::compute | ( | cv::Mat const & | img, |
std::vector< cv::KeyPoint > & | keypoints, | ||
cv::Mat & | descriptors | ||
) |
Compute descriptors for given keypoints.
Definition at line 117 of file ObjectMatcher.C.
void ObjectMatcher::detect | ( | cv::Mat const & | img, |
std::vector< cv::KeyPoint > & | keypoints | ||
) |
Detect keypoints.
Definition at line 111 of file ObjectMatcher.C.
Referenced by process(), process(), FirstPython.FirstPython::process(), PythonObject6D.PythonObject6D::process(), FirstPython.FirstPython::processNoUSB(), and PythonObject6D.PythonObject6D::processNoUSB().
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.
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.
size_t ObjectMatcher::numtrain | ( | ) | const |
Get number of training images.
Definition at line 304 of file ObjectMatcher.C.
|
overridevirtual |
Load training images and compute keypoints and descriptors.
Reimplemented from jevois::Component.
Definition at line 39 of file ObjectMatcher.C.
References jevois::Component::absolutePath(), ObjectMatcher::TrainData::descriptors, ObjectMatcher::TrainData::image, ObjectMatcher::TrainData::keypoints, LDEBUG, LINFO, ObjectMatcher::TrainData::name, and PLFATAL.
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.
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.
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.
|
related |
Parameter.
|
related |
Parameter.
|
related |
Parameter.
|
related |
Parameter.