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
f610c295
Commit
f610c295
authored
Jan 01, 2014
by
Anatoly Baksheev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more tests
parent
e7791e15
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
143 additions
and
29 deletions
+143
-29
widgets.hpp
modules/viz/include/opencv2/viz/widgets.hpp
+2
-2
clouds.cpp
modules/viz/src/clouds.cpp
+0
-12
shapes.cpp
modules/viz/src/shapes.cpp
+6
-6
test_precomp.cpp
modules/viz/test/test_precomp.cpp
+23
-0
test_precomp.hpp
modules/viz/test/test_precomp.hpp
+16
-0
test_tutorial2.cpp
modules/viz/test/test_tutorial2.cpp
+1
-1
test_tutorial3.cpp
modules/viz/test/test_tutorial3.cpp
+8
-8
tests_simple.cpp
modules/viz/test/tests_simple.cpp
+87
-0
No files found.
modules/viz/include/opencv2/viz/widgets.hpp
View file @
f610c295
...
...
@@ -234,9 +234,9 @@ namespace cv
{
public
:
//! Creates grid at the origin
WGrid
(
const
Vec2i
&
dimensions
,
const
Vec2
d
&
spacing
,
const
Color
&
color
=
Color
::
white
());
WGrid
(
const
Vec2i
&
dimensions
,
const
Vec2
f
&
spacing
,
const
Color
&
color
=
Color
::
white
());
//! Creates grid based on the plane equation
WGrid
(
const
Vec4f
&
coeffs
,
const
Vec2i
&
dimensions
,
const
Vec2
d
&
spacing
,
const
Color
&
color
=
Color
::
white
());
WGrid
(
const
Vec4f
&
coeffs
,
const
Vec2i
&
dimensions
,
const
Vec2
f
&
spacing
,
const
Color
&
color
=
Color
::
white
());
};
class
CV_EXPORTS
WCameraPosition
:
public
Widget3D
...
...
modules/viz/src/clouds.cpp
View file @
f610c295
...
...
@@ -63,12 +63,6 @@ cv::viz::WCloud::WCloud(InputArray _cloud, InputArray _colors)
Mat
cloud
=
_cloud
.
getMat
();
Mat
colors
=
_colors
.
getMat
();
if
(
cloud
.
isContinuous
()
&&
colors
.
isContinuous
())
{
cloud
=
cloud
.
reshape
(
cloud
.
channels
(),
1
);
colors
=
colors
.
reshape
(
colors
.
channels
(),
1
);
}
vtkSmartPointer
<
vtkCloudMatSource
>
cloud_source
=
vtkSmartPointer
<
vtkCloudMatSource
>::
New
();
cloud_source
->
SetColorCloud
(
cloud
,
colors
);
...
...
@@ -268,12 +262,6 @@ void cv::viz::WCloudCollection::addCloud(InputArray _cloud, InputArray _colors,
CV_Assert
(
cloud
.
type
()
==
CV_32FC3
||
cloud
.
type
()
==
CV_64FC3
||
cloud
.
type
()
==
CV_32FC4
||
cloud
.
type
()
==
CV_64FC4
);
CV_Assert
(
colors
.
depth
()
==
CV_8U
&&
cloud
.
size
()
==
colors
.
size
());
if
(
cloud
.
isContinuous
()
&&
colors
.
isContinuous
())
{
cloud
=
cloud
.
reshape
(
cloud
.
channels
(),
1
);
colors
=
colors
.
reshape
(
colors
.
channels
(),
1
);
}
vtkIdType
nr_points
;
vtkSmartPointer
<
vtkPolyData
>
polydata
=
CloudCollectionUtils
::
create
(
cloud
,
nr_points
);
...
...
modules/viz/src/shapes.cpp
View file @
f610c295
...
...
@@ -474,7 +474,7 @@ namespace cv { namespace viz { namespace
{
struct
GridUtils
{
static
vtkSmartPointer
<
vtkPolyData
>
createGrid
(
const
Vec2i
&
dimensions
,
const
Vec2
d
&
spacing
)
static
vtkSmartPointer
<
vtkPolyData
>
createGrid
(
const
Vec2i
&
dimensions
,
const
Vec2
f
&
spacing
)
{
// Create the grid using image data
vtkSmartPointer
<
vtkImageData
>
grid
=
vtkSmartPointer
<
vtkImageData
>::
New
();
...
...
@@ -500,7 +500,7 @@ namespace cv { namespace viz { namespace
};
}}}
cv
::
viz
::
WGrid
::
WGrid
(
const
Vec2i
&
dimensions
,
const
Vec2
d
&
spacing
,
const
Color
&
color
)
cv
::
viz
::
WGrid
::
WGrid
(
const
Vec2i
&
dimensions
,
const
Vec2
f
&
spacing
,
const
Color
&
color
)
{
vtkSmartPointer
<
vtkPolyData
>
grid
=
GridUtils
::
createGrid
(
dimensions
,
spacing
);
...
...
@@ -518,7 +518,7 @@ cv::viz::WGrid::WGrid(const Vec2i &dimensions, const Vec2d &spacing, const Color
setColor
(
color
);
}
cv
::
viz
::
WGrid
::
WGrid
(
const
Vec4f
&
coefs
,
const
Vec2i
&
dimensions
,
const
Vec2
d
&
spacing
,
const
Color
&
color
)
cv
::
viz
::
WGrid
::
WGrid
(
const
Vec4f
&
coefs
,
const
Vec2i
&
dimensions
,
const
Vec2
f
&
spacing
,
const
Color
&
color
)
{
vtkSmartPointer
<
vtkPolyData
>
grid
=
GridUtils
::
createGrid
(
dimensions
,
spacing
);
...
...
@@ -1224,11 +1224,11 @@ cv::viz::WTrajectory::WTrajectory(const std::vector<Affine3f> &path, int display
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
);
vtkSmartPointer
<
vtkPolyData
>
polyData
=
vtkSmartPointer
<
vtkPolyData
>::
New
();
vtkSmartPointer
<
vtkPolyLine
>
polyLine
=
vtkSmartPointer
<
vtkPolyLine
>::
New
();
polyLine
->
GetPointIds
()
->
SetNumberOfIds
(
nr_points
);
Vec3f
*
data_beg
=
vtkpoints_data
<
float
>
(
points
);
...
...
modules/viz/test/test_precomp.cpp
View file @
f610c295
#include "test_precomp.hpp"
cv
::
String
cv
::
Path
::
combine
(
const
String
&
item1
,
const
String
&
item2
)
{
if
(
item1
.
empty
())
return
item2
;
if
(
item2
.
empty
())
return
item1
;
char
last
=
item1
[
item1
.
size
()
-
1
];
bool
need_append
=
last
!=
'/'
&&
last
!=
'\\'
;
return
item1
+
(
need_append
?
"/"
:
""
)
+
item2
;
}
cv
::
String
cv
::
Path
::
combine
(
const
String
&
item1
,
const
String
&
item2
,
const
String
&
item3
)
{
return
combine
(
combine
(
item1
,
item2
),
item3
);
}
cv
::
String
cv
::
Path
::
change_extension
(
const
String
&
file
,
const
String
&
ext
)
{
String
::
size_type
pos
=
file
.
find_last_of
(
'.'
);
return
pos
==
String
::
npos
?
file
:
file
.
substr
(
0
,
pos
+
1
)
+
ext
;
}
modules/viz/test/test_precomp.hpp
View file @
f610c295
...
...
@@ -63,5 +63,21 @@
#include <iostream>
#include <fstream>
#include <string>
#include <limits>
namespace
cv
{
struct
Path
{
static
String
combine
(
const
String
&
item1
,
const
String
&
item2
);
static
String
combine
(
const
String
&
item1
,
const
String
&
item2
,
const
String
&
item3
);
static
String
change_extension
(
const
String
&
file
,
const
String
&
ext
);
};
inline
cv
::
String
get_dragon_ply_file_path
()
{
return
Path
::
combine
(
cvtest
::
TS
::
ptr
()
->
get_data_path
(),
"dragon.ply"
);
}
}
#endif
modules/viz/test/test_tutorial2.cpp
View file @
f610c295
...
...
@@ -48,7 +48,7 @@ void tutorial2()
}
TEST
(
Viz
_viz3d
,
DISABLED_tutorial2_pose_of_widget
)
TEST
(
Viz
,
DISABLED_tutorial2_pose_of_widget
)
{
tutorial2
();
}
modules/viz/test/test_tutorial3.cpp
View file @
f610c295
...
...
@@ -15,21 +15,21 @@ void tutorial3(bool camera_pov)
myWindow
.
showWidget
(
"Coordinate Widget"
,
viz
::
WCoordinateSystem
());
/// Let's assume camera has the following properties
Point3f
cam_pos
(
3.
0
f
,
3.0
f
,
3.0
f
),
cam_focal_point
(
3.0
f
,
3.0
f
,
2.0
f
),
cam_y_dir
(
-
1.0
f
,
0.0
f
,
0.0
f
);
Point3f
cam_pos
(
3.
f
,
3.
f
,
3.
f
),
cam_focal_point
(
3.
f
,
3.
f
,
2.
f
),
cam_y_dir
(
-
1.
f
,
0.
f
,
0.
f
);
/// We can get the pose of the cam using makeCameraPose
Affine3f
cam_pose
=
viz
::
makeCameraPose
(
cam_pos
,
cam_focal_point
,
cam_y_dir
);
/// We can get the transformation matrix from camera coordinate system to global using
/// - makeTransformToGlobal. We need the axes of the camera
Affine3f
transform
=
viz
::
makeTransformToGlobal
(
Vec3f
(
0.
0
f
,
-
1.0
f
,
0.0
f
),
Vec3f
(
-
1.0
f
,
0.0
f
,
0.0
f
),
Vec3f
(
0.0
f
,
0.0
f
,
-
1.0
f
),
cam_pos
);
Affine3f
transform
=
viz
::
makeTransformToGlobal
(
Vec3f
(
0.
f
,
-
1.
f
,
0.
f
),
Vec3f
(
-
1.
f
,
0.
f
,
0.
f
),
Vec3f
(
0.
f
,
0.
f
,
-
1.
f
),
cam_pos
);
/// Create a cloud widget.
Mat
bunny_cloud
=
viz
::
readCloud
(
"d:/cloud_dragon.ply"
);
viz
::
WCloud
cloud_widget
(
bunny
_cloud
,
viz
::
Color
::
green
());
Mat
dragon_cloud
=
viz
::
readCloud
(
get_dragon_ply_file_path
()
);
viz
::
WCloud
cloud_widget
(
dragon
_cloud
,
viz
::
Color
::
green
());
/// Pose of the widget in camera frame
Affine3f
cloud_pose
=
Affine3f
().
translate
(
Vec3f
(
0.
0
f
,
0.0
f
,
3.0
f
));
Affine3f
cloud_pose
=
Affine3f
().
translate
(
Vec3f
(
0.
f
,
0.
f
,
3.
f
));
/// Pose of the widget in global frame
Affine3f
cloud_pose_global
=
transform
*
cloud_pose
;
...
...
@@ -37,7 +37,7 @@ void tutorial3(bool camera_pov)
if
(
!
camera_pov
)
{
viz
::
WCameraPosition
cpw
(
0.5
);
// Coordinate axes
viz
::
WCameraPosition
cpw_frustum
(
Vec2f
(
0.889484
,
0.523599
));
// Camera frustum
viz
::
WCameraPosition
cpw_frustum
(
Vec2f
(
0.889484
f
,
0.523599
f
));
// Camera frustum
myWindow
.
showWidget
(
"CPW"
,
cpw
,
cam_pose
);
myWindow
.
showWidget
(
"CPW_FRUSTUM"
,
cpw_frustum
,
cam_pose
);
}
...
...
@@ -53,12 +53,12 @@ void tutorial3(bool camera_pov)
myWindow
.
spin
();
}
TEST
(
Viz
_viz3d
,
DISABLED_tutorial3_global_view
)
TEST
(
Viz
,
DISABLED_tutorial3_global_view
)
{
tutorial3
(
false
);
}
TEST
(
Viz
_viz3d
,
DISABLED_tutorial3_camera_view
)
TEST
(
Viz
,
DISABLED_tutorial3_camera_view
)
{
tutorial3
(
true
);
}
modules/viz/test/tests_simple.cpp
0 → 100644
View file @
f610c295
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
// Copyright (C) 2008-2013, Willow Garage Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and / or other materials provided with the distribution.
//
// * The name of the copyright holders may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#include "test_precomp.hpp"
using
namespace
cv
;
using
namespace
cv
::
viz
;
TEST
(
Viz
,
DISABLED_show_cloud_bluberry
)
{
Mat
dragon_cloud
=
readCloud
(
get_dragon_ply_file_path
());
Viz3d
viz
(
"show_cloud_bluberry"
);
viz
.
setBackgroundColor
();
viz
.
showWidget
(
"coosys"
,
WCoordinateSystem
());
viz
.
showWidget
(
"dragon"
,
WCloud
(
dragon_cloud
,
Color
::
bluberry
()));
viz
.
spin
();
}
TEST
(
Viz
,
DISABLED_show_cloud_random_color
)
{
Mat
dragon_cloud
=
readCloud
(
get_dragon_ply_file_path
());
Mat
colors
(
dragon_cloud
.
size
(),
CV_8UC3
);
theRNG
().
fill
(
colors
,
RNG
::
UNIFORM
,
0
,
255
);
Viz3d
viz
(
"show_cloud_random_color"
);
viz
.
setBackgroundColor
();
viz
.
showWidget
(
"coosys"
,
WCoordinateSystem
());
viz
.
showWidget
(
"dragon"
,
WCloud
(
dragon_cloud
,
colors
));
viz
.
spin
();
}
TEST
(
Viz
,
DISABLED_show_cloud_masked
)
{
Mat
dragon_cloud
=
readCloud
(
get_dragon_ply_file_path
());
Vec3f
qnan
=
Vec3f
::
all
(
std
::
numeric_limits
<
float
>::
quiet_NaN
());
for
(
size_t
i
=
0
;
i
<
dragon_cloud
.
total
();
++
i
)
if
(
i
%
15
!=
0
)
dragon_cloud
.
at
<
Vec3f
>
(
i
)
=
qnan
;
Viz3d
viz
(
"show_cloud_masked"
);
viz
.
setBackgroundColor
();
viz
.
showWidget
(
"coosys"
,
WCoordinateSystem
());
viz
.
showWidget
(
"dragon"
,
WCloud
(
dragon_cloud
));
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