试图找到棋盘角时打开cv python错误 [英] open cv python error when trying to find chessboard corners

查看:109
本文介绍了试图找到棋盘角时打开cv python错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须编写一个想要使用python和opencv的相机校准. 我当前遇到的问题如下:

I have to write a camera-calibration an wanted to use python and opencv. The current problem I have is the following:

我在下面写下了代码:

import sys
import numpy as np
import cv2

image = cv2.imread(sys.argv[1])
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)

ret = False
ret, corners = cv2.findChessboardCorners(image, (7,6), None)

print ret

到目前为止还算不错,但是我每次使用ret变量将哪个图像转为 False 都没关系,这基本上意味着没有发现拐角.

okay so far so good, but it doesn't matter which image I am using my ret variable is turning False every single time, which basically means that there were no corners found.

关于堆栈溢出的问题,这里有一些问题,但是没有一种解决方案可以解决我的问题.我尝试使用从500x500到8MP的图像,后来我对其进行了锐化,甚至使用原始的国际象棋棋盘来获取优势.他们都没有工作.

There are some questions about this problem here on stack overflow but none of the solutions there would work for my problem. I tried using Images from 500x500 up to 8MP, I sharpened them afterwards, I even used the original Chessboards to get the corners. None of them worked.

是否还有另一种方法来获取它们?或者我是否从头开始做任何完全错误的事情?

Is there another way to get them or am I doing anything complete false from the ground up?

我也尝试使用没有灰度的图像,但是问题是相同的.

I also tried using the images without grayscale but the problem is the same.

推荐答案

好的,我发现了问题所在.

Okay, I found out what the problem was.

我之前不知道的是,您必须输入的尺寸是棋盘的原始尺寸减去1:

The thing I didn't know before was that the dimensions you have to enter are original dimensions of the chessboard minus 1:

因此,如果您有10 x 7的电路板,则使用的尺寸为9 x 6.

So if you have a 10 x 7 board, the dimensions to use are 9 x 6.

这也许会对其他有相同问题的人有所帮助.

Maybe this will be helpful for other people having the same problem.

更新:修复了严重的错字.使用的尺寸为9 x 6,而不是9 x 7.

这篇关于试图找到棋盘角时打开cv python错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆