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
d2644654
Commit
d2644654
authored
Jan 07, 2014
by
Anatoly Baksheev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more refactoring
parent
40644403
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
64 additions
and
22 deletions
+64
-22
widgets.hpp
modules/viz/include/opencv2/viz/widgets.hpp
+2
-2
precomp.hpp
modules/viz/src/precomp.hpp
+31
-1
vizcore.cpp
modules/viz/src/vizcore.cpp
+1
-3
test_viz3d.cpp
modules/viz/test/test_viz3d.cpp
+30
-16
No files found.
modules/viz/include/opencv2/viz/widgets.hpp
View file @
d2644654
...
@@ -227,7 +227,7 @@ namespace cv
...
@@ -227,7 +227,7 @@ namespace cv
class
CV_EXPORTS
WCoordinateSystem
:
public
Widget3D
class
CV_EXPORTS
WCoordinateSystem
:
public
Widget3D
{
{
public
:
public
:
WCoordinateSystem
(
float
scale
=
1.
f
);
WCoordinateSystem
(
double
scale
=
1.
f
);
};
};
class
CV_EXPORTS
WGrid
:
public
Widget3D
class
CV_EXPORTS
WGrid
:
public
Widget3D
...
@@ -263,7 +263,7 @@ namespace cv
...
@@ -263,7 +263,7 @@ namespace cv
enum
{
FRAMES
=
1
,
PATH
=
2
,
BOTH
=
FRAMES
+
PATH
};
enum
{
FRAMES
=
1
,
PATH
=
2
,
BOTH
=
FRAMES
+
PATH
};
//! Takes vector<Affine3<T>> and displays trajectory of the given path either by coordinate frames or polyline
//! Takes vector<Affine3<T>> and displays trajectory of the given path either by coordinate frames or polyline
WTrajectory
(
InputArray
path
,
int
display_mode
=
WTrajectory
::
PATH
,
float
scale
=
1.
f
,
const
Color
&
color
=
Color
::
white
());
WTrajectory
(
InputArray
path
,
int
display_mode
=
WTrajectory
::
PATH
,
double
scale
=
1.
f
,
const
Color
&
color
=
Color
::
white
());
};
};
class
CV_EXPORTS
WTrajectoryFrustums
:
public
Widget3D
class
CV_EXPORTS
WTrajectoryFrustums
:
public
Widget3D
...
...
modules/viz/src/precomp.hpp
View file @
d2644654
...
@@ -172,10 +172,40 @@ namespace cv
...
@@ -172,10 +172,40 @@ namespace cv
friend
class
Viz3d
;
friend
class
Viz3d
;
};
};
template
<
typename
_Tp
>
bool
isNan
(
const
_Tp
*
data
)
template
<
typename
_Tp
>
inline
bool
isNan
(
const
_Tp
*
data
)
{
{
return
isNan
(
data
[
0
])
||
isNan
(
data
[
1
])
||
isNan
(
data
[
2
]);
return
isNan
(
data
[
0
])
||
isNan
(
data
[
1
])
||
isNan
(
data
[
2
]);
}
}
inline
vtkSmartPointer
<
vtkPolyData
>
getPolyData
(
const
Widget3D
&
widget
)
{
vtkSmartPointer
<
vtkProp
>
prop
=
WidgetAccessor
::
getProp
(
widget
);
vtkSmartPointer
<
vtkMapper
>
mapper
=
vtkActor
::
SafeDownCast
(
prop
)
->
GetMapper
();
return
vtkPolyData
::
SafeDownCast
(
mapper
->
GetInput
());
}
struct
VtkUtils
{
template
<
class
Filter
>
static
inline
void
SetInputData
(
vtkSmartPointer
<
Filter
>
filter
,
vtkPolyData
*
polydata
)
{
#if VTK_MAJOR_VERSION <= 5
filter
->
SetInput
(
polydata
);
#else
filter
->
SetInputData
(
polydata
);
#endif
}
template
<
class
Filter
>
static
inline
void
AddInputData
(
vtkSmartPointer
<
Filter
>
filter
,
vtkPolyData
*
polydata
)
{
#if VTK_MAJOR_VERSION <= 5
filter
->
AddInput
(
polydata
);
#else
filter
->
AddInputData
(
polydata
);
#endif
}
};
}
}
}
}
...
...
modules/viz/src/vizcore.cpp
View file @
d2644654
...
@@ -305,9 +305,7 @@ void cv::viz::writeTrajectory(InputArray _traj, const String& files_format, int
...
@@ -305,9 +305,7 @@ void cv::viz::writeTrajectory(InputArray _traj, const String& files_format, int
void
cv
::
viz
::
computeNormals
(
const
Mesh3d
&
mesh
,
OutputArray
_normals
)
void
cv
::
viz
::
computeNormals
(
const
Mesh3d
&
mesh
,
OutputArray
_normals
)
{
{
vtkSmartPointer
<
vtkProp
>
prop
=
WidgetAccessor
::
getProp
(
WMesh
(
mesh
));
vtkSmartPointer
<
vtkPolyData
>
polydata
=
getPolyData
(
WMesh
(
mesh
));
vtkSmartPointer
<
vtkMapper
>
mapper
=
vtkActor
::
SafeDownCast
(
prop
)
->
GetMapper
();
vtkSmartPointer
<
vtkPolyData
>
polydata
=
vtkPolyData
::
SafeDownCast
(
mapper
->
GetInput
());
vtkSmartPointer
<
vtkPolyDataNormals
>
normal_generator
=
vtkSmartPointer
<
vtkPolyDataNormals
>::
New
();
vtkSmartPointer
<
vtkPolyDataNormals
>
normal_generator
=
vtkSmartPointer
<
vtkPolyDataNormals
>::
New
();
#if VTK_MAJOR_VERSION <= 5
#if VTK_MAJOR_VERSION <= 5
...
...
modules/viz/test/test_viz3d.cpp
View file @
d2644654
...
@@ -45,37 +45,51 @@ using namespace cv;
...
@@ -45,37 +45,51 @@ using namespace cv;
TEST
(
Viz_viz3d
,
develop
)
TEST
(
Viz_viz3d
,
develop
)
{
{
std
::
cout
<<
std
::
string
(
cvtest
::
TS
::
ptr
()
->
get_data_path
())
+
"dragon.ply"
<<
std
::
endl
;
cv
::
Mat
cloud
=
cv
::
viz
::
readCloud
(
get_dragon_ply_file_path
())
;
cv
::
Mat
cloud
=
cv
::
viz
::
readCloud
(
String
(
cvtest
::
TS
::
ptr
()
->
get_data_path
())
+
"dragon.ply"
);
//cv::viz::Mesh3d mesh = cv::viz::Mesh3d::load(get_dragon_ply_file_path()
);
//theRNG().fill(mesh.colors, RNG::UNIFORM, 0, 255);
// for(size_t i = 0; i < cloud.total(); ++i)
// {
// if (i % 15 == 0)
// continue;
// const static float qnan = std::numeric_limits<float>::quiet_NaN();
// cloud.at<Vec3f>(i) = Vec3f(qnan, qnan, qnan);
// }
cv
::
viz
::
Viz3d
viz
(
"abc"
);
cv
::
viz
::
Viz3d
viz
(
"abc"
);
viz
.
setBackgroundColor
(
cv
::
viz
::
Color
::
mlab
());
viz
.
setBackgroundColor
(
cv
::
viz
::
Color
::
mlab
());
viz
.
showWidget
(
"coo"
,
cv
::
viz
::
WCoordinateSystem
(
0.1
));
viz
.
showWidget
(
"coo"
,
cv
::
viz
::
WCoordinateSystem
(
0.1
));
cv
::
Mat
colors
(
cloud
.
size
(),
CV_8UC3
,
cv
::
Scalar
(
0
,
255
,
0
));
// double c = cos(CV_PI/6);
// std::vector<Vec3d> pts;
// pts.push_back(Vec3d(0, 0.0, -1.0));
// pts.push_back(Vec3d(1, c, -0.5));
// pts.push_back(Vec3d(2, c, 0.5));
// pts.push_back(Vec3d(3, 0.0, 1.0));
// pts.push_back(Vec3d(4, -c, 0.5));
// pts.push_back(Vec3d(5, -c, -0.5));
// viz.showWidget("pl", cv::viz::WPolyLine(Mat(pts), cv::viz::Color::green()));
//viz.showWidget("pl", cv::viz::WPolyLine(cloud.colRange(0, 100), cv::viz::Color::green()));
//viz.spin();
//cv::Mat colors(cloud.size(), CV_8UC3, cv::Scalar(0, 255, 0));
//viz.showWidget("h", cv::viz::Widget::fromPlyFile("d:/horse-red.ply"));
//viz.showWidget("h", cv::viz::Widget::fromPlyFile("d:/horse-red.ply"));
//viz.showWidget("a", cv::viz::WArrow(cv::Point3f(0,0,0), cv::Point3f(1,1,1)));
//viz.showWidget("a", cv::viz::WArrow(cv::Point3f(0,0,0), cv::Point3f(1,1,1)));
std
::
vector
<
cv
::
Affine3d
>
gt
,
es
;
std
::
vector
<
cv
::
Affine3d
>
gt
,
es
;
cv
::
viz
::
readTrajectory
(
gt
,
"d:/Datasets/trajs/gt%05d.xml"
);
cv
::
viz
::
readTrajectory
(
gt
,
"d:/Datasets/trajs/gt%05d.xml"
);
cv
::
viz
::
readTrajectory
(
es
,
"d:/Datasets/trajs/es%05d.xml"
);
//cv::viz::readTrajectory(es, "d:/Datasets/trajs/es%05d.xml");
gt
.
resize
(
20
);
Affine3d
inv
=
gt
[
0
].
inv
();
for
(
size_t
i
=
0
;
i
<
gt
.
size
();
++
i
)
gt
[
i
]
=
inv
*
gt
[
i
];
//viz.showWidget("gt", viz::WTrajectory(gt, viz::WTrajectory::PATH, 1.f, viz::Color::blue()), gt[0].inv());
viz
.
showWidget
(
"gt"
,
viz
::
WTrajectory
(
gt
,
viz
::
WTrajectory
::
BOTH
,
0.01
f
,
viz
::
Color
::
blue
()));
viz
.
showWidget
(
"gt"
,
viz
::
WTrajectory
(
gt
,
viz
::
WTrajectory
::
PATH
,
1.
f
,
viz
::
Color
::
blue
()),
gt
[
0
].
inv
());
//viz.showWidget("tr", viz::WTrajectory(es, viz::WTrajectory::PATH, 1.f, viz::Color::red()), gt[0].inv());
viz
.
showWidget
(
"tr"
,
viz
::
WTrajectory
(
es
,
viz
::
WTrajectory
::
PATH
,
1.
f
,
viz
::
Color
::
red
()),
gt
[
0
].
inv
());
cv
::
RNG
rng
;
//theRNG().fill(colors, cv::RNG::UNIFORM, 0, 255);
rng
.
fill
(
colors
,
cv
::
RNG
::
UNIFORM
,
0
,
255
);
//viz.showWidget("c", cv::viz::WCloud(cloud, colors));
//viz.showWidget("c", cv::viz::WCloud(cloud, colors));
//viz.showWidget("c", cv::viz::WCloud(cloud, cv::viz::Color::bluberry()));
//viz.showWidget("c", cv::viz::WCloud(cloud, cv::viz::Color::bluberry()));
...
...
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