我正在尝试使用opencv 3.0.0版来检测十字准线。 我想要一些帮助,所以我可以解决问题并继续检测它的中心。image to detect
import cv2
import numpy as np
img = cv2.imread("cross1.png")
cv2.namedWindow('Original', cv2.WINDOW_NORMAL)
cv2.imshow('Original',img)
imgray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
ret,thresh = cv2.threshold(imgray,140,255,cv2.THRESH_BINARY)
cv2.namedWindow('thresh', cv2.WINDOW_NORMAL)
cv2.imshow('thresh',thresh)
clone=thresh.copy()
(_,cnts,_) = cv2.findContours(clone.copy(), cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)
print (len(cnts))
cv2.drawContours(clone,cnts , -1, (0, 255, 0), 2)
cv2.namedWindow('cont', cv2.WINDOW_NORMAL)
cv2.imshow('cont',clone)
cv2.waitKey(0)