 |
Visual Servoing Platform
version 3.3.0
|
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", name);
97 -i <input image path> %s\n\
98 Set image input path.\n\
99 From this path read \"doisneau/doisneau.jpg\"\n\
101 Setting the VISP_INPUT_IMAGE_PATH environment\n\
102 variable produces the same behaviour than using\n\
106 Disable the mouse click. Useful to automaze the \n\
107 execution of this program without humain intervention.\n\
110 Turn off the display.\n\
113 Number of iterations.\n\
116 Print the help.\n", ipath.c_str(), niter);
119 fprintf(stdout,
"\nERROR: Bad parameter [%s]\n", badparam);
135 bool getOptions(
int argc,
const char **argv, std::string &ipath,
bool &click_allowed,
bool &display,
int &niter)
143 click_allowed =
false;
152 niter = atoi(optarg_);
155 usage(argv[0], NULL, ipath, niter);
160 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)
180 std::string env_ipath;
181 std::string opt_ipath;
183 std::string filename;
184 bool opt_click_allowed =
true;
185 bool opt_display =
true;
193 if (!env_ipath.empty())
197 if (getOptions(argc, argv, opt_ipath, opt_click_allowed, opt_display, opt_niter) ==
false) {
202 if (!opt_ipath.empty())
207 if (!opt_ipath.empty() && !env_ipath.empty()) {
208 if (ipath != env_ipath) {
209 std::cout << std::endl <<
"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 <<
"ERROR:" << std::endl;
220 std::cerr <<
" Use -i <visp image path> option or set VISP_INPUT_IMAGE_PATH " << std::endl
221 <<
" environment variable to specify the location of the " << std::endl
222 <<
" image path where test images are located." << std::endl
232 for (
int i = 0; i < 4; i++)
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;
313 #if defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_GTK)
318 if (opt_display && opt_click_allowed) {
319 std::cout <<
"Click in the image to continue..." << std::endl;
330 #if defined VISP_HAVE_X11
332 #elif defined VISP_HAVE_GDI
334 #elif defined VISP_HAVE_GTK
337 #if defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_GTK)
339 d1.
init(Idiff, 40 + (
int)I.
getWidth(), 10,
"photometric visual servoing : s-s* ");
388 for (
unsigned int i = 0; i < n; i++)
389 diagHsd[i][i] = Hsd[i][i];
414 double normeError = 0;
416 std::cout <<
"--------------------------------------------" << iter++ << std::endl;
421 #if defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_GTK)
428 #if defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_GTK)
438 sI.
error(sId, error);
440 normeError = (error.sumSquare());
441 std::cout <<
"|e| " << normeError << std::endl;
457 e = H * Lsd.
t() * error;
462 std::cout <<
"lambda = " << lambda <<
" mu = " << mu;
463 std::cout <<
" |Tc| = " << sqrt(v.
sumSquare()) << std::endl;
469 }
while (normeError > 10000 && iter < opt_niter);
476 std::cout <<
"Catch an exception: " << e << std::endl;
Initialize the velocity controller.
Use the X11 console to display images on unix-like OS. Thus to enable this class X11 should be instal...
void setInterpolationType(const vpInterpolationType interplt)
vpColVector error(const vpBasicFeature &s_star, unsigned int select=FEATURE_ALL)
static double rad(double deg)
Generic class defining intrinsic camera parameters.
void setCameraPosition(const vpHomogeneousMatrix &cMt)
static void read(vpImage< unsigned char > &I, const std::string &filename)
void setPosition(const vpHomogeneousMatrix &wMc)
vpMatrix interaction(unsigned int select=FEATURE_ALL)
Display for windows using GDI (available on any windows 32 platform).
void init(const vpImage< unsigned char > &I, vpColVector *X)
Class which enables to project an image in the 3D space and get the view of a virtual camera.
Class that defines the simplest robot: a free flying camera.
Implementation of column vector and the associated operations.
The vpDisplayOpenCV allows to display image using the OpenCV library. Thus to enable this class OpenC...
Implementation of a matrix and operations on matrices.
virtual vpRobotStateType setRobotState(const vpRobot::vpRobotStateType newState)
static bool parse(int *argcPtr, const char **argv, vpArgvInfo *argTable, int flags)
vpHomogeneousMatrix getPosition() const
static void display(const vpImage< unsigned char > &I)
The vpDisplayGTK allows to display image using the GTK 3rd party library. Thus to enable this class G...
unsigned int getHeight() const
vpMatrix inverseByLU() const
void setCameraParameters(vpCameraParameters &_cam)
void buildFrom(const vpTranslationVector &t, const vpRotationMatrix &R)
void buildFrom(vpImage< unsigned char > &I)
void init(vpImage< unsigned char > &I, int winx=-1, int winy=-1, const std::string &title="")
void getImage(vpImage< unsigned char > &I, const vpCameraParameters &cam)
void init(vpImage< unsigned char > &I, int winx=-1, int winy=-1, const std::string &title="")
static void flush(const vpImage< unsigned char > &I)
virtual void setSamplingTime(const double &delta_t)
Class that defines the image luminance visual feature.
vpHomogeneousMatrix inverse() const
static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
Implementation of an homogeneous matrix and operations on such kind of matrices.
void setVelocity(const vpRobot::vpControlFrameType frame, const vpColVector &vel)
error that can be emited by ViSP classes.
unsigned int getWidth() const