前言
本篇主要是使用python opencv标定相机内参和畸变参数的记录,主要参考opencv官方文档中的示例。
本篇不会涉及标定原理。
准备棋盘格
一张棋盘格图(最好把棋盘格图粘贴到一块平板上,保证棋盘上的角点都在同一平面)。
这里提供一个简单的棋盘格生成程序,在A4纸打印分辨率为96ppi时,棋盘每个格子的宽度为cube_cm:
def generate_chessboard(cube_cm=2., pattern_size=(8, 6), scale=37.79527559055118):
"""
generate chessboard image with given cube length, which adapts to A4 paper print
:param cube_cm: float, single cube length in cm
:param pattern_size: (x, y), the number of points in x, y axes in the chessboard
:param scale: float, scale pixel/cm in A4 paper
"""
# convert cm to pixel
cube_pixel = cube_cm * scale
width = round(pattern_size[0] * cube_cm * scale)
height = round(pattern_size[1] * cube_cm * scale)
# generate canvas
image = np.zeros([width, height, 3], dtype=np.uint8)
image.fill(255)
color = (255, 255, 255)
fill_color = 0
# drawing the chessboard
for j in range(0, height + 1):
y = round(j * cube_pixel)
for i in range(0, width + 1):
x0 = round(i * cube_pixel)
y0 = y
rect_start = (x0, y0)
x1 = round


3867

被折叠的 条评论
为什么被折叠?



