2017-12-22 25 views

答えて

0
  1. 閾値
  2. findContours
  3. approxPolyDP

#findContours 
im2, contours, hierarchy = cv2.findContours(thresh,cv2.RETR_EXTERNAL,cv2.CHAIN_APPROX_SIMPLE) 

canvas = img.copy() 

## draw approx contours 

for cnt in contours: 
    arclen = cv2.arcLength(cnt, True) 
    approx = cv2.approxPolyDP(cnt, arclen*0.005, True) 
    #drawContours 
    cv2.drawContours(canvas, [approx], -1, (0,0,255), 1, cv2.LINE_AA) 

cv2.imwrite("result.png", canvas) 

enter image description here

関連する問題

 関連する問題