Visual Servoing Platform
version 3.7.0
Toggle main menu visibility
Loading...
Searching...
No Matches
vpImageSimulator.h
1
/*
2
* ViSP, open source Visual Servoing Platform software.
3
* Copyright (C) 2005 - 2025 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: Class which enables to project an image in the 3D space
31
* and get the view of a virtual camera.
32
*
33
*
34
* Authors:
35
* Amaury Dame
36
*/
37
38
#ifndef vpImageSimulator_h
39
#define vpImageSimulator_h
40
136
137
#include <visp3/core/vpCameraParameters.h>
138
#include <visp3/core/vpColVector.h>
139
#include <visp3/core/vpConfig.h>
140
#include <visp3/core/vpHomogeneousMatrix.h>
141
#include <visp3/core/vpImage.h>
142
#include <visp3/core/vpPoint.h>
143
#include <visp3/core/vpRect.h>
144
#include <visp3/core/vpTriangle.h>
145
146
#include <list>
147
#include <vector>
148
149
BEGIN_VISP_NAMESPACE
150
class
VISP_EXPORT
vpImageSimulator
151
{
152
public
:
153
typedef
enum
{
COLORED
,
GRAY_SCALED
} vpColorPlan;
154
155
typedef
enum
{
SIMPLE
,
BILINEAR_INTERPOLATION
} vpInterpolationType;
156
157
private
:
158
vpColVector
X[4];
159
vpHomogeneousMatrix
cMt;
160
vpColVector
X2[4];
161
std::vector<vpPoint> pt;
162
std::vector<vpPoint> ptClipped;
163
164
vpInterpolationType interp;
165
166
// normal repere objet
167
vpColVector
normal_obj;
168
// normal repere cam
169
vpColVector
normal_Cam;
170
// normal repere cam sous forme de pointeur sinon vpColVector prend trop de
171
// temps
172
double
*normal_Cam_optim;
173
174
// distance du plan au centre de camera
175
double
distance;
176
double
visible_result;
177
bool
visible;
178
179
// point 3D du plan definissant ou sera le pixel (0,0) de l'image
180
double
*X0_2_optim;
181
182
// variable pour intersection algebre : vecteurs de la base 2D et leur norme
183
double
frobeniusNorm_u, fronbniusNorm_v;
184
185
// 2 vecteur 3D (typiquement deux cotes du plan) qui definissent le repere
186
// 2D u,v de l'image
187
vpColVector
vbase_u, vbase_v;
188
// version pointeur des vecteurs de base
189
double
*vbase_u_optim;
190
double
*vbase_v_optim;
191
192
// allocation memoire du point 3D d'intersection entre le vecteur
193
// (centre_cam - point_plan_image) et le plan
194
double
*Xinter_optim;
195
196
// triangles de projection du plan
197
std::vector<vpTriangle> listTriangle;
198
199
// image de texture
200
vpColorPlan colorI;
201
vpImage<unsigned char>
Ig;
202
vpImage<vpRGBa>
Ic;
203
204
vpRect
rect;
205
bool
cleanPrevImage;
206
bool
setBackgroundTexture;
// flag set when the background is to a texture
207
// using setBackGroundTexture()
208
vpColor
bgColor;
209
210
vpColVector
focal;
211
212
// boolean to tell if the points in the camera frame have to be clipped
213
bool
needClipping;
214
215
public
:
216
VP_EXPLICIT
vpImageSimulator
(
const
vpColorPlan &col = COLORED);
217
vpImageSimulator
(
const
vpImageSimulator
&text);
218
virtual
~vpImageSimulator
();
219
220
vpImageSimulator
&operator=(
const
vpImageSimulator
&sim);
221
222
// creation du plan a partir de ses coordonnees 3D ds repere objet et de son
223
// image texture
224
void
init(
const
vpImage<unsigned char>
&I,
vpColVector
*X);
225
void
init(
const
vpImage<vpRGBa>
&I,
vpColVector
*X);
226
#ifdef VISP_HAVE_MODULE_IO
227
void
init(
const
char
*file_image,
vpColVector
*X);
228
#endif
229
void
init(
const
vpImage<unsigned char>
&I,
const
std::vector<vpPoint> &X);
230
void
init(
const
vpImage<vpRGBa>
&I,
const
std::vector<vpPoint> &X);
231
#ifdef VISP_HAVE_MODULE_IO
232
void
init(
const
char
*file_image,
const
std::vector<vpPoint> &X);
233
#endif
234
235
// projection du plan par cMo => creation des deux triangles definissant
236
// projection du plan sur plan image (coord en metre)
237
void
setCameraPosition(
const
vpHomogeneousMatrix
&cMt);
238
239
void
setInterpolationType
(
const
vpInterpolationType
interplt) { this->interp = interplt; }
240
241
void
getImage(
vpImage<unsigned char>
&I,
const
vpCameraParameters
&cam);
242
void
getImage(
vpImage<vpRGBa>
&I,
const
vpCameraParameters
&cam);
243
244
void
getImage(
vpImage<unsigned char>
&I,
vpImage<unsigned char>
&Isrc,
const
vpCameraParameters
&cam);
245
void
getImage(
vpImage<vpRGBa>
&I,
vpImage<vpRGBa>
&Isrc,
const
vpCameraParameters
&cam);
246
247
void
getImage(
vpImage<unsigned char>
&I,
const
vpCameraParameters
&cam,
vpMatrix
&zBuffer);
248
void
getImage(
vpImage<vpRGBa>
&I,
const
vpCameraParameters
&cam,
vpMatrix
&zBuffer);
249
250
static
void
getImage(
vpImage<unsigned char>
&I, std::list<vpImageSimulator> &list,
const
vpCameraParameters
&cam);
251
static
void
getImage(
vpImage<vpRGBa>
&I, std::list<vpImageSimulator> &list,
const
vpCameraParameters
&cam);
252
253
std::vector<vpColVector> get3DcornersTextureRectangle();
254
255
friend
VISP_EXPORT std::ostream &operator<<(std::ostream &os,
const
vpImageSimulator
&
/*ip*/
);
256
268
void
setCleanPreviousImage
(
const
bool
&clean,
const
vpColor
&color =
vpColor::white
)
269
{
270
cleanPrevImage = clean;
271
bgColor = color;
272
}
273
280
inline
void
setBackGroundTexture
(
const
vpImage<unsigned char>
&Iback)
281
{
282
setBackgroundTexture =
true
;
283
Ig = Iback;
284
}
285
286
private
:
287
void
initPlan(
vpColVector
*X);
288
289
// result = plan est visible.
290
// ie: un plan est oriente dans si normal_plan.focal < 0 => plan est visible
291
// sinon invisible.
292
bool
isVisible() {
return
visible; }
293
294
// function that project a point x,y on the plane, return true if the
295
// projection is on the limited plane
296
// and in this case return the corresponding image pixel Ipixelplan
297
bool
getPixel(
const
vpImagePoint &iP,
unsigned
char
&Ipixelplan);
298
bool
getPixel(
const
vpImagePoint &iP, vpRGBa &Ipixelplan);
299
bool
getPixel(vpImage<unsigned char> &Isrc,
const
vpImagePoint &iP,
unsigned
char
&Ipixelplan);
300
bool
getPixel(vpImage<vpRGBa> &Isrc,
const
vpImagePoint &iP, vpRGBa &Ipixelplan);
301
bool
getPixelDepth(
const
vpImagePoint &iP,
double
&Zpixelplan);
302
bool
getPixelVisibility(
const
vpImagePoint &iP,
double
&Zpixelplan);
303
304
// operation 3D de base :
305
void
project(
const
vpColVector &_vin,
const
vpHomogeneousMatrix &_cMt, vpColVector &_vout);
306
// donne coordonnes homogenes de _v;
307
void
getHomogCoord(
const
vpColVector &_v, vpColVector &_vH);
308
// donne coordonnes _v en fction coord homogenes _vH;
309
void
getCoordFromHomog(
const
vpColVector &_vH, vpColVector &_v);
310
311
void
getRoi(
const
unsigned
int
&Iwidth,
const
unsigned
int
&Iheight,
const
vpCameraParameters &cam,
312
const
std::vector<vpPoint> &point, vpRect &rect);
313
};
314
END_VISP_NAMESPACE
315
#endif
316
317
/*
318
* Local variables:
319
* c-basic-offset: 2
320
* End:
321
*/
vpCameraParameters
Generic class defining intrinsic camera parameters.
Definition
vpCameraParameters.h:311
vpColVector
Implementation of column vector and the associated operations.
Definition
vpColVector.h:191
vpColor
Class to define RGB colors available for display functionalities.
Definition
vpColor.h:157
vpColor::white
static const vpColor white
Definition
vpColor.h:193
vpHomogeneousMatrix
Implementation of an homogeneous matrix and operations on such kind of matrices.
Definition
vpHomogeneousMatrix.h:221
vpImageSimulator
Class which enables to project an image in the 3D space and get the view of a virtual camera.
Definition
vpImageSimulator.h:151
vpImageSimulator::setBackGroundTexture
void setBackGroundTexture(const vpImage< unsigned char > &Iback)
Definition
vpImageSimulator.h:280
vpImageSimulator::vpInterpolationType
vpInterpolationType
Definition
vpImageSimulator.h:155
vpImageSimulator::SIMPLE
@ SIMPLE
Definition
vpImageSimulator.h:155
vpImageSimulator::BILINEAR_INTERPOLATION
@ BILINEAR_INTERPOLATION
Definition
vpImageSimulator.h:155
vpImageSimulator::vpImageSimulator
VP_EXPLICIT vpImageSimulator(const vpColorPlan &col=COLORED)
Definition
vpImageSimulator.cpp:57
vpImageSimulator::setCleanPreviousImage
void setCleanPreviousImage(const bool &clean, const vpColor &color=vpColor::white)
Definition
vpImageSimulator.h:268
vpImageSimulator::setInterpolationType
void setInterpolationType(const vpInterpolationType interplt)
Definition
vpImageSimulator.h:239
vpImageSimulator::COLORED
@ COLORED
Definition
vpImageSimulator.h:153
vpImageSimulator::GRAY_SCALED
@ GRAY_SCALED
Definition
vpImageSimulator.h:153
vpImage
Definition of the vpImage class member functions.
Definition
vpImage.h:131
vpMatrix
Implementation of a matrix and operations on matrices.
Definition
vpMatrix.h:175
vpRect
Defines a rectangle in the plane.
Definition
vpRect.h:79
BEGIN_VISP_NAMESPACE
Definition
vpMbtDistanceCircle.cpp:55
modules
robot
include
visp3
robot
vpImageSimulator.h
Generated by
1.17.0