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)
13 static std::vector<vpImagePoint> traj[4];
14 for (
unsigned int i=0; i<4; i++) {
15 traj[i].push_back(dot[i].getCog());
17 for (
unsigned int i=0; i<4; i++) {
18 for (
unsigned int j=1; j<traj[i].size(); j++) {
24 #if defined(VISP_HAVE_OGRE)
26 #
if VISP_VERSION_INT > VP_VERSION_INT(2,7,0)
37 vpImageTools::binarise(I, (
unsigned char)254, (
unsigned char)255, (
unsigned char)0, (
unsigned char)255, (
unsigned char)255);
43 #if defined(VISP_HAVE_OGRE) && (defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI))
44 unsigned int thickness = 3;
56 std::vector<vpPoint> point(4) ;
57 point[0].setWorldCoordinates(-0.1,-0.1, 0);
58 point[1].setWorldCoordinates( 0.1,-0.1, 0);
59 point[2].setWorldCoordinates( 0.1, 0.1, 0);
60 point[3].setWorldCoordinates(-0.1, 0.1, 0);
69 ogre.
init(background,
false,
true);
74 std::vector<std::string> name(4);
75 for (
int i=0; i<4; i++) {
76 std::ostringstream s; s <<
"Sphere" << i; name[i] = s.str();
77 ogre.
load(name[i],
"Sphere.mesh");
78 ogre.
setScale(name[i], 0.02f, 0.02f, 0.02f);
86 light->setDiffuseColour(1, 1, 1);
87 light->setSpecularColour(1, 1, 1);
88 light->setPosition((Ogre::Real)cdMo[0][3], (Ogre::Real)cdMo[1][3], (Ogre::Real)(-cdMo[2][3]));
89 light->setType(Ogre::Light::LT_POINT);
100 ogre_get_render_image(ogre, background, cdMo, I);
103 #if defined(VISP_HAVE_X11)
104 vpDisplayX d(I, 0, 0,
"Camera view at desired position");
105 #elif defined(VISP_HAVE_GDI)
106 vpDisplayGDI d(I, 0, 0,
"Camera view at desired position");
108 std::cout <<
"No image viewer is available..." << std::endl;
115 std::vector<vpDot2> dot(4);
118 for (
int i = 0 ; i < 4 ; i++) {
120 dot[i].setGraphics(
true);
121 dot[i].setGraphicsThickness(thickness);
122 dot[i].initTracking(I);
128 ogre_get_render_image(ogre, background, cMo, I);
135 for (
int i = 0 ; i < 4 ; i++) {
144 dot[i].setGraphics(
true);
145 dot[i].initTracking(I);
150 for (
int i = 0 ; i < 4 ; i++) {
153 point[i].changeFrame(cMo, cP) ;
171 ogre_get_render_image(ogre, background, cMo, I);
175 for (
int i = 0 ; i < 4 ; i++) {
180 for (
int i = 0 ; i < 4 ; i++) {
183 point[i].changeFrame(cMo, cP) ;
189 display_trajectory(I, dot, thickness);
static void display(vpServo &s, const vpCameraParameters &cam, vpImage< unsigned char > &I, vpColor currentColor=vpColor::green, vpColor desiredColor=vpColor::red, unsigned int thickness=1)
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)
create a new ste of two visual features
void setLambda(double _lambda)
set the gain lambda
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)
void kill()
destruction (memory deallocation if required)
vpColVector computeControlLaw()
compute the desired control law
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)
Set the type of the interaction matrix (current, mean, desired, user).
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)
Class required to compute the visual servoing control law descbribed in and .
void load(const std::string &name, const std::string &model)
Class that consider the case of a translation vector.
void setServo(vpServoType _servo_type)
Choice of the visual servoing control law.