Visual Servoing Platform  version 3.5.1 under development (2022-10-03)
#include <visp3/core/vpIoTools.h>
#include <visp3/gui/vpDisplayGDI.h>
#include <visp3/gui/vpDisplayOpenCV.h>
#include <visp3/gui/vpDisplayX.h>
#include <visp3/io/vpImageIo.h>
#include "pose_helper.h"
int main(int, char *argv[])
try {
vpImageIo::read(I, vpIoTools::getParent(argv[0]) + "/data/square.pgm");
#if defined(VISP_HAVE_X11)
vpDisplayX d(I);
#elif defined(VISP_HAVE_GDI)
#elif defined(VISP_HAVE_OPENCV)
vpCameraParameters cam(840, 840, I.getWidth() / 2, I.getHeight() / 2);
std::vector<vpDot2> dot(4);
std::vector<vpImagePoint> ip(4);
dot[0].initTracking(I, vpImagePoint(193, 157));
dot[1].initTracking(I, vpImagePoint(203, 366));
dot[2].initTracking(I, vpImagePoint(313, 402));
dot[3].initTracking(I, vpImagePoint(304, 133));
std::vector<vpPoint> point;
point.push_back(vpPoint(-0.06, -0.06, 0));
point.push_back(vpPoint(0.06, -0.06, 0));
point.push_back(vpPoint(0.06, 0.06, 0));
point.push_back(vpPoint(-0.06, 0.06, 0));
bool init = true;
while (1) {
vpImageIo::read(I, vpIoTools::getParent(argv[0]) + "/data/square.pgm");
for (unsigned int i = 0; i < dot.size(); i++) {
ip[i] = dot[i].getCog();
computePose(point, ip, cam, init, cMo);
if (init)
init = false; // turn off pose initialisation
if (vpDisplay::getClick(I, false))
} catch (const vpException &e) {
std::cout << "Catch an exception: " << e.getMessage() << std::endl;
Generic class defining intrinsic camera parameters.
static const vpColor none
Definition: vpColor.h:229
Display for windows using GDI (available on any windows 32 platform).
Definition: vpDisplayGDI.h:129
The vpDisplayOpenCV allows to display image using the OpenCV library. Thus to enable this class OpenC...
Use the X11 console to display images on unix-like OS. Thus to enable this class X11 should be instal...
Definition: vpDisplayX.h:135
static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
static void display(const vpImage< unsigned char > &I)
static void flush(const vpImage< unsigned char > &I)
static void displayFrame(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, double size, const vpColor &color=vpColor::none, unsigned int thickness=1, const vpImagePoint &offset=vpImagePoint(0, 0))
error that can be emited by ViSP classes.
Definition: vpException.h:72
const char * getMessage() const
Definition: vpException.cpp:87
Implementation of an homogeneous matrix and operations on such kind of matrices.
static void read(vpImage< unsigned char > &I, const std::string &filename, int backend=IO_DEFAULT_BACKEND)
Definition: vpImageIo.cpp:148
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
Definition: vpImagePoint.h:89
unsigned int getWidth() const
Definition: vpImage.h:246
unsigned int getHeight() const
Definition: vpImage.h:188
void init(unsigned int h, unsigned int w, Type value)
Definition: vpImage.h:631
static std::string getParent(const std::string &pathname)
Definition: vpIoTools.cpp:1617
Class that defines a 3D point in the object frame and allows forward projection of a 3D point in the ...
Definition: vpPoint.h:82
VISP_EXPORT int wait(double t0, double t)