43 #include <visp3/core/vpDebug.h>
45 #include <visp3/core/vpImage.h>
46 #include <visp3/io/vpImageIo.h>
47 #include <visp3/core/vpImageTools.h>
49 #include <visp3/core/vpCameraParameters.h>
50 #include <visp3/core/vpTime.h>
51 #include <visp3/robot/vpSimulatorCamera.h>
53 #include <visp3/core/vpMath.h>
54 #include <visp3/core/vpHomogeneousMatrix.h>
55 #include <visp3/gui/vpDisplayGTK.h>
56 #include <visp3/gui/vpDisplayGDI.h>
57 #include <visp3/gui/vpDisplayOpenCV.h>
58 #include <visp3/gui/vpDisplayD3D.h>
59 #include <visp3/gui/vpDisplayX.h>
61 #include <visp3/visual_features/vpFeatureLuminance.h>
62 #include <visp3/io/vpParseArgv.h>
64 #include <visp3/robot/vpImageSimulator.h>
68 #include <visp3/io/vpParseArgv.h>
69 #include <visp3/core/vpIoTools.h>
72 #define GETOPTARGS "cdi:n:h"
74 void usage(
const char *name,
const char *badparam, std::string ipath,
int niter);
75 bool getOptions(
int argc,
const char **argv, std::string &ipath,
76 bool &click_allowed,
bool &display,
int &niter);
88 void usage(
const char *name,
const char *badparam, std::string ipath,
int niter)
91 Tracking of Surf key-points.\n\
94 %s [-i <input image path>] [-c] [-d] [-n <number of iterations>] [-h]\n", name);
98 -i <input image path> %s\n\
99 Set image input path.\n\
100 From this path read \"ViSP-images/doisneau/doisneau.jpg\"\n\
102 Setting the VISP_INPUT_IMAGE_PATH environment\n\
103 variable produces the same behaviour than using\n\
107 Disable the mouse click. Useful to automaze the \n\
108 execution of this program without humain intervention.\n\
111 Turn off the display.\n\
114 Number of iterations.\n\
118 ipath.c_str(), niter);
121 fprintf(stdout,
"\nERROR: Bad parameter [%s]\n", badparam);
137 bool getOptions(
int argc,
const char **argv, std::string &ipath,
138 bool &click_allowed,
bool &display,
int &niter)
145 case 'c': click_allowed =
false;
break;
146 case 'd': display =
false;
break;
147 case 'i': ipath = optarg_;
break;
148 case 'n': niter = atoi(optarg_);
break;
149 case 'h': usage(argv[0], NULL, ipath, niter);
return false;
break;
152 usage(argv[0], optarg_, ipath, niter);
157 if ((c == 1) || (c == -1)) {
159 usage(argv[0], NULL, ipath, niter);
160 std::cerr <<
"ERROR: " << std::endl;
161 std::cerr <<
" Bad argument " << optarg_ << std::endl << std::endl;
171 main(
int argc,
const char ** argv)
174 std::string env_ipath;
175 std::string opt_ipath;
177 std::string filename;
178 bool opt_click_allowed =
true;
179 bool opt_display =
true;
186 if (! env_ipath.empty())
190 if (getOptions(argc, argv, opt_ipath, opt_click_allowed,
191 opt_display, opt_niter) ==
false) {
196 if (!opt_ipath.empty())
201 if (!opt_ipath.empty() && !env_ipath.empty()) {
202 if (ipath != env_ipath) {
203 std::cout << std::endl
204 <<
"WARNING: " << std::endl;
205 std::cout <<
" Since -i <visp image path=" << ipath <<
"> "
206 <<
" is different from VISP_IMAGE_PATH=" << env_ipath << std::endl
207 <<
" we skip the environment variable." << std::endl;
212 if (opt_ipath.empty() && env_ipath.empty()){
213 usage(argv[0], NULL, ipath, opt_niter);
214 std::cerr << std::endl
215 <<
"ERROR:" << std::endl;
216 std::cerr <<
" Use -i <visp image path> option or set VISP_INPUT_IMAGE_PATH "
218 <<
" environment variable to specify the location of the " << std::endl
219 <<
" image path where test images are located." << std::endl << std::endl;
228 for (
int i = 0; i < 4; i++) X[i].resize(3);
252 sim.
init(Itexture, X);
271 #if defined VISP_HAVE_X11
273 #elif defined VISP_HAVE_GDI
275 #elif defined VISP_HAVE_GTK
277 #elif defined VISP_HAVE_OPENCV
281 #if defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_GTK) || defined(VISP_HAVE_OPENCV)
283 d.
init(I, 20, 10,
"Photometric visual servoing : s") ;
287 if (opt_display && opt_click_allowed) {
288 std::cout <<
"Click in the image to continue..." << std::endl;
308 #if defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_GTK)
313 if (opt_display && opt_click_allowed) {
314 std::cout <<
"Click in the image to continue..." << std::endl;
325 #if defined VISP_HAVE_X11
327 #elif defined VISP_HAVE_GDI
329 #elif defined VISP_HAVE_GTK
332 #if defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_GTK)
334 d1.
init(Idiff, 40+(
int)I.
getWidth(), 10,
"photometric visual servoing : s-s* ") ;
383 for(
unsigned int i = 0 ; i < n ; i++) diagHsd[i][i] = Hsd[i][i];
408 double normeError = 0;
410 std::cout <<
"--------------------------------------------" << iter++ << std::endl ;
415 #if defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_GTK)
422 #if defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_GTK)
432 sI.
error(sId,error) ;
435 std::cout <<
"|e| "<<normeError <<std::endl ;
452 e = H * Lsd.
t() *error ;
457 std::cout <<
"lambda = " << lambda <<
" mu = " << mu ;
458 std::cout <<
" |Tc| = " << sqrt(v.
sumSquare()) << std::endl;
465 while(normeError > 10000 && iter < opt_niter);
473 std::cout <<
"Catch an exception: " << e << std::endl;
void setPosition(const vpHomogeneousMatrix &wMc)
void init(vpImage< unsigned char > &I, int winx=-1, int winy=-1, const char *title=NULL)
Implementation of a matrix and operations on matrices.
void init(const vpImage< unsigned char > &I, vpColVector *X)
void setVelocity(const vpRobot::vpControlFrameType frame, const vpColVector &vel)
unsigned int getWidth() const
Implementation of an homogeneous matrix and operations on such kind of matrices.
Class that defines the simplest robot: a free flying camera.
void buildFrom(vpImage< unsigned char > &I)
void getImage(vpImage< unsigned char > &I, const vpCameraParameters &cam)
Display for windows using GDI (available on any windows 32 platform).
void setCameraParameters(vpCameraParameters &_cam)
Define the X11 console to display images.
error that can be emited by ViSP classes.
void init(vpImage< unsigned char > &I, int winx=-1, int winy=-1, const char *title=NULL)
static void flush(const vpImage< unsigned char > &I)
static bool parse(int *argcPtr, const char **argv, vpArgvInfo *argTable, int flags)
virtual vpRobotStateType setRobotState(const vpRobot::vpRobotStateType newState)
virtual void setSamplingTime(const double &delta_t)
void setCameraPosition(const vpHomogeneousMatrix &cMt)
Initialize the velocity controller.
void setInterpolationType(const vpInterpolationType interplt)
Class that defines the image luminance visual feature.
vpMatrix interaction(const unsigned int select=FEATURE_ALL)
static void display(const vpImage< unsigned char > &I)
The vpDisplayOpenCV allows to display image using the opencv library.
Generic class defining intrinsic camera parameters.
vpColVector error(const vpBasicFeature &s_star, const unsigned int select=FEATURE_ALL)
Class which enables to project an image in the 3D space and get the view of a virtual camera...
The vpDisplayGTK allows to display image using the GTK+ library version 1.2.
vpHomogeneousMatrix getPosition() const
void buildFrom(const vpTranslationVector &t, const vpRotationMatrix &R)
static double rad(double deg)
Implementation of column vector and the associated operations.
vpMatrix inverseByLU() const
vpHomogeneousMatrix inverse() const
unsigned int getHeight() const
virtual bool getClick(bool blocking=true)=0
static void read(vpImage< unsigned char > &I, const char *filename)