gpt4 book ai didi

python - 使用python进行相机校准

转载 作者:行者123 更新时间:2023-12-02 17:50:39 24 4
gpt4 key购买 nike

我正在尝试使用棋盘法校准拖曳网络摄像头
但是每次我执行opencv示例中提供的代码源
我收到此消息:

processing ../cpp\img1.jpg... chessboard not found
processing ../cpp\img2.jpg... chessboard not found
processing ../cpp\img3.jpg... chessboard not found
processing ../cpp\img4.jpg... chessboard not found
processing ../cpp\img5.jpg... chessboard not found

这是img1
http://i.stack.imgur.com/04b4U.jpg

好的,代码是opencv示例中的代码,这里是cv2的一部分。FindChessboard()
 for fn in img_names:
print 'processing %s...' % fn,
img = cv2.imread(fn, 0)
h, w = img.shape[:2]
found, corners = cv2.findChessboardCorners(img, pattern_size)
if found:
term = ( cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_COUNT, 30, 0.1 )
cv2.cornerSubPix(img, corners, (5, 5), (-1, -1), term)
if debug_dir:
vis = cv2.cvtColor(img, cv2.COLOR_GRAY2BGR)
cv2.drawChessboardCorners(vis, pattern_size, corners, found)
path, name, ext = splitfn(fn)
cv2.imwrite('%s/%s_chess.bmp' % (debug_dir, name), vis)
if not found:
print 'chessboard not found'
continue
img_points.append(corners.reshape(-1, 2))
obj_points.append(pattern_points)

print 'ok'

最佳答案

假设您的代码正确,则您的棋盘可能有问题。查看有关函数findChessboardCorners(link)的文档,最后有一条注释说明:

The function requires white space (like a square-thick border, the wider the better) around the board to make the detection more robust in various environments. Otherwise, if there is no border and the background is dark, the outer black squares cannot be segmented properly and so the square grouping and ordering algorithm fails.



如果您查看 this calibration tutorial中提供的图像,则棋盘周围会有更多空白,这很重要:

同样,这可能是一种印象,但是看来您的外部正方形与其他正方形的大小不同,这也可能很重要。

关于python - 使用python进行相机校准,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22251142/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com