37#include <visp3/core/vpConfig.h>
38#include <visp3/core/vpDebug.h>
40#include <visp3/core/vpImage.h>
41#include <visp3/core/vpImageTools.h>
42#include <visp3/io/vpImageIo.h>
44#include <visp3/core/vpCameraParameters.h>
45#include <visp3/core/vpTime.h>
46#include <visp3/robot/vpSimulatorCamera.h>
48#include <visp3/core/vpHomogeneousMatrix.h>
49#include <visp3/core/vpMath.h>
50#include <visp3/gui/vpDisplayFactory.h>
52#include <visp3/io/vpParseArgv.h>
53#include <visp3/visual_features/vpFeatureLuminance.h>
56#include <visp3/robot/vpImageSimulator.h>
59#include <visp3/core/vpIoTools.h>
60#include <visp3/io/vpParseArgv.h>
63#define GETOPTARGS "cdi:n:h"
65#ifdef ENABLE_VISP_NAMESPACE
69void usage(
const char *name,
const char *badparam,
const std::string &ipath,
int niter);
70bool getOptions(
int argc,
const char **argv, std::string &ipath,
bool &click_allowed,
bool &display,
int &niter);
82void usage(
const char *name,
const char *badparam,
const std::string &ipath,
int niter)
85Tracking of Surf key-points.\n\
88 %s [-i <input image path>] [-c] [-d] [-n <number of iterations>] [-h]\n",
93 -i <input image path> %s\n\
94 Set image input path.\n\
95 From this path read \"doisneau/doisneau.jpg\"\n\
97 Setting the VISP_INPUT_IMAGE_PATH environment\n\
98 variable produces the same behaviour than using\n\
102 Disable the mouse click. Useful to automate the \n\
103 execution of this program without human intervention.\n\
106 Turn off the display.\n\
109 Number of iterations.\n\
113 ipath.c_str(), niter);
116 fprintf(stdout,
"\nERROR: Bad parameter [%s]\n", badparam);
132bool getOptions(
int argc,
const char **argv, std::string &ipath,
bool &click_allowed,
bool &display,
int &niter)
140 click_allowed =
false;
149 niter = atoi(optarg_);
152 usage(argv[0],
nullptr, ipath, niter);
156 usage(argv[0], optarg_, ipath, niter);
161 if ((c == 1) || (c == -1)) {
163 usage(argv[0],
nullptr, ipath, niter);
164 std::cerr <<
"ERROR: " << std::endl;
165 std::cerr <<
" Bad argument " << optarg_ << std::endl << std::endl;
172int main(
int argc,
const char **argv)
174#if (defined(VISP_HAVE_LAPACK) || defined(VISP_HAVE_EIGEN3) || defined(VISP_HAVE_OPENCV))
175#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
176 std::shared_ptr<vpDisplay>
d, d1;
182 std::string env_ipath;
183 std::string opt_ipath;
186 bool opt_click_allowed =
true;
187 bool opt_display =
true;
195 if (!env_ipath.empty())
199 if (getOptions(argc, argv, opt_ipath, opt_click_allowed, opt_display, opt_niter) ==
false) {
204 if (!opt_ipath.empty())
209 if (!opt_ipath.empty() && !env_ipath.empty()) {
210 if (ipath != env_ipath) {
211 std::cout << std::endl <<
"WARNING: " << std::endl;
212 std::cout <<
" Since -i <visp image path=" << ipath <<
"> "
213 <<
" is different from VISP_IMAGE_PATH=" << env_ipath << std::endl
214 <<
" we skip the environment variable." << std::endl;
219 if (opt_ipath.empty() && env_ipath.empty()) {
220 usage(argv[0],
nullptr, ipath, opt_niter);
221 std::cerr << std::endl <<
"ERROR:" << std::endl;
222 std::cerr <<
" Use -i <visp image path> option or set VISP_INPUT_IMAGE_PATH " << std::endl
223 <<
" environment variable to specify the location of the " << std::endl
224 <<
" image path where test images are located." << std::endl
234 for (
int i = 0;
i < 4;
i++)
259 sim.
init(Itexture, X);
278#if defined(VISP_HAVE_DISPLAY)
280#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
288 if (opt_display && opt_click_allowed) {
289 std::cout <<
"Click in the image to continue..." << std::endl;
309#if defined(VISP_HAVE_DISPLAY)
314 if (opt_display && opt_click_allowed) {
315 std::cout <<
"Click in the image to continue..." << std::endl;
326#if defined(VISP_HAVE_DISPLAY)
328#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
340 wMc = wMo *
cMo.inverse();
341 robot.setPosition(wMc);
351 sI.
init(I.getHeight(), I.getWidth(), Z);
357 sId.
init(I.getHeight(), I.getWidth(), Z);
381 for (
unsigned int i = 0;
i < n;
i++)
382 diagHsd[i][i] = Hsd[i][i];
407 double normeError = 0;
412 std::cout <<
"--------------------------------------------" <<
iter++ << std::endl;
417#if defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_GTK)
424#if defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_GTK)
434 sI.
error(sId, error);
436 normeError = (
error.sumSquare());
437 std::cout <<
"|e| " << normeError << std::endl;
450 H = ((mu * diagHsd) + Hsd).inverseByLU();
458 std::cout <<
"lambda = " << lambda <<
" mu = " << mu;
459 std::cout <<
" |Tc| = " << sqrt(
v.sumSquare()) << std::endl;
463 wMc = robot.getPosition();
465 }
while (normeError > 10000 && iter < opt_niter);
468 std::cout <<
"Time to convergence: " << chrono.
getDurationMs() <<
" ms" << std::endl;
473#if (VISP_CXX_STANDARD < VISP_CXX_STANDARD_11)
484 std::cout <<
"Catch an exception: " <<
e << std::endl;
485#if (VISP_CXX_STANDARD < VISP_CXX_STANDARD_11)
498 std::cout <<
"Cannot run this example: install Lapack, Eigen3 or OpenCV" << std::endl;
Generic class defining intrinsic camera parameters.
void start(bool reset=true)
Implementation of column vector and the associated operations.
Class that defines generic functionalities for display.
static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
static void display(const vpImage< unsigned char > &I)
static void flush(const vpImage< unsigned char > &I)
error that can be emitted by ViSP classes.
Class that defines the image luminance visual feature.
vpFeatureLuminance & buildFrom(vpImage< unsigned char > &I)
vpColVector error(const vpBasicFeature &s_star, unsigned int select=FEATURE_ALL) VP_OVERRIDE
void init(unsigned int _nbr, unsigned int _nbc, double _Z)
vpMatrix interaction(unsigned int select=FEATURE_ALL) VP_OVERRIDE
void setCameraParameters(const vpCameraParameters &_cam)
Implementation of an homogeneous matrix and operations on such kind of matrices.
vpHomogeneousMatrix inverse() const
static void read(vpImage< unsigned char > &I, const std::string &filename, int backend=IO_DEFAULT_BACKEND)
Class which enables to project an image in the 3D space and get the view of a virtual camera.
void getImage(vpImage< unsigned char > &I, const vpCameraParameters &cam)
void init(const vpImage< unsigned char > &I, vpColVector *X)
void setInterpolationType(const vpInterpolationType interplt)
void setCameraPosition(const vpHomogeneousMatrix &cMt)
Definition of the vpImage class member functions.
static double rad(double deg)
Implementation of a matrix and operations on matrices.
static bool parse(int *argcPtr, const char **argv, vpArgvInfo *argTable, int flags)
virtual void setSamplingTime(const double &delta_t)
@ STATE_VELOCITY_CONTROL
Initialize the velocity controller.
Class that defines the simplest robot: a free flying camera.
std::shared_ptr< vpDisplay > createDisplay()
Return a smart pointer vpDisplay specialization if a GUI library is available or nullptr otherwise.
vpDisplay * allocateDisplay()
Return a newly allocated vpDisplay specialization if a GUI library is available or nullptr otherwise.