opencv python error: Assertion failed (size.width>0 && size.height>0)

前端 未结 1 1131
梦如初夏
梦如初夏 2021-01-28 18:47

I am getting an error while running the following code.

import cv2
import numpy as np
img = cv2.imread(\'messi.jpg\',0)
img = cv2.line(img,(0,0),(50,50),(255,0,0         


        
1条回答
  •  日久生厌
    2021-01-28 18:59

    Its because cv2.line returns None and you are assigning that to your img variable. So when you get to the next line and try to show the image, there is no image to be shown.

    Replace img = cv2.line(img,(0,0),(50,50),(255,0,0),5) with cv2.line(img,(0,0),(50,50),(255,0,0),5)

    Read more about cv2.circle here.

    0 讨论(0)
提交回复
热议问题