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
26a68232
Commit
26a68232
authored
Jun 21, 2013
by
ozantonkal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
showLine implementation
parent
b387581d
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
42 additions
and
24 deletions
+42
-24
viz3d.hpp
modules/viz/include/opencv2/viz/viz3d.hpp
+2
-0
viz3d_impl.hpp
modules/viz/src/q/viz3d_impl.hpp
+2
-1
viz3d.cpp
modules/viz/src/viz3d.cpp
+5
-0
viz3d_impl.cpp
modules/viz/src/viz3d_impl.cpp
+29
-20
test_viz3d.cpp
modules/viz/test/test_viz3d.cpp
+4
-3
No files found.
modules/viz/include/opencv2/viz/viz3d.hpp
View file @
26a68232
...
...
@@ -31,6 +31,8 @@ namespace temp_viz
void
showPointCloud
(
const
String
&
id
,
InputArray
cloud
,
const
Color
&
color
,
const
Affine3f
&
pose
=
Affine3f
::
Identity
());
bool
addPointCloudNormals
(
const
Mat
&
cloud
,
const
Mat
&
normals
,
int
level
=
100
,
float
scale
=
0.02
f
,
const
String
&
id
=
"cloud"
);
void
showLine
(
const
String
&
id
,
const
Point3f
&
pt1
,
const
Point3f
&
pt2
,
const
Color
&
color
);
bool
addPlane
(
const
ModelCoefficients
&
coefficients
,
const
String
&
id
=
"plane"
);
bool
addPlane
(
const
ModelCoefficients
&
coefficients
,
double
x
,
double
y
,
double
z
,
const
String
&
id
=
"plane"
);
...
...
modules/viz/src/q/viz3d_impl.hpp
View file @
26a68232
...
...
@@ -137,9 +137,10 @@ public:
// This tends to close the window...
interactor_
->
TerminateApp
();
}
void
showLine
(
const
String
&
id
,
const
cv
::
Point3f
&
pt1
,
const
cv
::
Point3f
&
pt2
,
const
Color
&
color
);
bool
addPolygon
(
const
cv
::
Mat
&
cloud
,
const
Color
&
color
,
const
std
::
string
&
id
=
"polygon"
);
bool
addLine
(
const
cv
::
Point3f
&
pt1
,
const
cv
::
Point3f
&
pt2
,
const
Color
&
color
,
const
std
::
string
&
id
=
"line"
);
bool
addArrow
(
const
cv
::
Point3f
&
pt1
,
const
cv
::
Point3f
&
pt2
,
const
Color
&
color
,
bool
display_length
,
const
std
::
string
&
id
=
"arrow"
);
bool
addArrow
(
const
cv
::
Point3f
&
pt1
,
const
cv
::
Point3f
&
pt2
,
const
Color
&
color_line
,
const
Color
&
color_text
,
const
std
::
string
&
id
=
"arrow"
);
bool
addSphere
(
const
cv
::
Point3f
&
center
,
float
radius
,
const
Color
&
color
,
const
std
::
string
&
id
=
"sphere"
);
...
...
modules/viz/src/viz3d.cpp
View file @
26a68232
...
...
@@ -78,6 +78,11 @@ void temp_viz::Viz3d::spinOnce (int time, bool force_redraw)
impl_
->
spinOnce
(
time
,
force_redraw
);
}
void
temp_viz
::
Viz3d
::
showLine
(
const
String
&
id
,
const
Point3f
&
pt1
,
const
Point3f
&
pt2
,
const
Color
&
color
)
{
impl_
->
showLine
(
id
,
pt1
,
pt2
,
color
);
}
bool
temp_viz
::
Viz3d
::
addPlane
(
const
ModelCoefficients
&
coefficients
,
const
String
&
id
)
{
return
impl_
->
addPlane
(
coefficients
,
id
);
...
...
modules/viz/src/viz3d_impl.cpp
View file @
26a68232
...
...
@@ -266,33 +266,42 @@ bool temp_viz::Viz3d::VizImpl::addPointCloudNormals (const cv::Mat &cloud, const
}
////////////////////////////////////////////////////////////////////////////////////////////
bool
temp_viz
::
Viz3d
::
VizImpl
::
addLine
(
const
cv
::
Point3f
&
pt1
,
const
cv
::
Point3f
&
pt2
,
const
Color
&
color
,
const
std
::
string
&
id
)
void
temp_viz
::
Viz3d
::
VizImpl
::
showLine
(
const
String
&
id
,
const
cv
::
Point3f
&
pt1
,
const
cv
::
Point3f
&
pt2
,
const
Color
&
color
)
{
// Check
to see if this ID entry already exists (has it been already added to the visualizer?)
// Check
if this Id already exists
ShapeActorMap
::
iterator
am_it
=
shape_actor_map_
->
find
(
id
);
if
(
am_it
!=
shape_actor_map_
->
end
())
return
std
::
cout
<<
"[addLine] A shape with id <"
<<
id
<<
"> already exists! Please choose a different id and retry."
<<
std
::
endl
,
false
;
vtkSmartPointer
<
vtkDataSet
>
data
=
createLine
(
pt1
,
pt2
);
bool
exists
=
(
am_it
!=
shape_actor_map_
->
end
());
// If it exists just update
if
(
exists
)
{
vtkSmartPointer
<
vtkLODActor
>
actor
=
vtkLODActor
::
SafeDownCast
(
am_it
->
second
);
reinterpret_cast
<
vtkDataSetMapper
*>
(
actor
->
GetMapper
())
->
SetInput
(
createLine
(
pt1
,
pt2
));
Color
c
=
vtkcolor
(
color
);
actor
->
GetProperty
()
->
SetColor
(
c
.
val
);
actor
->
GetMapper
()
->
ScalarVisibilityOff
();
actor
->
Modified
();
}
else
{
// Create new line
vtkSmartPointer
<
vtkDataSet
>
data
=
createLine
(
pt1
,
pt2
);
// Create an Actor
vtkSmartPointer
<
vtkLODActor
>
actor
;
createActorFromVTKDataSet
(
data
,
actor
);
actor
->
GetProperty
()
->
SetRepresentationToWireframe
();
// Create an Actor
vtkSmartPointer
<
vtkLODActor
>
actor
;
createActorFromVTKDataSet
(
data
,
actor
);
actor
->
GetProperty
()
->
SetRepresentationToWireframe
();
Color
c
=
vtkcolor
(
color
);
actor
->
GetProperty
()
->
SetColor
(
c
.
val
);
actor
->
GetMapper
()
->
ScalarVisibilityOff
();
renderer_
->
AddActor
(
actor
);
Color
c
=
vtkcolor
(
color
);
actor
->
GetProperty
()
->
SetColor
(
c
.
val
);
actor
->
GetMapper
()
->
ScalarVisibilityOff
();
renderer_
->
AddActor
(
actor
);
// Save the pointer/ID pair to the global actor map
(
*
shape_actor_map_
)[
id
]
=
actor
;
return
(
true
);
// Save the pointer/ID pair to the global actor map
(
*
shape_actor_map_
)[
id
]
=
actor
;
}
}
bool
temp_viz
::
Viz3d
::
VizImpl
::
addPolygonMesh
(
const
Mesh3d
&
mesh
,
const
Mat
&
mask
,
const
std
::
string
&
id
)
{
CV_Assert
(
mesh
.
cloud
.
type
()
==
CV_32FC3
&&
mesh
.
cloud
.
rows
==
1
&&
!
mesh
.
polygons
.
empty
());
...
...
modules/viz/test/test_viz3d.cpp
View file @
26a68232
...
...
@@ -86,18 +86,19 @@ TEST(Viz_viz3d, accuracy)
float
pos_x
=
0.0
f
;
float
pos_y
=
0.0
f
;
float
pos_z
=
0.0
f
;
temp_viz
::
Mesh3d
::
Ptr
mesh
=
temp_viz
::
mesh_load
(
"d:/horse.ply"
);
v
.
addPolygonMesh
(
*
mesh
,
"pq"
);
//
temp_viz::Mesh3d::Ptr mesh = temp_viz::mesh_load("d:/horse.ply");
//
v.addPolygonMesh(*mesh, "pq");
int
col_blue
=
0
;
int
col_green
=
0
;
int
col_red
=
0
;
while
(
!
v
.
wasStopped
())
{
// Creating new point cloud with id cloud1
cv
::
Affine3f
cloudPosition
(
angle_x
,
angle_y
,
angle_z
,
cv
::
Vec3f
(
pos_x
,
pos_y
,
pos_z
));
v
.
showPointCloud
(
"cloud1"
,
cloud
,
temp_viz
::
Color
(
col_blue
,
col_green
,
col_red
),
cloudPosition
);
v
.
showLine
(
"line1"
,
cv
::
Point3f
(
0.0
,
0.0
,
0.0
),
cv
::
Point3f
(
pos_x
,
pos_y
,
pos_z
)
,
temp_viz
::
Color
(
255
-
col_blue
,
255
-
col_green
,
255
-
col_red
));
angle_x
+=
0.1
f
;
angle_y
-=
0.1
f
;
...
...
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