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;
188 char *ptenv = getenv(
"VISP_INPUT_IMAGE_PATH");
193 if (! env_ipath.empty())
198 if (getOptions(argc, argv, opt_ipath, opt_click_allowed,
199 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
212 <<
"WARNING: " << std::endl;
213 std::cout <<
" Since -i <visp image path=" << ipath <<
"> "
214 <<
" is different from VISP_IMAGE_PATH=" << env_ipath << std::endl
215 <<
" we skip the environment variable." << std::endl;
220 if (opt_ipath.empty() && env_ipath.empty()){
221 usage(argv[0], NULL, ipath, opt_niter);
222 std::cerr << std::endl
223 <<
"ERROR:" << std::endl;
224 std::cerr <<
" Use -i <visp image path> option or set VISP_INPUT_IMAGE_PATH "
226 <<
" environment variable to specify the location of the " << std::endl
227 <<
" image path where test images are located." << std::endl << std::endl;
236 for (
int i = 0; i < 4; i++) X[i].resize(3);
260 sim.
init(Itexture, X);
283 #if defined VISP_HAVE_X11
285 #elif defined VISP_HAVE_GDI
287 #elif defined VISP_HAVE_GTK
291 #if defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_GTK)
293 d.
init(I, 20, 10,
"Photometric visual servoing : s") ;
297 if (opt_display && opt_click_allowed) {
298 std::cout <<
"Click in the image to continue..." << std::endl;
317 #if defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_GTK)
322 if (opt_display && opt_click_allowed) {
323 std::cout <<
"Click in the image to continue..." << std::endl;
336 #if defined VISP_HAVE_X11
338 #elif defined VISP_HAVE_GDI
340 #elif defined VISP_HAVE_GTK
343 #if defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_GTK)
345 d1.
init(Idiff, 40+(
int)I.
getWidth(), 10,
"photometric visual servoing : s-s* ") ;
397 for(
unsigned int i = 0 ; i < n ; i++) diagHsd[i][i] = Hsd[i][i];
431 double normeError = 0;
435 std::cout <<
"--------------------------------------------" << iter++ << std::endl ;
441 #if defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_GTK)
448 #if defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_GTK)
458 sI.
error(sId,error) ;
461 std::cout <<
"|e| "<<normeError <<std::endl ;
478 e = H * Lsd.
t() *error ;
483 std::cout <<
"lambda = " << lambda <<
" mu = " << mu ;
484 std::cout <<
" |Tc| = " << sqrt(v.
sumSquare()) << std::endl;
491 while(normeError > 10000 && iter < opt_niter);
499 std::cout <<
"Catch an exception: " << e << std::endl;
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)
double sumSquare() const
return sum of the Aij^2 (for all i, for all j)
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)
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)