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
efcc3412
Commit
efcc3412
authored
Nov 17, 2013
by
Anatoly Baksheev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added viz tutorial 3 test
parent
e154bce2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
93 additions
and
5 deletions
+93
-5
test_precomp.hpp
modules/viz/test/test_precomp.hpp
+2
-0
test_tutorial3.cpp
modules/viz/test/test_tutorial3.cpp
+86
-0
test_viz3d.cpp
modules/viz/test/test_viz3d.cpp
+5
-5
No files found.
modules/viz/test/test_precomp.hpp
View file @
efcc3412
...
...
@@ -60,6 +60,8 @@
#include "opencv2/ts.hpp"
#include <opencv2/core.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/viz.hpp>
#include <iostream>
#include <fstream>
...
...
modules/viz/test/test_tutorial3.cpp
0 → 100644
View file @
efcc3412
#include "test_precomp.hpp"
using
namespace
cv
;
using
namespace
std
;
/**
* @function cvcloud_load
* @brief load bunny.ply
*/
Mat
cvcloud_load
()
{
Mat
cloud
(
1
,
20000
,
CV_32FC3
);
ifstream
ifs
(
"d:/cloud_dragon.ply"
);
string
str
;
for
(
size_t
i
=
0
;
i
<
12
;
++
i
)
getline
(
ifs
,
str
);
Point3f
*
data
=
cloud
.
ptr
<
cv
::
Point3f
>
();
//float dummy1, dummy2;
for
(
size_t
i
=
0
;
i
<
20000
;
++
i
)
ifs
>>
data
[
i
].
x
>>
data
[
i
].
y
>>
data
[
i
].
z
;
// >> dummy1 >> dummy2;
//cloud *= 5.0f;
return
cloud
;
}
/**
* @function main
*/
void
tutorial3
(
bool
camera_pov
)
{
/// Create a window
viz
::
Viz3d
myWindow
(
"Coordinate Frame"
);
/// Add coordinate axes
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
);
/// 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
);
/// Create a cloud widget.
Mat
bunny_cloud
=
cvcloud_load
();
viz
::
WCloud
cloud_widget
(
bunny_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
));
/// Pose of the widget in global frame
Affine3f
cloud_pose_global
=
transform
*
cloud_pose
;
/// Visualize camera frame
if
(
!
camera_pov
)
{
viz
::
WCameraPosition
cpw
(
0.5
);
// Coordinate axes
viz
::
WCameraPosition
cpw_frustum
(
Vec2f
(
0.889484
,
0.523599
));
// Camera frustum
myWindow
.
showWidget
(
"CPW"
,
cpw
,
cam_pose
);
myWindow
.
showWidget
(
"CPW_FRUSTUM"
,
cpw_frustum
,
cam_pose
);
}
/// Visualize widget
myWindow
.
showWidget
(
"bunny"
,
cloud_widget
,
cloud_pose_global
);
/// Set the viewer pose to that of camera
if
(
camera_pov
)
myWindow
.
setViewerPose
(
cam_pose
);
/// Start event loop.
myWindow
.
spin
();
}
TEST
(
Viz_viz3d
,
tutorial3_global_view
)
{
tutorial3
(
false
);
}
TEST
(
Viz_viz3d
,
tutorial3_camera_view
)
{
tutorial3
(
true
);
}
modules/viz/test/test_viz3d.cpp
View file @
efcc3412
...
...
@@ -40,13 +40,11 @@
//
//M*/
#include "test_precomp.hpp"
#include <opencv2/viz.hpp>
#include <opencv2/highgui.hpp>
#include <string>
using
namespace
cv
;
cv
::
Mat
cvcloud_load
()
static
cv
::
Mat
cvcloud_load
()
{
cv
::
Mat
cloud
(
1
,
20000
,
CV_32FC3
);
std
::
ifstream
ifs
(
"/Users/nerei/cloud_dragon.ply"
);
...
...
@@ -90,7 +88,7 @@ void keyboard_callback(const viz::KeyboardEvent & event, void * cookie)
}
}
TEST
(
Viz_viz3d
,
accuracy
)
TEST
(
Viz_viz3d
,
develop
)
{
cv
::
viz
::
Viz3d
viz
(
"abc"
);
...
...
@@ -178,4 +176,6 @@ TEST(Viz_viz3d, accuracy)
angle
+=
10
;
viz
.
spinOnce
(
42
,
true
);
}
volatile
void
*
a
=
(
void
*
)
&
cvcloud_load
;
(
void
)
a
;
//fixing warnings
}
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