 |
Visual Servoing Platform
version 3.3.0
|
2 #include <visp3/core/vpConfig.h>
3 #ifdef VISP_HAVE_MODULE_AR
4 #include <visp3/ar/vpAROgre.h>
6 #include <visp3/blob/vpDot2.h>
7 #include <visp3/gui/vpDisplayGDI.h>
8 #include <visp3/gui/vpDisplayOpenCV.h>
9 #include <visp3/gui/vpDisplayX.h>
10 #include <visp3/robot/vpSimulatorCamera.h>
11 #include <visp3/vision/vpPose.h>
12 #include <visp3/visual_features/vpFeatureBuilder.h>
13 #include <visp3/vs/vpServo.h>
14 #include <visp3/vs/vpServoDisplay.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)
53 #if defined(VISP_HAVE_OGRE) && (defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_OPENCV))
55 unsigned int thickness = 3;
67 std::vector<vpPoint> point;
68 point.push_back(
vpPoint(-0.1, -0.1, 0));
69 point.push_back(
vpPoint(0.1, -0.1, 0));
70 point.push_back(
vpPoint(0.1, 0.1, 0));
71 point.push_back(
vpPoint(-0.1, 0.1, 0));
80 ogre.
init(background,
false,
true);
85 std::vector<std::string> name(4);
86 for (
unsigned int i = 0; i < 4; i++) {
90 ogre.
load(name[i],
"Sphere.mesh");
100 light->setDiffuseColour(1, 1, 1);
101 light->setSpecularColour(1, 1, 1);
102 light->setPosition((Ogre::Real)cdMo[0][3], (Ogre::Real)cdMo[1][3], (Ogre::Real)(-cdMo[2][3]));
103 light->setType(Ogre::Light::LT_POINT);
114 ogre_get_render_image(ogre, background, cdMo, I);
117 #if defined(VISP_HAVE_X11)
118 vpDisplayX d(I, 0, 0,
"Camera view at desired position");
119 #elif defined(VISP_HAVE_GDI)
120 vpDisplayGDI d(I, 0, 0,
"Camera view at desired position");
121 #elif defined(VISP_HAVE_OPENCV)
124 std::cout <<
"No image viewer is available..." << std::endl;
131 std::vector<vpDot2> dot(4);
134 for (
unsigned int i = 0; i < 4; i++) {
136 dot[i].setGraphics(
true);
137 dot[i].setGraphicsThickness(thickness);
138 dot[i].initTracking(I);
144 ogre_get_render_image(ogre, background, cMo, I);
152 for (
unsigned int i = 0; i < 4; i++) {
161 dot[i].setGraphics(
true);
162 dot[i].initTracking(I);
167 for (
unsigned int i = 0; i < 4; i++) {
170 point[i].changeFrame(cMo, cP);
189 ogre_get_render_image(ogre, background, cMo, I);
193 for (
unsigned int i = 0; i < 4; i++) {
198 for (
unsigned int i = 0; i < 4; i++) {
201 point[i].changeFrame(cMo, cP);
207 display_trajectory(I, dot, thickness);
219 std::cout <<
"Catch a ViSP exception: " << e << std::endl;
221 std::cout <<
"Catch an exception " << std::endl;
Use the X11 console to display images on unix-like OS. Thus to enable this class X11 should be instal...
Ogre::SceneManager * getSceneManager()
VISP_EXPORT int wait(double t0, double t)
static void displayLine(const vpImage< unsigned char > &I, const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness=1, bool segment=true)
void load(const std::string &entityName, const std::string &model)
static void setTitle(const vpImage< unsigned char > &I, const std::string &windowtitle)
static void convert(const vpImage< unsigned char > &src, vpImage< vpRGBa > &dest)
static double rad(double deg)
void getRenderingOutput(vpImage< vpRGBa > &I, const vpHomogeneousMatrix &cMo)
Generic class defining intrinsic camera parameters.
double getSamplingTime() const
Display for windows using GDI (available on any windows 32 platform).
static void create(vpFeaturePoint &s, const vpCameraParameters &cam, const vpDot &d)
void setRotation(const std::string &sceneName, const vpRotationMatrix &wRo)
virtual void display(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMw)
Class that consider the case of a translation vector.
Class that defines the simplest robot: a free flying camera.
Implementation of column vector and the associated operations.
The vpDisplayOpenCV allows to display image using the OpenCV library. Thus to enable this class OpenC...
void setServo(const vpServoType &servo_type)
vpHomogeneousMatrix getPosition() const
static void display(const vpImage< unsigned char > &I)
static void displayText(const vpImage< unsigned char > &I, const vpImagePoint &ip, const std::string &s, const vpColor &color)
Implementation of a rotation matrix and operations on such kind of matrices.
unsigned int getHeight() const
void setScale(const std::string &sceneName, float factorx, float factory, float factorz)
void setCameraParameters(const vpCameraParameters &cameraP)
void setShowConfigDialog(bool showConfigDialog)
Implementation of an augmented reality viewer using Ogre3D 3rd party.
void addFeature(vpBasicFeature &s, vpBasicFeature &s_star, unsigned int select=vpBasicFeature::FEATURE_ALL)
Class that defines a 2D point visual feature which is composed by two parameters that are the cartes...
void setInteractionMatrixType(const vpServoIteractionMatrixType &interactionMatrixType, const vpServoInversionType &interactionMatrixInversion=PSEUDO_INVERSE)
static const vpColor green
vpColVector computeControlLaw()
static void flush(const vpImage< unsigned char > &I)
virtual void setSamplingTime(const double &delta_t)
vpHomogeneousMatrix inverse() const
Class that defines what is a point.
static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
void addResource(const std::string &resourceLocation)
Implementation of an homogeneous matrix and operations on such kind of matrices.
void setVelocity(const vpRobot::vpControlFrameType frame, const vpColVector &vel)
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)
error that can be emited by ViSP classes.
void setPosition(const std::string &sceneName, const vpTranslationVector &wTo)
virtual void init(vpImage< unsigned char > &I, bool bufferedKeys=false, bool hidden=false)
unsigned int getWidth() const