problem with imread() in Python
I have a issue of reading a image with imread() in Python. I downloaded opencv 3.0.0 and numpy to C:\Python27\LIb\site-packages. and then I tried to get my image file and I typed the test code in follow.
import numpy
import cv2
img= cv2.imread('C:\test.jpg', 0)
cv2.imshow('image', img)
but I got a error message like 'size.width > 0 && height>0 in function cv::imshow' . it seems that imread failed to get my image. I am thinking I did wrong way to get the image path (I am sure that test.jpg is in local disk(C:)), then I tried various ways to get the image path like 'C:\test.jpg', 'C:/test.jpg', etc. but these did not work.
I am sure that opencv and numpy is working, because when I coded like,
import numpy as np
import cv2
cols= 640
rows= 480
image= np.zeros((rows, cols, 3), np.uint8)
cv2.imshow('image', image)
Grayish screen came out.
Can anyone help ?
Thanks
are you sure it is .jpg and not .jpeg?
I'm having the same problem with OpenCV 2.4.12. Made sure the file exists (i.e os.path.isfile("/path/to/file.jpg") returns true. Made sure jpg is a supported format looking at the output of print cv2.getBuildInformation() Everything seems to be fine, except imread returns a "None"...