2 #include <visp/vpDisplayX.h>
3 #include <visp/vpDisplayGDI.h>
4 #include <visp/vpAROgre.h>
5 #include <visp/vpFeatureBuilder.h>
6 #include <visp/vpPose.h>
7 #include <visp/vpServo.h>
8 #include <visp/vpServoDisplay.h>
9 #include <visp/vpSimulatorCamera.h>
11 void display_trajectory(
const vpImage<unsigned char> &I,
const std::vector<vpDot2> &dot,
unsigned int thickness);
12 #if defined(VISP_HAVE_OGRE)
17 void display_trajectory(
const vpImage<unsigned char> &I,
const std::vector<vpDot2> &dot,
unsigned int thickness)
19 static std::vector<vpImagePoint> traj[4];
20 for (
unsigned int i=0; i<4; i++) {
21 traj[i].push_back(dot[i].getCog());
23 for (
unsigned int i=0; i<4; i++) {
24 for (
unsigned int j=1; j<traj[i].size(); j++) {
30 #if defined(VISP_HAVE_OGRE)
40 vpImageTools::binarise(I, (
unsigned char)254, (
unsigned char)255, (
unsigned char)0, (
unsigned char)255, (
unsigned char)255);
46 #if defined(VISP_HAVE_OGRE) && (defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI))
48 unsigned int thickness = 3;
60 std::vector<vpPoint> point(4) ;
61 point[0].setWorldCoordinates(-0.1,-0.1, 0);
62 point[1].setWorldCoordinates( 0.1,-0.1, 0);
63 point[2].setWorldCoordinates( 0.1, 0.1, 0);
64 point[3].setWorldCoordinates(-0.1, 0.1, 0);
73 ogre.
init(background,
false,
true);
78 std::vector<std::string> name(4);
79 for (
int i=0; i<4; i++) {
80 std::ostringstream s; s <<
"Sphere" << i; name[i] = s.str();
81 ogre.
load(name[i],
"Sphere.mesh");
82 ogre.
setScale(name[i], 0.02f, 0.02f, 0.02f);
90 light->setDiffuseColour(1, 1, 1);
91 light->setSpecularColour(1, 1, 1);
92 light->setPosition((Ogre::Real)cdMo[0][3], (Ogre::Real)cdMo[1][3], (Ogre::Real)(-cdMo[2][3]));
93 light->setType(Ogre::Light::LT_POINT);
104 ogre_get_render_image(ogre, background, cdMo, I);
107 #if defined(VISP_HAVE_X11)
108 vpDisplayX d(I, 0, 0,
"Camera view at desired position");
109 #elif defined(VISP_HAVE_GDI)
110 vpDisplayGDI d(I, 0, 0,
"Camera view at desired position");
112 std::cout <<
"No image viewer is available..." << std::endl;
119 std::vector<vpDot2> dot(4);
122 for (
int i = 0 ; i < 4 ; i++) {
124 dot[i].setGraphics(
true);
125 dot[i].setGraphicsThickness(thickness);
126 dot[i].initTracking(I);
132 ogre_get_render_image(ogre, background, cMo, I);
139 for (
int i = 0 ; i < 4 ; i++) {
148 dot[i].setGraphics(
true);
149 dot[i].initTracking(I);
154 for (
int i = 0 ; i < 4 ; i++) {
157 point[i].changeFrame(cMo, cP) ;
175 ogre_get_render_image(ogre, background, cMo, I);
179 for (
int i = 0 ; i < 4 ; i++) {
184 for (
int i = 0 ; i < 4 ; i++) {
187 point[i].changeFrame(cMo, cP) ;
193 display_trajectory(I, dot, thickness);
206 std::cout <<
"Catch a ViSP exception: " << e << std::endl;
209 std::cout <<
"Catch an exception " << std::endl;
void setVelocity(const vpRobot::vpControlFrameType frame, const vpColVector &vel)
void setRotation(const std::string &name, const vpRotationMatrix &wRo)
unsigned int getWidth() const
static void convert(const vpImage< unsigned char > &src, vpImage< vpRGBa > &dest)
double getSamplingTime() const
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.
Display for windows using GDI (available on any windows 32 platform).
void setShowConfigDialog(const bool showConfigDialog)
Define the X11 console to display images.
void addFeature(vpBasicFeature &s, vpBasicFeature &s_star, const unsigned int select=vpBasicFeature::FEATURE_ALL)
error that can be emited by ViSP classes.
Class that defines a 2D point visual feature which is composed by two parameters that are the cartes...
Implementation of an augmented reality viewer.
static int wait(double t0, double t)
static const vpColor green
static void flush(const vpImage< unsigned char > &I)
Ogre::SceneManager * getSceneManager()
virtual void display(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMw)
The vpRotationMatrix considers the particular case of a rotation matrix.
virtual void setSamplingTime(const double &delta_t)
vpColVector computeControlLaw()
virtual void init(vpImage< unsigned char > &I, bool bufferedKeys=false, bool hidden=false)
static void display(const vpImage< unsigned char > &I)
void setCameraParameters(const vpCameraParameters &cameraP)
Generic class defining intrinsic camera parameters.
void getPosition(vpHomogeneousMatrix &wMc) const
virtual void setTitle(const char *title)=0
void getRenderingOutput(vpImage< vpRGBa > &I, const vpHomogeneousMatrix &cMo)
void setInteractionMatrixType(const vpServoIteractionMatrixType &interactionMatrixType, const vpServoInversionType &interactionMatrixInversion=PSEUDO_INVERSE)
static double rad(double deg)
Class that provides a data structure for the column vectors as well as a set of operations on these v...
virtual void displayCharString(const vpImagePoint &ip, const char *text, const vpColor &color=vpColor::green)=0
vpHomogeneousMatrix inverse() const
void setScale(const std::string &name, const float factorx, const float factory, const float factorz)
void addResource(const std::string &resourceLocation)
unsigned int getHeight() const
void setPosition(const std::string &name, const vpTranslationVector &wTo)
virtual bool getClick(bool blocking=true)=0
void set_Z(const double Z)
virtual void displayLine(const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness=1)=0
static void create(vpFeaturePoint &s, const vpCameraParameters &cam, const vpDot &d)
void load(const std::string &name, const std::string &model)
void setServo(const vpServoType &servo_type)
Class that consider the case of a translation vector.
static void display(const vpServo &s, const vpCameraParameters &cam, const vpImage< unsigned char > &I, vpColor currentColor=vpColor::green, vpColor desiredColor=vpColor::red, unsigned int thickness=1)