Ask Your Question
0

Can't open image from Python

asked 2016-07-12 21:57:58 -0600

RMC gravatar image

updated 2016-07-17 19:25:37 -0600

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!

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

answered 2016-07-18 07:59:51 -0600

dandur gravatar image

updated 2016-07-18 08:51:39 -0600

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")
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2016-07-12 21:57:58 -0600

Seen: 2,146 times

Last updated: Jul 18 '16