Visual Servoing Platform
version 3.7.0
Toggle main menu visibility
Loading...
Searching...
No Matches
vpProjectionDisplay.cpp
1
/*
2
* ViSP, open source Visual Servoing Platform software.
3
* Copyright (C) 2005 - 2024 by Inria. All rights reserved.
4
*
5
* This software is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
9
* See the file LICENSE.txt at the root directory of this source
10
* distribution for additional information about the GNU GPL.
11
*
12
* For using ViSP with software that can not be combined with the GNU
13
* GPL, please contact Inria about acquiring a ViSP Professional
14
* Edition License.
15
*
16
* See https://visp.inria.fr for more information.
17
*
18
* This software was developed at:
19
* Inria Rennes - Bretagne Atlantique
20
* Campus Universitaire de Beaulieu
21
* 35042 Rennes Cedex
22
* France
23
*
24
* If you have questions regarding the use of this file, please contact
25
* Inria at visp@inria.fr
26
*
27
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
28
* WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
29
*
30
* Description:
31
* Interface with the image for feature display.
32
*/
33
38
39
#include <visp3/core/vpConfig.h>
40
#if defined(VISP_HAVE_DISPLAY)
41
42
// Meter/pixel conversion
43
#include <visp3/core/vpCameraParameters.h>
44
#include <visp3/core/vpMath.h>
45
#include <visp3/core/vpMeterPixelConversion.h>
46
#include <visp3/core/vpPoint.h>
47
48
// Color / image / display
49
#include <visp3/core/vpColor.h>
50
#include <visp3/core/vpImage.h>
51
52
#include <visp3/core/vpDisplay.h>
53
54
#include <visp3/gui/vpProjectionDisplay.h>
55
56
//#include <visp3/visual_features/vpBasicFeature.h>
57
58
BEGIN_VISP_NAMESPACE
59
60
void
vpProjectionDisplay::insert
(
vpForwardProjection
&fp)
61
{
62
// vpForwardProjection *f ;
63
// f = fp.duplicate() ;
64
// f->setDeallocate(vpForwardProjection::vpDisplayForwardProjection) ;
65
66
listFp.push_back(&fp);
67
}
68
69
void
vpProjectionDisplay::init
()
70
{
71
o.setWorldCoordinates(0, 0, 0);
72
x.setWorldCoordinates(0.1, 0, 0);
73
y.setWorldCoordinates(0, 0.1, 0);
74
z.setWorldCoordinates(0, 0, 0.1);
75
traj.resize(0, 2);
76
}
77
void
vpProjectionDisplay::init
(
const
int
select)
78
{
79
if
(select &
vpProjectionDisplay::internalView
()) {
80
Icam.resize(256, 256);
81
dIcam.init(Icam, 100, 100);
82
}
83
if
(select &
vpProjectionDisplay::externalView
()) {
84
Iext.resize(256, 256);
85
dIext.init(Iext, 400, 100);
86
}
87
88
init
();
89
}
90
91
void
vpProjectionDisplay::close
() { }
92
93
void
vpProjectionDisplay::display
(
vpImage<unsigned char>
&I,
const
vpHomogeneousMatrix
&cextMo,
94
const
vpHomogeneousMatrix
&cMo,
const
vpCameraParameters
&cam,
const
vpColor
&color,
95
const
bool
&displayTraj,
unsigned
int
thickness)
96
{
97
98
for
(std::list<vpForwardProjection *>::const_iterator it = listFp.begin(); it != listFp.end(); ++it) {
99
vpForwardProjection
*fp = *it;
100
fp->
display
(I, cextMo, cam, color, thickness);
101
}
102
103
if
(displayTraj)
// display past camera positions
104
for
(
unsigned
int
i = 0; i < traj.getRows(); ++i)
105
vpDisplay::displayCircle
(I,
static_cast<
int
>
(traj[i][0]),
static_cast<
int
>
(traj[i][1]), 2,
vpColor::green
,
true
);
106
107
displayCamera
(I, cextMo, cMo, cam, thickness);
108
109
if
(displayTraj)
// store current camera position
110
{
111
const
unsigned
int
n = traj.getRows();
112
traj.resize(n + 1, 2,
false
);
113
vpMeterPixelConversion::convertPoint
(cam, o.p[0], o.p[1], traj[n][1], traj[n][0]);
114
}
115
}
116
117
void
vpProjectionDisplay::displayCamera
(
vpImage<unsigned char>
&I,
const
vpHomogeneousMatrix
&cextMo,
118
const
vpHomogeneousMatrix
&cMo,
const
vpCameraParameters
&cam,
119
unsigned
int
thickness)
120
{
121
vpHomogeneousMatrix
c1Mc;
122
c1Mc = cextMo * cMo.inverse();
123
124
o.track(c1Mc);
125
126
if
(o.get_Z() < 0)
// do not print camera if behind the external camera
127
return
;
128
129
x.track(c1Mc);
130
y.track(c1Mc);
131
z.track(c1Mc);
132
133
vpImagePoint
ipo;
134
vpImagePoint
ip;
135
136
vpMeterPixelConversion::convertPoint
(cam, o.p[0], o.p[1], ipo);
137
138
vpMeterPixelConversion::convertPoint
(cam, x.p[0], x.p[1], ip);
139
vpDisplay::displayArrow
(I, ipo, ip,
vpColor::red
, 4 + thickness, 2 + thickness, thickness);
140
141
vpMeterPixelConversion::convertPoint
(cam, y.p[0], y.p[1], ip);
142
vpDisplay::displayArrow
(I, ipo, ip,
vpColor::green
, 4 + thickness, 2 + thickness, thickness);
143
144
vpMeterPixelConversion::convertPoint
(cam, z.p[0], z.p[1], ip);
145
vpDisplay::displayArrow
(I, ipo, ip,
vpColor::blue
, 4 + thickness, 2 + thickness, thickness);
146
}
147
148
END_VISP_NAMESPACE
149
150
#elif !defined(VISP_BUILD_SHARED_LIBS)
151
// Work around to avoid warning: libvisp_gui.a(vpProjectionDisplay.cpp.o)
152
// has no symbols
153
void
dummy_vpProjectionDisplay() { }
154
#endif
vpCameraParameters
Generic class defining intrinsic camera parameters.
Definition
vpCameraParameters.h:311
vpColor
Class to define RGB colors available for display functionalities.
Definition
vpColor.h:157
vpColor::red
static const vpColor red
Definition
vpColor.h:198
vpColor::blue
static const vpColor blue
Definition
vpColor.h:204
vpColor::green
static const vpColor green
Definition
vpColor.h:201
vpDisplay::displayCircle
static void displayCircle(const vpImage< unsigned char > &I, const vpImageCircle &circle, const vpColor &color, bool fill=false, unsigned int thickness=1)
Definition
vpDisplay_uchar.cpp:154
vpDisplay::displayArrow
static void displayArrow(const vpImage< unsigned char > &I, const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color=vpColor::white, unsigned int w=4, unsigned int h=2, unsigned int thickness=1)
Definition
vpDisplay_uchar.cpp:58
vpForwardProjection
Class that defines what is a generic geometric feature.
Definition
vpForwardProjection.h:65
vpForwardProjection::display
virtual void display(const vpImage< unsigned char > &I, const vpCameraParameters &cam, const vpColor &color=vpColor::green, unsigned int thickness=1)=0
vpHomogeneousMatrix
Implementation of an homogeneous matrix and operations on such kind of matrices.
Definition
vpHomogeneousMatrix.h:221
vpImagePoint
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
Definition
vpImagePoint.h:82
vpImage
Definition of the vpImage class member functions.
Definition
vpImage.h:131
vpMeterPixelConversion::convertPoint
static void convertPoint(const vpCameraParameters &cam, const double &x, const double &y, double &u, double &v)
Definition
vpMeterPixelConversion.h:105
vpProjectionDisplay::insert
void insert(vpForwardProjection &fp)
Definition
vpProjectionDisplay.cpp:60
vpProjectionDisplay::displayCamera
void displayCamera(vpImage< unsigned char > &I, const vpHomogeneousMatrix &cextMo, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, unsigned int thickness=1)
Definition
vpProjectionDisplay.cpp:117
vpProjectionDisplay::externalView
static int externalView()
Definition
vpProjectionDisplay.h:92
vpProjectionDisplay::init
void init()
Definition
vpProjectionDisplay.cpp:69
vpProjectionDisplay::internalView
static int internalView()
Definition
vpProjectionDisplay.h:91
vpProjectionDisplay::display
void display(vpImage< unsigned char > &I, const vpHomogeneousMatrix &cextMo, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, const vpColor &color, const bool &displayTraj=false, unsigned int thickness=1)
Definition
vpProjectionDisplay.cpp:93
vpProjectionDisplay::close
void close()
Definition
vpProjectionDisplay.cpp:91
BEGIN_VISP_NAMESPACE
Definition
vpMbtDistanceCircle.cpp:55
modules
gui
src
forward-projection
vpProjectionDisplay.cpp
Generated by
1.17.0