ViSP
Main Page
Related Pages
Modules
Classes
Examples
All
Classes
Functions
Variables
Enumerations
Enumerator
Friends
Groups
Pages
tutorial-image-simulator.cpp
1
2
#include <visp/vpDisplayX.h>
3
#include <visp/vpDisplayGDI.h>
4
#include <visp/vpImageIo.h>
5
#include <visp/vpImageSimulator.h>
6
7
int
main()
8
{
9
vpImage<unsigned char>
target;
10
vpImageIo::read
(target,
"./target_square.pgm"
);
11
12
vpColVector
X[4];
13
for
(
int
i = 0; i < 4; i++) X[i].resize(3);
14
// Top left Top right Bottom right Bottom left
15
X[0][0] = -0.1; X[1][0] = 0.1; X[2][0] = 0.1; X[3][0] = -0.1;
16
X[0][1] = -0.1; X[1][1] = -0.1; X[2][1] = 0.1; X[3][1] = 0.1;
17
X[0][2] = 0; X[1][2] = 0; X[2][2] = 0; X[3][2] = 0;
18
19
vpImage<unsigned char>
I(480, 640);
20
vpCameraParameters
cam(840, 840, I.
getWidth
()/2, I.
getHeight
()/2);
21
vpHomogeneousMatrix
cMo(0, 0, 0.35, 0,
vpMath::rad
(30),
vpMath::rad
(15));
22
23
vpImageSimulator
sim;
24
sim.
setInterpolationType
(
vpImageSimulator::BILINEAR_INTERPOLATION
);
25
sim.
init
(target, X);
26
27
// Get the new image of the projected planar image target
28
sim.
setCleanPreviousImage
(
true
);
29
sim.
setCameraPosition
(cMo);
30
sim.
getImage
(I, cam);
31
32
try
{
33
vpImageIo::write
(I,
"./rendered_image.jpg"
);
34
}
35
catch
(...) {
36
std::cout <<
"Unsupported image format"
<< std::endl;
37
}
38
39
#if defined(VISP_HAVE_X11)
40
vpDisplayX
d(I);
41
#elif defined(VISP_HAVE_GDI)
42
vpDisplayGDI
d(I);
43
#else
44
std::cout <<
"No image viewer is available..."
<< std::endl;
45
#endif
46
47
vpDisplay::setTitle
(I,
"Planar image projection"
);
48
vpDisplay::display
(I);
49
vpDisplay::flush
(I);
50
std::cout <<
"A click to quit..."
<< std::endl;
51
vpDisplay::getClick
(I);
52
}
tutorial
simulator
image
tutorial-image-simulator.cpp
Generated on Tue Sep 17 2013 00:21:44 for ViSP by
1.8.4