xy1770 发表于 2020-7-22 13:38:40

(OpenCV)报错Traceback

本帖最后由 xy1770 于 2020-7-22 14:36 编辑

import cv2 as cv

filename = ('//Users//sg//Desktop//lena.jpeg')
img = cv.imread(filename)
cv.imshow('hello,Lena!',img)
cv.waitKey()
cv.destroyAllWindows()


python 3.7
openCV 3.4

报错:

/usr/local/bin/python3.7 /Users/sg/PycharmProjects/OpenCV-1/test.py
Traceback (most recent call last):
File "/Users/sg/PycharmProjects/OpenCV-1/test.py", line 5, in <module>
    cv.imshow('hello,Lena!',img)
cv2.error: OpenCV(3.4.10) /Users/travis/build/skvark/opencv-python/opencv/modules/highgui/src/window.cpp:382: error: (-215:Assertion failed) size.width>0 && size.height>0 in function 'imshow'


Process finished with exit code 1

Twilight6 发表于 2020-7-22 14:00:04


是版本问题吗? 我这里可以正常运行你的代码

zltzlt 发表于 2020-7-22 14:06:47

你的图片能正常打开吗?

livcui 发表于 2020-7-22 14:12:54

看报错似乎是图片的问题,换一张图片看看。
页: [1]
查看完整版本: (OpenCV)报错Traceback