Visual Servoing Platform
version 3.7.0
Toggle main menu visibility
Loading...
Searching...
No Matches
vpAR.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
* Use to display an image behind the internal view of the simulator
32
* used for augmented reality application
33
*/
34
40
41
#include <visp3/core/vpConfig.h>
42
43
#ifdef VISP_HAVE_COIN3D_AND_GUI
44
45
#include <visp3/ar/vpAR.h>
46
#include <visp3/core/vpDebug.h>
47
#include <visp3/core/vpTime.h>
48
49
/* Objets OIV. */
50
#include <Inventor/nodes/SoCone.h>
/* Objet cone. */
51
#include <Inventor/nodes/SoCoordinate3.h>
/* Liste de points. */
52
#include <Inventor/nodes/SoCylinder.h>
/* Objet cylindre. */
53
#include <Inventor/nodes/SoIndexedFaceSet.h>
/* Liste de face. */
54
#include <Inventor/nodes/SoPointLight.h>
/* Objet lumiere ponctuelle. */
55
#include <Inventor/nodes/SoRotationXYZ.h>
/* Transfo rotation simple. */
56
#include <Inventor/nodes/SoScale.h>
/* Trasnfo mise a l'echelle. */
57
#include <Inventor/nodes/SoTranslation.h>
/* Trasnfo translation. */
58
59
#include <Inventor/actions/SoWriteAction.h>
60
#include <Inventor/nodes/SoDirectionalLight.h>
/* Objet lumiere directionnelle*/
61
#include <Inventor/nodes/SoDrawStyle.h>
/* Style de rendu. */
62
#include <Inventor/nodes/SoEnvironment.h>
/* Eclairage ambiant. */
63
#include <Inventor/nodes/SoGroup.h>
/* Groupement de noeuds (sans separation)*/
64
#include <Inventor/nodes/SoMaterial.h>
/* Matiere (couleur) des objets. */
65
66
BEGIN_VISP_NAMESPACE
70
vpAR::~vpAR
() {
kill
(); }
71
79
void
vpAR::initInternalViewer
(
unsigned
int
width,
unsigned
int
height,
vpImageType
type)
80
{
81
82
vpSimulator::initInternalViewer
(width, height);
83
84
// no image is loaded
85
background =
false
;
86
87
if
(
image_background
!=
nullptr
) {
88
free(
image_background
);
89
image_background
=
nullptr
;
90
}
91
92
typeImage
= type;
93
if
(
typeImage
==
grayImage
)
94
image_background
= (GLubyte *)malloc(
internal_width
*
internal_height
*
sizeof
(GLubyte));
95
else
96
image_background
= (GLubyte *)malloc(3 *
internal_width
*
internal_height
*
sizeof
(GLubyte));
97
}
98
104
// Grey pictures SetBackGroundImage
105
void
vpAR::setImage
(
vpImage<unsigned char>
&I)
106
{
107
108
if
((
internal_width
!= I.getWidth()) || (
internal_height
!= I.getHeight())) {
109
vpERROR_TRACE
(
"The image size is different from the view size "
);
110
throw
(
vpException
(
vpException::dimensionError
),
"The image size is different from the view size"
);
111
}
112
113
background =
true
;
114
115
for
(
unsigned
int
i = 0; i < I.getHeight(); i++)
116
for
(
unsigned
int
j = 0; j < I.getWidth(); j++)
117
// le repere image open GL est en bas a gauche donc l'image serait
118
// inverse
119
image_background
[i * I.getWidth() + j] = I[I.getHeight() - i - 1][j];
120
}
121
127
// Color pictures SetBackGroundImage
128
void
vpAR::setImage
(
vpImage<vpRGBa>
&I)
129
{
130
if
((
internal_width
!= I.getWidth()) || (
internal_height
!= I.getHeight())) {
131
vpERROR_TRACE
(
"The image size is different from the view size "
);
132
throw
(
vpException
(
vpException::dimensionError
),
"The image size is different from the view size"
);
133
}
134
135
background =
true
;
136
137
for
(
unsigned
int
i = 0; i < I.getHeight(); i++) {
138
unsigned
int
k = 0;
139
for
(
unsigned
int
j = 0; j < I.getWidth(); j++)
140
// le repere image open GL est en bas a gauche donc l'image serait inverse
141
{
142
image_background
[i * I.getWidth() * 3 + k + 0] = I[I.getHeight() - i - 1][j].R;
143
image_background
[i * I.getWidth() * 3 + k + 1] = I[I.getHeight() - i - 1][j].G;
144
image_background
[i * I.getWidth() * 3 + k + 2] = I[I.getHeight() - i - 1][j].B;
145
k += 3;
146
}
147
}
148
}
149
END_VISP_NAMESPACE
150
#elif !defined(VISP_BUILD_SHARED_LIBS)
151
// Work around to avoid warning: libvisp_ar.a(vpAR.cpp.o) has no symbols
152
void
dummy_vpAR() { }
153
#endif
vpAR::setImage
void setImage(vpImage< unsigned char > &I)
Definition
vpAR.cpp:105
vpAR::initInternalViewer
void initInternalViewer(unsigned int width, unsigned int height, vpImageType type=grayImage)
Definition
vpAR.cpp:79
vpAR::~vpAR
virtual ~vpAR()
Definition
vpAR.cpp:70
vpException
error that can be emitted by ViSP classes.
Definition
vpException.h:60
vpException::dimensionError
@ dimensionError
Bad dimension.
Definition
vpException.h:71
vpImage
Definition of the vpImage class member functions.
Definition
vpImage.h:131
vpSimulator::internal_height
unsigned int internal_height
Definition
vpSimulator.h:159
vpSimulator::image_background
GLubyte * image_background
Definition
vpSimulator.h:126
vpSimulator::kill
void kill()
perform some destruction
Definition
vpSimulator.cpp:302
vpSimulator::internal_width
unsigned int internal_width
Definition
vpSimulator.h:158
vpSimulator::typeImage
vpImageType typeImage
Definition
vpSimulator.h:124
vpSimulator::vpImageType
vpImageType
Definition
vpSimulator.h:123
vpSimulator::grayImage
@ grayImage
Definition
vpSimulator.h:123
vpSimulator::initInternalViewer
virtual void initInternalViewer(unsigned int nlig, unsigned int ncol)
initialize the camera view
Definition
vpSimulator.cpp:447
vpERROR_TRACE
#define vpERROR_TRACE
Definition
vpDebug.h:423
BEGIN_VISP_NAMESPACE
Definition
vpMbtDistanceCircle.cpp:55
modules
ar
src
coin-simulator
vpAR.cpp
Generated by
1.17.0