Python opencv drawContours does not show anything

后端 未结 4 491
南旧
南旧 2020-12-24 08:51

I followed the tutorial at this page but nothing seems to happen when the line cv2.drawContours(im,contours,-1,(0,255,0),3) is executed. I was expecting to see

4条回答
  •  攒了一身酷
    2020-12-24 09:20

    I guess your original image is in gray bit plane. Since your bit plane is Gray instead of BGR and so the contour is not showing up. Because it's slightly black and grey which you cannot distinguish. Here's the simple solution [By converting the bit plane]:

    im=cv2.cvtColor(im,cv2.COLOR_GRAY2BGR)
    cv2.drawContours(im,contours,-1,(0,255,0),3)
    

提交回复
热议问题