矩阵变换基础

三维变换

三维空间中的旋转--旋转向量

3D数学 ---- 矩阵和线性变换(1)

Resolving rotation matrices to obtain the angles

Q:

have used this code as a basis to detect my rectangular target in a scene.I use ORB and Flann Matcher.I have been able to draw the bounding box of the detected target in my scene successfully using the findHomography() and perspectiveTransform() functions. 
The reference image (img_object in the above code) is a straight view of only the rectangular target.Now the target in my scene image may be tilted forwards or backwards.I want to find out the angle by which it has been tilted.I have read various posts and came to the conclusion that the homography returned by findHomography() can be decomposed to the rotation matrix and translation vector. I have used code from https:/gist.github.com/inspirit/740979 recommended by this link translated to C++.This is the Zhang SVD decomposition code got from the camera calibration module of OpenCV.I got the complete explanation of this decomposition code from O'Reilly's Learning OpenCV book. 
I also used solvePnP() on the the keypoints returned by the matcher to cross check the rotation matrix and the translation vector returned from the homography decomposition but they do not seem to the same. 
I have already the measurements of the tilts of all my scene images.i found 2 ways to retrieve the angles from the rotation matrix to check how well they match my values.

Given a 3×3 rotation matrix

R = 
[ r_{11} & r_{12} & r_{13} ]
[ r_{21} & r_{22} & r_{23} ]
[ r_{31} & r_{32} & r_{33} ]

The 3 Euler angles are
theta_{x} = atan2(r_{32}, r_{33})

theta_{y} = atan2(-r_{31}, sqrt{r_{32}^2 + r_{33}^2})

theta_{z} = atan2(r_{21}, r_{11})

The axis,angle representation - Being R a general rotation matrix, its corresponding rotation axis u and rotation angle θ can be retrieved from:
cos(θ) = ( trace(R) − 1) / 2
[u]× = (R − R⊤) / 2 sin(θ)

I calculated the angles using both the methods for the rotation matrices obtained from the homography decomposition and the solvepnp().All the angles are different and give very unexpected values. 
Is there a hole in my understanding?I do not understand where my calculations are wrong.Are there any alternatives i can use?

A:

Why do you expect them to be the same? They are not the same thing at all.

The Euler angles are three angles of rotation about one axis at a time, starting from the world frame.

Rodriguez's formula gives components of one vector in the world frame, and an angle of rotation about that vector.

acually since am using both the formulas on the same rotation matrix,shouldn't one of the 3 euler angle match the angle gotten from the                              Rodriguez formula? I am new to these concepts so please correct me if am wrong. –  user2958957 Feb 14 '14 at 8:16  
       
                             No. The angle in Rodriguez's formula is the total rotation, Euler angles are three ordered rotations about three separate axis that,                                            together, accomplish the same total rotation. Suggestion, get yourself four pencils and some tape, bind three of them at 90 deg angles,                                then model the whole problem in your hands. –  Francesco Callari Feb 14 '14 at 14:17  
       
                             thanks for clarifying :) I have been also looking for alternative ways for homography decomposition and used Jav_Rock's answer in this                                for the homography returned by findHomography() but rotation angles are always 0. Is there a difference when am estimating a                                                homography between 2 images using matched points and using only 4 precise points to compute the homography? –  user2958957                                    Feb 17 '14 at 5:41

How to calculate Rotation and Translation matrices from homography?

Q:

I have already done the comparison of 2 images of same scene which are taken by one camera with different view angles(say left and right) using SURF in emgucv (C#). And it gave me a 3x3 homography matrix for 2D transformation. But now I want to make those 2 images in 3D environment (using DirectX). To do that I need to calculate relative location and orientation of 2nd image(right) to the 1st image(left) in 3D form. How can I calculate Rotation and Translate matrices for 2nd image?

I need also z value for 2nd image.

I read something called 'Homograhy decomposition'. Is it the way?

Is there anybody who familiar with homography decomposition and is there any algorithm which it implement?

Thanks in advance for any help.

A:

Homography only works for planar scenes (ie: all of your points are coplanar). If that is the case then the homography is a projective transformation and it can be decomposed into its components.
But if your scene isn't coplanar (which I think is the case from your description) then it's going to take a bit more work. Instead of a homography you need to calculate the fundamental matrix (which emgucv will do for you). The fundamental matrix is a combination of the camera intrinsic matrix (K), the relative rotation (R) and translation (t) between the two views. Recovering the rotation and translation is pretty straight forward if you know K. It looks like emgucv has methods for camera calibration. I am not familiar with their particular method but these generally involve taking several images of a scene with know geometry.

Thanks jlewis42 for pay attention on this matter. –  mili Feb 17 '12 at 3:21
   
But I calculate fundamental matrix as u said(using random generate points and project it using homography) and also I calculate thecamera intrinsic matrix using chess board method of EmguCV. But I can not find any method to get R and T directly from fundamentalmatrix. After that I calculate the essential matrix as describe in here and get the R and T as describe in here so It did not give me anacceptable answer. Where could be the error? –  mili Feb 17 '12 at 3:44 1

Unfortunately I can't answer that without knowing how the result is wrong. Here's a couple of things to look into: Are you sure all of your pointcorrespondences are valid? Check whether the fundamental matrix is correct using epipolar geometry(en.wikipedia.org/wiki/Epipolar_geometry). Basically if you multiply a point in the left image by the fundamental matrix it will give you theequation of a line in the right image (in ax + by + c = 0 form). The corresponding point in the right image will lie on that line. Also try recombining K, R and t to see if you get back the same F –  jlewis42 Feb 17 '12 at 17:22
   
Thanks jlewis42 I will take a look at these things and trying to fix the errors. again thanks. –  mili Feb 29 '12 at 1:06

To figure out camera motion (exact rotation and translation up to a scaling factor) you need

Calculate fundamental matrix F, for example, using eight-point algorithm
Calculate Essential matrix E = A’FA, where A is intrinsic camera matrix
Decompose E which is by definition Tx * R via SVD into E=ULV’
Create a special 3x3 matrix

0 -1  0   
W = 1  0  0      
    0  0  1  
that helps to run decomposition:

R = UW-1VT, Tx = ULWUT, where

0  -tx  ty
Tx =  tz  0   -tx
     -ty  tx   0 
Since E can have an arbitrary sign and W can be replace by Winv we have 4 distinct solution and have to select the one which produces most points in front of the camera.

It's been a while since you asked this question. By now, there are some good references on this problem.

One of them is "invitation to 3D image" by Ma, chapter 5 of it is free here http://vision.ucla.edu//MASKS/chapters.html

Also, Vision Toolbox of Peter Corke includes the tools to perform this. However, he does not explain much math of the decomposition

Extract face rotation from homography in a video

Calculating scale, rotation and translation from Homography matrix

decomposeHomographyMat

单应矩阵计算旋转角和平移量相关推荐

  1. ORBSLAM2单应矩阵计算及代码分析

    单应矩阵代码分析 if(mpInitializer->Initialize(mCurrentFrame, //当前帧mvIniMatches, //当前帧和参考帧的特征点的匹配关系Rcw, tc ...

  2. 根据相机外参实现单应矩阵计算的理论与实践

    论文阅读模块将分享点云处理,SLAM,三维视觉,高精地图相关的文章.公众号致力于理解三维视觉领域相关内容的干货分享,欢迎各位加入我,我们一起每天一篇文章阅读,开启分享之旅,有兴趣的可联系微信diany ...

  3. 内参矩阵、外参矩阵、旋转矩阵、平移矩阵、单应矩阵、本征矩阵、基础矩阵

    自己在单目结构光系统.双单目结构光系统及双目相机系统学习的过程中接触到如标题所列的各种矩阵,总感觉理解不到位,现在特总结下,方便日后查阅及修正自己的理解. 自己已经总结了单目相机各坐标系的变换,链接如 ...

  4. 基础矩阵,本质矩阵,单应性矩阵讲解

    ORB-SLAM点云地图中相机的位姿初始化,无论算法工作在平面场景,还是非平面场景下,都能够完成初始化的工作.其中主要是使用了适用于平面场景的单应性矩阵H和适用于非平面场景的基础矩阵F,程序中通过一个 ...

  5. 单应性Homograph估计:从传统算法到深度学习

    点击上方"3D视觉工坊",选择"星标" 干货第一时间送达 本文作者:白裳 https://zhuanlan.zhihu.com/p/74597564 本文已由原 ...

  6. 【python】图像映射:单应性变换与图像扭曲

    [python]图像映射:单应性变换与图像扭曲 单应性变换(Homography) 图像扭曲(仿射变换) 图中图 分段仿射扭曲 单应性变换(Homography) 单应性变换(Homography)即 ...

  7. opencv求两张图像光流_OpenCV单应性矩阵发现参数估算方法详解

    点击上方蓝字关注我们 微信公众号:OpenCV学堂 关注获取更多计算机视觉与深度学习知识 单应性矩阵计算函数与应用 OpenCV在通过特征描述子完成描述子匹配之后,会得到一些关键点对,我们会把这些关键 ...

  8. sift算法_单应性Homograph估计:从传统算法到深度学习

    点击上方"CVer",选择加"星标"置顶 重磅干货,第一时间送达 本文作者:白裳 https://zhuanlan.zhihu.com/p/74597564 本 ...

  9. 单目slam基础 特点匹配 光流匹配 单应变换恢复变换矩阵 本质矩阵恢复变换矩阵 深度滤波

    非滤波单目slam基础 非滤波方法的单目视觉SLAM系统综述 论文 直接法 特征点法 混合法区别与联系 按照 2D−2D 数据关联方式的不同 ,视觉定位方法可以分为直接法.非直接法和混合法1. 直接法 ...

  10. svo: semi-direct visual odometry 半直接视觉里程计 fast角点匹配 光流匹配 单应变换求位姿 直接法求解位姿 高斯均匀分布混合深度滤波

    svo: semi-direct visual odometry 半直接视觉里程计 本博文github地址 svo代码注释 SVO代码分析 较细致 svo: semi-direct visual od ...

最新文章

  1. 文巾解题 167. 两数之和 II - 输入有序数组
  2. Javascript---js的编码及解码
  3. iview 循环 卡片 更好图标 背景色 标题
  4. 化学公式编辑器如何给图形着色
  5. CSS盒子模型居中方法,附超全教程文档
  6. 从阿西莫夫机器人三大定律 谈起
  7. hoolilaw特别分享:在美国喝多少酒就算酒驾
  8. 【光学】Matlab模拟几何光学中的球差、彗差、像散、场曲四种像差
  9. [系统安全] 二十二.PE数字签名之(下)微软证书漏洞CVE-2020-0601复现及Windows验证机制分析
  10. 想成为高级程序员MYSQL的那些知识你需要全懂
  11. 【十进制 转 二进制】【二进制 转 十进制】10进制 VS 2进制【清华大学考研机试题】
  12. 打不开“计算机管理”
  13. 电子计算机奏出美妙的交响改为把字句,按要求改写下面的句子. 美妙的琴声陶醉了兄妹俩. 改为被字句: 改为把字句:...
  14. 树莓派六足仿生蜘蛛机器人Hexapod二次开发源代码
  15. linux编译安装zfs,ZFS安装配置
  16. 《乐高EV3机器人搭建与编程》——2.5 可循环充电锂电池
  17. Ubuntu16.04下为Titan RTX 安装显卡驱动、CUDA、cudnn
  18. ipconfig命令的几种使用方法
  19. 如何查看python源代码_Python源代码: 如何获取微信公众号历史记录文章
  20. 【java】本地客户端内嵌浏览器2 - chrome/chromium/cef/jcef

热门文章

  1. 《剑指offer》之知识汇总
  2. 软件测试面试必问的10个问题
  3. mysql数据库压缩_Mysql压缩解决方案
  4. Can‘t update 分支名 has no tracked branch
  5. 电路交换、报文交换和分组交换的区别
  6. java物流项目描述_java-web模块物流项目四
  7. uva 473 - Raucous Rockers(dp)
  8. Linux·串口编程
  9. 一句话理解到底什么是电平触发器,脉冲触发器,同步触发器,边沿触发器
  10. 知其然知其所以然 itoa实现 整型转字符串