compatibility issue with contourArea in openCV 3

前端 未结 4 1063
既然无缘
既然无缘 2020-12-17 08:52

I am trying to do a simple area calculation of contours I get from findContours. My openCv version is 3.1.0

My code is:

cc = cv2.findContours(im_bw.c         


        
4条回答
  •  孤街浪徒
    2020-12-17 09:33

    In Opencv 3 API version the cv2.findContours() returns 3 objects

    • image
    • contours
    • hierarchy

    So you need to rewrite your statement as:

    image, contours, hierarchy = cv2.findContours(im_bw.copy(), cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
    

提交回复
热议问题