2020-12-30

本文介绍了如何在C++中利用Eigen库进行图像点的旋转和平移操作,以此实现图像的基本变换。
摘要由CSDN通过智能技术生成

 坐标转换案例

在C++中利用Eigen库对图像中的点进行旋转平移,以达到对图像的基本操作。

#include <iostream>
#include <Eigen/Dense>
#include <math.h>
#include <opencv/cv.hpp>

using namespace std;
# define deg2rad M_PI/180

Eigen::Matrix4f createTransformMatrix(Eigen::Vector3f theta, Eigen::Vector3f pose) {
    /* 介绍:根据旋转角度和平移向量,算出4*4的旋转平移矩阵
     * Eigen::Vector3d theta:旋转角度
     * Eigen::Vector3d pose:平移向量
     * */
    //平移矩阵

    Eigen::Matrix4f Pan_Matrix;
    Pan_Matrix <<
               1, 0, 0, pose[0],
            0, 1, 0, pose[1],
            0, 0, 1, pose[2],
            0, 0, 0, 1;
    //绕x旋转
    Eigen::Matrix3f x_rotate;
    x_rotate << 1, 0, 0,
            0, cos(deg2rad * theta[0]), -sin(deg2rad * theta[0]),
            0, sin(deg2rad * theta[0]), cos(deg2rad * theta[0]);
    //绕y旋转
    Eigen::Matrix3f y_rotate;
    y_rotate << cos(deg2rad * theta[1]), 0, sin(deg2rad * theta[1]),
            0, 1, 0,
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值