Visual Servoing Platform version 3.7.0
Loading...
Searching...
No Matches
tutorial-draw-frame.cpp
1
2#include <visp3/core/vpConfig.h>
3#include <visp3/gui/vpDisplayFactory.h>
4#include <visp3/core/vpHomogeneousMatrix.h>
5
6#ifdef ENABLE_VISP_NAMESPACE
7using namespace VISP_NAMESPACE_NAME;
8#endif
9
10int main()
11{
12#if defined(VISP_HAVE_DISPLAY)
13 vpImage<unsigned char> I(2160, 3840, 128);
14
15 // Initialize the display with the image I. Display and image are now linked together
16#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
17 std::shared_ptr<vpDisplay> d = vpDisplayFactory::createDisplay(I, -1, -1, "Frame drawing", vpDisplay::SCALE_AUTO);
18#else
20#endif
21
23
24 double dTheta = 45;
25 double dOffset = 0.25;
26 std::string axisName[3] = { "x", "y", "z" };
27 double px = 600; double py = 600;
28 double u0 = 320; double v0 = 240;
29
30 // Create a camera parameter container
32
33 // Camera initialization with a perspective projection without distortion model
34 cam.initPersProjWithoutDistortion(px, py, u0, v0);
35
36 for (unsigned int idAxis = 0; idAxis < 3; idAxis++) {
37 unsigned int tOffset = 0;
38 for (double theta = -180; theta < 180; theta += dTheta) {
39 vpTranslationVector t(0.05, 0.25 * (idAxis + 1), 0.37);
40 vpRxyzVector r(0, 0, 0);
41 t[0] = t[0] + tOffset * dOffset;
42 tOffset++;
43 r[idAxis] = vpMath::rad(theta);
45 cMo.buildFrom(t, vpRotationMatrix(r));
46 std::stringstream ss_name;
47 ss_name << "cMo_";
48 ss_name << static_cast<int>(theta);
49 ss_name << "_";
50 ss_name << axisName[idAxis];
51
53 vpDisplay::displayFrame(I, cMo, cam, 0.1, vpColor::none, 1, vpImagePoint(), ss_name.str(), vpColor::yellow, vpImagePoint(40, 40));
55 }
56 }
57
59 std::cout << "A click to quit..." << std::endl;
61
62#if (VISP_CXX_STANDARD < VISP_CXX_STANDARD_11)
63 delete d;
64#endif
65
66#else
67 std::cout << "No gui available to display an image..." << std::endl;
68#endif
69
70 return EXIT_SUCCESS;
71}
Generic class defining intrinsic camera parameters.
static const vpColor none
Definition vpColor.h:210
static const vpColor yellow
Definition vpColor.h:206
Class that defines generic functionalities for display.
Definition vpDisplay.h:171
static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
static void display(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), const std::string &frameName="", const vpColor &textColor=vpColor::black, const vpImagePoint &textOffset=vpImagePoint(15, 15))
static void flush(const vpImage< unsigned char > &I)
Implementation of an homogeneous matrix and operations on such kind of matrices.
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
Definition of the vpImage class member functions.
Definition vpImage.h:131
static double rad(double deg)
Definition vpMath.h:129
Implementation of a rotation matrix and operations on such kind of matrices.
Implementation of a rotation vector as Euler angle minimal representation.
Class that consider the case of a translation vector.
std::shared_ptr< vpDisplay > createDisplay()
Return a smart pointer vpDisplay specialization if a GUI library is available or nullptr otherwise.
vpDisplay * allocateDisplay()
Return a newly allocated vpDisplay specialization if a GUI library is available or nullptr otherwise.