2 #include <visp3/core/vpConfig.h>
3 #ifdef VISP_HAVE_MODULE_AR
4 #include <visp3/ar/vpAROgre.h>
6 #include <visp3/gui/vpDisplayX.h>
7 #include <visp3/gui/vpDisplayOpenCV.h>
8 #include <visp3/gui/vpDisplayGDI.h>
9 #include <visp3/visual_features/vpFeatureBuilder.h>
10 #include <visp3/vision/vpPose.h>
11 #include <visp3/vs/vpServo.h>
12 #include <visp3/vs/vpServoDisplay.h>
13 #include <visp3/robot/vpSimulatorCamera.h>
14 #include <visp3/blob/vpDot2.h>
16 void display_trajectory(
const vpImage<unsigned char> &I,
const std::vector<vpDot2> &dot,
unsigned int thickness);
17 #if defined(VISP_HAVE_OGRE)
22 void display_trajectory(
const vpImage<unsigned char> &I,
const std::vector<vpDot2> &dot,
unsigned int thickness)
24 static std::vector<vpImagePoint> traj[4];
25 for (
unsigned int i=0; i<4; i++) {
26 traj[i].push_back(dot[i].getCog());
28 for (
unsigned int i=0; i<4; i++) {
29 for (
unsigned int j=1; j<traj[i].size(); j++) {
35 #if defined(VISP_HAVE_OGRE)
45 vpImageTools::binarise(I, (
unsigned char)254, (
unsigned char)255, (
unsigned char)0, (
unsigned char)255, (
unsigned char)255);
51 #if defined(VISP_HAVE_OGRE) && (defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_OPENCV))
53 unsigned int thickness = 3;
65 std::vector<vpPoint> point;
66 point.push_back(
vpPoint(-0.1,-0.1, 0) );
67 point.push_back(
vpPoint( 0.1,-0.1, 0) );
68 point.push_back(
vpPoint( 0.1, 0.1, 0) );
69 point.push_back(
vpPoint(-0.1, 0.1, 0) );
78 ogre.
init(background,
false,
true);
83 std::vector<std::string> name(4);
84 for (
int i=0; i<4; i++) {
85 std::ostringstream s; s <<
"Sphere" << i; name[i] = s.str();
86 ogre.
load(name[i],
"Sphere.mesh");
87 ogre.
setScale(name[i], 0.02f, 0.02f, 0.02f);
95 light->setDiffuseColour(1, 1, 1);
96 light->setSpecularColour(1, 1, 1);
97 light->setPosition((Ogre::Real)cdMo[0][3], (Ogre::Real)cdMo[1][3], (Ogre::Real)(-cdMo[2][3]));
98 light->setType(Ogre::Light::LT_POINT);
109 ogre_get_render_image(ogre, background, cdMo, I);
112 #if defined(VISP_HAVE_X11)
113 vpDisplayX d(I, 0, 0,
"Camera view at desired position");
114 #elif defined(VISP_HAVE_GDI)
115 vpDisplayGDI d(I, 0, 0,
"Camera view at desired position");
116 #elif defined(VISP_HAVE_OPENCV)
119 std::cout <<
"No image viewer is available..." << std::endl;
126 std::vector<vpDot2> dot(4);
129 for (
int i = 0 ; i < 4 ; i++) {
131 dot[i].setGraphics(
true);
132 dot[i].setGraphicsThickness(thickness);
133 dot[i].initTracking(I);
139 ogre_get_render_image(ogre, background, cMo, I);
146 for (
int i = 0 ; i < 4 ; i++) {
155 dot[i].setGraphics(
true);
156 dot[i].initTracking(I);
161 for (
int i = 0 ; i < 4 ; i++) {
164 point[i].changeFrame(cMo, cP) ;
182 ogre_get_render_image(ogre, background, cMo, I);
186 for (
int i = 0 ; i < 4 ; i++) {
191 for (
int i = 0 ; i < 4 ; i++) {
194 point[i].changeFrame(cMo, cP) ;
200 display_trajectory(I, dot, thickness);
213 std::cout <<
"Catch a ViSP exception: " << e << std::endl;
216 std::cout <<
"Catch an exception " << std::endl;
void setRotation(const std::string &sceneName, const vpRotationMatrix &wRo)
VISP_EXPORT int wait(double t0, double t)
void setVelocity(const vpRobot::vpControlFrameType frame, const vpColVector &vel)
unsigned int getWidth() const
static void convert(const vpImage< unsigned char > &src, vpImage< vpRGBa > &dest)
double getSamplingTime() const
Implementation of an homogeneous matrix and operations on such kind of matrices.
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)
static void displayText(const vpImage< unsigned char > &I, const vpImagePoint &ip, const std::string &s, const vpColor &color)
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 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)
Class that defines what is a point.
Implementation of a rotation matrix and operations on such kind of matrices.
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)
The vpDisplayOpenCV allows to display image using the opencv library.
void setScale(const std::string &sceneName, const float factorx, const float factory, const float factorz)
Generic class defining intrinsic camera parameters.
virtual void setTitle(const char *title)=0
void getRenderingOutput(vpImage< vpRGBa > &I, const vpHomogeneousMatrix &cMo)
vpHomogeneousMatrix getPosition() const
void load(const std::string &entityName, const std::string &model)
void setInteractionMatrixType(const vpServoIteractionMatrixType &interactionMatrixType, const vpServoInversionType &interactionMatrixInversion=PSEUDO_INVERSE)
static double rad(double deg)
Implementation of column vector and the associated operations.
void setPosition(const std::string &sceneName, const vpTranslationVector &wTo)
vpHomogeneousMatrix inverse() const
void addResource(const std::string &resourceLocation)
unsigned int getHeight() const
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 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)