48 #include <visp/vpDebug.h>
50 #include <visp/vpImage.h>
51 #include <visp/vpImageIo.h>
52 #include <visp/vpImageTools.h>
54 #include <visp/vpCameraParameters.h>
55 #include <visp/vpTime.h>
56 #include <visp/vpRobotCamera.h>
58 #include <visp/vpMath.h>
59 #include <visp/vpHomogeneousMatrix.h>
60 #include <visp/vpDisplayGTK.h>
61 #include <visp/vpDisplayGDI.h>
62 #include <visp/vpDisplayOpenCV.h>
63 #include <visp/vpDisplayD3D.h>
64 #include <visp/vpDisplayX.h>
66 #include <visp/vpFeatureLuminance.h>
67 #include <visp/vpParseArgv.h>
69 #include <visp/vpImageSimulator.h>
73 #include <visp/vpParseArgv.h>
74 #include <visp/vpIoTools.h>
77 #define GETOPTARGS "cdi:n:h"
79 void usage(
const char *name,
const char *badparam, std::string ipath,
int niter);
80 bool getOptions(
int argc,
const char **argv, std::string &ipath,
81 bool &click_allowed,
bool &display,
int &niter);
93 void usage(
const char *name,
const char *badparam, std::string ipath,
int niter)
96 Tracking of Surf key-points.\n\
99 %s [-i <input image path>] [-c] [-d] [-n <number of iterations>] [-h]\n", name);
103 -i <input image path> %s\n\
104 Set image input path.\n\
105 From this path read \"ViSP-images/doisneau/doisneau.jpg\"\n\
107 Setting the VISP_INPUT_IMAGE_PATH environment\n\
108 variable produces the same behaviour than using\n\
112 Disable the mouse click. Useful to automaze the \n\
113 execution of this program without humain intervention.\n\
116 Turn off the display.\n\
119 Number of iterations.\n\
123 ipath.c_str(), niter);
126 fprintf(stdout,
"\nERROR: Bad parameter [%s]\n", badparam);
142 bool getOptions(
int argc,
const char **argv, std::string &ipath,
143 bool &click_allowed,
bool &display,
int &niter)
150 case 'c': click_allowed =
false;
break;
151 case 'd': display =
false;
break;
152 case 'i': ipath = optarg_;
break;
153 case 'n': niter = atoi(optarg_);
break;
154 case 'h': usage(argv[0], NULL, ipath, niter);
return false;
break;
157 usage(argv[0], optarg_, ipath, niter);
162 if ((c == 1) || (c == -1)) {
164 usage(argv[0], NULL, ipath, niter);
165 std::cerr <<
"ERROR: " << std::endl;
166 std::cerr <<
" Bad argument " << optarg_ << std::endl << std::endl;
176 main(
int argc,
const char ** argv)
179 std::string env_ipath;
180 std::string opt_ipath;
182 std::string filename;
183 bool opt_click_allowed =
true;
184 bool opt_display =
true;
191 if (! env_ipath.empty())
195 if (getOptions(argc, argv, opt_ipath, opt_click_allowed,
196 opt_display, opt_niter) ==
false) {
201 if (!opt_ipath.empty())
206 if (!opt_ipath.empty() && !env_ipath.empty()) {
207 if (ipath != env_ipath) {
208 std::cout << std::endl
209 <<
"WARNING: " << std::endl;
210 std::cout <<
" Since -i <visp image path=" << ipath <<
"> "
211 <<
" is different from VISP_IMAGE_PATH=" << env_ipath << std::endl
212 <<
" we skip the environment variable." << std::endl;
217 if (opt_ipath.empty() && env_ipath.empty()){
218 usage(argv[0], NULL, ipath, opt_niter);
219 std::cerr << std::endl
220 <<
"ERROR:" << std::endl;
221 std::cerr <<
" Use -i <visp image path> option or set VISP_INPUT_IMAGE_PATH "
223 <<
" environment variable to specify the location of the " << std::endl
224 <<
" image path where test images are located." << std::endl << std::endl;
233 for (
int i = 0; i < 4; i++) X[i].resize(3);
257 sim.
init(Itexture, X);
276 #if defined VISP_HAVE_X11
278 #elif defined VISP_HAVE_GDI
280 #elif defined VISP_HAVE_GTK
282 #elif defined VISP_HAVE_OPENCV
286 #if defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_GTK) || defined(VISP_HAVE_OPENCV)
288 d.
init(I, 20, 10,
"Photometric visual servoing : s") ;
292 if (opt_display && opt_click_allowed) {
293 std::cout <<
"Click in the image to continue..." << std::endl;
311 #if defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_GTK)
316 if (opt_display && opt_click_allowed) {
317 std::cout <<
"Click in the image to continue..." << std::endl;
328 #if defined VISP_HAVE_X11
330 #elif defined VISP_HAVE_GDI
332 #elif defined VISP_HAVE_GTK
335 #if defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_GTK)
337 d1.
init(Idiff, 40+(
int)I.
getWidth(), 10,
"photometric visual servoing : s-s* ") ;
385 for(
unsigned int i = 0 ; i < n ; i++) diagHsd[i][i] = Hsd[i][i];
410 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) ;
437 std::cout <<
"|e| "<<normeError <<std::endl ;
454 e = H * Lsd.
t() *error ;
459 std::cout <<
"lambda = " << lambda <<
" mu = " << mu ;
460 std::cout <<
" |Tc| = " << sqrt(v.
sumSquare()) << std::endl;
467 while(normeError > 10000 && iter < opt_niter);
475 std::cout <<
"Catch an exception: " << e << std::endl;
void init(vpImage< unsigned char > &I, int winx=-1, int winy=-1, const char *title=NULL)
Definition of the vpMatrix class.
void init(const vpImage< unsigned char > &I, vpColVector *X)
unsigned int getWidth() const
The class provides a data structure for the homogeneous matrices as well as a set of operations on th...
void buildFrom(vpImage< unsigned char > &I)
void setPosition(const vpHomogeneousMatrix &cMw)
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.
Class that defines the simplest robot: a free flying camera.
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.
void buildFrom(const vpTranslationVector &t, const vpRotationMatrix &R)
Construction from translation vector and rotation matrix.
static double rad(double deg)
void getPosition(vpHomogeneousMatrix &cMw) const
Class that provides a data structure for the column vectors as well as a set of operations on these v...
vpMatrix inverseByLU() const
unsigned int getHeight() const
virtual bool getClick(bool blocking=true)=0
static void read(vpImage< unsigned char > &I, const char *filename)
void setVelocity(const vpRobot::vpControlFrameType frame, const vpColVector &v)