我一直在尝试检测复选框。虽然我能够检测到其他图像中的方形轮廓,但我无法获取该特定图像的轮廓。请帮我检测复选框。
这是我的代码,
for myfile in files:
image=cv2.imread(myfile)
image = cv2.resize(image, (180,60), interpolation = cv2.INTER_AREA)
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
#apply otsu's threshold
thresh = cv2.threshold(gray, 0, 255, cv2.THRESH_BINARY_INV + cv2.THRESH_OTSU)[1]
#setting up threshold values
threshold_max_area = 300
threshold_min_area = 10
#finding contours in the image
cnts = cv2.findContours(thresh, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
cnts = cnts[0] if len(cnts) == 2 else cnts[1]
#getting the coordinates for each checkbox
count=0
centers=[]
for c in cnts:
peri = cv2.arcLength(c, True)
approx = cv2.approxPolyDP(c, 0.035 * …Run Code Online (Sandbox Code Playgroud)