Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Imshow doesn't work in Jupyter and PyCharm

Hello,

I want to use Imshow in Jupyter Notebook (PyCharm just for checking if it is a Jupyter specific problem, but I get the same result there).

When I type in

img1 = cv2.imread(r"savefig/plotXBIC_singlecell/01.png")
cv2.imshow("image",img1)
cv2.waitKey(0)
cv2.destroyAllWindows()

I get the error message:

OpenCV(4.2.0) /io/opencv/modules/highgui/src/window.cpp:376: error: (-215:Assertion failed) size.width>0 && size.height>0 in function 'imshow'

And when I do this:

gray = cv2.cvtColor(img1, cv2.COLOR_BGR2GRAY)

I get the error message:

OpenCV(4.2.0) /io/opencv/modules/imgproc/src/color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cvtColor'

Can you help me, please? :)

Imshow doesn't work in Jupyter and PyCharm

Hello,

I want to use Imshow in Jupyter Notebook (PyCharm just for checking if it is a Jupyter specific problem, but I get the same result there).

When I type in

img1 = cv2.imread(r"savefig/plotXBIC_singlecell/01.png")
cv2.imshow("image",img1)
cv2.waitKey(0)
cv2.destroyAllWindows()

I get the error message:

OpenCV(4.2.0) /io/opencv/modules/highgui/src/window.cpp:376: error: (-215:Assertion failed) size.width>0 && size.height>0 in function 'imshow'

And when I do this:

gray = cv2.cvtColor(img1, cv2.COLOR_BGR2GRAY)

I get the error message:

OpenCV(4.2.0) /io/opencv/modules/imgproc/src/color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cvtColor'

EDIT: I checked with path.exists() if the path exists and yes, it does (both the relative and absolute one). And in both cases, with the same path (relative/absolute) I get a None when I type in print(cv2.imread(r"savefig/..../01.png))

Can you help me, please? :)