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
7d458e85
Commit
7d458e85
authored
Jul 25, 2013
by
ozantonkal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
trajectory widget display options: display path, display frames, display both
parent
aa2594c0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
39 deletions
+45
-39
widgets.hpp
modules/viz/include/opencv2/viz/widgets.hpp
+3
-1
shape_widgets.cpp
modules/viz/src/shape_widgets.cpp
+42
-38
No files found.
modules/viz/include/opencv2/viz/widgets.hpp
View file @
7d458e85
...
...
@@ -180,7 +180,9 @@ namespace cv
class
CV_EXPORTS
TrajectoryWidget
:
public
Widget3D
{
public
:
TrajectoryWidget
(
const
std
::
vector
<
Affine3f
>
&
path
,
const
Color
&
color
=
Color
::
white
(),
bool
show_frames
=
false
,
double
scale
=
1.0
);
enum
{
DISPLAY_FRAMES
=
1
,
DISPLAY_PATH
=
2
};
TrajectoryWidget
(
const
std
::
vector
<
Affine3f
>
&
path
,
int
display_mode
=
TrajectoryWidget
::
DISPLAY_PATH
,
const
Color
&
color
=
Color
::
white
(),
double
scale
=
1.0
);
TrajectoryWidget
(
const
std
::
vector
<
Affine3f
>
&
path
,
const
Matx33f
&
K
,
double
scale
=
1.0
,
const
Color
&
color
=
Color
::
white
());
// Camera frustums
private
:
...
...
modules/viz/src/shape_widgets.cpp
View file @
7d458e85
...
...
@@ -1162,38 +1162,54 @@ struct cv::viz::TrajectoryWidget::ApplyPath
}
};
cv
::
viz
::
TrajectoryWidget
::
TrajectoryWidget
(
const
std
::
vector
<
Affine3f
>
&
path
,
const
Color
&
color
,
bool
show_frames
,
double
scale
)
cv
::
viz
::
TrajectoryWidget
::
TrajectoryWidget
(
const
std
::
vector
<
Affine3f
>
&
path
,
int
display_mode
,
const
Color
&
color
,
double
scale
)
{
vtkIdType
nr_points
=
path
.
size
();
vtkSmartPointer
<
vtkPoints
>
points
=
vtkSmartPointer
<
vtkPoints
>::
New
();
vtkSmartPointer
<
vtkPolyData
>
polyData
=
vtkSmartPointer
<
vtkPolyData
>::
New
();
vtkSmartPointer
<
vtkPolyLine
>
polyLine
=
vtkSmartPointer
<
vtkPolyLine
>::
New
();
points
->
SetDataTypeToFloat
();
points
->
SetNumberOfPoints
(
nr_points
);
polyLine
->
GetPointIds
()
->
SetNumberOfIds
(
nr_points
);
Vec3f
last_pos
(
0.0
f
,
0.0
f
,
0.0
f
);
Vec3f
*
data_beg
=
vtkpoints_data
<
float
>
(
points
);
*
data_beg
=
path
[
0
]
*
last_pos
;
vtkSmartPointer
<
vtkAppendPolyData
>
appendFilter
=
vtkSmartPointer
<
vtkAppendPolyData
>::
New
();
for
(
vtkIdType
i
=
0
;
i
<
nr_points
;
++
i
)
if
(
display_mode
&
TrajectoryWidget
::
DISPLAY_PATH
)
{
last_pos
=
path
[
i
]
*
last_pos
;
*
data_beg
++
=
last_pos
;
polyLine
->
GetPointIds
()
->
SetId
(
i
,
i
);
}
vtkSmartPointer
<
vtkCellArray
>
cells
=
vtkSmartPointer
<
vtkCellArray
>::
New
();
cells
->
InsertNextCell
(
polyLine
);
// Create a poly line along the path
vtkIdType
nr_points
=
path
.
size
();
polyData
->
SetPoints
(
points
);
polyData
->
SetLines
(
cells
);
vtkSmartPointer
<
vtkPoints
>
points
=
vtkSmartPointer
<
vtkPoints
>::
New
();
vtkSmartPointer
<
vtkPolyData
>
polyData
=
vtkSmartPointer
<
vtkPolyData
>::
New
();
vtkSmartPointer
<
vtkPolyLine
>
polyLine
=
vtkSmartPointer
<
vtkPolyLine
>::
New
();
points
->
SetDataTypeToFloat
();
points
->
SetNumberOfPoints
(
nr_points
);
polyLine
->
GetPointIds
()
->
SetNumberOfIds
(
nr_points
);
Vec3f
last_pos
(
0.0
f
,
0.0
f
,
0.0
f
);
Vec3f
*
data_beg
=
vtkpoints_data
<
float
>
(
points
);
for
(
vtkIdType
i
=
0
;
i
<
nr_points
;
++
i
)
{
last_pos
=
path
[
i
]
*
last_pos
;
*
data_beg
++
=
last_pos
;
polyLine
->
GetPointIds
()
->
SetId
(
i
,
i
);
}
vtkSmartPointer
<
vtkCellArray
>
cells
=
vtkSmartPointer
<
vtkCellArray
>::
New
();
cells
->
InsertNextCell
(
polyLine
);
polyData
->
SetPoints
(
points
);
polyData
->
SetLines
(
cells
);
// Set the color for polyData
vtkSmartPointer
<
vtkUnsignedCharArray
>
colors
=
vtkSmartPointer
<
vtkUnsignedCharArray
>::
New
();
colors
->
SetNumberOfComponents
(
3
);
// TODO Make this more efficient
for
(
int
i
=
0
;
i
<
nr_points
;
++
i
)
colors
->
InsertNextTuple3
(
color
[
2
],
color
[
1
],
color
[
0
]);
polyData
->
GetPointData
()
->
SetScalars
(
colors
);
appendFilter
->
AddInputConnection
(
polyData
->
GetProducerPort
());
}
vtkSmartPointer
<
vtkAppendPolyData
>
appendFilter
=
vtkSmartPointer
<
vtkAppendPolyData
>::
New
();
if
(
show_frames
)
if
(
display_mode
&
TrajectoryWidget
::
DISPLAY_FRAMES
)
{
// Create frames and transform along the path
vtkSmartPointer
<
vtkAxes
>
axes
=
vtkSmartPointer
<
vtkAxes
>::
New
();
axes
->
SetOrigin
(
0
,
0
,
0
);
axes
->
SetScaleFactor
(
scale
);
...
...
@@ -1220,18 +1236,6 @@ cv::viz::TrajectoryWidget::TrajectoryWidget(const std::vector<Affine3f> &path, c
ApplyPath
::
applyPath
(
axes_tubes
->
GetOutput
(),
appendFilter
,
path
);
}
// Set the color for polyData
vtkSmartPointer
<
vtkUnsignedCharArray
>
colors
=
vtkSmartPointer
<
vtkUnsignedCharArray
>::
New
();
colors
->
SetNumberOfComponents
(
3
);
// TODO Make this more efficient
for
(
int
i
=
0
;
i
<
nr_points
;
++
i
)
colors
->
InsertNextTuple3
(
color
[
2
],
color
[
1
],
color
[
0
]);
polyData
->
GetPointData
()
->
SetScalars
(
colors
);
appendFilter
->
AddInputConnection
(
polyData
->
GetProducerPort
());
vtkSmartPointer
<
vtkPolyDataMapper
>
mapper
=
vtkSmartPointer
<
vtkPolyDataMapper
>::
New
();
mapper
->
SetScalarModeToUsePointData
();
mapper
->
SetInput
(
appendFilter
->
GetOutput
());
...
...
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