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
f6e9b811
Commit
f6e9b811
authored
Dec 01, 2013
by
Anatoly Baksheev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
reduced exported interface names (to make IntelliSense hints less littered)
parent
44c1d4df
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
73 additions
and
98 deletions
+73
-98
widgets.hpp
modules/viz/include/opencv2/viz/widgets.hpp
+0
-29
cloud_widgets.cpp
modules/viz/src/cloud_widgets.cpp
+34
-20
shape_widgets.cpp
modules/viz/src/shape_widgets.cpp
+36
-21
widget.cpp
modules/viz/src/widget.cpp
+3
-28
No files found.
modules/viz/include/opencv2/viz/widgets.hpp
View file @
f6e9b811
...
...
@@ -119,8 +119,6 @@ namespace cv
Affine3f
getPose
()
const
;
void
setColor
(
const
Color
&
color
);
private
:
struct
MatrixConverter
;
};
...
...
@@ -145,8 +143,6 @@ namespace cv
public
:
WPlane
(
const
Vec4f
&
coefs
,
float
size
=
1.
f
,
const
Color
&
color
=
Color
::
white
());
WPlane
(
const
Vec4f
&
coefs
,
const
Point3f
&
pt
,
float
size
=
1.
f
,
const
Color
&
color
=
Color
::
white
());
private
:
struct
SetSizeImpl
;
};
class
CV_EXPORTS
WSphere
:
public
Widget3D
...
...
@@ -189,9 +185,6 @@ namespace cv
{
public
:
WPolyLine
(
InputArray
points
,
const
Color
&
color
=
Color
::
white
());
private
:
struct
CopyImpl
;
};
class
CV_EXPORTS
WGrid
:
public
Widget3D
...
...
@@ -201,10 +194,6 @@ namespace cv
WGrid
(
const
Vec2i
&
dimensions
,
const
Vec2d
&
spacing
,
const
Color
&
color
=
Color
::
white
());
//! Creates grid based on the plane equation
WGrid
(
const
Vec4f
&
coeffs
,
const
Vec2i
&
dimensions
,
const
Vec2d
&
spacing
,
const
Color
&
color
=
Color
::
white
());
private
:
struct
GridImpl
;
};
class
CV_EXPORTS
WText3D
:
public
Widget3D
...
...
@@ -257,9 +246,6 @@ namespace cv
WCameraPosition
(
const
Matx33f
&
K
,
const
Mat
&
img
,
float
scale
=
1.
f
,
const
Color
&
color
=
Color
::
white
());
//! Creates frustum and display given image at the far plane
WCameraPosition
(
const
Vec2f
&
fov
,
const
Mat
&
img
,
float
scale
=
1.
f
,
const
Color
&
color
=
Color
::
white
());
private
:
struct
ProjectImage
;
};
class
CV_EXPORTS
WTrajectory
:
public
Widget3D
...
...
@@ -273,9 +259,6 @@ namespace cv
WTrajectory
(
const
std
::
vector
<
Affine3f
>
&
path
,
const
Matx33f
&
K
,
float
scale
=
1.
f
,
const
Color
&
color
=
Color
::
white
());
//! Displays trajectory of the given path by frustums
WTrajectory
(
const
std
::
vector
<
Affine3f
>
&
path
,
const
Vec2f
&
fov
,
float
scale
=
1.
f
,
const
Color
&
color
=
Color
::
white
());
private
:
struct
ApplyPath
;
};
class
CV_EXPORTS
WSpheresTrajectory
:
public
Widget3D
...
...
@@ -292,9 +275,6 @@ namespace cv
WCloud
(
InputArray
cloud
,
InputArray
colors
);
//! All points in cloud have the same color
WCloud
(
InputArray
cloud
,
const
Color
&
color
=
Color
::
white
());
private
:
struct
CreateCloudWidget
;
};
class
CV_EXPORTS
WCloudCollection
:
public
Widget3D
...
...
@@ -306,27 +286,18 @@ namespace cv
void
addCloud
(
InputArray
cloud
,
InputArray
colors
,
const
Affine3f
&
pose
=
Affine3f
::
Identity
());
//! All points in cloud have the same color
void
addCloud
(
InputArray
cloud
,
const
Color
&
color
=
Color
::
white
(),
const
Affine3f
&
pose
=
Affine3f
::
Identity
());
private
:
struct
CreateCloudWidget
;
};
class
CV_EXPORTS
WCloudNormals
:
public
Widget3D
{
public
:
WCloudNormals
(
InputArray
cloud
,
InputArray
normals
,
int
level
=
100
,
float
scale
=
0.02
f
,
const
Color
&
color
=
Color
::
white
());
private
:
struct
ApplyCloudNormals
;
};
class
CV_EXPORTS
WMesh
:
public
Widget3D
{
public
:
WMesh
(
const
Mesh3d
&
mesh
);
private
:
struct
CopyImpl
;
};
template
<>
CV_EXPORTS
Widget2D
Widget
::
cast
<
Widget2D
>
();
...
...
modules/viz/src/cloud_widgets.cpp
View file @
f6e9b811
...
...
@@ -59,8 +59,10 @@ namespace cv
///////////////////////////////////////////////////////////////////////////////////////////////
/// Point Cloud Widget implementation
struct
cv
::
viz
::
WCloud
::
CreateCloudWidget
namespace
cv
{
namespace
viz
{
namespace
{
struct
CloudUtils
{
static
inline
vtkSmartPointer
<
vtkPolyData
>
create
(
const
Mat
&
cloud
,
vtkIdType
&
nr_points
)
{
vtkSmartPointer
<
vtkPolyData
>
polydata
=
vtkSmartPointer
<
vtkPolyData
>::
New
();
...
...
@@ -144,7 +146,9 @@ struct cv::viz::WCloud::CreateCloudWidget
vertices
->
SetCells
(
nr_points
,
cells
);
return
polydata
;
}
};
};
}}}
cv
::
viz
::
WCloud
::
WCloud
(
InputArray
_cloud
,
InputArray
_colors
)
{
...
...
@@ -160,7 +164,7 @@ cv::viz::WCloud::WCloud(InputArray _cloud, InputArray _colors)
}
vtkIdType
nr_points
;
vtkSmartPointer
<
vtkPolyData
>
polydata
=
C
reateCloudWidget
::
create
(
cloud
,
nr_points
);
vtkSmartPointer
<
vtkPolyData
>
polydata
=
C
loudUtils
::
create
(
cloud
,
nr_points
);
// Filter colors
Vec3b
*
colors_data
=
new
Vec3b
[
nr_points
];
...
...
@@ -207,7 +211,7 @@ cv::viz::WCloud::WCloud(InputArray _cloud, const Color &color)
CV_Assert
(
cloud
.
type
()
==
CV_32FC3
||
cloud
.
type
()
==
CV_64FC3
||
cloud
.
type
()
==
CV_32FC4
||
cloud
.
type
()
==
CV_64FC4
);
vtkIdType
nr_points
;
vtkSmartPointer
<
vtkPolyData
>
polydata
=
C
reateCloudWidget
::
create
(
cloud
,
nr_points
);
vtkSmartPointer
<
vtkPolyData
>
polydata
=
C
loudUtils
::
create
(
cloud
,
nr_points
);
vtkSmartPointer
<
vtkDataSetMapper
>
mapper
=
vtkSmartPointer
<
vtkDataSetMapper
>::
New
();
#if VTK_MAJOR_VERSION <= 5
...
...
@@ -242,8 +246,10 @@ template<> cv::viz::WCloud cv::viz::Widget::cast<cv::viz::WCloud>()
///////////////////////////////////////////////////////////////////////////////////////////////
/// Cloud Collection Widget implementation
struct
cv
::
viz
::
WCloudCollection
::
CreateCloudWidget
namespace
cv
{
namespace
viz
{
namespace
{
struct
CloudCollectionUtils
{
static
inline
vtkSmartPointer
<
vtkPolyData
>
create
(
const
Mat
&
cloud
,
vtkIdType
&
nr_points
)
{
vtkSmartPointer
<
vtkPolyData
>
polydata
=
vtkSmartPointer
<
vtkPolyData
>::
New
();
...
...
@@ -374,7 +380,8 @@ struct cv::viz::WCloudCollection::CreateCloudWidget
vtkIdType
old_cloud_points
=
actor
->
GetNumberOfCloudPoints
();
actor
->
SetNumberOfCloudPoints
(
int
(
std
::
max
<
vtkIdType
>
(
1
,
old_cloud_points
+
poly_data
->
GetNumberOfPoints
()
/
10
)));
}
};
};
}}}
cv
::
viz
::
WCloudCollection
::
WCloudCollection
()
{
...
...
@@ -397,7 +404,7 @@ void cv::viz::WCloudCollection::addCloud(InputArray _cloud, InputArray _colors,
}
vtkIdType
nr_points
;
vtkSmartPointer
<
vtkPolyData
>
polydata
=
C
reateCloudWidget
::
create
(
cloud
,
nr_points
);
vtkSmartPointer
<
vtkPolyData
>
polydata
=
C
loudCollectionUtils
::
create
(
cloud
,
nr_points
);
// Filter colors
Vec3b
*
colors_data
=
new
Vec3b
[
nr_points
];
...
...
@@ -429,7 +436,7 @@ void cv::viz::WCloudCollection::addCloud(InputArray _cloud, InputArray _colors,
CV_Assert
(
"Incompatible widget type."
&&
actor
);
Vec3d
minmax
(
scalars
->
GetRange
());
C
reateCloudWidget
::
createMapper
(
actor
,
transform_filter
->
GetOutput
(),
minmax
);
C
loudCollectionUtils
::
createMapper
(
actor
,
transform_filter
->
GetOutput
(),
minmax
);
}
void
cv
::
viz
::
WCloudCollection
::
addCloud
(
InputArray
_cloud
,
const
Color
&
color
,
const
Affine3f
&
pose
)
...
...
@@ -438,7 +445,7 @@ void cv::viz::WCloudCollection::addCloud(InputArray _cloud, const Color &color,
CV_Assert
(
cloud
.
type
()
==
CV_32FC3
||
cloud
.
type
()
==
CV_64FC3
||
cloud
.
type
()
==
CV_32FC4
||
cloud
.
type
()
==
CV_64FC4
);
vtkIdType
nr_points
;
vtkSmartPointer
<
vtkPolyData
>
polydata
=
C
reateCloudWidget
::
create
(
cloud
,
nr_points
);
vtkSmartPointer
<
vtkPolyData
>
polydata
=
C
loudCollectionUtils
::
create
(
cloud
,
nr_points
);
vtkSmartPointer
<
vtkUnsignedCharArray
>
scalars
=
vtkSmartPointer
<
vtkUnsignedCharArray
>::
New
();
scalars
->
SetNumberOfComponents
(
3
);
...
...
@@ -468,7 +475,7 @@ void cv::viz::WCloudCollection::addCloud(InputArray _cloud, const Color &color,
CV_Assert
(
"Incompatible widget type."
&&
actor
);
Vec3d
minmax
(
scalars
->
GetRange
());
C
reateCloudWidget
::
createMapper
(
actor
,
transform_filter
->
GetOutput
(),
minmax
);
C
loudCollectionUtils
::
createMapper
(
actor
,
transform_filter
->
GetOutput
(),
minmax
);
}
template
<>
cv
::
viz
::
WCloudCollection
cv
::
viz
::
Widget
::
cast
<
cv
::
viz
::
WCloudCollection
>
()
...
...
@@ -480,8 +487,10 @@ template<> cv::viz::WCloudCollection cv::viz::Widget::cast<cv::viz::WCloudCollec
///////////////////////////////////////////////////////////////////////////////////////////////
/// Cloud Normals Widget implementation
struct
cv
::
viz
::
WCloudNormals
::
ApplyCloudNormals
namespace
cv
{
namespace
viz
{
namespace
{
struct
CloudNormalsUtils
{
template
<
typename
_Tp
>
struct
Impl
{
...
...
@@ -549,11 +558,13 @@ struct cv::viz::WCloudNormals::ApplyCloudNormals
static
inline
vtkSmartPointer
<
vtkCellArray
>
apply
(
const
Mat
&
cloud
,
const
Mat
&
normals
,
int
level
,
float
scale
,
_Tp
*&
pts
,
vtkIdType
&
nr_normals
)
{
if
(
cloud
.
cols
>
1
&&
cloud
.
rows
>
1
)
return
ApplyCloudNorma
ls
::
Impl
<
_Tp
>::
applyOrganized
(
cloud
,
normals
,
level
,
scale
,
pts
,
nr_normals
);
return
CloudNormalsUti
ls
::
Impl
<
_Tp
>::
applyOrganized
(
cloud
,
normals
,
level
,
scale
,
pts
,
nr_normals
);
else
return
ApplyCloudNorma
ls
::
Impl
<
_Tp
>::
applyUnorganized
(
cloud
,
normals
,
level
,
scale
,
pts
,
nr_normals
);
return
CloudNormalsUti
ls
::
Impl
<
_Tp
>::
applyUnorganized
(
cloud
,
normals
,
level
,
scale
,
pts
,
nr_normals
);
}
};
};
}}}
cv
::
viz
::
WCloudNormals
::
WCloudNormals
(
InputArray
_cloud
,
InputArray
_normals
,
int
level
,
float
scale
,
const
Color
&
color
)
{
...
...
@@ -574,7 +585,7 @@ cv::viz::WCloudNormals::WCloudNormals(InputArray _cloud, InputArray _normals, in
data
->
SetNumberOfComponents
(
3
);
float
*
pts
=
0
;
lines
=
ApplyCloudNorma
ls
::
apply
(
cloud
,
normals
,
level
,
scale
,
pts
,
nr_normals
);
lines
=
CloudNormalsUti
ls
::
apply
(
cloud
,
normals
,
level
,
scale
,
pts
,
nr_normals
);
data
->
SetArray
(
&
pts
[
0
],
2
*
nr_normals
*
3
,
0
);
points
->
SetData
(
data
);
}
...
...
@@ -586,7 +597,7 @@ cv::viz::WCloudNormals::WCloudNormals(InputArray _cloud, InputArray _normals, in
data
->
SetNumberOfComponents
(
3
);
double
*
pts
=
0
;
lines
=
ApplyCloudNorma
ls
::
apply
(
cloud
,
normals
,
level
,
scale
,
pts
,
nr_normals
);
lines
=
CloudNormalsUti
ls
::
apply
(
cloud
,
normals
,
level
,
scale
,
pts
,
nr_normals
);
data
->
SetArray
(
&
pts
[
0
],
2
*
nr_normals
*
3
,
0
);
points
->
SetData
(
data
);
}
...
...
@@ -619,8 +630,10 @@ template<> cv::viz::WCloudNormals cv::viz::Widget::cast<cv::viz::WCloudNormals>(
///////////////////////////////////////////////////////////////////////////////////////////////
/// Mesh Widget implementation
struct
cv
::
viz
::
WMesh
::
CopyImpl
namespace
cv
{
namespace
viz
{
namespace
{
struct
MeshUtils
{
template
<
typename
_Tp
>
static
Vec
<
_Tp
,
3
>
*
copy
(
const
Mat
&
source
,
Vec
<
_Tp
,
3
>
*
output
,
int
*
look_up
,
const
Mat
&
nan_mask
)
{
...
...
@@ -646,7 +659,8 @@ struct cv::viz::WMesh::CopyImpl
}
return
output
;
}
};
};
}}}
cv
::
viz
::
WMesh
::
WMesh
(
const
Mesh3d
&
mesh
)
{
...
...
@@ -665,14 +679,14 @@ cv::viz::WMesh::WMesh(const Mesh3d &mesh)
{
points
->
SetDataTypeToFloat
();
Vec3f
*
data_beg
=
vtkpoints_data
<
float
>
(
points
);
Vec3f
*
data_end
=
CopyImpl
::
copy
(
mesh
.
cloud
,
data_beg
,
look_up
,
mesh
.
cloud
);
Vec3f
*
data_end
=
MeshUtils
::
copy
(
mesh
.
cloud
,
data_beg
,
look_up
,
mesh
.
cloud
);
nr_points
=
data_end
-
data_beg
;
}
else
{
points
->
SetDataTypeToDouble
();
Vec3d
*
data_beg
=
vtkpoints_data
<
double
>
(
points
);
Vec3d
*
data_end
=
CopyImpl
::
copy
(
mesh
.
cloud
,
data_beg
,
look_up
,
mesh
.
cloud
);
Vec3d
*
data_end
=
MeshUtils
::
copy
(
mesh
.
cloud
,
data_beg
,
look_up
,
mesh
.
cloud
);
nr_points
=
data_end
-
data_beg
;
}
...
...
modules/viz/src/shape_widgets.cpp
View file @
f6e9b811
...
...
@@ -84,8 +84,10 @@ template<> cv::viz::WLine cv::viz::Widget::cast<cv::viz::WLine>()
///////////////////////////////////////////////////////////////////////////////////////////////
/// plane widget implementation
struct
cv
::
viz
::
WPlane
::
SetSizeImpl
namespace
cv
{
namespace
viz
{
namespace
{
struct
PlaneUtils
{
template
<
typename
_Tp
>
static
vtkSmartPointer
<
vtkTransformPolyDataFilter
>
setSize
(
const
Vec
<
_Tp
,
3
>
&
center
,
vtkSmartPointer
<
vtkAlgorithmOutput
>
poly_data_port
,
double
size
)
{
...
...
@@ -102,7 +104,8 @@ struct cv::viz::WPlane::SetSizeImpl
return
transform_filter
;
}
};
};
}}}
cv
::
viz
::
WPlane
::
WPlane
(
const
Vec4f
&
coefs
,
float
size
,
const
Color
&
color
)
{
...
...
@@ -115,7 +118,7 @@ cv::viz::WPlane::WPlane(const Vec4f& coefs, float size, const Color &color)
plane
->
GetOrigin
(
p_center
.
val
);
vtkSmartPointer
<
vtkDataSetMapper
>
mapper
=
vtkSmartPointer
<
vtkDataSetMapper
>::
New
();
mapper
->
SetInputConnection
(
SetSizeImpl
::
setSize
(
p_center
,
plane
->
GetOutputPort
(),
size
)
->
GetOutputPort
());
mapper
->
SetInputConnection
(
PlaneUtils
::
setSize
(
p_center
,
plane
->
GetOutputPort
(),
size
)
->
GetOutputPort
());
vtkSmartPointer
<
vizActor
>
actor
=
vtkSmartPointer
<
vizActor
>::
New
();
actor
->
SetMapper
(
mapper
);
...
...
@@ -136,7 +139,7 @@ cv::viz::WPlane::WPlane(const Vec4f& coefs, const Point3f& pt, float size, const
plane
->
SetCenter
(
p_center
[
0
],
p_center
[
1
],
p_center
[
2
]);
vtkSmartPointer
<
vtkDataSetMapper
>
mapper
=
vtkSmartPointer
<
vtkDataSetMapper
>::
New
();
mapper
->
SetInputConnection
(
SetSizeImpl
::
setSize
(
p_center
,
plane
->
GetOutputPort
(),
size
)
->
GetOutputPort
());
mapper
->
SetInputConnection
(
PlaneUtils
::
setSize
(
p_center
,
plane
->
GetOutputPort
(),
size
)
->
GetOutputPort
());
vtkSmartPointer
<
vizActor
>
actor
=
vtkSmartPointer
<
vizActor
>::
New
();
actor
->
SetMapper
(
mapper
);
...
...
@@ -406,8 +409,10 @@ template<> cv::viz::WCoordinateSystem cv::viz::Widget::cast<cv::viz::WCoordinate
///////////////////////////////////////////////////////////////////////////////////////////////
/// polyline widget implementation
struct
cv
::
viz
::
WPolyLine
::
CopyImpl
namespace
cv
{
namespace
viz
{
namespace
{
struct
PolyLineUtils
{
template
<
typename
_Tp
>
static
void
copy
(
const
Mat
&
source
,
Vec
<
_Tp
,
3
>
*
output
,
vtkSmartPointer
<
vtkPolyLine
>
polyLine
)
{
...
...
@@ -424,7 +429,8 @@ struct cv::viz::WPolyLine::CopyImpl
}
}
}
};
};
}}}
cv
::
viz
::
WPolyLine
::
WPolyLine
(
InputArray
_pointData
,
const
Color
&
color
)
{
...
...
@@ -448,13 +454,13 @@ cv::viz::WPolyLine::WPolyLine(InputArray _pointData, const Color &color)
{
// Get a pointer to the beginning of the data array
Vec3f
*
data_beg
=
vtkpoints_data
<
float
>
(
points
);
CopyImpl
::
copy
(
pointData
,
data_beg
,
polyLine
);
PolyLineUtils
::
copy
(
pointData
,
data_beg
,
polyLine
);
}
else
if
(
pointData
.
depth
()
==
CV_64F
)
{
// Get a pointer to the beginning of the data array
Vec3d
*
data_beg
=
vtkpoints_data
<
double
>
(
points
);
CopyImpl
::
copy
(
pointData
,
data_beg
,
polyLine
);
PolyLineUtils
::
copy
(
pointData
,
data_beg
,
polyLine
);
}
vtkSmartPointer
<
vtkCellArray
>
cells
=
vtkSmartPointer
<
vtkCellArray
>::
New
();
...
...
@@ -486,8 +492,10 @@ template<> cv::viz::WPolyLine cv::viz::Widget::cast<cv::viz::WPolyLine>()
///////////////////////////////////////////////////////////////////////////////////////////////
/// grid widget implementation
struct
cv
::
viz
::
WGrid
::
GridImpl
namespace
cv
{
namespace
viz
{
namespace
{
struct
GridUtils
{
static
vtkSmartPointer
<
vtkPolyData
>
createGrid
(
const
Vec2i
&
dimensions
,
const
Vec2d
&
spacing
)
{
// Create the grid using image data
...
...
@@ -511,11 +519,12 @@ struct cv::viz::WGrid::GridImpl
filter
->
Update
();
return
filter
->
GetOutput
();
}
};
};
}}}
cv
::
viz
::
WGrid
::
WGrid
(
const
Vec2i
&
dimensions
,
const
Vec2d
&
spacing
,
const
Color
&
color
)
{
vtkSmartPointer
<
vtkPolyData
>
grid
=
Grid
Impl
::
createGrid
(
dimensions
,
spacing
);
vtkSmartPointer
<
vtkPolyData
>
grid
=
Grid
Utils
::
createGrid
(
dimensions
,
spacing
);
vtkSmartPointer
<
vtkDataSetMapper
>
mapper
=
vtkSmartPointer
<
vtkDataSetMapper
>::
New
();
#if VTK_MAJOR_VERSION <= 5
...
...
@@ -533,7 +542,7 @@ cv::viz::WGrid::WGrid(const Vec2i &dimensions, const Vec2d &spacing, const Color
cv
::
viz
::
WGrid
::
WGrid
(
const
Vec4f
&
coefs
,
const
Vec2i
&
dimensions
,
const
Vec2d
&
spacing
,
const
Color
&
color
)
{
vtkSmartPointer
<
vtkPolyData
>
grid
=
Grid
Impl
::
createGrid
(
dimensions
,
spacing
);
vtkSmartPointer
<
vtkPolyData
>
grid
=
Grid
Utils
::
createGrid
(
dimensions
,
spacing
);
// Estimate the transform to set the normal based on the coefficients
Vec3f
normal
(
coefs
[
0
],
coefs
[
1
],
coefs
[
2
]);
...
...
@@ -938,8 +947,10 @@ template<> cv::viz::WImage3D cv::viz::Widget::cast<cv::viz::WImage3D>()
///////////////////////////////////////////////////////////////////////////////////////////////
/// camera position widget implementation
struct
cv
::
viz
::
WCameraPosition
::
ProjectImag
e
namespace
cv
{
namespace
viz
{
namespac
e
{
struct
CameraPositionUtils
{
static
void
projectImage
(
float
fovy
,
float
far_end_height
,
const
Mat
&
image
,
double
scale
,
const
Color
&
color
,
vtkSmartPointer
<
vtkActor
>
actor
)
{
...
...
@@ -1030,7 +1041,8 @@ struct cv::viz::WCameraPosition::ProjectImage
actor
->
SetMapper
(
planeMapper
);
actor
->
SetTexture
(
texture
);
}
};
};
}}}
cv
::
viz
::
WCameraPosition
::
WCameraPosition
(
float
scale
)
{
...
...
@@ -1164,7 +1176,7 @@ cv::viz::WCameraPosition::WCameraPosition(const Matx33f &K, const Mat &image, fl
float
far_end_height
=
2.0
f
*
c_y
*
scale
/
f_y
;
vtkSmartPointer
<
vtkActor
>
actor
=
vtkSmartPointer
<
vtkActor
>::
New
();
ProjectImage
::
projectImage
(
fovy
,
far_end_height
,
image
,
scale
,
color
,
actor
);
CameraPositionUtils
::
projectImage
(
fovy
,
far_end_height
,
image
,
scale
,
color
,
actor
);
WidgetAccessor
::
setProp
(
*
this
,
actor
);
}
...
...
@@ -1175,7 +1187,7 @@ cv::viz::WCameraPosition::WCameraPosition(const Vec2f &fov, const Mat &image, fl
float
far_end_height
=
2.0
*
scale
*
tan
(
fov
[
1
]
*
0.5
);
vtkSmartPointer
<
vtkActor
>
actor
=
vtkSmartPointer
<
vtkActor
>::
New
();
ProjectImage
::
projectImage
(
fovy
,
far_end_height
,
image
,
scale
,
color
,
actor
);
CameraPositionUtils
::
projectImage
(
fovy
,
far_end_height
,
image
,
scale
,
color
,
actor
);
WidgetAccessor
::
setProp
(
*
this
,
actor
);
}
...
...
@@ -1188,8 +1200,10 @@ template<> cv::viz::WCameraPosition cv::viz::Widget::cast<cv::viz::WCameraPositi
///////////////////////////////////////////////////////////////////////////////////////////////
/// trajectory widget implementation
struct
cv
::
viz
::
WTrajectory
::
ApplyPath
namespace
cv
{
namespace
viz
{
namespace
{
struct
TrajectoryUtils
{
static
void
applyPath
(
vtkSmartPointer
<
vtkPolyData
>
poly_data
,
vtkSmartPointer
<
vtkAppendPolyData
>
append_filter
,
const
std
::
vector
<
Affine3f
>
&
path
)
{
vtkIdType
nr_points
=
path
.
size
();
...
...
@@ -1218,7 +1232,8 @@ struct cv::viz::WTrajectory::ApplyPath
append_filter
->
AddInputConnection
(
filter
->
GetOutputPort
());
}
}
};
};
}}}
cv
::
viz
::
WTrajectory
::
WTrajectory
(
const
std
::
vector
<
Affine3f
>
&
path
,
int
display_mode
,
const
Color
&
color
,
float
scale
)
{
...
...
@@ -1303,7 +1318,7 @@ cv::viz::WTrajectory::WTrajectory(const std::vector<Affine3f> &path, int display
axes_tubes
->
SetNumberOfSides
(
6
);
axes_tubes
->
Update
();
ApplyPath
::
applyPath
(
axes_tubes
->
GetOutput
(),
appendFilter
,
path
);
TrajectoryUtils
::
applyPath
(
axes_tubes
->
GetOutput
(),
appendFilter
,
path
);
}
vtkSmartPointer
<
vtkPolyDataMapper
>
mapper
=
vtkSmartPointer
<
vtkPolyDataMapper
>::
New
();
...
...
@@ -1348,7 +1363,7 @@ cv::viz::WTrajectory::WTrajectory(const std::vector<Affine3f> &path, const Matx3
filter
->
Update
();
vtkSmartPointer
<
vtkAppendPolyData
>
appendFilter
=
vtkSmartPointer
<
vtkAppendPolyData
>::
New
();
ApplyPath
::
applyPath
(
filter
->
GetOutput
(),
appendFilter
,
path
);
TrajectoryUtils
::
applyPath
(
filter
->
GetOutput
(),
appendFilter
,
path
);
vtkSmartPointer
<
vtkPolyDataMapper
>
mapper
=
vtkSmartPointer
<
vtkPolyDataMapper
>::
New
();
mapper
->
SetInputConnection
(
appendFilter
->
GetOutputPort
());
...
...
@@ -1388,7 +1403,7 @@ cv::viz::WTrajectory::WTrajectory(const std::vector<Affine3f> &path, const Vec2f
filter
->
Update
();
vtkSmartPointer
<
vtkAppendPolyData
>
appendFilter
=
vtkSmartPointer
<
vtkAppendPolyData
>::
New
();
ApplyPath
::
applyPath
(
filter
->
GetOutput
(),
appendFilter
,
path
);
TrajectoryUtils
::
applyPath
(
filter
->
GetOutput
(),
appendFilter
,
path
);
vtkSmartPointer
<
vtkPolyDataMapper
>
mapper
=
vtkSmartPointer
<
vtkPolyDataMapper
>::
New
();
mapper
->
SetInputConnection
(
appendFilter
->
GetOutputPort
());
...
...
modules/viz/src/widget.cpp
View file @
f6e9b811
...
...
@@ -303,27 +303,6 @@ void cv::viz::WidgetAccessor::setProp(Widget& widget, vtkSmartPointer<vtkProp> p
///////////////////////////////////////////////////////////////////////////////////////////////
/// widget3D implementation
struct
cv
::
viz
::
Widget3D
::
MatrixConverter
{
static
Matx44f
convertToMatx
(
const
vtkSmartPointer
<
vtkMatrix4x4
>&
vtk_matrix
)
{
Matx44f
m
;
for
(
int
i
=
0
;
i
<
4
;
i
++
)
for
(
int
k
=
0
;
k
<
4
;
k
++
)
m
(
i
,
k
)
=
vtk_matrix
->
GetElement
(
i
,
k
);
return
m
;
}
static
vtkSmartPointer
<
vtkMatrix4x4
>
convertToVtkMatrix
(
const
Matx44f
&
m
)
{
vtkSmartPointer
<
vtkMatrix4x4
>
vtk_matrix
=
vtkSmartPointer
<
vtkMatrix4x4
>::
New
();
for
(
int
i
=
0
;
i
<
4
;
i
++
)
for
(
int
k
=
0
;
k
<
4
;
k
++
)
vtk_matrix
->
SetElement
(
i
,
k
,
m
(
i
,
k
));
return
vtk_matrix
;
}
};
void
cv
::
viz
::
Widget3D
::
setPose
(
const
Affine3f
&
pose
)
{
vtkProp3D
*
actor
=
vtkProp3D
::
SafeDownCast
(
WidgetAccessor
::
getProp
(
*
this
));
...
...
@@ -345,10 +324,9 @@ void cv::viz::Widget3D::updatePose(const Affine3f &pose)
setPose
(
pose
);
return
;
}
Matx44f
matrix_cv
=
MatrixConverter
::
convertToMatx
(
matrix
);
Affine3f
updated_pose
=
pose
*
Affine3f
(
matrix_cv
);
matrix
=
MatrixConverter
::
convertToVtkMatrix
(
updated_pose
.
matrix
);
Affine3f
updated_pose
=
pose
*
Affine3f
(
convertToMatx
(
matrix
)
);
matrix
=
convertToVtkMatrix
(
updated_pose
.
matrix
);
actor
->
SetUserMatrix
(
matrix
);
actor
->
Modified
();
...
...
@@ -358,10 +336,7 @@ cv::Affine3f cv::viz::Widget3D::getPose() const
{
vtkProp3D
*
actor
=
vtkProp3D
::
SafeDownCast
(
WidgetAccessor
::
getProp
(
*
this
));
CV_Assert
(
"Widget is not 3D."
&&
actor
);
vtkSmartPointer
<
vtkMatrix4x4
>
matrix
=
actor
->
GetUserMatrix
();
Matx44f
matrix_cv
=
MatrixConverter
::
convertToMatx
(
matrix
);
return
Affine3f
(
matrix_cv
);
return
Affine3f
(
convertToMatx
(
actor
->
GetUserMatrix
()));
}
void
cv
::
viz
::
Widget3D
::
setColor
(
const
Color
&
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