matlab纠正图⽚⾓度,matlab–使⽤Roll-Pitch-Yaw⾓度的变换
图像(图像校正)
我正在处理⼀个应⽤程序,我需要纠正从移动摄像机平台拍摄的图像.该平台测量滚动,俯仰和偏航⾓度,我想让它看起来像从上⾯拍摄的图像,通过这种信息的某种转换.
换句话说,我想要⼀个完美的平⾯躺在地上,从远处拍摄照相机的⽅向,要进⾏变形,以便⼴场完美对称.
我⼀直在试图通过OpenCV(C)和Matlab这样做,但是我似乎缺少⼀些关于如何做到这⼀点的基础.
在Matlab中,我尝试过以下操作:
纳威 隆巴顿%% Transform perspective
img = imread('my_favourite_image.jpg');
收费翻译
R = R_z(yaw_angle)*R_y(pitch_angle)*R_x(roll_angle);
tform = projective2d(R);
outputImage = imwarp(img,tform);
figure(1), imshow(outputImage);
其中R_z / y / x是标准旋转矩阵(⽤度数实现).
对于⼀些偏航旋转,它⼀切正常⼯作:狐狸叫下载
engagewithR = R_z(10)*R_y(0)*R_x(0);
结果如下:
如果我尝试以与X轴或Y轴相同的量旋转图像,我会得到如下结果:
R = R_z(10)*R_y(0)*R_x(10);
然⽽,如果我旋转10度,除以⼀些巨⼤的数字,它开始看起来OK.但是再⼀次,这是⼀个没有研究价值的结果:
R = R_z(10)*R_y(0)*R_x(10/1000);
有⼈可以帮我理解为什么旋转X轴或Y轴会使转型变得疯狂吗?有什么办法可以解决这个问题吗?这是否可以使⽤某种欧拉参数来解决?任何帮助将⾼度赞赏!
curry
更新:完整设置和测量
为了完整,已经添加了完整的测试代码和初始图像,以及平台欧拉⾓度:
码:
%% Transform perspective
function [] = main()
img = imread('some_image.jpg');
R = R_z(0)*R_y(0)*R_x(10);
tform = projective2d(R);
outputImage = imwarp(img,tform);
figure(1), imshow(outputImage);
end
%% Matrix for Yaw-rotation about the Z-axis
function [R] = R_z(psi)
R = [cosd(psi) -sind(psi) 0;
mdlsind(psi) cosd(psi) 0;
0 0 1];
end
%% Matrix for Pitch-rotation about the Y-axis
function [R] = R_y(theta)
特朗普演讲视频R = [cosd(theta) 0 sind(theta);
0 1 0 ;
-
sind(theta) 0 cosd(theta) ];
ilc
end
%% Matrix for Roll-rotation about the X-axis
ready player onefunction [R] = R_x(phi)
R = [1 0 0;
0 cosd(phi) -sind(phi);
幽默语言0 sind(phi) cosd(phi)];
end
初始形象:
BODY坐标系中的相机平台测量:
Roll: -10
Pitch: -30
Yaw: 166 (angular deviation from north)
从我所了解的⾓度看,与转型并不直接相关.不过我可能错了.
附加信息:
我想指定使⽤安装程序的环境不包含可靠地⽤作参考的⾏(海洋照⽚)(地平线通常不在图⽚中).此外,初始图像中的正⽅形仅⽤作衡量变换是否正确的度量,也不会在实际情况下出现.