vnl_matrix_fixed<mitk::ScalarType, 4, 4> Transform::GetMatrix() const { vnl_vector_fixed<mitk::ScalarType, 3> transl = this->GetVnlTranslation(); vnl_matrix_fixed<mitk::ScalarType, 3, 3> rot = this->GetVnlRotationMatrix(); vnl_matrix_fixed<mitk::ScalarType, 4, 4> homMat; homMat.set_identity(); //std::cout << homMat << std::endl; for(unsigned int i=0; i<rot.rows(); ++i) for(unsigned int j=0; j<rot.cols(); ++j) homMat(i,j) = rot(i,j); for(unsigned int i=0; i<transl.size(); ++i) homMat(i,3) = transl[i]; return homMat; }
cv::Mat PointVec2HomogeneousMat(const std::vector<cv::Point2f>& pts) { int num_pts = pts.size(); cv::Mat homMat(3, num_pts, CV_32FC1); for(int i=0; i<num_pts; i++){ homMat.at<float>(0,i) = pts[i].x; homMat.at<float>(1,i) = pts[i].y; homMat.at<float>(2,i) = 1.0; } return homMat; }