如何解决findChessboardCorners 在 opencv 4.5.2 python 中不起作用
我在 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 举报,一经查实,本站将立刻删除。