 |
Visual Servoing Platform
version 3.3.0
|
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/vpKeyPointSurf.h>
8 int main(
int argc,
const char **argv)
10 #if defined(VISP_HAVE_OPENCV_NONFREE) && (VISP_HAVE_OPENCV_VERSION < 0x030000)
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;
30 surf.buildReference(I);
37 vpDisplayOpenCV d(Idisp, 0, 0,
"Homography from matched Surf keypoints");
43 corner_ref[0].
set_ij(115, 64);
44 corner_ref[1].
set_ij(83, 253);
45 corner_ref[2].
set_ij(282, 307);
46 corner_ref[3].
set_ij(330, 72);
49 for (
unsigned int i = 0; i < 4; i++) {
60 while (!reader.
end()) {
68 unsigned int nbMatch = surf.matchPoint(I);
71 std::vector<vpImagePoint> iPref(nbMatch),
74 std::vector<double> mPref_x(nbMatch), mPref_y(nbMatch);
75 std::vector<double> mPcur_x(nbMatch), mPcur_y(nbMatch);
76 std::vector<bool> inliers(nbMatch);
79 for (
unsigned int i = 0; i < nbMatch; i++) {
81 surf.getMatchedPoints(i, matched_ref, matched_cur);
88 iPref[i] = matched_ref;
89 iPcur[i] = matched_cur;
96 (
unsigned int)mPref_x.size() / 2, 2.0 / cam.
get_px(),
true);
98 vpHomography::robust(mPref_x, mPref_y, mPcur_x, mPcur_y, curHref, inliers, residual, 0.4, 4,
true);
103 for (
int i = 0; i < 4; i++) {
110 for (
int i = 0; i < 4; i++) {
116 for (
unsigned int i = 0; i < nbMatch; i++) {
117 if (inliers[i] ==
true)
static const vpColor white
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)
void insert(const vpImage< Type > &src, const vpImagePoint &topLeft)
static void displayLine(const vpImage< unsigned char > &I, const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness=1, bool segment=true)
Generic class defining intrinsic camera parameters.
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 > &inlier, double &residual, double weights_threshold=0.4, unsigned int niter=4, bool normalization=true)
void set_ij(double ii, double jj)
static const vpColor blue
unsigned int getHeight() const
The vpDisplayOpenCV allows to display image using the OpenCV library. Thus to enable this class OpenC...
unsigned int getWidth() const
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)
static void display(const vpImage< unsigned char > &I)
static vpImagePoint project(const vpCameraParameters &cam, const vpHomography &bHa, const vpImagePoint &iPa)
static void convertPoint(const vpCameraParameters &cam, const double &u, const double &v, double &x, double &y)
Implementation of an homography and operations on homographies.
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
static const vpColor green
static void flush(const vpImage< unsigned char > &I)
static void displayCross(const vpImage< unsigned char > &I, const vpImagePoint &ip, unsigned int size, const vpColor &color, unsigned int thickness=1)
static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
void acquire(vpImage< vpRGBa > &I)
void resize(unsigned int h, unsigned int w)
resize the image : Image initialization