視差和深度分析與計算

Linear_Luo發表於2016-08-27

  我們先來看opencv給出的一個教程[ http://docs.opencv.org/3.1.0/dd/d53/tutorial_py_depthmap.html ]裡面對概念的說明。先看下面這張圖:
這裡寫圖片描述
  通過這張圖,我們得出視差的計算表示式為:

disparity=xx=BFZ
disparity=x-x^{'}=\frac{BF}{Z}

  其中x
x
x
x^{'}
對應的是場景中的3D點和相機中心在影象平面上的投影點的距離,stack flow上面的回答[ http://stackoverflow.com/questions/17607312/difference-between-disparity-map-and-disparity-image-in-stereo-matching ]更加準確,這個稍後再來參考。B
B
是兩個相機中心的距離,f
f
是相機的焦距,Z
Z
就是對應點的深度了(作者在這兒選擇Z代表深度,應該也是想要表達深度是Z軸方向的距離)。通過上面的表示式我們也能看出來深度和視差成反比。下面再來理解下視差這個概念。下面的英文講解得相當透徹,就不多此一舉翻譯成中文了。
  Disparity refers to the distance between two corresponding points in the left and right image of a stereo pair. If you look at the image below you see a labelled point X (ignore X1, X2 & X3). By following the dotted line from X to OL you see the intersection point with the left hand plane at XL. The same principal applies with the right-hand image plane.
這裡寫圖片描述
  If X projects to a point in the left frame XL = (u,v) and to the right frame at XR = (p,q) you can find the disparity for this point as the magnitude of the vector between (u,v) and (p,q). Obviously this process involves choosing a point in the left hand frame and then finding its match (often called the corresponding point) in the right hand image; often this is a particularly difficult task to do without making a lot of mistakes.

相關文章