摄像头Camera标定Calibration原理Theory
攝像頭Camera標定Calibration原理Theory
cv2.cameraCalibration
Pinhole camera calibration calls camera
vision from 3D objects in the real world and transforms them into a 2D image.
攝像頭標定這里指利用常規(小孔成像)攝像頭觀察真實三位物體對二維圖像的矯正轉換。
We named points from objects as objects
point and points in image as image points.
3D的點被叫做物體點,而2D的圖像點被叫做圖像點。
To calibrate camera, we need to undistort
radial distortion and tangential distortion.
Radial Distortion: Radial Distortion is the
most common type that affects the images, In which when a camera captured
pictures of straight lines appeared slightly curved or bent.
Tangential distortion: Tangential
distortion occurs mainly because the lens is not parallely aligned to the
imaging plane, that makes the image to be extended a little while longer or
tilted, it makes the objects appear farther away or even closer than they
actually are.
攝像頭標定矯正主要解決徑向畸變和切向畸變。
徑向畸變是圖像像素點以畸變中心為中心點,沿著徑向產生的位置偏差,從而導致圖像中所成的像發生形變。
圖像徑向畸變是成像過程中最主要的畸變,同時也是對成像效果影響最大的畸變,廣角或者魚眼的畸變效果,
矯正算法采用多項式擬合:
切向畸變,這是由于透鏡與成像平面不可能絕對平行造成的。
這種畸變會造成圖像中的某些點看上去的位置會比我們認為的位置要近一些。
Five Distortion Coefficients 五個畸變系數:
In math, the Transformation from 3D object
points, P of X, Y and Z to X and Y is done by a transformative matrix called
the camera matrix?, we’ll be using this to calibrate the camera.
max = 攝像機矩陣 = 攝像機的內部參數(焦距和光學中心)
內部參數是攝像機本身具有的,包括的信息有焦距(f x ,f y ),光學中心(c x ,c y )。
dist = 外部參數(旋轉和變換向量)
外部參數與旋轉和變換向量相對應,它可以將 3D 點的坐標轉換到坐標系統中。
It’s recommended to use at least 20 images
to get a reliable calibration, For this, we have a lot of images here, each
chess board has eight by six corners to detect
于是必須要提供一些包含明顯圖案模式的樣本棋盤圖片,一般至少需要 10 個(部分中文資料)建議20個這樣的圖案模式。
or
where
(X, Y, Z) are the coordinates of a 3D point
in the world coordinate space
(u, v) are the coordinates of the
projection point in pixels
A is a camera matrix, or a matrix of
intrinsic parameters
(cx, cy) is a principal point that is
usually at the image center
fx, fy are the focal lengths expressed in
pixel units.
A chessboard is great for calibration
because it’s regular, high contrast pattern makes it easy to detect
automatically. And we know how an undistorted flat chessboard looks like. So,
if we use our camera to take pictures of Chessboard at different angles
棋盤主要是通過角點來計算畸變,
import numpy as np
import cv2, glob
calibrate_source_path =
‘./data/camera_cal/*.jpg’
calibrate_test_path =
‘./data/test_image.jpg’
define
objpoints = []
imgpoints = []
nx = 8
ny = 6
objp = np.zeros((ny*nx,3),np.float32)
objp[:,:2] =
np.mgrid[0:nx,0:ny].T.reshape(-1,2)
chessboard
for path in
glob.glob(calibrate_source_path):
gray
= cv2.cvtColor(cv2.imread(path),cv2.COLOR_BGR2GRAY)
ret,corners =
cv2.findChessboardCorners(gray,(nx,ny))
if
ret:
objpoints.append(objp)
imgpoints.append(corners);
gray = cv2.drawChessboardCorners(gray, (nx,ny), corners, ret)
execute
img = cv2.imread(calibrate_test_path)
ret, mtx, dist, rvecs, tvecs =
cv2.calibrateCamera(objpoints, imgpoints, img.shape[1:], None, None)
dst = cv2.undistort(img, mtx, dist, None,
mtx)
display
cv2.imshow(None,
cv2.pyrDown(np.hstack((img,dst))))
cv2.waitKey(0); cv2.destroyAllWindows()
總結
以上是生活随笔為你收集整理的摄像头Camera标定Calibration原理Theory的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 斯坦福大学李飞飞团队图像分类课程笔记
- 下一篇: 摄像头和相机模型和内参原理