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
5307339f
Commit
5307339f
authored
Sep 07, 2013
by
Ozan Tonkal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tutorial code for makeTransformToGlobal, makeCameraPose, minor fixes in widget_pose tutorial
parent
7116e22b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
90 additions
and
4 deletions
+90
-4
transformations.cpp
samples/cpp/tutorial_code/viz/transformations.cpp
+86
-0
widget_pose.cpp
samples/cpp/tutorial_code/viz/widget_pose.cpp
+4
-4
No files found.
samples/cpp/tutorial_code/viz/transformations.cpp
0 → 100644
View file @
5307339f
/**
* @file transformations.cpp
* @brief Visualizing cloud in different positions, coordinate frames, camera frustums
* @author Ozan Cagri Tonkal
*/
#include <opencv2/viz.hpp>
#include <iostream>
using
namespace
cv
;
using
namespace
std
;
/**
* @function help
* @brief Display instructions to use this tutorial program
*/
void
help
()
{
cout
<<
"--------------------------------------------------------------------------"
<<
endl
<<
"This program shows how to use makeTransformToGlobal() to compute required pose,"
<<
"how to use makeCameraPose and Viz3d::setViewerPose. You can observe the scene "
<<
"from camera point of view (C) or global point of view (G)"
<<
endl
<<
"Usage:"
<<
endl
<<
"./coordinate_frame [ G | C ]"
<<
endl
<<
endl
;
}
/**
* @function main
*/
int
main
(
int
argn
,
char
**
argv
)
{
help
();
if
(
argn
<
2
)
{
cout
<<
"Missing arguments."
<<
endl
;
return
1
;
}
bool
camera_pov
=
(
argv
[
1
][
0
]
==
'C'
);
/// Create a window
viz
::
Viz3d
myWindow
(
"Coordinate Frame"
);
/// Add coordinate axes
myWindow
.
showWidget
(
"Coordinate Widget"
,
viz
::
CoordinateSystemWidget
());
/// 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
,
0.0
,
0.0
);
/// 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.
viz
::
SphereWidget
sphere_widget
(
Point3f
(
0.0
,
0.0
,
0.0
),
0.5
,
10
,
viz
::
Color
::
red
());
/// Pose of the widget in camera frame
Affine3f
sphere_pose
=
Affine3f
().
translate
(
Vec3f
(
0.0
f
,
0.0
f
,
3.0
f
));
/// Pose of the widget in global frame
Affine3f
sphere_pose_global
=
transform
*
sphere_pose
;
/// Visualize camera frame
if
(
!
camera_pov
)
{
viz
::
CameraPositionWidget
cpw
(
0.5
);
// Coordinate axes
viz
::
CameraPositionWidget
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
(
"sphere"
,
sphere_widget
,
sphere_pose_global
);
/// Set the viewer pose to that of camera
if
(
camera_pov
)
myWindow
.
setViewerPose
(
cam_pose
);
/// Start event loop.
myWindow
.
spin
();
return
0
;
}
samples/cpp/tutorial_code/viz/widget_pose.cpp
View file @
5307339f
/**
/**
* @file
creating_widgets
.cpp
* @file
widget_pose
.cpp
* @brief
Creating custom widgets using VTK
* @brief
Setting pose of a widget
* @author Ozan Cagri Tonkal
* @author Ozan Cagri Tonkal
*/
*/
...
@@ -20,9 +20,9 @@ void help()
...
@@ -20,9 +20,9 @@ void help()
cout
cout
<<
"--------------------------------------------------------------------------"
<<
endl
<<
"--------------------------------------------------------------------------"
<<
endl
<<
"This program shows how to visualize a cube rotated around (1,1,1) and shifted "
<<
"This program shows how to visualize a cube rotated around (1,1,1) and shifted "
<<
"using Rodrigues
matrix
."
<<
endl
<<
"using Rodrigues
vector
."
<<
endl
<<
"Usage:"
<<
endl
<<
"Usage:"
<<
endl
<<
"./
coordinate_frame"
<<
endl
<<
"./
widget_pose"
<<
endl
<<
endl
;
<<
endl
;
}
}
...
...
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