I am following this tutorial
The suggested code is:
import numpy as np
import cv2
# Load an color image in grayscale
img = cv2.imread('messi5.jpg',0)
cv2.imshow('image',img)
cv2.waitKey(0)
cv2.destroyAllWindows()
I want to load an image located in my desktop so I changed the
img = cv2.imread('messi5.jpg',0)
line to this line:
img = cv2.imread('/home/Desktop/1.jpg',0)
when I run the code through terminal it produces error:
OpenCV Error: Assertion failed (size.width>0 && size.height>0) in imshow, file /home/sohib/Documents/OpenCV/modules/highgui/src/window.cpp, line 312
Traceback (most recent call last):
File "1.py", line 6, in <module>
cv2.imshow('image',img)
cv2.error: /home/sohib/Documents/OpenCV/modules/highgui/src/window.cpp:312: error: (-215) size.width>0 && size.height>0 in function imshow
Have I included the wrong path to the image in the imread
part?
How can I solve this issue?
Notes:
I am on Ubuntu 16.04.LTS
The tutorial documentation is for OpenCV 3.0.0, but I am using 3.2.0
'/home/Desktop/1.jpg'
does not exist. It should be'/home/yourname/Desktop/1.jpg'
, unless Desktop is your name :). don't use$HOME
or~
.