50 #include <visp/vpCameraParameters.h>
51 #include <visp/vpDisplayOpenCV.h>
52 #include <visp/vpDisplayX.h>
53 #include <visp/vpDisplayGTK.h>
54 #include <visp/vpDisplayGDI.h>
55 #include <visp/vpDisplayD3D.h>
56 #include <visp/vpFeatureBuilder.h>
57 #include <visp/vpFeaturePoint.h>
58 #include <visp/vpHomogeneousMatrix.h>
59 #include <visp/vpImage.h>
60 #include <visp/vpImageIo.h>
61 #include <visp/vpIoTools.h>
62 #include <visp/vpMath.h>
63 #include <visp/vpParseArgv.h>
64 #include <visp/vpServo.h>
65 #include <visp/vpSimulatorCamera.h>
66 #include <visp/vpTime.h>
67 #include <visp/vpVelocityTwistMatrix.h>
68 #include <visp/vpWireFrameSimulator.h>
70 #define GETOPTARGS "dh"
72 #ifdef VISP_HAVE_DISPLAY
83 void usage(
const char *name, std::string ipath,
const char *badparam)
86 Demonstration of the wireframe simulator with a simple visual servoing.\n\
88 The visual servoing consists in bringing the camera at a desired \n\
89 position from the object.\n\
91 The visual features used to compute the pose of the camera and \n\
92 thus the control law are four points.\n\
94 This demonstration explains also how to move the object around a world\n\
95 reference frame. Here, the movement is a rotation around the x and y axis\n\
96 at a given distance from the world frame. In fact the object trajectory\n\
97 is on a sphere whose center is the origin of the world frame.\n\
100 %s [-d] [-h]\n", name);
104 -i <input image path> %s\n\
105 Set mire.pgm image input path.\n\
106 From this path read \"ViSP-images/mire/mire.pgm\" video.\n\
107 Setting the VISP_INPUT_IMAGE_PATH environment variable \n\
108 produces the same behaviour than using this option.\n\
111 Turn off the display.\n\
114 Print the help.\n", ipath.c_str());
117 fprintf(stdout,
"\nERROR: Bad parameter [%s]\n", badparam);
133 bool getOptions(
int argc,
const char **argv, std::string &ipath,
bool &display)
140 case 'i': ipath = optarg;
break;
141 case 'd': display =
false;
break;
142 case 'h': usage(argv[0],ipath, NULL);
return false;
break;
145 usage(argv[0],ipath, optarg);
150 if ((c == 1) || (c == -1)) {
152 usage(argv[0], ipath, NULL);
153 std::cerr <<
"ERROR: " << std::endl;
154 std::cerr <<
" Bad argument " << optarg << std::endl << std::endl;
163 main(
int argc,
const char ** argv)
165 bool opt_display =
true;
166 std::string opt_ipath;
167 std::string env_ipath;
169 std::string filename;
172 if (getOptions(argc, argv, opt_ipath, opt_display) ==
false) {
180 #if defined VISP_HAVE_X11
182 #elif defined VISP_HAVE_OPENCV
184 #elif defined VISP_HAVE_GDI
186 #elif defined VISP_HAVE_D3D9
188 #elif defined VISP_HAVE_GTK
197 display[0].
init(Iint, 100, 100,
"The internal view") ;
198 display[1].
init(Iext1, 100, 100,
"The first external view") ;
199 display[2].
init(Iext2, 100, 100,
"The second external view") ;
219 float sampling_time = 0.040f;
245 for (
int i = 0 ; i < 4 ; i++)
250 for (
int i = 0 ; i < 4 ; i++)
254 for (
int i = 0 ; i < 4 ; i++)
255 point[i].track(cdMo);
258 for (
int i = 0 ; i < 4 ; i++)
272 for (
int i = 0 ; i < 4 ; i++)
277 std::list<vpImageSimulator> list;
281 for (
int i = 0; i < 4; i++) X[i].resize(3);
298 char *ptenv = getenv(
"VISP_INPUT_IMAGE_PATH");
302 if (! env_ipath.empty())
305 if (!opt_ipath.empty())
312 imsim.
init(filename.c_str(), X);
316 vpTRACE(
"You need the ViSP data ");
321 list.push_back(imsim);
374 std::cout <<
"Click on a display" << std::endl;
401 for (
int i = 0 ; i < 4 ; i++)
403 point[i].
track(cMo) ;
452 std::cout <<
"|| s - s* || = " << ( task.
getError() ).sumSquare() <<std::endl ;
464 vpERROR_TRACE(
"You do not have X11, OpenCV, GDI, D3D9 or GTK display functionalities...");