ViSP
Main Page
Related Pages
Modules
Classes
Examples
All
Classes
Functions
Variables
Enumerations
Enumerator
Friends
Groups
Pages
vpProjectionDisplay.cpp
1
/****************************************************************************
2
*
3
* $Id: vpProjectionDisplay.cpp 4056 2013-01-05 13:04:42Z fspindle $
4
*
5
* This file is part of the ViSP software.
6
* Copyright (C) 2005 - 2013 by INRIA. All rights reserved.
7
*
8
* This software is free software; you can redistribute it and/or
9
* modify it under the terms of the GNU General Public License
10
* ("GPL") version 2 as published by the Free Software Foundation.
11
* See the file LICENSE.txt at the root directory of this source
12
* distribution for additional information about the GNU GPL.
13
*
14
* For using ViSP with software that can not be combined with the GNU
15
* GPL, please contact INRIA about acquiring a ViSP Professional
16
* Edition License.
17
*
18
* See http://www.irisa.fr/lagadic/visp/visp.html for more information.
19
*
20
* This software was developed at:
21
* INRIA Rennes - Bretagne Atlantique
22
* Campus Universitaire de Beaulieu
23
* 35042 Rennes Cedex
24
* France
25
* http://www.irisa.fr/lagadic
26
*
27
* If you have questions regarding the use of this file, please contact
28
* INRIA at visp@inria.fr
29
*
30
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
31
* WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
32
*
33
*
34
* Description:
35
* Interface with the image for feature display.
36
*
37
* Authors:
38
* Eric Marchand
39
*
40
*****************************************************************************/
41
42
48
#include <visp/vpConfig.h>
49
#if (defined (VISP_HAVE_X11) || defined(VISP_HAVE_GTK) || defined(VISP_HAVE_GDI))
50
51
// Meter/pixel conversion
52
#include <visp/vpCameraParameters.h>
53
#include <visp/vpMeterPixelConversion.h>
54
#include <visp/vpPoint.h>
55
#include <visp/vpMath.h>
56
57
//Color / image / display
58
#include <visp/vpColor.h>
59
#include <visp/vpImage.h>
60
61
#include <visp/vpDisplay.h>
62
63
#include <visp/vpProjectionDisplay.h>
64
65
#include <visp/vpBasicFeature.h>
66
67
68
void
69
vpProjectionDisplay::insert
(
vpForwardProjection
&fp)
70
{
71
// vpForwardProjection *f ;
72
// f = fp.duplicate() ;
73
// f->setDeallocate(vpForwardProjection::vpDisplayForwardProjection) ;
74
75
listFp.push_back(&fp);
76
}
77
78
void
79
vpProjectionDisplay::init
()
80
{
81
o.
setWorldCoordinates
(0,0,0) ;
82
x.
setWorldCoordinates
(0.1,0,0) ;
83
y.
setWorldCoordinates
(0,0.1,0) ;
84
z.
setWorldCoordinates
(0,0,0.1) ;
85
traj.
resize
(0,2);
86
}
87
void
88
vpProjectionDisplay::init
(
const
int
select)
89
{
90
if
(select &
vpProjectionDisplay::internalView
())
91
{
92
Icam.
resize
(256,256) ;
93
dIcam.
init
(Icam,100,100) ;
94
}
95
if
(select &
vpProjectionDisplay::externalView
())
96
{
97
Iext.
resize
(256,256) ;
98
dIext.
init
(Iext,400,100) ;
99
}
100
101
init
() ;
102
}
103
104
105
void
106
vpProjectionDisplay::close
()
107
{
108
109
}
110
111
void
112
vpProjectionDisplay::display
(
vpImage<unsigned char>
&I,
113
const
vpHomogeneousMatrix
&cextMo,
114
const
vpHomogeneousMatrix
&cMo,
115
const
vpCameraParameters
&cam,
116
const
vpColor
color,
117
const
bool
&displayTraj)
118
{
119
120
for
(std::list<vpForwardProjection *>::const_iterator it = listFp.begin() ; it != listFp.end(); ++it )
121
{
122
vpForwardProjection
*fp = *it ;
123
fp->
display
(I,cextMo,cam, color) ;
124
}
125
126
if
(displayTraj)
// display past camera positions
127
for
(
unsigned
int
i=0;i<traj.
getRows
();++i)
128
vpDisplay::displayCircle
(I,(
int
)traj[i][0],(int)traj[i][1],2,
vpColor::green
,
true
);
129
130
displayCamera
(I,cextMo,cMo, cam);
131
132
if
(displayTraj)
// store current camera position
133
{
134
const
unsigned
int
n = traj.
getRows
();
135
traj.
resize
(n+1,2,
false
);
136
vpMeterPixelConversion::convertPoint
(cam,o.
p
[0],o.
p
[1],traj[n][1],traj[n][0]);
137
}
138
}
139
140
141
void
142
vpProjectionDisplay::displayCamera
(
vpImage<unsigned char>
&I,
143
const
vpHomogeneousMatrix
&cextMo,
144
const
vpHomogeneousMatrix
&cMo,
145
const
vpCameraParameters
&cam)
146
{
147
vpHomogeneousMatrix
c1Mc ;
148
c1Mc = cextMo*cMo.
inverse
() ;
149
150
o.
track
(c1Mc) ;
151
152
if
(o.
get_Z
() < 0)
// do not print camera if behind the external camera
153
return
;
154
155
x.
track
(c1Mc) ;
156
y.
track
(c1Mc) ;
157
z.
track
(c1Mc) ;
158
159
vpImagePoint
ipo;
160
vpImagePoint
ipx;
161
162
vpMeterPixelConversion::convertPoint
(cam, o.
p
[0], o.
p
[1], ipo) ;
163
164
vpMeterPixelConversion::convertPoint
(cam, x.
p
[0], x.
p
[1], ipx) ;
165
vpDisplay::displayArrow
(I, ipo, ipx,
vpColor::green
) ;
166
167
vpMeterPixelConversion::convertPoint
(cam, y.
p
[0], y.
p
[1], ipx) ;
168
vpDisplay::displayArrow
(I, ipo, ipx,
vpColor::blue
) ;
169
170
vpMeterPixelConversion::convertPoint
(cam, z.
p
[0], z.
p
[1], ipx) ;
171
vpDisplay::displayArrow
(I, ipo, ipx,
vpColor::red
) ;
172
}
173
174
#endif
175
176
/*
177
* Local variables:
178
* c-basic-offset: 2
179
* End:
180
*/
src
simulator
coin-simulator
vpProjectionDisplay.cpp
Generated on Fri Apr 26 2013 19:54:35 for ViSP by
1.8.1.2