Pyton生成标定板
做一个和Opencv相关的项目调研,这里留下些记录….

使用Opencv进行图摄像头标定时,要用到标定板。下面用Python开始生成一个标定板:
#!/usr/bin/env python2# -*- coding: utf-8 -*-"""Created on Wed Mar 21 16:21:49 2018
@author: xiaoxiwang"""
import cv2import numpy as npimport matplotlib.pyplot as plt
# 宽450像素width = 450# 高350像素height = 350# 50 x 50 一个单元格length = 50
img = np.zeros((width, height), dtype=np.uint8)
for j in range(height): for i in range(width): if ((int)(i / length) + (int)(j / length)) % 2: img[i, j] = 255# 将标定板保存为图checkboard.jpgcv2.imwrite('checkerborad.jpg', img)# 使用matplotlib查看生成的标定板plt.subplot(111), plt.imshow(img, cmap='gray'), plt.title('Output')plt.show()