Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
5813a3a9
Commit
5813a3a9
authored
Jul 10, 2013
by
ozantonkal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
text3D widget implementation
parent
e1859002
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
66 additions
and
0 deletions
+66
-0
widgets.hpp
modules/viz/include/opencv2/viz/widgets.hpp
+10
-0
simple_widgets.cpp
modules/viz/src/simple_widgets.cpp
+53
-0
test_viz3d.cpp
modules/viz/test/test_viz3d.cpp
+3
-0
No files found.
modules/viz/include/opencv2/viz/widgets.hpp
View file @
5813a3a9
...
...
@@ -121,6 +121,15 @@ namespace temp_viz
GridWidget
(
Vec2i
dimensions
,
Vec2d
spacing
,
const
Color
&
color
=
Color
::
white
());
};
class
CV_EXPORTS
Text3DWidget
:
public
Widget3D
{
public
:
Text3DWidget
(
const
String
&
text
,
const
Point3f
&
position
,
double
text_scale
=
1.0
,
const
Color
&
color
=
Color
::
white
());
void
setText
(
const
String
&
text
);
String
getText
()
const
;
};
class
CV_EXPORTS
TextWidget
:
public
Widget2D
{
public
:
...
...
@@ -161,6 +170,7 @@ namespace temp_viz
template
<>
CV_EXPORTS
CoordinateSystemWidget
Widget
::
cast
<
CoordinateSystemWidget
>
();
template
<>
CV_EXPORTS
PolyLineWidget
Widget
::
cast
<
PolyLineWidget
>
();
template
<>
CV_EXPORTS
GridWidget
Widget
::
cast
<
GridWidget
>
();
template
<>
CV_EXPORTS
Text3DWidget
Widget
::
cast
<
Text3DWidget
>
();
template
<>
CV_EXPORTS
TextWidget
Widget
::
cast
<
TextWidget
>
();
template
<>
CV_EXPORTS
CloudWidget
Widget
::
cast
<
CloudWidget
>
();
template
<>
CV_EXPORTS
CloudNormalsWidget
Widget
::
cast
<
CloudNormalsWidget
>
();
...
...
modules/viz/src/simple_widgets.cpp
View file @
5813a3a9
...
...
@@ -450,6 +450,59 @@ template<> temp_viz::GridWidget temp_viz::Widget::cast<temp_viz::GridWidget>()
return
static_cast
<
GridWidget
&>
(
widget
);
}
///////////////////////////////////////////////////////////////////////////////////////////////
/// text3D widget implementation
temp_viz
::
Text3DWidget
::
Text3DWidget
(
const
String
&
text
,
const
Point3f
&
position
,
double
text_scale
,
const
Color
&
color
)
{
vtkSmartPointer
<
vtkVectorText
>
textSource
=
vtkSmartPointer
<
vtkVectorText
>::
New
();
textSource
->
SetText
(
text
.
c_str
());
textSource
->
Update
();
vtkSmartPointer
<
vtkPolyDataMapper
>
mapper
=
vtkSmartPointer
<
vtkPolyDataMapper
>::
New
();
mapper
->
SetInputConnection
(
textSource
->
GetOutputPort
());
vtkSmartPointer
<
vtkFollower
>
actor
=
vtkSmartPointer
<
vtkFollower
>::
New
();
actor
->
SetMapper
(
mapper
);
actor
->
SetPosition
(
position
.
x
,
position
.
y
,
position
.
z
);
actor
->
SetScale
(
text_scale
);
WidgetAccessor
::
setProp
(
*
this
,
actor
);
setColor
(
color
);
}
void
temp_viz
::
Text3DWidget
::
setText
(
const
String
&
text
)
{
vtkFollower
*
actor
=
vtkFollower
::
SafeDownCast
(
WidgetAccessor
::
getProp
(
*
this
));
CV_Assert
(
actor
);
// Update text source
vtkPolyDataMapper
*
mapper
=
vtkPolyDataMapper
::
SafeDownCast
(
actor
->
GetMapper
());
vtkVectorText
*
textSource
=
vtkVectorText
::
SafeDownCast
(
mapper
->
GetInputConnection
(
0
,
0
)
->
GetProducer
());
CV_Assert
(
textSource
);
textSource
->
SetText
(
text
.
c_str
());
textSource
->
Update
();
}
temp_viz
::
String
temp_viz
::
Text3DWidget
::
getText
()
const
{
vtkFollower
*
actor
=
vtkFollower
::
SafeDownCast
(
WidgetAccessor
::
getProp
(
*
this
));
CV_Assert
(
actor
);
vtkPolyDataMapper
*
mapper
=
vtkPolyDataMapper
::
SafeDownCast
(
actor
->
GetMapper
());
vtkVectorText
*
textSource
=
vtkVectorText
::
SafeDownCast
(
mapper
->
GetInputConnection
(
0
,
0
)
->
GetProducer
());
CV_Assert
(
textSource
);
return
textSource
->
GetText
();
}
template
<>
temp_viz
::
Text3DWidget
temp_viz
::
Widget
::
cast
<
temp_viz
::
Text3DWidget
>
()
{
Widget3D
widget
=
this
->
cast
<
Widget3D
>
();
return
static_cast
<
Text3DWidget
&>
(
widget
);
}
///////////////////////////////////////////////////////////////////////////////////////////////
/// text widget implementation
...
...
modules/viz/test/test_viz3d.cpp
View file @
5813a3a9
...
...
@@ -142,6 +142,9 @@ TEST(Viz_viz3d, accuracy)
temp_viz
::
GridWidget
gw
(
temp_viz
::
Vec2i
(
10
,
10
),
temp_viz
::
Vec2d
(
0.1
,
0.1
));
v
.
showWidget
(
"grid"
,
gw
);
lw
=
v
.
getWidget
(
"grid"
).
cast
<
temp_viz
::
LineWidget
>
();
temp_viz
::
Text3DWidget
t3w
(
"OpenCV"
,
cv
::
Point3f
(
0.0
,
2.0
,
0.0
),
1.0
,
temp_viz
::
Color
(
255
,
255
,
0
));
v
.
showWidget
(
"txt3d"
,
t3w
);
// float grid_x_angle = 0.0;
while
(
!
v
.
wasStopped
())
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment