|
|
|
@ -604,13 +604,18 @@ void cv::viz::Viz3d::VizImpl::setCamera(const Camera2 &camera) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
void cv::viz::Viz3d::VizImpl::getCamera(viz::Camera2 &camera) |
|
|
|
|
cv::viz::Camera2 cv::viz::Viz3d::VizImpl::getCamera() const |
|
|
|
|
{ |
|
|
|
|
vtkCamera& active_camera = *renderer_->GetActiveCamera(); |
|
|
|
|
camera.setFov(Vec2f(0.0, active_camera.GetViewAngle() * CV_PI / 180.0f)); |
|
|
|
|
camera.setClip(Vec2d(active_camera.GetClippingRange())); |
|
|
|
|
camera.setWindowSize(Size(renderer_->GetRenderWindow()->GetSize()[0], |
|
|
|
|
renderer_->GetRenderWindow()->GetSize()[1])); |
|
|
|
|
|
|
|
|
|
Vec2f fov(0.0, active_camera.GetViewAngle() * CV_PI / 180.0f); |
|
|
|
|
Vec2d clip(active_camera.GetClippingRange()); |
|
|
|
|
Size window_size(renderer_->GetRenderWindow()->GetSize()[0], |
|
|
|
|
renderer_->GetRenderWindow()->GetSize()[1]); |
|
|
|
|
|
|
|
|
|
Camera2 camera(fov, window_size); |
|
|
|
|
camera.setClip(clip); |
|
|
|
|
return camera; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
@ -664,6 +669,35 @@ cv::Affine3f cv::viz::Viz3d::VizImpl::getViewerPose () |
|
|
|
|
return cv::Affine3f(R, pos); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
void cv::viz::Viz3d::VizImpl::convertToWindowCoordinates(const Point3f &pt, Point3f &window_coord) |
|
|
|
|
{ |
|
|
|
|
// Use the built in function of renderer
|
|
|
|
|
double point_wcs[3] = {pt.x, pt.y, pt.z}; |
|
|
|
|
renderer_->WorldToView(point_wcs[0], point_wcs[1], point_wcs[2]); |
|
|
|
|
window_coord.x = point_wcs[0]; |
|
|
|
|
window_coord.y = point_wcs[1]; |
|
|
|
|
window_coord.z = point_wcs[2]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
void cv::viz::Viz3d::VizImpl::converTo3DRay(const Point3f &window_coord, Point3f &origin, Vec3f &direction) |
|
|
|
|
{ |
|
|
|
|
// Use the built in function of renderer
|
|
|
|
|
double point_view[3] = {window_coord.x, window_coord.y, window_coord.z}; |
|
|
|
|
renderer_->ViewToWorld(point_view[0], point_view[1], point_view[2]); |
|
|
|
|
|
|
|
|
|
vtkCamera &active_camera = *renderer_->GetActiveCamera(); |
|
|
|
|
double *cam_pos = active_camera.GetPosition(); |
|
|
|
|
origin.x = cam_pos[0]; |
|
|
|
|
origin.y = cam_pos[1]; |
|
|
|
|
origin.z = cam_pos[2]; |
|
|
|
|
direction[0] = point_view[0] - cam_pos[0]; |
|
|
|
|
direction[1] = point_view[1] - cam_pos[1]; |
|
|
|
|
direction[2] = point_view[2] - cam_pos[2]; |
|
|
|
|
normalize(direction); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
void cv::viz::Viz3d::VizImpl::resetCamera () |
|
|
|
|
{ |
|
|
|
|