做一个和Opencv相关的项目调研,这里留下些记录….
使用Opencv进行图摄像头标定时,要用到标定板。下面用Python开始生成一个标定板:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Created on Wed Mar 21 16:21:49 2018
@author: xiaoxiwang
"""
import cv2
import numpy as np
import 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.jpg
cv2.imwrite('checkerborad.jpg', img)
# 使用matplotlib查看生成的标定板
plt.subplot(111), plt.imshow(img, cmap='gray'), plt.title('Output')
plt.show()
|