ViSP  2.9.0
tutorial-matching-surf.cpp
1 
2 #include <visp/vpKeyPointSurf.h>
3 #include <visp/vpDisplayOpenCV.h>
4 #include <visp/vpVideoReader.h>
5 
6 int main()
7 {
8 #if defined(VISP_HAVE_OPENCV_NONFREE) && defined(VISP_HAVE_FFMPEG)
10 
11  vpVideoReader reader;
12  reader.setFileName("video-postcard.mpeg");
13  reader.acquire(I);
14 
15  vpKeyPointSurf surf;
16  surf.buildReference(I);
17 
19  Idisp.resize(I.getHeight(), 2*I.getWidth());
20  Idisp.insert(I, vpImagePoint(0, 0));
21  Idisp.insert(I, vpImagePoint(0, I.getWidth()));
22 
23  vpDisplayOpenCV d(Idisp, 0, 0, "Matching surf keypoints") ;
24  vpDisplay::display(Idisp);
25  vpDisplay::flush(Idisp);
26 
27  while ( ! reader.end() )
28  {
29  reader.acquire(I);
30  Idisp.insert(I, vpImagePoint(0, I.getWidth()));
31 
32  vpDisplay::display(Idisp);
34 
35  int nbMatch = surf.matchPoint(I);
36 
37  vpImagePoint iPref, iPcur;
38  for (int i = 0; i < nbMatch; i++)
39  {
40  surf.getMatchedPoints(i, iPref, iPcur);
41  vpDisplay::displayLine(Idisp, iPref, iPcur + vpImagePoint(0, I.getWidth()), vpColor::green);
42  }
43  vpDisplay::flush(Idisp);
44 
45  if (vpDisplay::getClick(Idisp, false))
46  break;
47  }
48 
49  vpDisplay::getClick(Idisp);
50 #endif
51 
52  return 0;
53 }
unsigned int getWidth() const
Definition: vpImage.h:159
Class that enables to manipulate easily a video file or a sequence of images. As it inherits from the...
unsigned int matchPoint(const vpImage< unsigned char > &I)
void getMatchedPoints(const unsigned int index, vpImagePoint &referencePoint, vpImagePoint &currentPoint)
static const vpColor green
Definition: vpColor.h:170
static void flush(const vpImage< unsigned char > &I)
Definition: vpDisplay.cpp:1994
Class that implements the SURF key points and technics thanks to the OpenCV library.
static void display(const vpImage< unsigned char > &I)
Definition: vpDisplay.cpp:206
The vpDisplayOpenCV allows to display image using the opencv library.
void acquire(vpImage< vpRGBa > &I)
void resize(const unsigned int h, const unsigned int w)
set the size of the image
Definition: vpImage.h:532
void setFileName(const char *filename)
unsigned int buildReference(const vpImage< unsigned char > &I)
void insert(const vpImage< Type > &src, const vpImagePoint topLeft)
Definition: vpImage.h:816
unsigned int getHeight() const
Definition: vpImage.h:150
virtual bool getClick(bool blocking=true)=0
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
Definition: vpImagePoint.h:92
virtual void displayLine(const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness=1)=0
static const vpColor white
Definition: vpColor.h:162