Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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