问题描述
我在 python 中使用 findChessboardCorners() 来查找角点,但它从未奏效。我尝试了灰色图像和黑白图像,但它仍然不起作用。有人能帮我吗?这是代码和图片。
import numpy as np
import cv2
import math
from matplotlib import pyplot as plt
def draw_img(img):
plt.figure()
plt.imshow(img)
plt.axis('off')
plt.show()
img = cv2.imread("a.png")
gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY) # Gray
complement_gray = cv2.bitwise_not(gray) # Complement gray
_,bw_img = cv2.threshold(gray,127,255,cv2.THRESH_BINARY) # black and white
success = False
for i in range(3,12):
for j in range(3,12):
ret,corners = cv2.findChessboardCorners(img,(i,j),cv2.CALIB_CB_ADAPTIVE_THRESH + cv2.CALIB_CB_FILTER_QUADS)
if ret:
success = True;
break;
ret,corners = cv2.findChessboardCorners(complement_gray,corners = cv2.findChessboardCorners(bw_img,cv2.CALIB_CB_ADAPTIVE_THRESH + cv2.CALIB_CB_FILTER_QUADS)
if ret:
success = True;
break;
if success:
print("Success")
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)