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
53b82186
Commit
53b82186
authored
Jan 11, 2014
by
Anatoly Baksheev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
addeed test for text 2d/3d
parent
bb891f05
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
4 deletions
+31
-4
widgets.hpp
modules/viz/include/opencv2/viz/widgets.hpp
+2
-1
shapes.cpp
modules/viz/src/shapes.cpp
+8
-3
tests_simple.cpp
modules/viz/test/tests_simple.cpp
+21
-0
No files found.
modules/viz/include/opencv2/viz/widgets.hpp
View file @
53b82186
...
...
@@ -206,7 +206,7 @@ namespace cv
class
CV_EXPORTS
WText
:
public
Widget2D
{
public
:
WText
(
const
String
&
text
,
const
Point
2i
&
pos
,
int
font_size
=
20
,
const
Color
&
color
=
Color
::
white
());
WText
(
const
String
&
text
,
const
Point
&
pos
,
int
font_size
=
20
,
const
Color
&
color
=
Color
::
white
());
void
setText
(
const
String
&
text
);
String
getText
()
const
;
...
...
@@ -215,6 +215,7 @@ namespace cv
class
CV_EXPORTS
WText3D
:
public
Widget3D
{
public
:
//! creates text label in 3D. If face_camera = false, text plane normal is oriented along z-axis. Use widget pose to orient it properly
WText3D
(
const
String
&
text
,
const
Point3d
&
position
,
double
text_scale
=
1.
,
bool
face_camera
=
true
,
const
Color
&
color
=
Color
::
white
());
void
setText
(
const
String
&
text
);
...
...
modules/viz/src/shapes.cpp
View file @
53b82186
...
...
@@ -135,8 +135,12 @@ cv::viz::WPlane::WPlane(const Vec4d& coefs, double size, const Color &color)
Vec3d
p_center
;
plane
->
GetOrigin
(
p_center
.
val
);
vtkSmartPointer
<
vtkTransformPolyDataFilter
>
filter
=
PlaneUtils
::
setSize
(
p_center
,
plane
->
GetOutputPort
(),
size
);
filter
->
Update
();
vtkSmartPointer
<
vtkPolyDataMapper
>
mapper
=
vtkSmartPointer
<
vtkPolyDataMapper
>::
New
();
mapper
->
SetInputConnection
(
PlaneUtils
::
setSize
(
p_center
,
plane
->
GetOutputPort
(),
size
)
->
GetOutputPor
t
());
VtkUtils
::
SetInputData
(
mapper
,
filter
->
GetOutpu
t
());
vtkSmartPointer
<
vtkActor
>
actor
=
vtkSmartPointer
<
vtkActor
>::
New
();
actor
->
SetMapper
(
mapper
);
...
...
@@ -571,6 +575,7 @@ cv::viz::WText3D::WText3D(const String &text, const Point3d &position, double te
actor
->
SetMapper
(
mapper
);
actor
->
SetPosition
(
position
.
x
,
position
.
y
,
position
.
z
);
actor
->
SetScale
(
text_scale
);
actor
->
GetProperty
()
->
LightingOff
();
WidgetAccessor
::
setProp
(
*
this
,
actor
);
}
...
...
@@ -579,7 +584,7 @@ cv::viz::WText3D::WText3D(const String &text, const Point3d &position, double te
void
cv
::
viz
::
WText3D
::
setText
(
const
String
&
text
)
{
vtk
Follower
*
actor
=
vtkFollowe
r
::
SafeDownCast
(
WidgetAccessor
::
getProp
(
*
this
));
vtk
Actor
*
actor
=
vtkActo
r
::
SafeDownCast
(
WidgetAccessor
::
getProp
(
*
this
));
CV_Assert
(
"This widget does not support text."
&&
actor
);
// Update text source
...
...
@@ -613,7 +618,7 @@ template<> cv::viz::WText3D cv::viz::Widget::cast<cv::viz::WText3D>()
///////////////////////////////////////////////////////////////////////////////////////////////
/// text widget implementation
cv
::
viz
::
WText
::
WText
(
const
String
&
text
,
const
Point
2i
&
pos
,
int
font_size
,
const
Color
&
color
)
cv
::
viz
::
WText
::
WText
(
const
String
&
text
,
const
Point
&
pos
,
int
font_size
,
const
Color
&
color
)
{
vtkSmartPointer
<
vtkTextActor
>
actor
=
vtkSmartPointer
<
vtkTextActor
>::
New
();
actor
->
SetPosition
(
pos
.
x
,
pos
.
y
);
...
...
modules/viz/test/tests_simple.cpp
View file @
53b82186
...
...
@@ -291,6 +291,7 @@ TEST(Viz, DISABLED_show_image_3d)
TEST
(
Viz
,
show_simple_widgets
)
{
Viz3d
viz
(
"show_simple_widgets"
);
viz
.
showWidget
(
"coos"
,
WCoordinateSystem
());
viz
.
showWidget
(
"cube"
,
WCube
());
viz
.
showWidget
(
"cub0"
,
WCube
(
Vec3d
::
all
(
-
1.0
),
Vec3d
::
all
(
-
0.5
),
false
,
Color
::
indigo
()));
...
...
@@ -301,6 +302,26 @@ TEST(Viz, show_simple_widgets)
viz
.
showWidget
(
"cyl0"
,
WCylinder
(
Vec3d
(
-
0.5
,
0.5
,
-
0.5
),
Vec3d
(
0.5
,
0.5
,
-
0.5
),
0.125
,
30
,
Color
::
brown
()));
viz
.
showWidget
(
"con0"
,
WCone
(
0.25
,
0.125
,
6
,
Color
::
azure
()));
viz
.
showWidget
(
"con1"
,
WCone
(
0.125
,
Point3d
(
0.5
,
-
0.5
,
0.5
),
Point3d
(
0.5
,
-
1.0
,
0.5
),
6
,
Color
::
turquoise
()));
viz
.
showWidget
(
"text2d"
,
WText
(
"Simple text"
,
Point
(
20
,
20
),
20
,
Color
::
green
()));
viz
.
showWidget
(
"text3d"
,
WText3D
(
"Simple 3D text"
,
Point3d
(
0.5
,
0.5
,
0.5
),
0.125
,
false
,
Color
::
green
()));
viz
.
spinOnce
(
1500
,
true
);
viz
.
getWidget
(
"text2d"
).
cast
<
WText
>
().
setText
(
"New simple text"
);
viz
.
getWidget
(
"text3d"
).
cast
<
WText3D
>
().
setText
(
"Updated text 3D"
);
viz
.
spin
();
}
TEST
(
Viz
,
show_follower
)
{
Viz3d
viz
(
"show_follower"
);
viz
.
showWidget
(
"coos"
,
WCoordinateSystem
());
viz
.
showWidget
(
"cube"
,
WCube
());
viz
.
showWidget
(
"t3d_2"
,
WText3D
(
"Simple 3D follower"
,
Point3d
(
-
0.5
,
-
0.5
,
0.5
),
0.125
,
true
,
Color
::
green
()));
viz
.
spinOnce
(
1500
,
true
);
//viz.getWidget("t3d_2").cast<WText3D>().setText("Updated follower 3D");
viz
.
spin
();
}
...
...
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