# 相机标定
## 1、保存相机采集的图像
```
import cv2
cap = cv2.VideoCapture(0)
index = 0
while (1):
ret,frame = cap.read()
cv2.imshow("capture",frame)
# ckey = cv2.waitKey(1)&0xFF
ckey = cv2.waitKey(1)
print(ckey)
if ret and (ckey == ord('s')):
# if ret:
# if ret and 0xFF == ord('q'):
# print(ckey)
index = index + 1
print(index)
cv2.imwrite('C:/Users/kangs/Desktop/calibration/' + str(index) + '.jpg',frame)
if index > 20:
break
cap.release()
cv2.destroyAllWindows()
```
## 2、相机标定
```
# coding: utf-8
# Camera Calibration with OpenCV
# ### Run the code in the cell below to extract object points and image points for camera calibration.
import numpy as np
import cv2
import glob
import matplotlib
from scipy import io
matplotlib.use('qt5agg')
import matplotlib.pyplot as plt
np.set_printoptions(suppress=True)
#

该博客介绍了如何使用OpenCV进行相机标定的过程,包括采集图像、寻找棋盘格角点、标定参数计算以及图像去畸变。示例代码展示了从捕获图像到生成并保存校正后的图像的完整步骤。
最低0.47元/天 解锁文章
4871

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



