Visual Servoing Platform  version 3.0.1
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
tutorial-matching-keypoint.cpp
1 #include <visp3/gui/vpDisplayOpenCV.h>
3 #include <visp3/io/vpVideoReader.h>
4 #include <visp3/io/vpImageIo.h>
6 #include <visp3/vision/vpKeyPoint.h>
8 
9 int main() {
11 #if (VISP_HAVE_OPENCV_VERSION >= 0x020101)
14 
15  vpVideoReader reader;
16  reader.setFileName("video-postcard.mpeg");
17  reader.acquire(I);
18 
20  const std::string detectorName = "ORB";
21  const std::string extractorName = "ORB";
22  //Hamming distance must be used with ORB
23  const std::string matcherName = "BruteForce-Hamming";
25  vpKeyPoint keypoint(detectorName, extractorName, matcherName, filterType);
26  std::cout << "Reference keypoints=" << keypoint.buildReference(I) << std::endl;
28 
31  Idisp.resize(I.getHeight(), 2*I.getWidth());
32  Idisp.insert(I, vpImagePoint(0, 0));
33  Idisp.insert(I, vpImagePoint(0, I.getWidth()));
36  vpDisplayOpenCV d(Idisp, 0, 0, "Matching keypoints with ORB keypoints") ;
37  vpDisplay::display(Idisp);
38  vpDisplay::flush(Idisp);
40 
41  while ( ! reader.end() )
42  {
44  reader.acquire(I);
45  Idisp.insert(I, vpImagePoint(0, I.getWidth()));
47 
49  vpDisplay::display(Idisp);
52 
54  unsigned int nbMatch = keypoint.matchPoint(I);
56 
57  std::cout << "Matches=" << nbMatch << std::endl;
58 
60  vpImagePoint iPref, iPcur;
61  for (unsigned int i = 0; i < nbMatch; i++)
62  {
63  keypoint.getMatchedPoints(i, iPref, iPcur);
66  vpDisplay::displayLine(Idisp, iPref, iPcur + vpImagePoint(0, I.getWidth()), vpColor::green);
68  }
70  vpDisplay::flush(Idisp);
72 
73  if (vpDisplay::getClick(Idisp, false))
74  break;
75  }
76 
77  vpDisplay::getClick(Idisp);
78 #endif
79 
80  return 0;
81 }
static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
unsigned int getWidth() const
Definition: vpImage.h:226
Class that enables to manipulate easily a video file or a sequence of images. As it inherits from the...
static const vpColor green
Definition: vpColor.h:166
static void flush(const vpImage< unsigned char > &I)
static void display(const vpImage< unsigned char > &I)
The vpDisplayOpenCV allows to display image using the OpenCV library. Thus to enable this class OpenC...
void acquire(vpImage< vpRGBa > &I)
void resize(const unsigned int h, const unsigned int w)
resize the image : Image initialization
Definition: vpImage.h:903
void setFileName(const char *filename)
Class that allows keypoints detection (and descriptors extraction) and matching thanks to OpenCV libr...
Definition: vpKeyPoint.h:217
void insert(const vpImage< Type > &src, const vpImagePoint topLeft)
Definition: vpImage.h:1226
vpFilterMatchingType
Definition: vpKeyPoint.h:222
unsigned int getHeight() const
Definition: vpImage.h:175
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
Definition: vpImagePoint.h:88
static void displayLine(const vpImage< unsigned char > &I, const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness=1)
static const vpColor white
Definition: vpColor.h:158