小编Sha*_*r P的帖子

opencv 复选框检测

我一直在尝试检测复选框。虽然我能够检测到其他图像中的方形轮廓,但我无法获取该特定图像的轮廓。请帮我检测复选框。

输入图像: 输入图像

这是我的代码,

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)

python opencv image-processing contour computer-vision

1
推荐指数
1
解决办法
2468
查看次数