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
f060eee5
Commit
f060eee5
authored
Aug 05, 2013
by
ozantonkal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix window_size setter, remove camera related old methods from viz3d
parent
439ba98e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
151 deletions
+25
-151
types.cpp
modules/viz/src/types.cpp
+4
-2
viz3d_impl.cpp
modules/viz/src/viz3d_impl.cpp
+20
-128
viz3d_impl.hpp
modules/viz/src/viz3d_impl.hpp
+1
-21
No files found.
modules/viz/src/types.cpp
View file @
f060eee5
...
...
@@ -165,10 +165,10 @@ cv::viz::Camera2::Camera2(const Vec2f &fov, const Size &window_size)
{
CV_Assert
(
window_size
.
width
>
0
&&
window_size
.
height
>
0
);
setClip
(
Vec2d
(
0.01
,
1000.01
));
// Default clipping
window_size_
=
window_size
;
fov_
=
fov
;
principal_point_
=
Vec2f
(
-
1.0
f
,
-
1.0
f
);
// Default symmetric lens
focal_
=
Vec2f
(
-
1.0
f
,
-
1.0
f
);
setFov
(
fov
);
setWindowSize
(
window_size
);
}
cv
::
viz
::
Camera2
::
Camera2
(
const
cv
::
Mat
&
K
,
const
Size
&
window_size
)
...
...
@@ -195,6 +195,8 @@ void cv::viz::Camera2::setWindowSize(const Size &window_size)
fov_
[
0
]
=
2
*
atan2
(
tan
(
fov_
[
1
]
*
0.5
),
aspect_ratio_new
);
// This assumes that the lens is symmetric!
else
fov_
[
0
]
=
(
atan2
(
principal_point_
[
0
],
focal_
[
0
])
+
atan2
(
window_size
.
width
-
principal_point_
[
0
],
focal_
[
0
]))
*
180
/
CV_PI
;
window_size_
=
window_size
;
}
void
cv
::
viz
::
Camera2
::
computeProjectionMatrix
(
Matx44f
&
proj
)
const
...
...
modules/viz/src/viz3d_impl.cpp
View file @
f060eee5
...
...
@@ -542,25 +542,12 @@ bool cv::viz::Viz3d::VizImpl::setShapeRenderingProperties (int property, double
/////////////////////////////////////////////////////////////////////////////////////////////
void
cv
::
viz
::
Viz3d
::
VizImpl
::
initCameraParameters
()
{
Camera
camera_temp
;
// Set default camera parameters to something meaningful
camera_temp
.
clip
=
Vec2d
(
0.01
,
1000.01
);
// Look straight along the z-axis
camera_temp
.
focal
=
Vec3d
(
0.0
,
0.0
,
1.0
);
// Position the camera at the origin
camera_temp
.
pos
=
Vec3d
(
0.0
,
0.0
,
0.0
);
// Set the up-vector of the camera to be the y-axis
camera_temp
.
view_up
=
Vec3d
(
0.0
,
1.0
,
0.0
);
// Set the camera field of view to about
camera_temp
.
fovy
=
0.8575
;
camera_temp
.
window_size
=
Vec2i
(
window_
->
GetScreenSize
())
/
2
;
camera_temp
.
window_pos
=
Vec2i
(
0
,
0
);
setCameraParameters
(
camera_temp
);
Vec2i
window_size
(
window_
->
GetScreenSize
());
window_size
/=
2
;
Camera2
camera_temp
(
Vec2f
(
0.0
,
0.8575
),
Size
(
window_size
[
0
],
window_size
[
1
]));
setCamera
(
camera_temp
);
setViewerPose
(
makeCameraPose
(
Vec3f
(
0.0
f
,
0.0
f
,
0.0
f
),
Vec3f
(
0.0
f
,
0.0
f
,
1.0
f
),
Vec3f
(
0.0
f
,
1.0
f
,
0.0
f
)));
}
/////////////////////////////////////////////////////////////////////////////////////////////
...
...
@@ -577,19 +564,19 @@ void cv::viz::Viz3d::VizImpl::updateCamera ()
}
/////////////////////////////////////////////////////////////////////////////////////////////
void
cv
::
viz
::
Viz3d
::
VizImpl
::
getCameras
(
cv
::
viz
::
Camera
&
camera
)
{
vtkCamera
*
active_camera
=
renderer_
->
GetActiveCamera
();
camera
.
pos
=
cv
::
Vec3d
(
active_camera
->
GetPosition
());
camera
.
focal
=
cv
::
Vec3d
(
active_camera
->
GetFocalPoint
());
camera
.
clip
=
cv
::
Vec2d
(
active_camera
->
GetClippingRange
());
camera
.
view_up
=
cv
::
Vec3d
(
active_camera
->
GetViewUp
());
camera
.
fovy
=
active_camera
->
GetViewAngle
()
/
180.0
*
CV_PI
;
camera
.
window_size
=
cv
::
Vec2i
(
renderer_
->
GetRenderWindow
()
->
GetSize
());
camera
.
window_pos
=
cv
::
Vec2d
::
all
(
0
);
}
//
void cv::viz::Viz3d::VizImpl::getCameras (cv::viz::Camera& camera)
//
{
//
vtkCamera* active_camera = renderer_->GetActiveCamera ();
//
//
camera.pos = cv::Vec3d(active_camera->GetPosition());
//
camera.focal = cv::Vec3d(active_camera->GetFocalPoint());
//
camera.clip = cv::Vec2d(active_camera->GetClippingRange());
//
camera.view_up = cv::Vec3d(active_camera->GetViewUp());
//
//
camera.fovy = active_camera->GetViewAngle()/ 180.0 * CV_PI;
//
camera.window_size = cv::Vec2i(renderer_->GetRenderWindow()->GetSize());
//
camera.window_pos = cv::Vec2d::all(0);
//
}
/////////////////////////////////////////////////////////////////////////////////////////////
void
cv
::
viz
::
Viz3d
::
VizImpl
::
setCamera
(
const
Camera2
&
camera
)
...
...
@@ -704,105 +691,10 @@ void cv::viz::Viz3d::VizImpl::resetCamera ()
renderer_
->
ResetCamera
();
}
/////////////////////////////////////////////////////////////////////////////////////////////
void
cv
::
viz
::
Viz3d
::
VizImpl
::
setCameraPosition
(
const
cv
::
Vec3d
&
pos
,
const
cv
::
Vec3d
&
view
,
const
cv
::
Vec3d
&
up
)
{
vtkSmartPointer
<
vtkCamera
>
cam
=
renderer_
->
GetActiveCamera
();
cam
->
SetPosition
(
pos
[
0
],
pos
[
1
],
pos
[
2
]);
cam
->
SetFocalPoint
(
view
[
0
],
view
[
1
],
view
[
2
]);
cam
->
SetViewUp
(
up
[
0
],
up
[
1
],
up
[
2
]);
renderer_
->
Render
();
}
/////////////////////////////////////////////////////////////////////////////////////////////
void
cv
::
viz
::
Viz3d
::
VizImpl
::
setCameraPosition
(
double
pos_x
,
double
pos_y
,
double
pos_z
,
double
up_x
,
double
up_y
,
double
up_z
)
{
//rens_->InitTraversal ();
vtkSmartPointer
<
vtkCamera
>
cam
=
renderer_
->
GetActiveCamera
();
cam
->
SetPosition
(
pos_x
,
pos_y
,
pos_z
);
cam
->
SetViewUp
(
up_x
,
up_y
,
up_z
);
renderer_
->
Render
();
}
/////////////////////////////////////////////////////////////////////////////////////////////
void
cv
::
viz
::
Viz3d
::
VizImpl
::
setCameraParameters
(
const
cv
::
Matx33f
&
intrinsics
,
const
cv
::
Affine3f
&
extrinsics
)
{
// Position = extrinsic translation
cv
::
Vec3f
pos_vec
=
extrinsics
.
translation
();
// Rotate the view vector
cv
::
Matx33f
rotation
=
extrinsics
.
rotation
();
cv
::
Vec3f
y_axis
(
0.
f
,
1.
f
,
0.
f
);
cv
::
Vec3f
up_vec
(
rotation
*
y_axis
);
// Compute the new focal point
cv
::
Vec3f
z_axis
(
0.
f
,
0.
f
,
1.
f
);
cv
::
Vec3f
focal_vec
=
pos_vec
+
rotation
*
z_axis
;
// Get the width and height of the image - assume the calibrated centers are at the center of the image
Eigen
::
Vector2i
window_size
;
window_size
[
0
]
=
static_cast
<
int
>
(
intrinsics
(
0
,
2
));
window_size
[
1
]
=
static_cast
<
int
>
(
intrinsics
(
1
,
2
));
// Compute the vertical field of view based on the focal length and image heigh
double
fovy
=
2
*
atan
(
window_size
[
1
]
/
(
2.
*
intrinsics
(
1
,
1
)))
*
180.0
/
M_PI
;
//rens_->InitTraversal ();
vtkSmartPointer
<
vtkCamera
>
cam
=
renderer_
->
GetActiveCamera
();
cam
->
SetPosition
(
pos_vec
[
0
],
pos_vec
[
1
],
pos_vec
[
2
]);
cam
->
SetFocalPoint
(
focal_vec
[
0
],
focal_vec
[
1
],
focal_vec
[
2
]);
cam
->
SetViewUp
(
up_vec
[
0
],
up_vec
[
1
],
up_vec
[
2
]);
cam
->
SetUseHorizontalViewAngle
(
0
);
cam
->
SetViewAngle
(
fovy
);
cam
->
SetClippingRange
(
0.01
,
1000.01
);
window_
->
SetSize
(
window_size
[
0
],
window_size
[
1
]);
renderer_
->
Render
();
}
/////////////////////////////////////////////////////////////////////////////////////////////
void
cv
::
viz
::
Viz3d
::
VizImpl
::
setCameraParameters
(
const
cv
::
viz
::
Camera
&
camera
)
{
//rens_->InitTraversal ();
vtkSmartPointer
<
vtkCamera
>
cam
=
renderer_
->
GetActiveCamera
();
cam
->
SetPosition
(
camera
.
pos
[
0
],
camera
.
pos
[
1
],
camera
.
pos
[
2
]);
cam
->
SetFocalPoint
(
camera
.
focal
[
0
],
camera
.
focal
[
1
],
camera
.
focal
[
2
]);
cam
->
SetViewUp
(
camera
.
view_up
[
0
],
camera
.
view_up
[
1
],
camera
.
view_up
[
2
]);
cam
->
SetClippingRange
(
camera
.
clip
.
val
);
cam
->
SetUseHorizontalViewAngle
(
0
);
cam
->
SetViewAngle
(
camera
.
fovy
*
180.0
/
M_PI
);
window_
->
SetSize
(
static_cast
<
int
>
(
camera
.
window_size
[
0
]),
static_cast
<
int
>
(
camera
.
window_size
[
1
]));
}
/////////////////////////////////////////////////////////////////////////////////////////////
void
cv
::
viz
::
Viz3d
::
VizImpl
::
setCameraClipDistances
(
double
near
,
double
far
)
{
//rens_->InitTraversal ();
vtkSmartPointer
<
vtkCamera
>
cam
=
renderer_
->
GetActiveCamera
();
cam
->
SetClippingRange
(
near
,
far
);
}
/////////////////////////////////////////////////////////////////////////////////////////////
void
cv
::
viz
::
Viz3d
::
VizImpl
::
setCameraFieldOfView
(
double
fovy
)
{
//rens_->InitTraversal ();
vtkSmartPointer
<
vtkCamera
>
cam
=
renderer_
->
GetActiveCamera
();
cam
->
SetUseHorizontalViewAngle
(
0
);
cam
->
SetViewAngle
(
fovy
*
180.0
/
M_PI
);
}
/////////////////////////////////////////////////////////////////////////////////////////////
void
cv
::
viz
::
Viz3d
::
VizImpl
::
resetCameraViewpoint
(
const
std
::
string
&
id
)
{
// TODO Cloud actor is not used
vtkSmartPointer
<
vtkMatrix4x4
>
camera_pose
;
static
CloudActorMap
::
iterator
it
=
cloud_actor_map_
->
find
(
id
);
if
(
it
!=
cloud_actor_map_
->
end
())
...
...
modules/viz/src/viz3d_impl.hpp
View file @
f060eee5
...
...
@@ -121,27 +121,7 @@ public:
/** \brief Reset the camera direction from {0, 0, 0} to the center_{x, y, z} of a given dataset.
* \param[in] id the point cloud object id (default: cloud) */
void
resetCameraViewpoint
(
const
String
&
id
=
"cloud"
);
/** \brief Set the camera pose given by position, viewpoint and up vector
* \param[in] pos camera location
* \param[in] view the view point of the camera
* \param[in] up the view up direction of the camera */
void
setCameraPosition
(
const
cv
::
Vec3d
&
pos
,
const
cv
::
Vec3d
&
view
,
const
cv
::
Vec3d
&
up
);
/** \brief Set the camera location and viewup according to the given arguments
* \param[in] pos_x,y,z the x,y,z coordinate of the camera location
* \param[in] up_x,y,z the x,y,z component of the view up direction of the camera */
void
setCameraPosition
(
double
pos_x
,
double
pos_y
,
double
pos_z
,
double
up_x
,
double
up_y
,
double
up_z
);
/** \brief Set the camera parameters via an intrinsics and and extrinsics matrix
* \note This assumes that the pixels are square and that the center of the image is at the center of the sensor.
* \param[in] intrinsics the intrinsics that will be used to compute the VTK camera parameters
* \param[in] extrinsics the extrinsics that will be used to compute the VTK camera parameters */
void
setCameraParameters
(
const
cv
::
Matx33f
&
intrinsics
,
const
Affine3f
&
extrinsics
);
void
setCameraParameters
(
const
Camera
&
camera
);
void
setCameraClipDistances
(
double
near
,
double
far
);
void
setCameraFieldOfView
(
double
fovy
);
void
getCameras
(
Camera
&
camera
);
//to implement Viz3d set/getViewerPose()
void
setViewerPose
(
const
Affine3f
&
pose
);
Affine3f
getViewerPose
();
...
...
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