Visual Servoing Platform
version 3.7.0
Toggle main menu visibility
Loading...
Searching...
No Matches
vpObjectCentricRenderer.h
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
35
#ifndef VP_OBJECT_CENTRIC_RENDERER_H
36
#define VP_OBJECT_CENTRIC_RENDERER_H
37
38
#include <visp3/core/vpConfig.h>
39
40
#if defined(VISP_HAVE_PANDA3D)
41
42
#include <visp3/core/vpMeterPixelConversion.h>
43
#include <visp3/ar/vpPanda3DRendererSet.h>
44
#include <visp3/core/vpRect.h>
45
46
BEGIN_VISP_NAMESPACE
47
59
class
VISP_EXPORT
vpObjectCentricRenderer
:
public
vpPanda3DRendererSet
60
{
61
public
:
62
vpObjectCentricRenderer
(
const
vpPanda3DRenderParameters
&renderParameters);
63
64
virtual
void
setRenderParameters
(
const
vpPanda3DRenderParameters
¶ms) VP_OVERRIDE
65
{
66
vpPanda3DRendererSet::setRenderParameters
(params);
67
}
68
69
vpRect
getBoundingBox
()
const
{
return
m_bb; }
70
71
void
setFocusedObject
(
const
std::string &focused)
72
{
73
m_focusedObject = focused;
74
m_shouldComputeBBPoints =
true
;
75
}
76
77
void
beforeFrameRendered
() VP_OVERRIDE;
78
79
void
computeBoundingBox3DPoints();
80
void
computeClipping(
float
&nearV,
float
&farV);
81
82
std::vector<
vpColVector
>
getBoundingBox3D
()
83
{
84
if
(m_shouldComputeBBPoints) {
85
computeBoundingBox3DPoints
();
86
m_shouldComputeBBPoints =
false
;
87
}
88
return
m_bb3DPoints;
89
}
90
91
void
get3DExtents
(
vpTranslationVector
&minValues,
vpTranslationVector
&maxValues)
92
{
93
if
(m_shouldComputeBBPoints) {
94
computeBoundingBox3DPoints
();
95
m_shouldComputeBBPoints =
false
;
96
}
97
for
(
unsigned
int
i = 0; i < 3; ++i) {
98
minValues[i] = std::numeric_limits<double>::max();
99
maxValues[i] = std::numeric_limits<double>::min();
100
}
101
102
for
(
const
vpColVector
&point: m_bb3DPoints) {
103
for
(
unsigned
int
i = 0; i < 3; ++i) {
104
if
(point[i] < minValues[i]) {
105
minValues[i] = point[i];
106
}
107
if
(point[i] > maxValues[i]) {
108
maxValues[i] = point[i];
109
}
110
}
111
}
112
}
113
114
115
116
vpRect
computeBoundingBox();
117
118
template
<
typename
T>
119
void
placeRenderInto
(
const
vpImage<T>
&render,
vpImage<T>
&target,
const
T &clearValue)
120
{
121
if
(!m_enableCrop) {
122
target = render;
123
}
124
else
{
125
const
unsigned
h =
m_renderParameters
.getImageHeight();
126
const
unsigned
w =
m_renderParameters
.getImageWidth();
127
const
unsigned
top =
static_cast<
unsigned
int
>
(std::max(0.0, m_bb.getTop()));
128
const
unsigned
left =
static_cast<
unsigned
int
>
(std::max(0.0, m_bb.getLeft()));
129
const
unsigned
bottom =
static_cast<
unsigned
int
>
(std::min(
static_cast<
double
>
(h), m_bb.getBottom()));
130
const
unsigned
right =
static_cast<
unsigned
int
>
(std::min(
static_cast<
double
>
(w), m_bb.getRight()));
131
132
target.
resize
(h, w, clearValue);
133
for
(
unsigned
int
i = top; i < bottom; ++i) {
134
memcpy(target.
bitmap
+ i * w + left, render[i - top], (right - left) *
sizeof
(T));
135
// for (unsigned int j = left; j < right; ++j) {
136
// target[i][j] = render[i - unsigned(m_bb.getTop())][j - unsigned(m_bb.getLeft())];
137
// }
138
}
139
140
}
141
}
142
143
private
:
144
bool
m_enableCrop;
145
std::string m_focusedObject;
146
vpRect
m_bb;
147
std::vector<vpColVector> m_bb3DPoints;
148
bool
m_shouldComputeBBPoints;
149
vpPanda3DRenderParameters
m_subRenderParams;
150
};
151
152
END_VISP_NAMESPACE
153
154
#endif
155
#endif
vpColVector
Implementation of column vector and the associated operations.
Definition
vpColVector.h:191
vpImage
Definition of the vpImage class member functions.
Definition
vpImage.h:131
vpImage::resize
void resize(unsigned int h, unsigned int w)
resize the image : Image initialization
Definition
vpImage.h:544
vpImage::bitmap
Type * bitmap
points toward the bitmap
Definition
vpImage.h:135
vpObjectCentricRenderer::getBoundingBox
vpRect getBoundingBox() const
Definition
vpObjectCentricRenderer.h:69
vpObjectCentricRenderer::getBoundingBox3D
std::vector< vpColVector > getBoundingBox3D()
Definition
vpObjectCentricRenderer.h:82
vpObjectCentricRenderer::vpObjectCentricRenderer
vpObjectCentricRenderer(const vpPanda3DRenderParameters &renderParameters)
Definition
vpObjectCentricRenderer.cpp:44
vpObjectCentricRenderer::setRenderParameters
virtual void setRenderParameters(const vpPanda3DRenderParameters ¶ms) VP_OVERRIDE
Set new rendering parameters. If the scene has already been initialized, the renderer camera is updat...
Definition
vpObjectCentricRenderer.h:64
vpObjectCentricRenderer::get3DExtents
void get3DExtents(vpTranslationVector &minValues, vpTranslationVector &maxValues)
Definition
vpObjectCentricRenderer.h:91
vpObjectCentricRenderer::computeBoundingBox3DPoints
void computeBoundingBox3DPoints()
Definition
vpObjectCentricRenderer.cpp:80
vpObjectCentricRenderer::setFocusedObject
void setFocusedObject(const std::string &focused)
Definition
vpObjectCentricRenderer.h:71
vpObjectCentricRenderer::placeRenderInto
void placeRenderInto(const vpImage< T > &render, vpImage< T > &target, const T &clearValue)
Definition
vpObjectCentricRenderer.h:119
vpPanda3DBaseRenderer::m_renderParameters
vpPanda3DRenderParameters m_renderParameters
Pointer to owning window, which can create buffers etc. It is not necessarily visible.
Definition
vpPanda3DBaseRenderer.h:292
vpPanda3DRenderParameters
Rendering parameters for a panda3D simulation.
Definition
vpPanda3DRenderParameters.h:58
vpPanda3DRendererSet::vpPanda3DRendererSet
vpPanda3DRendererSet()
Definition
vpPanda3DRendererSet.cpp:39
vpPanda3DRendererSet::setRenderParameters
virtual void setRenderParameters(const vpPanda3DRenderParameters ¶ms) VP_OVERRIDE
Set new rendering parameters. If the scene has already been initialized, the renderer camera is updat...
Definition
vpPanda3DRendererSet.cpp:155
vpPanda3DRendererSet::beforeFrameRendered
virtual void beforeFrameRendered() VP_OVERRIDE
Definition
vpPanda3DRendererSet.h:216
vpRect
Defines a rectangle in the plane.
Definition
vpRect.h:79
vpTranslationVector
Class that consider the case of a translation vector.
Definition
vpTranslationVector.h:119
BEGIN_VISP_NAMESPACE
Definition
vpMbtDistanceCircle.cpp:55
modules
tracker
rbt
include
visp3
rbt
vpObjectCentricRenderer.h
Generated by
1.17.0