stereo_rectify.cpp
Go to the documentation of this file.
00001 #include "stereo_rectify.hpp"
00002 
00003 #include <iostream>
00004 
00005 namespace fovis
00006 {
00007 
00008 void
00009 stereo_rectify(const CameraIntrinsicsParameters& left_params,
00010                const CameraIntrinsicsParameters& right_params,
00011                const Eigen::Quaterniond& rotation_quat,
00012                const Eigen::Vector3d& translation,
00013                Eigen::Matrix3d* left_rotation,
00014                Eigen::Matrix3d* right_rotation,
00015                CameraIntrinsicsParameters* rectified_params)
00016 {
00017   // Get two cameras to same orientation, minimally rotating each.
00018   Eigen::AngleAxisd rect_rot(rotation_quat);
00019   rect_rot.angle() *= -0.5;
00020 
00021   Eigen::Vector3d rect_trans = rect_rot * translation;
00022   // Bring translation to alignment with (1, 0, 0).
00023   Eigen::Matrix3d rot;
00024   rot.row(0) = -rect_trans;
00025   rot.row(0).normalize();
00026   rot.row(1) = Eigen::Vector3d(0, 0, 1).cross(rot.row(0));
00027   rot.row(2) = rot.row(0).cross(rot.row(1));
00028 
00029   //std::cerr << "rot =\n" << rot << std::endl << std::endl;
00030 
00031   (*left_rotation) = rot * rect_rot.inverse();
00032   (*right_rotation) = rot * rect_rot;
00033 
00034   // For now just use left camera's intrinsic parameters
00035   *rectified_params = left_params;
00036 
00037   // Just to be explicit
00038   rectified_params->k1 = 0;
00039   rectified_params->k2 = 0;
00040   rectified_params->k3 = 0;
00041   rectified_params->p1 = 0;
00042   rectified_params->p2 = 0;
00043 }
00044 
00045 }


libfovis
Author(s): Albert Huang, Maurice Fallon
autogenerated on Thu Jun 6 2019 20:16:12