Python opencv drawContours does not show anything

后端 未结 4 490
南旧
南旧 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:02

    You have to do something to the effect of:

    cv2.drawContours(im,contours,-1,(255,255,0),3)
    cv2.imshow("Keypoints", im)
    cv2.waitKey(0)
    
    0 讨论(0)
  • 2020-12-24 09:10

    I had the same issue. I believe the issue is that the underlying image is 1-channel rather than 3-channel. Therefore, you need to set the color so it's nonzero in the first element (e.g. (255,0,0)).

    0 讨论(0)
  • 2020-12-24 09:16

    i too had the same problem. The thing is it shows, but too dark for our eyes to see. Solution: change the colour from (0,255,0) (for some weird reason, i too had give exactly the same color!) to (128,255,0) (or some better brighter colour)

    0 讨论(0)
  • 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)
    
    0 讨论(0)
提交回复
热议问题