def processContoursinGt(path):
folder = sort_files(path)
length_cont_gt = []
for i in range(20,len(folder)):
newPath = path + "/0 (" + str(i) + ")" + ".png"
img = cv2.imread(newPath,cv2.CV_LOAD_IMAGE_COLOR)
#print "Image in processContour: ",img
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
gray = cv2.GaussianBlur(gray, (31, 31), 0)
thresh = cv2.threshold(gray, 25, 255, cv2.THRESH_BINARY)[1]
thresh = cv2.dilate(thresh, None, iterations=2)
(cnts, _) = cv2.findContours(thresh.copy(), cv2.RETR_EXTERNAL,cv2.CHAIN_APPROX_SIMPLE)
length_cont_gt.append(len(cnts))
return length_cont_gt
评论列表
文章目录