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
74 void usage(
const char *name, std::string ipath,
const char *badparam);
75 bool getOptions(
int argc,
const char **argv, std::string &ipath,
bool &display);
86 void usage(
const char *name, std::string ipath,
const char *badparam)
89 Demonstration of the wireframe simulator with a simple visual servoing.\n\
91 The visual servoing consists in bringing the camera at a desired \n\
92 position from the object.\n\
94 The visual features used to compute the pose of the camera and \n\
95 thus the control law are four points.\n\
97 This demonstration explains also how to move the object around a world\n\
98 reference frame. Here, the movement is a rotation around the x and y axis\n\
99 at a given distance from the world frame. In fact the object trajectory\n\
100 is on a sphere whose center is the origin of the world frame.\n\
103 %s [-d] [-h]\n", name);
107 -i <input image path> %s\n\
108 Set mire.pgm image input path.\n\
109 From this path read \"ViSP-images/mire/mire.pgm\" video.\n\
110 Setting the VISP_INPUT_IMAGE_PATH environment variable \n\
111 produces the same behaviour than using this option.\n\
114 Turn off the display.\n\
117 Print the help.\n", ipath.c_str());
120 fprintf(stdout,
"\nERROR: Bad parameter [%s]\n", badparam);
136 bool getOptions(
int argc,
const char **argv, std::string &ipath,
bool &display)
143 case 'i': ipath = optarg_;
break;
144 case 'd': display =
false;
break;
145 case 'h': usage(argv[0],ipath, NULL);
return false;
break;
148 usage(argv[0],ipath, optarg_);
153 if ((c == 1) || (c == -1)) {
155 usage(argv[0], ipath, NULL);
156 std::cerr <<
"ERROR: " << std::endl;
157 std::cerr <<
" Bad argument " << optarg_ << std::endl << std::endl;
166 main(
int argc,
const char ** argv)
169 bool opt_display =
true;
170 std::string opt_ipath;
171 std::string env_ipath;
173 std::string filename;
176 if (getOptions(argc, argv, opt_ipath, opt_display) ==
false) {
184 #if defined VISP_HAVE_X11
186 #elif defined VISP_HAVE_OPENCV
188 #elif defined VISP_HAVE_GDI
190 #elif defined VISP_HAVE_D3D9
192 #elif defined VISP_HAVE_GTK
199 display[0].
init(Iint, 100, 100,
"The internal view") ;
200 display[1].
init(Iext1, 100, 100,
"The first external view") ;
201 display[2].
init(Iext2, 100, 100,
"The second external view") ;
215 float sampling_time = 0.040f;
241 for (
int i = 0 ; i < 4 ; i++)
246 for (
int i = 0 ; i < 4 ; i++)
250 for (
int i = 0 ; i < 4 ; i++)
251 point[i].track(cdMo);
254 for (
int i = 0 ; i < 4 ; i++)
268 for (
int i = 0 ; i < 4 ; i++)
273 std::list<vpImageSimulator> list;
277 for (
int i = 0; i < 4; i++) X[i].resize(3);
294 char *ptenv = getenv(
"VISP_INPUT_IMAGE_PATH");
298 if (! env_ipath.empty())
301 if (!opt_ipath.empty())
306 imsim.
init(filename.c_str(), X);
308 list.push_back(imsim);
361 std::cout <<
"Click on a display" << std::endl;
388 for (
int i = 0 ; i < 4 ; i++)
390 point[i].
track(cMo) ;
439 std::cout <<
"|| s - s* || = " << ( task.
getError() ).sumSquare() <<std::endl ;
448 std::cout <<
"Catch an exception: " << e << std::endl;
456 vpERROR_TRACE(
"You do not have X11, OpenCV, GDI, D3D9 or GTK display functionalities...");
void setPosition(const vpHomogeneousMatrix &wMc)
The object displayed at the desired position is the same than the scene object defined in vpSceneObje...
Definition of the vpMatrix class.
void init(const vpImage< unsigned char > &I, vpColVector *X)
void setVelocity(const vpRobot::vpControlFrameType frame, const vpColVector &vel)
void setMaxTranslationVelocity(const double maxVt)
The class provides a data structure for the homogeneous matrices as well as a set of operations on th...
Class that defines the simplest robot: a free flying camera.
A 40cm by 40cm plate with 4 points at coordinates (-0.1,-0.1,0), (0.1,-0.1,0), (0.1,0.1,0), (0.1,0.1,0). Each point is represented by a circle with 2cm radius.
void set_fMo(const vpHomogeneousMatrix &fMo_)
Display for windows using GDI (available on any windows 32 platform).
void set_eJe(const vpMatrix &eJe_)
Define the X11 console to display images.
void addFeature(vpBasicFeature &s, vpBasicFeature &s_star, const unsigned int select=vpBasicFeature::FEATURE_ALL)
static const vpColor none
error that can be emited by ViSP classes.
void init(vpImage< unsigned char > &I, int winx=-1, int winy=-1, const char *title=NULL)
void track(const vpHomogeneousMatrix &cMo)
Class that defines a 2D point visual feature which is composed by two parameters that are the cartes...
void setExternalCameraPosition(const vpHomogeneousMatrix &cam_Mf)
static double measureTimeMs()
static int wait(double t0, double t)
void setDesiredCameraPosition(const vpHomogeneousMatrix &cdMo_)
static void flush(const vpImage< unsigned char > &I)
static bool parse(int *argcPtr, const char **argv, vpArgvInfo *argTable, int flags)
Class that defines what is a point.
virtual void setSamplingTime(const double &delta_t)
Display for windows using Direct3D.
vpColVector getError() const
vpHomogeneousMatrix get_fMo() const
vpColVector computeControlLaw()
virtual void setWindowPosition(int winx, int winy)=0
static void display(const vpImage< unsigned char > &I)
The vpDisplayOpenCV allows to display image using the opencv library.
Generic class defining intrinsic camera parameters.
void getPosition(vpHomogeneousMatrix &wMc) const
Class which enables to project an image in the 3D space and get the view of a virtual camera...
void initScene(const vpSceneObject &obj, const vpSceneDesiredObject &desiredObject)
The vpDisplayGTK allows to display image using the GTK+ library version 1.2.
Class that consider the particular case of twist transformation matrix that allows to transform a vel...
void getExternalImage(vpImage< unsigned char > &I)
Implementation of a wire frame simulator. Compared to the vpSimulator class, it does not require thir...
static void displayFrame(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, double size, const vpColor &color, unsigned int thickness=1)
void setInteractionMatrixType(const vpServoIteractionMatrixType &interactionMatrixType, const vpServoInversionType &interactionMatrixInversion=PSEUDO_INVERSE)
static double rad(double deg)
void setExternalCameraParameters(const vpCameraParameters &cam)
void setCameraPositionRelObj(const vpHomogeneousMatrix &cMo_)
void setMaxRotationVelocity(const double maxVr)
void getInternalImage(vpImage< unsigned char > &I)
Class that provides a data structure for the column vectors as well as a set of operations on these v...
void set_cVe(const vpVelocityTwistMatrix &cVe_)
vpHomogeneousMatrix inverse() const
void setInternalCameraParameters(const vpCameraParameters &cam)
void print(const vpServo::vpServoPrintType display_level=ALL, std::ostream &os=std::cout)
virtual bool getClick(bool blocking=true)=0
static void create(vpFeaturePoint &s, const vpCameraParameters &cam, const vpDot &d)
void get_eJe(vpMatrix &eJe)
void setServo(const vpServoType &servo_type)
vpHomogeneousMatrix getExternalCameraPosition() const
void setWorldCoordinates(const double ox, const double oy, const double oz)
Set the point world coordinates. We mean here the coordinates of the point in the object frame...