1 #include <visp3/core/vpPixelMeterConversion.h>
3 #include <visp3/gui/vpDisplayOpenCV.h>
4 #include <visp3/io/vpVideoReader.h>
5 #include <visp3/vision/vpHomography.h>
6 #include <visp3/vision/vpKeyPoint.h>
8 int main(
int argc,
const char **argv)
10 #if (VISP_HAVE_OPENCV_VERSION >= 0x020101)
15 method = atoi(argv[1]);
18 std::cout <<
"Uses Ransac to estimate the homography" << std::endl;
20 std::cout <<
"Uses a robust scheme to estimate the homography" << std::endl;
29 const std::string detectorName =
"ORB";
30 const std::string extractorName =
"ORB";
32 const std::string matcherName =
"BruteForce-Hamming";
34 vpKeyPoint keypoint(detectorName, extractorName, matcherName, filterType);
35 keypoint.buildReference(I);
48 corner_ref[0].
set_ij(115, 64);
49 corner_ref[1].
set_ij(83, 253);
50 corner_ref[2].
set_ij(282, 307);
51 corner_ref[3].
set_ij(330, 72);
54 for (
unsigned int i = 0; i < 4; i++) {
66 while (!reader.
end()) {
74 unsigned int nbMatch = keypoint.matchPoint(I);
75 std::cout <<
"Nb matches: " << nbMatch << std::endl;
78 std::vector<vpImagePoint> iPref(nbMatch),
81 std::vector<double> mPref_x(nbMatch), mPref_y(nbMatch);
82 std::vector<double> mPcur_x(nbMatch), mPcur_y(nbMatch);
83 std::vector<bool> inliers(nbMatch);
86 for (
unsigned int i = 0; i < nbMatch; i++) {
87 keypoint.getMatchedPoints(i, iPref[i], iPcur[i]);
99 (
unsigned int)(mPref_x.size() * 0.25), 2.0 / cam.
get_px(),
true);
101 vpHomography::robust(mPref_x, mPref_y, mPcur_x, mPcur_y, curHref, inliers, residual, 0.4, 4,
true);
103 std::cout <<
"Cannot compute homography from matches..." << std::endl;
110 for (
int i = 0; i < 4; i++) {
117 for (
int i = 0; i < 4; i++) {
123 for (
unsigned int i = 0; i < nbMatch; i++) {
124 if (inliers[i] ==
true)