Imread Not Working in Opencv

OpenCV imread() is not working

You need to use the waitKey() function after imshow(). You can pass in a delay parameter to show the image for a certain time (in milliseconds).

Example:

#--- It will display the image for 30 ms 
waitKey(30);

#--- It will display the image until a key is pressed
waitKey();

Check THIS PAGE for more.

There is also a demo example shown HERE

OpenCV Python not opening images with imread()

Probably you have problem with special meaning of \ in text - like \t or \n

Use \\ in place of \

imgloc = "F:\\Kyle\\Desktop\\Coinjar\\Test images\\ten.png"

or use prefix r'' (and it will treat it as raw text without special codes)

imgloc = r"F:\Kyle\Desktop\Coinjar\Test images\ten.png"

EDIT:

Some modules accept even / like in Linux path

imgloc = "F:/Kyle/Desktop/Coinjar/Test images/ten.png"

cv::imread() in OpenCV not reading my .png

It is possible that the image you are using is of corrupted data. The imread() function will not return anything to your imgTrainingNumbers matrix if you...
a. have not specified the path correctly
b. the image is not in a proper format/is corrupted
c. some linking issue

Replace the image with something else to test the theory.

Why isn't imread in openCV opening some of the images?

Try changing

img = cv2.imread('C:\Users\harit\Desktop\images\12.jpg')

to

img = cv2.imread(r'C:\Users\harit\Desktop\images\12.jpg')

Backslash is an escape character, and the r before the quotes tells python to "ignore" them.

For example:

>>> s = 'C:\Users\harit\Desktop\images\12.jpg'
>>> print s
C:\Users\harit\Desktop\images
.jpg

This is the wrong path!... with an 'r' in front of the string:

>>> s = r'C:\Users\harit\Desktop\images\12.jpg'
>>> print s
C:\Users\harit\Desktop\images\12.jpg

See https://docs.python.org/3/reference/lexical_analysis.html#string-and-bytes-literals for more on raw strings



Related Topics



Leave a reply



Submit