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
16c8c988
Commit
16c8c988
authored
Jul 22, 2013
by
ozantonkal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
trajectory widget with frustums
parent
f3b228c9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
64 additions
and
4 deletions
+64
-4
widgets.hpp
modules/viz/include/opencv2/viz/widgets.hpp
+1
-2
shape_widgets.cpp
modules/viz/src/shape_widgets.cpp
+63
-2
No files found.
modules/viz/include/opencv2/viz/widgets.hpp
View file @
16c8c988
...
...
@@ -177,8 +177,7 @@ namespace cv
{
public
:
TrajectoryWidget
(
const
std
::
vector
<
Affine3f
>
&
path
,
const
Color
&
color
=
Color
::
white
(),
bool
show_frames
=
false
,
double
scale
=
1.0
);
// TrajectoryWidget(const std::vector<Affine3f> &path, double scale = 1.0);
TrajectoryWidget
(
const
std
::
vector
<
Affine3f
>
&
path
,
const
Matx33f
&
K
);
// Camera frustums
TrajectoryWidget
(
const
std
::
vector
<
Affine3f
>
&
path
,
const
Matx33f
&
K
,
double
scale
=
1.0
,
const
Color
&
color
=
Color
::
white
());
// Camera frustums
};
class
CV_EXPORTS
CloudWidget
:
public
Widget3D
...
...
modules/viz/src/shape_widgets.cpp
View file @
16c8c988
...
...
@@ -908,7 +908,6 @@ cv::viz::CameraPositionWidget::CameraPositionWidget(const Matx33f &K, double sca
frustumSource
->
SetPlanes
(
planes
);
frustumSource
->
Update
();
// Extract the edges so we have the grid
vtkSmartPointer
<
vtkExtractEdges
>
filter
=
vtkSmartPointer
<
vtkExtractEdges
>::
New
();
filter
->
SetInput
(
frustumSource
->
GetOutput
());
filter
->
Update
();
...
...
@@ -1060,4 +1059,66 @@ cv::viz::TrajectoryWidget::TrajectoryWidget(const std::vector<Affine3f> &path, c
WidgetAccessor
::
setProp
(
*
this
,
actor
);
}
cv
::
viz
::
TrajectoryWidget
::
TrajectoryWidget
(
const
std
::
vector
<
Affine3f
>
&
path
,
const
Matx33f
&
K
,
double
scale
,
const
Color
&
color
)
{
vtkIdType
nr_points
=
path
.
size
();
vtkSmartPointer
<
vtkAppendPolyData
>
appendFilter
=
vtkSmartPointer
<
vtkAppendPolyData
>::
New
();
vtkSmartPointer
<
vtkCamera
>
camera
=
vtkSmartPointer
<
vtkCamera
>::
New
();
float
f_x
=
K
(
0
,
0
);
float
f_y
=
K
(
1
,
1
);
float
c_y
=
K
(
1
,
2
);
float
aspect_ratio
=
f_y
/
f_x
;
// Assuming that this is an ideal camera (c_y and c_x are at the center of the image)
float
fovy
=
2.0
f
*
atan2
(
c_y
,
f_y
)
*
180
/
CV_PI
;
camera
->
SetViewAngle
(
fovy
);
camera
->
SetPosition
(
0.0
,
0.0
,
0.0
);
camera
->
SetViewUp
(
0.0
,
1.0
,
0.0
);
camera
->
SetFocalPoint
(
0.0
,
0.0
,
1.0
);
camera
->
SetClippingRange
(
0.01
,
scale
);
double
planesArray
[
24
];
camera
->
GetFrustumPlanes
(
aspect_ratio
,
planesArray
);
vtkSmartPointer
<
vtkMatrix4x4
>
mat_trans
=
vtkSmartPointer
<
vtkMatrix4x4
>::
New
();
mat_trans
->
Identity
();
for
(
vtkIdType
i
=
0
;
i
<
nr_points
;
++
i
)
{
vtkSmartPointer
<
vtkPlanes
>
planes
=
vtkSmartPointer
<
vtkPlanes
>::
New
();
planes
->
SetFrustumPlanes
(
planesArray
);
vtkSmartPointer
<
vtkFrustumSource
>
frustumSource
=
vtkSmartPointer
<
vtkFrustumSource
>::
New
();
frustumSource
->
SetPlanes
(
planes
);
frustumSource
->
Update
();
// Extract the edges
vtkSmartPointer
<
vtkExtractEdges
>
filter
=
vtkSmartPointer
<
vtkExtractEdges
>::
New
();
filter
->
SetInput
(
frustumSource
->
GetOutput
());
filter
->
Update
();
// Transform the default coordinate frame
vtkSmartPointer
<
vtkTransform
>
transform
=
vtkSmartPointer
<
vtkTransform
>::
New
();
transform
->
PreMultiply
();
vtkMatrix4x4
::
Multiply4x4
(
convertToVtkMatrix
(
path
[
i
].
matrix
),
mat_trans
,
mat_trans
);
transform
->
SetMatrix
(
mat_trans
);
vtkSmartPointer
<
vtkTransformPolyDataFilter
>
transform_filter
=
vtkSmartPointer
<
vtkTransformPolyDataFilter
>::
New
();
transform_filter
->
SetInput
(
filter
->
GetOutput
());
transform_filter
->
SetTransform
(
transform
);
transform_filter
->
Update
();
appendFilter
->
AddInputConnection
(
transform_filter
->
GetOutputPort
());
}
vtkSmartPointer
<
vtkPolyDataMapper
>
mapper
=
vtkSmartPointer
<
vtkPolyDataMapper
>::
New
();
mapper
->
SetInput
(
appendFilter
->
GetOutput
());
vtkSmartPointer
<
vtkActor
>
actor
=
vtkSmartPointer
<
vtkActor
>::
New
();
actor
->
SetMapper
(
mapper
);
WidgetAccessor
::
setProp
(
*
this
,
actor
);
setColor
(
color
);
}
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