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
8d327fa4
Commit
8d327fa4
authored
Jan 13, 2014
by
Anatoly Baksheev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated for compatibility with VTK6.0
parent
e472d45d
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
44 additions
and
17 deletions
+44
-17
OpenCVDetectVTK.cmake
cmake/OpenCVDetectVTK.cmake
+1
-1
clouds.cpp
modules/viz/src/clouds.cpp
+2
-2
precomp.hpp
modules/viz/src/precomp.hpp
+27
-1
shapes.cpp
modules/viz/src/shapes.cpp
+12
-12
widget.cpp
modules/viz/src/widget.cpp
+1
-0
tests_simple.cpp
modules/viz/test/tests_simple.cpp
+1
-1
No files found.
cmake/OpenCVDetectVTK.cmake
View file @
8d327fa4
...
...
@@ -2,7 +2,7 @@ if(NOT WITH_VTK OR ANDROID OR IOS)
return
()
endif
()
find_package
(
VTK 6.0 QUIET COMPONENTS vtkRenderingCore vtkInteractionWidgets vtkInteractionStyle vtkIOLegacy vtkIOPLY vtkRenderingFreeType vtkRenderingLOD vtkFiltersTexture NO_MODULE
)
find_package
(
VTK 6.0 QUIET COMPONENTS vtkRenderingCore vtkInteractionWidgets vtkInteractionStyle vtkIOLegacy vtkIOPLY vtkRenderingFreeType vtkRenderingLOD vtkFiltersTexture
vtkIOExport
NO_MODULE
)
if
(
NOT DEFINED VTK_FOUND OR NOT VTK_FOUND
)
find_package
(
VTK 5.10 QUIET COMPONENTS vtkCommon vtkFiltering vtkRendering vtkWidgets vtkImaging NO_MODULE
)
...
...
modules/viz/src/clouds.cpp
View file @
8d327fa4
...
...
@@ -230,8 +230,8 @@ void cv::viz::WCloudCollection::addCloud(InputArray cloud, InputArray colors, co
CV_Assert
(
"Cloud Widget without data"
&&
currdata
);
vtkSmartPointer
<
vtkAppendPolyData
>
append_filter
=
vtkSmartPointer
<
vtkAppendPolyData
>::
New
();
append_filter
->
AddInputConnection
(
currdata
->
GetProducerPort
()
);
append_filter
->
AddInputConnection
(
polydata
->
GetProducerPort
()
);
VtkUtils
::
AddInputData
(
append_filter
,
currdata
);
VtkUtils
::
AddInputData
(
append_filter
,
polydata
);
append_filter
->
Update
();
VtkUtils
::
SetInputData
(
mapper
,
append_filter
->
GetOutput
());
...
...
modules/viz/src/precomp.hpp
View file @
8d327fa4
...
...
@@ -230,6 +230,25 @@ namespace cv
filter
->
SetInputData
(
polydata
);
#endif
}
template
<
class
Filter
>
static
void
SetSourceData
(
vtkSmartPointer
<
Filter
>
filter
,
vtkPolyData
*
polydata
)
{
#if VTK_MAJOR_VERSION <= 5
filter
->
SetSource
(
polydata
);
#else
filter
->
SetSourceData
(
polydata
);
#endif
}
template
<
class
Filter
>
static
void
SetInputData
(
vtkSmartPointer
<
Filter
>
filter
,
vtkImageData
*
polydata
)
{
#if VTK_MAJOR_VERSION <= 5
filter
->
SetInput
(
polydata
);
#else
filter
->
SetInputData
(
polydata
);
#endif
}
template
<
class
Filter
>
static
void
AddInputData
(
vtkSmartPointer
<
Filter
>
filter
,
vtkPolyData
*
polydata
)
...
...
@@ -285,7 +304,14 @@ namespace cv
static
vtkSmartPointer
<
vtkPolyData
>
TransformPolydata
(
vtkSmartPointer
<
vtkPolyData
>
polydata
,
const
Affine3d
&
pose
)
{
return
TransformPolydata
(
polydata
->
GetProducerPort
(),
pose
);
vtkSmartPointer
<
vtkTransform
>
transform
=
vtkSmartPointer
<
vtkTransform
>::
New
();
transform
->
SetMatrix
(
vtkmatrix
(
pose
.
matrix
));
vtkSmartPointer
<
vtkTransformPolyDataFilter
>
transform_filter
=
vtkSmartPointer
<
vtkTransformPolyDataFilter
>::
New
();
VtkUtils
::
SetInputData
(
transform_filter
,
polydata
);
transform_filter
->
SetTransform
(
transform
);
transform_filter
->
Update
();
return
transform_filter
->
GetOutput
();
}
};
}
...
...
modules/viz/src/shapes.cpp
View file @
8d327fa4
...
...
@@ -355,7 +355,7 @@ cv::viz::WCoordinateSystem::WCoordinateSystem(double scale)
polydata
->
GetPointData
()
->
SetScalars
(
colors
);
vtkSmartPointer
<
vtkTubeFilter
>
tube_filter
=
vtkSmartPointer
<
vtkTubeFilter
>::
New
();
tube_filter
->
SetInputConnection
(
polydata
->
GetProducerPort
()
);
VtkUtils
::
SetInputData
(
tube_filter
,
polydata
);
tube_filter
->
SetRadius
(
axes
->
GetScaleFactor
()
/
50.0
);
tube_filter
->
SetNumberOfSides
(
6
);
tube_filter
->
Update
();
...
...
@@ -447,7 +447,7 @@ cv::viz::WGrid::WGrid(const Vec2i &cells, const Vec2d &cells_spacing, const Colo
// Extract the edges so we have the grid
vtkSmartPointer
<
vtkExtractEdges
>
extract_edges
=
vtkSmartPointer
<
vtkExtractEdges
>::
New
();
extract_edges
->
SetInputConnection
(
grid_data
->
GetProducerPort
()
);
VtkUtils
::
SetInputData
(
extract_edges
,
grid_data
);
extract_edges
->
Update
();
vtkSmartPointer
<
vtkPolyDataMapper
>
mapper
=
vtkSmartPointer
<
vtkPolyDataMapper
>::
New
();
...
...
@@ -854,13 +854,13 @@ cv::viz::WCameraPosition::WCameraPosition(const Matx33d &K, InputArray _image, d
// Frustum needs to be textured or else it can't be combined with image
vtkSmartPointer
<
vtkTextureMapToPlane
>
frustum_texture
=
vtkSmartPointer
<
vtkTextureMapToPlane
>::
New
();
frustum_texture
->
SetInputConnection
(
frustum
->
GetProducerPort
()
);
VtkUtils
::
SetInputData
(
frustum_texture
,
frustum
);
frustum_texture
->
SetSRange
(
0.0
,
0.0
);
// Texture mapping with only one pixel
frustum_texture
->
SetTRange
(
0.0
,
0.0
);
// from the image to have constant color
vtkSmartPointer
<
vtkAppendPolyData
>
append_filter
=
vtkSmartPointer
<
vtkAppendPolyData
>::
New
();
append_filter
->
AddInputConnection
(
frustum_texture
->
GetOutputPort
());
append_filter
->
AddInputConnection
(
plane
->
GetProducerPort
()
);
VtkUtils
::
AddInputData
(
append_filter
,
plane
);
vtkSmartPointer
<
vtkActor
>
actor
=
getActor
(
image_widget
);
actor
->
GetMapper
()
->
SetInputConnection
(
append_filter
->
GetOutputPort
());
...
...
@@ -886,13 +886,13 @@ cv::viz::WCameraPosition::WCameraPosition(const Vec2d &fov, InputArray _image, d
// Frustum needs to be textured or else it can't be combined with image
vtkSmartPointer
<
vtkTextureMapToPlane
>
frustum_texture
=
vtkSmartPointer
<
vtkTextureMapToPlane
>::
New
();
frustum_texture
->
SetInputConnection
(
frustum
->
GetProducerPort
()
);
VtkUtils
::
SetInputData
(
frustum_texture
,
frustum
);
frustum_texture
->
SetSRange
(
0.0
,
0.0
);
// Texture mapping with only one pixel
frustum_texture
->
SetTRange
(
0.0
,
0.0
);
// from the image to have constant color
vtkSmartPointer
<
vtkAppendPolyData
>
append_filter
=
vtkSmartPointer
<
vtkAppendPolyData
>::
New
();
append_filter
->
AddInputConnection
(
frustum_texture
->
GetOutputPort
());
append_filter
->
AddInputConnection
(
plane
->
GetProducerPort
()
);
VtkUtils
::
AddInputData
(
append_filter
,
plane
);
vtkSmartPointer
<
vtkActor
>
actor
=
getActor
(
image_widget
);
actor
->
GetMapper
()
->
SetInputConnection
(
append_filter
->
GetOutputPort
());
...
...
@@ -917,7 +917,7 @@ cv::viz::WTrajectory::WTrajectory(InputArray _path, int display_mode, double sca
{
Mat
points
=
vtkTrajectorySource
::
ExtractPoints
(
_path
);
vtkSmartPointer
<
vtkPolyData
>
polydata
=
getPolyData
(
WPolyLine
(
points
,
color
));
append_filter
->
AddInputConnection
(
polydata
->
GetProducerPort
()
);
VtkUtils
::
AddInputData
(
append_filter
,
polydata
);
}
if
(
display_mode
&
WTrajectory
::
FRAMES
)
...
...
@@ -929,7 +929,7 @@ cv::viz::WTrajectory::WTrajectory(InputArray _path, int display_mode, double sca
vtkSmartPointer
<
vtkTensorGlyph
>
tensor_glyph
=
vtkSmartPointer
<
vtkTensorGlyph
>::
New
();
tensor_glyph
->
SetInputConnection
(
source
->
GetOutputPort
());
tensor_glyph
->
SetSourceConnection
(
glyph
->
GetProducerPort
()
);
VtkUtils
::
SetSourceData
(
tensor_glyph
,
glyph
);
tensor_glyph
->
ExtractEigenvaluesOff
();
// Treat as a rotation matrix, not as something with eigenvalues
tensor_glyph
->
ThreeGlyphsOff
();
tensor_glyph
->
SymmetricOff
();
...
...
@@ -968,7 +968,7 @@ cv::viz::WTrajectoryFrustums::WTrajectoryFrustums(InputArray _path, const Matx33
vtkSmartPointer
<
vtkTensorGlyph
>
tensor_glyph
=
vtkSmartPointer
<
vtkTensorGlyph
>::
New
();
tensor_glyph
->
SetInputConnection
(
source
->
GetOutputPort
());
tensor_glyph
->
SetSourceConnection
(
glyph
->
GetProducerPort
()
);
VtkUtils
::
SetSourceData
(
tensor_glyph
,
glyph
);
tensor_glyph
->
ExtractEigenvaluesOff
();
// Treat as a rotation matrix, not as something with eigenvalues
tensor_glyph
->
ThreeGlyphsOff
();
tensor_glyph
->
SymmetricOff
();
...
...
@@ -994,7 +994,7 @@ cv::viz::WTrajectoryFrustums::WTrajectoryFrustums(InputArray _path, const Vec2d
vtkSmartPointer
<
vtkTensorGlyph
>
tensor_glyph
=
vtkSmartPointer
<
vtkTensorGlyph
>::
New
();
tensor_glyph
->
SetInputConnection
(
source
->
GetOutputPort
());
tensor_glyph
->
SetSourceConnection
(
glyph
->
GetProducerPort
()
);
VtkUtils
::
SetSourceData
(
tensor_glyph
,
glyph
);
tensor_glyph
->
ExtractEigenvaluesOff
();
// Treat as a rotation matrix, not as something with eigenvalues
tensor_glyph
->
ThreeGlyphsOff
();
tensor_glyph
->
SymmetricOff
();
...
...
@@ -1046,7 +1046,7 @@ cv::viz::WTrajectorySpheres::WTrajectorySpheres(InputArray _path, double line_le
vtkSmartPointer
<
vtkPolyData
>
polydata
=
sphere_source
->
GetOutput
();
polydata
->
GetCellData
()
->
SetScalars
(
VtkUtils
::
FillScalars
(
polydata
->
GetNumberOfCells
(),
c
));
append_filter
->
AddInputConnection
(
polydata
->
GetProducerPort
()
);
VtkUtils
::
AddInputData
(
append_filter
,
polydata
);
if
(
i
>
0
)
{
...
...
@@ -1064,7 +1064,7 @@ cv::viz::WTrajectorySpheres::WTrajectorySpheres(InputArray _path, double line_le
line_source
->
Update
();
vtkSmartPointer
<
vtkPolyData
>
polydata
=
line_source
->
GetOutput
();
polydata
->
GetCellData
()
->
SetScalars
(
VtkUtils
::
FillScalars
(
polydata
->
GetNumberOfCells
(),
c
));
append_filter
->
AddInputConnection
(
polydata
->
GetProducerPort
()
);
VtkUtils
::
AddInputData
(
append_filter
,
polydata
);
}
}
append_filter
->
Update
();
...
...
modules/viz/src/widget.cpp
View file @
8d327fa4
...
...
@@ -276,6 +276,7 @@ void cv::viz::Widget3D::applyTransform(const Affine3d &transform)
vtkSmartPointer
<
vtkPolyDataMapper
>
mapper
=
vtkPolyDataMapper
::
SafeDownCast
(
actor
->
GetMapper
());
CV_Assert
(
"Widget doesn't have a polydata mapper"
&&
mapper
);
mapper
->
Update
();
VtkUtils
::
SetInputData
(
mapper
,
VtkUtils
::
TransformPolydata
(
mapper
->
GetInput
(),
transform
));
}
...
...
modules/viz/test/tests_simple.cpp
View file @
8d327fa4
...
...
@@ -113,7 +113,7 @@ TEST(Viz, show_painted_clouds)
viz
.
setBackgroundMeshLab
();
viz
.
showWidget
(
"coosys"
,
WCoordinateSystem
());
viz
.
showWidget
(
"cloud1"
,
WPaintedCloud
(
cloud
),
Affine3d
(
Vec3d
(
0.0
,
-
CV_PI
/
2
,
0.0
),
Vec3d
(
-
1.5
,
0.0
,
0.0
)));
viz
.
showWidget
(
"cloud2"
,
WPaintedCloud
(
cloud
,
Vec3d
(
0.0
,
0.0
,
-
1.0
),
Vec3d
(
0.0
,
0.0
,
1
.0
)),
Affine3d
(
Vec3d
(
0.0
,
CV_PI
/
2
,
0.0
),
Vec3d
(
1.5
,
0.0
,
0.0
)));
viz
.
showWidget
(
"cloud2"
,
WPaintedCloud
(
cloud
,
Vec3d
(
0.0
,
-
0.75
,
-
1.0
),
Vec3d
(
0.0
,
0.75
,
0
.0
)),
Affine3d
(
Vec3d
(
0.0
,
CV_PI
/
2
,
0.0
),
Vec3d
(
1.5
,
0.0
,
0.0
)));
viz
.
showWidget
(
"cloud3"
,
WPaintedCloud
(
cloud
,
Vec3d
(
0.0
,
0.0
,
-
1.0
),
Vec3d
(
0.0
,
0.0
,
1.0
),
Color
::
blue
(),
Color
::
red
()));
viz
.
showWidget
(
"arrow"
,
WArrow
(
Vec3d
(
0.0
,
1.0
,
-
1.0
),
Vec3d
(
0.0
,
1.0
,
1.0
),
0.009
,
Color
::
raspberry
()));
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