Visual Servoing Platform
version 3.7.0
Toggle main menu visibility
Loading...
Searching...
No Matches
tutorial-matching-keypoint-SIFT.cpp
1
2
#include <visp3/core/vpConfig.h>
3
#include <visp3/gui/vpDisplayOpenCV.h>
4
#include <visp3/io/vpImageIo.h>
5
#include <visp3/io/vpVideoReader.h>
7
#include <visp3/vision/vpKeyPoint.h>
9
10
int
main()
11
{
13
#if defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_HIGHGUI) && defined(HAVE_OPENCV_IMGPROC) && \
14
(((VISP_HAVE_OPENCV_VERSION < 0x050000) && defined(HAVE_OPENCV_CALIB3D) && defined(HAVE_OPENCV_FEATURES2D) && defined(HAVE_OPENCV_XFEATURES2D)) || \
15
((VISP_HAVE_OPENCV_VERSION >= 0x050000) && defined(HAVE_OPENCV_3D) && defined(HAVE_OPENCV_FEATURES)))
16
18
#ifdef ENABLE_VISP_NAMESPACE
19
using namespace
VISP_NAMESPACE_NAME
;
20
#endif
21
vpImage<unsigned char>
I;
22
23
vpVideoReader
reader;
24
reader.
setFileName
(
"video-postcard.mp4"
);
25
reader.
acquire
(I);
26
28
const
std::string detectorName =
"SIFT"
;
29
const
std::string extractorName =
"SIFT"
;
30
// Use L2 distance with a matching done using FLANN (Fast Library for
31
// Approximate Nearest Neighbors)
32
const
std::string matcherName =
"FlannBased"
;
33
vpKeyPoint::vpFilterMatchingType
filterType =
vpKeyPoint::ratioDistanceThreshold
;
34
vpKeyPoint
keypoint(detectorName, extractorName, matcherName, filterType);
36
38
std::cout <<
"Reference keypoints="
<< keypoint.buildReference(I) << std::endl;
40
42
vpImage<unsigned char>
Idisp
;
43
Idisp
.resize(I.getHeight(), 2 * I.getWidth());
44
Idisp
.insert(I,
vpImagePoint
(0, 0));
45
Idisp
.insert(I,
vpImagePoint
(0, I.getWidth()));
48
vpDisplayOpenCV
d
(Idisp, 0, 0,
"Matching keypoints with SIFT keypoints"
);
49
vpDisplay::display
(Idisp);
50
vpDisplay::flush
(Idisp);
52
53
while
(!reader.
end
()) {
55
reader.
acquire
(I);
56
Idisp
.insert(I,
vpImagePoint
(0, I.getWidth()));
58
60
vpDisplay::display
(Idisp);
61
vpDisplay::displayLine
(Idisp,
vpImagePoint
(0, I.getWidth()),
vpImagePoint
(I.getHeight(), I.getWidth()),
62
vpColor::white
, 2);
64
65
vpChrono
chrono;
66
chrono.
start
();
68
unsigned
int
nbMatch = keypoint.matchPoint(I);
70
chrono.
stop
();
71
std::ostringstream oss;
72
oss <<
"Computation time: "
<< chrono.
getDurationMs
() <<
" ms"
;
73
vpDisplay::displayText
(Idisp,
vpImagePoint
(20, 20), oss.str(),
vpColor::red
);
74
75
std::cout <<
"Matches="
<< nbMatch << std::endl;
76
78
vpImagePoint
iPref, iPcur;
79
for
(
unsigned
int
i = 0;
i
< nbMatch;
i
++) {
80
keypoint.getMatchedPoints(i, iPref, iPcur);
83
vpDisplay::displayLine
(Idisp, iPref, iPcur +
vpImagePoint
(0, I.getWidth()),
vpColor::green
);
85
}
87
vpDisplay::flush
(Idisp);
89
90
if
(
vpDisplay::getClick
(Idisp,
false
))
91
break
;
92
}
93
94
vpDisplay::getClick
(Idisp);
95
#endif
96
97
return
EXIT_SUCCESS;
98
}
vpChrono
Definition
vpTime.h:90
vpChrono::start
void start(bool reset=true)
Definition
vpTime.cpp:411
vpChrono::stop
void stop()
Definition
vpTime.cpp:426
vpChrono::getDurationMs
double getDurationMs()
Definition
vpTime.cpp:400
vpColor::white
static const vpColor white
Definition
vpColor.h:193
vpColor::red
static const vpColor red
Definition
vpColor.h:198
vpColor::green
static const vpColor green
Definition
vpColor.h:201
vpDisplayOpenCV
The vpDisplayOpenCV allows to display image using the OpenCV library. Thus to enable this class OpenC...
Definition
vpDisplayOpenCV.h:139
vpDisplay::getClick
static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
Definition
vpDisplay_uchar.cpp:894
vpDisplay::display
static void display(const vpImage< unsigned char > &I)
Definition
vpDisplay_uchar.cpp:869
vpDisplay::displayLine
static void displayLine(const vpImage< unsigned char > &I, const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness=1, bool segment=true)
Definition
vpDisplay_uchar.cpp:458
vpDisplay::flush
static void flush(const vpImage< unsigned char > &I)
Definition
vpDisplay_uchar.cpp:845
vpDisplay::displayText
static void displayText(const vpImage< unsigned char > &I, const vpImagePoint &ip, const std::string &s, const vpColor &color)
Definition
vpDisplay_uchar.cpp:788
vpImagePoint
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
Definition
vpImagePoint.h:82
vpImage
Definition of the vpImage class member functions.
Definition
vpImage.h:131
vpKeyPoint
Class that allows keypoints 2D features detection (and descriptors extraction) and matching thanks to...
Definition
vpKeyPoint.h:274
vpKeyPoint::vpFilterMatchingType
vpFilterMatchingType
Definition
vpKeyPoint.h:278
vpKeyPoint::ratioDistanceThreshold
@ ratioDistanceThreshold
Definition
vpKeyPoint.h:283
vpVideoReader
Class that enables to manipulate easily a video file or a sequence of images. As it inherits from the...
Definition
vpVideoReader.h:181
vpVideoReader::setFileName
void setFileName(const std::string &filename)
Definition
vpVideoReader.cpp:123
vpVideoReader::end
bool end()
Definition
vpVideoReader.h:255
vpVideoReader::acquire
void acquire(vpImage< vpRGBa > &I) VP_OVERRIDE
Definition
vpVideoReader.cpp:286
VISP_NAMESPACE_NAME
Definition
vpEigenConversion.h:44
yolo-centering-task-afma6.d
d
Definition
yolo-centering-task-afma6.py:273
yolo-centering-task-afma6.Idisp
Idisp
Definition
yolo-centering-task-afma6.py:208
yolo-centering-task-afma6.i
i
Definition
yolo-centering-task-afma6.py:329
tutorial
detection
matching
tutorial-matching-keypoint-SIFT.cpp
Generated by
1.17.0