mirror of
https://github.com/opencv/opencv.git
synced 2024-11-29 13:47:32 +08:00
simulate real cameras by working around vtkUserTransform to set projection matrix
This commit is contained in:
parent
422b967e9a
commit
71dc5f8291
@ -573,6 +573,16 @@ void cv::viz::Viz3d::VizImpl::setCamera(const Camera &camera)
|
||||
active_camera.SetViewAngle (camera.getFov()[1] * 180.0f / CV_PI);
|
||||
active_camera.SetClippingRange (camera.getClip()[0], camera.getClip()[1]);
|
||||
window_->SetSize (camera.getWindowSize().width, camera.getWindowSize().height);
|
||||
|
||||
// Use the intrinsic parameters of the camera to simulate more realistically
|
||||
Matx44f proj_matrix;
|
||||
camera.computeProjectionMatrix(proj_matrix);
|
||||
Matx44f old_proj_matrix = convertToMatx(active_camera.GetProjectionTransformMatrix(((float)camera.getWindowSize().width) / camera.getWindowSize().height, -1.0f, 1.0f));
|
||||
vtkTransform * transform = vtkTransform::New();
|
||||
// This is a hack around not being able to set Projection Matrix
|
||||
transform->SetMatrix(convertToVtkMatrix(proj_matrix * old_proj_matrix.inv()));
|
||||
active_camera.SetUserTransform(transform);
|
||||
transform->Delete();
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
Loading…
Reference in New Issue
Block a user