java opencv 平移,单应性opencv的旋转和平移矩阵

I'm working on an android application in java,I calculated homography with opencv using findHomography(), how I can find the matrix of the camera pose containing the rotation and translation through homography

Mat homography = Calib3d.findHomography(ReferencePoints2, ReferencePoints1,0,Calib3d.RANSAC);

解决方案

You need to know the intrinsic parameters of the camera to do that.

Considers the z=0 plane. The point

X=(x,y,0,1)'

is projected to the image as

p=P*X.

Now use the decomposition

P=K[R t],

where K is the calibration matrix and [R t] are extrinsic parameters. Since z=0, the third column vector of R is multiplied by zero. We can now drop the 3rd column to get

p=K*[r1 r2 t]*(x,y,1)=H*(x,y,1),

where H is a planar homography.

You have already computed H from e.g. known points. The first and second column of R and the vector t can now be recovered

[r1 r2 t]=inv(K)*H.

Make sure that r1 and r2 are unit length, then t is the correct translation vector. The third column vector of R can be recovered because R is orthogonal, for example using the cross product.

r3=cross(r1,r2).

Since H is a measurement, the r1 and r2 you computed are not exact. You can use the SVD for obtaining the closest rotation matrix to a measurement. You can then compose a projection matrix

P=K[r1 r2 r3 t]

which projects any 3D point in the coordinate frame based on your 2D coordinate system of the homograohy.

Here is some course material, which describes this situation.

As @nbsrujan (thanks) pointed out, for those using OpenCV, there is a function which can decompose a homography into translation and rotation matrices given the intrinsics.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值