2#include <visp3/core/vpConfig.h>
3#include <visp3/core/vpPixelMeterConversion.h>
4#include <visp3/gui/vpDisplayOpenCV.h>
5#include <visp3/io/vpVideoReader.h>
6#include <visp3/vision/vpHomography.h>
7#include <visp3/vision/vpKeyPoint.h>
9int main(
int argc,
const char **argv)
11#if defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_HIGHGUI) && defined(HAVE_OPENCV_IMGPROC) && \
12 (((VISP_HAVE_OPENCV_VERSION < 0x050000) && defined(HAVE_OPENCV_CALIB3D) && defined(HAVE_OPENCV_FEATURES2D)) || \
13 ((VISP_HAVE_OPENCV_VERSION >= 0x050000) && defined(HAVE_OPENCV_3D) && defined(HAVE_OPENCV_FEATURES)))
15#ifdef ENABLE_VISP_NAMESPACE
22 method = atoi(argv[1]);
25 std::cout <<
"Uses Ransac to estimate the homography" << std::endl;
27 std::cout <<
"Uses a robust scheme to estimate the homography" << std::endl;
36 const std::string detectorName =
"ORB";
37 const std::string extractorName =
"ORB";
39 const std::string matcherName =
"BruteForce-Hamming";
41 vpKeyPoint keypoint(detectorName, extractorName, matcherName, filterType);
42 keypoint.buildReference(I);
45 Idisp.resize(I.getHeight(), 2 * I.getWidth());
55 corner_ref[0].
set_ij(115, 64);
56 corner_ref[1].
set_ij(83, 253);
57 corner_ref[2].
set_ij(282, 307);
58 corner_ref[3].
set_ij(330, 72);
61 for (
unsigned int i = 0;
i < 4;
i++) {
73 while (!reader.
end()) {
81 unsigned int nbMatch = keypoint.matchPoint(I);
82 std::cout <<
"Nb matches: " << nbMatch << std::endl;
85 std::vector<vpImagePoint> iPref(nbMatch), iPcur(nbMatch);
87 std::vector<double> mPref_x(nbMatch), mPref_y(nbMatch);
88 std::vector<double> mPcur_x(nbMatch), mPcur_y(nbMatch);
89 std::vector<bool> inliers(nbMatch);
92 for (
unsigned int i = 0;
i < nbMatch;
i++) {
93 keypoint.getMatchedPoints(i, iPref[i], iPcur[i]);
105 static_cast<unsigned int>(mPref_x.size() * 0.25), 2.0 /
cam.get_px(),
true);
108 vpHomography::robust(mPref_x, mPref_y, mPcur_x, mPcur_y, curHref, inliers, residual, 0.4, 4,
true);
112 std::cout <<
"Cannot compute homography from matches..." << std::endl;
119 for (
int i = 0;
i < 4;
i++) {
126 for (
int i = 0;
i < 4;
i++) {
132 for (
unsigned int i = 0;
i < nbMatch;
i++) {
133 if (inliers[i] ==
true)
Generic class defining intrinsic camera parameters.
static const vpColor white
static const vpColor blue
static const vpColor green
The vpDisplayOpenCV allows to display image using the OpenCV library. Thus to enable this class OpenC...
static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
static void display(const vpImage< unsigned char > &I)
static void displayLine(const vpImage< unsigned char > &I, const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness=1, bool segment=true)
static void displayCross(const vpImage< unsigned char > &I, const vpImagePoint &ip, unsigned int size, const vpColor &color, unsigned int thickness=1)
static void flush(const vpImage< unsigned char > &I)
Implementation of an homography and operations on homographies.
static vpImagePoint project(const vpCameraParameters &cam, const vpHomography &bHa, const vpImagePoint &iPa)
static void robust(const std::vector< double > &xb, const std::vector< double > &yb, const std::vector< double > &xa, const std::vector< double > &ya, vpHomography &aHb, std::vector< bool > &inliers, double &residual, double weights_threshold=0.4, unsigned int niter=4, bool normalization=true)
static bool ransac(const std::vector< double > &xb, const std::vector< double > &yb, const std::vector< double > &xa, const std::vector< double > &ya, vpHomography &aHb, std::vector< bool > &inliers, double &residual, unsigned int nbInliersConsensus, double threshold, bool normalization=true)
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
void set_ij(double ii, double jj)
Definition of the vpImage class member functions.
Class that allows keypoints 2D features detection (and descriptors extraction) and matching thanks to...
static void convertPoint(const vpCameraParameters &cam, const double &u, const double &v, double &x, double &y)
Class that enables to manipulate easily a video file or a sequence of images. As it inherits from the...
void setFileName(const std::string &filename)
void acquire(vpImage< vpRGBa > &I) VP_OVERRIDE