43 #include <visp3/core/vpDebug.h> 45 #include <visp3/core/vpImage.h> 46 #include <visp3/core/vpImageTools.h> 47 #include <visp3/io/vpImageIo.h> 49 #include <visp3/core/vpCameraParameters.h> 50 #include <visp3/core/vpTime.h> 51 #include <visp3/robot/vpSimulatorCamera.h> 53 #include <visp3/core/vpHomogeneousMatrix.h> 54 #include <visp3/core/vpMath.h> 55 #include <visp3/gui/vpDisplayD3D.h> 56 #include <visp3/gui/vpDisplayGDI.h> 57 #include <visp3/gui/vpDisplayGTK.h> 58 #include <visp3/gui/vpDisplayOpenCV.h> 59 #include <visp3/gui/vpDisplayX.h> 61 #include <visp3/io/vpParseArgv.h> 62 #include <visp3/visual_features/vpFeatureLuminance.h> 65 #include <visp3/robot/vpImageSimulator.h> 68 #include <visp3/core/vpIoTools.h> 69 #include <visp3/io/vpParseArgv.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,
bool &click_allowed,
bool &display,
int &niter);
87 void usage(
const char *name,
const char *badparam, std::string ipath,
int niter)
90 Tracking of Surf key-points.\n\ 93 %s [-i <input image path>] [-c] [-d] [-n <number of iterations>] [-h]\n",
98 -i <input image path> %s\n\ 99 Set image input path.\n\ 100 From this path read \"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,
bool &click_allowed,
bool &display,
int &niter)
145 click_allowed =
false;
154 niter = atoi(optarg_);
157 usage(argv[0], NULL, ipath, niter);
161 usage(argv[0], optarg_, ipath, niter);
166 if ((c == 1) || (c == -1)) {
168 usage(argv[0], NULL, ipath, niter);
169 std::cerr <<
"ERROR: " << std::endl;
170 std::cerr <<
" Bad argument " << optarg_ << std::endl << std::endl;
177 int main(
int argc,
const char **argv)
179 #if (defined(VISP_HAVE_LAPACK) || defined(VISP_HAVE_EIGEN3) || defined(VISP_HAVE_OPENCV)) 181 std::string env_ipath;
182 std::string opt_ipath;
184 std::string filename;
185 bool opt_click_allowed =
true;
186 bool opt_display =
true;
194 if (!env_ipath.empty())
198 if (getOptions(argc, argv, opt_ipath, opt_click_allowed, opt_display, opt_niter) ==
false) {
203 if (!opt_ipath.empty())
208 if (!opt_ipath.empty() && !env_ipath.empty()) {
209 if (ipath != env_ipath) {
210 std::cout << std::endl <<
"WARNING: " << std::endl;
211 std::cout <<
" Since -i <visp image path=" << ipath <<
"> " 212 <<
" is different from VISP_IMAGE_PATH=" << env_ipath << std::endl
213 <<
" we skip the environment variable." << std::endl;
218 if (opt_ipath.empty() && env_ipath.empty()) {
219 usage(argv[0], NULL, ipath, opt_niter);
220 std::cerr << std::endl <<
"ERROR:" << std::endl;
221 std::cerr <<
" Use -i <visp image path> option or set VISP_INPUT_IMAGE_PATH " << std::endl
222 <<
" environment variable to specify the location of the " << std::endl
223 <<
" image path where test images are located." << std::endl
233 for (
int i = 0; i < 4; i++)
258 sim.
init(Itexture, X);
277 #if defined VISP_HAVE_X11 279 #elif defined VISP_HAVE_GDI 281 #elif defined VISP_HAVE_GTK 283 #elif defined VISP_HAVE_OPENCV 287 #if defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_GTK) || defined(VISP_HAVE_OPENCV) 289 d.
init(I, 20, 10,
"Photometric visual servoing : s");
293 if (opt_display && opt_click_allowed) {
294 std::cout <<
"Click in the image to continue..." << std::endl;
314 #if defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_GTK) 319 if (opt_display && opt_click_allowed) {
320 std::cout <<
"Click in the image to continue..." << std::endl;
331 #if defined VISP_HAVE_X11 333 #elif defined VISP_HAVE_GDI 335 #elif defined VISP_HAVE_GTK 338 #if defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_GTK) 340 d1.
init(Idiff, 40 + static_cast<int>(I.
getWidth()), 10,
"photometric visual servoing : s-s* ");
389 for (
unsigned int i = 0; i < n; i++)
390 diagHsd[i][i] = Hsd[i][i];
415 double normeError = 0;
420 std::cout <<
"--------------------------------------------" << iter++ << std::endl;
425 #if defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_GTK) 432 #if defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_GTK) 442 sI.
error(sId, error);
445 std::cout <<
"|e| " << normeError << std::endl;
461 e = H * Lsd.
t() * error;
466 std::cout <<
"lambda = " << lambda <<
" mu = " << mu;
467 std::cout <<
" |Tc| = " << sqrt(v.
sumSquare()) << std::endl;
473 }
while (normeError > 10000 && iter < opt_niter);
476 std::cout <<
"Time to convergence: " << chrono.
getDurationMs() <<
" ms" << std::endl;
483 std::cout <<
"Catch an exception: " << e << std::endl;
489 std::cout <<
"Cannot run this example: install Lapack, Eigen3 or OpenCV" << std::endl;
void setPosition(const vpHomogeneousMatrix &wMc)
Implementation of a matrix and operations on matrices.
void init(const vpImage< unsigned char > &I, vpColVector *X)
static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
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)
Use the X11 console to display images on unix-like OS. Thus to enable this class X11 should be instal...
error that can be emited by ViSP classes.
void init(vpImage< unsigned char > &I, int winx=-1, int winy=-1, const std::string &title="")
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)
vpMatrix interaction(unsigned int select=FEATURE_ALL)
void start(bool reset=true)
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.
vpColVector error(const vpBasicFeature &s_star, unsigned int select=FEATURE_ALL)
static void display(const vpImage< unsigned char > &I)
The vpDisplayOpenCV allows to display image using the OpenCV library. Thus to enable this class OpenC...
Generic class defining intrinsic camera parameters.
void init(vpImage< unsigned char > &I, int win_x=-1, int win_y=-1, const std::string &win_title="")
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 3rd party library. Thus to enable this class G...
vpHomogeneousMatrix getPosition() const
void buildFrom(const vpTranslationVector &t, const vpRotationMatrix &R)
static double rad(double deg)
static void read(vpImage< unsigned char > &I, const std::string &filename)
Implementation of column vector and the associated operations.
vpMatrix inverseByLU() const
vpHomogeneousMatrix inverse() const
unsigned int getHeight() const