gknows / pyscripter

Automatically exported from code.google.com/p/pyscripter
0 stars 0 forks source link

cv2 and referencing image files #707

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

PyScripter 2.5.3.0 x86 on Windows XP 32-bit
Python 2.7.3
OpenCV 2.4.1

Create script:
import cv2
import sys
import numpy as np

img = cv2.imread("Lenna.jpg",cv2.CV_LOAD_IMAGE_COLOR)
print img[1,1]

What is the expected output? 

[125 138 224]

What do you see instead?

Running from PyScripter, you get: 

Traceback (most recent call last):
  File "<interactive input>", line 1, in <module>
TypeError: 'NoneType' object has no attribute '__getitem__'

What version of the product are you using? On what operating system?

Please provide any additional information below.

Original issue reported on code.google.com by and...@flappingbird.com on 2 Dec 2012 at 12:28

GoogleCodeExporter commented 9 years ago
Is "Lenna.jpg" in your current directory?

Try this:
>>> import os
>>> os.getcwd()
'C:\\Program Files\\PyScripter'

If it isn't, imread() will return None:
>>> img = cv2.imread('nofilehere')
>>> print img
None

Original comment by uwadba...@gmail.com on 2 Dec 2012 at 10:20

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Hmmm... works now.  Yesterday I thought it had problems; I recall I could 
display the image, but then accessing img[1,1] gave the error.

Works now.

Original comment by and...@flappingbird.com on 2 Dec 2012 at 1:34

GoogleCodeExporter commented 9 years ago

Original comment by pyscripter on 24 Mar 2015 at 6:13