一个小记录,怎么使用圆点标定板对相机进行标定。
opencv api手册页面
https://docs.opencv.org/master/d9/d0c/group__calib3d.html#ga7f02cd21c8352142890190227628fa80
参考了
http://answers.opencv.org/question/3471/findcirclesgrid-not-working/
不过测试后,标定结果貌似不怎么好
SimpleBlob 看起来可以调节很多参数,应该需要仔细设定

opencv 圆点标定板图像 路径是
opencv安装目录\sources\doc\acircles_pattern.png
在这里插入图片描述

下面代码情况示例
在这里插入图片描述

import cv2

w = 4
h = 11
criteria = (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 30, 0.001)

def find_corners(img):
    gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
    params = cv2.SimpleBlobDetector_Params()
    params.maxArea = 10e4
    params.minArea = 10
    params.minDistBetweenBlobs = 5
    blobDetector = cv2.SimpleBlobDetector_create(params)
    ret, corners = cv2.findCirclesGrid(gray, (w, h), cv2.CALIB_CB_ASYMMETRIC_GRID, blobDetector, None)
    if ret:
        cv2.cornerSubPix(gray, corners, (w, h), (-1, -1), criteria)
        return corners
    return None

cam = cv2.VideoCapture(0)
if not cam.isOpened():
    print('open cam failure')
    exit(0)
while True:
    ret, img = cam.read()
    if ret:
        cv2.imshow('viewer', img)
        key = cv2.waitKey(1000 // 60) & 0xff
        if key == ord(' '):
            corners = find_corners(img)
            # 将角点在图像上显示
            cv2.drawChessboardCorners(img, (w, h), corners, corners is not None)
            cv2.imshow('findCorners', img)
GitHub 加速计划 / opencv31 / opencv
77.38 K
55.71 K
下载
OpenCV: 开源计算机视觉库
最近提交(Master分支:2 个月前 )
c3747a68 Added Universal Windows Package build to CI. 12 天前
9b635da5 - 12 天前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐