can someone help me identify the problem in my code, I'm trying to find all the contours in my image and then coat it with an ash border but it seems to only coat some of the contours. '''
image_find_goal = "/absolutePathWays.img"
kernel = np.ones((5,5),np.uint8)
#findGoal(image_find_goal)
img1 = cv.imread(image_find_goal,cv.IMREAD_GRAYSCALE)
ret,mask = cv.threshold(img1, 125, 255, cv.THRESH_BINARY_INV)
contours, hierarchy = cv.findContours(mask,cv.RETR_TREE,cv.CHAIN_APPROX_NONE)
for cnt in contours:
approx = cv.approxPolyDP(cnt,0.01*cv.arcLength(cnt,True),True)
if len(approx) == 4:
cv.drawContours(mask,cnt,-1,(119,256,51),5)
mask3 = cv.resize(mask,(640,640))
cv.imshow('IMAGE', mask3)
cv.waitKey(0)
cv.destroyWindow(mask3)
'''
if len(approx) == 4:
to
if len(approx) >= 4:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.