Ask Your Question
0

Can't open image from Python

asked Jul 13 '16

RMC gravatar image

updated Jul 18 '16

From IDLE, I do:

Python 2.7.5 (default, May 15 2013, 22:43:36) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> import numpy
>>> 
>>> import cv2
>>> print cv2.__version__
3.1.0
>>> 

>>> img =cv2.imread("C:\Users\XXXX\map.tif")

Traceback (most recent call last):
  File "<pyshell#7>", line 1, in <module>
    img =cv2.imread("C:\Users\XXXX\map.tif")
error: C:\builds\master_PackSlaveAddon-win32-vc12-static\opencv\modules\core\src\matrix.cpp:424: error: (-215) u != 0 in function cv::Mat::create

>>>

Any idea what is wrong? I tried a variety of image files. Same result.
Thanks!

Preview: (hide)

1 answer

Sort by » oldest newest most voted
2

answered Jul 18 '16

dandur gravatar image

updated Jul 18 '16

You use invalid path. Try this (note 'r' before path):

img = cv2.imread(r"C:\Users\XXXX\map.tif")

Or use \\:

img = cv2.imread("C:\\Users\\XXXX\\map.tif")
Preview: (hide)

Question Tools

1 follower

Stats

Asked: Jul 13 '16

Seen: 2,279 times

Last updated: Jul 18 '16