tags:

views:

113

answers:

3

Hello,

i want to do some OpenCV Basic Operations using Python. My Problem is that the Pythoninterpreter says that the file i want to open with cv.LoadImage() dont exists. But as you can see in my code and the and the Interpreter Output this file exists and the Program should be able to read it.

Likly the answer is simple (im new at Python Programming!). Thanks for answers!

Here my Code:

import cv, sys, os

print sys.argv[1]
print os.getcwd()
print os.access(sys.argv[1], os.F_OK)

img = cv.LoadImage(sys.argv[1], 1)

cv.NamedWindow("orginal", CV_WINDOW_AUTOSIZE)
cv.ShowImage("orginal", img)

cv.waitKey(0)

here is the Pythoninterpreter Output:

dennis@Powertux:~/opencv/showPicture$ python2.5 showPicture.py google-de02.jpg google-de02.jpg
/home/steffke/opencv/showPicture
True
Traceback (most recent call last):
  File "showPicture.py", line 7, in <module>
    img = cv.LoadImage(sys.argv[1], 1)
IOError: [Errno 2] No such file or directory: 'google-de02.jpg'
+1  A: 

Try giving it the whole path instead of the name only, or maybe using .\google-de02.jpg.

Gabriele Cirulli
It seems that the OpenCV script can't access the file. Like terabytest suggests, make sure that the path to the file within the CV package is correct (e.g. by specifying an absolute path) and that the permissions are set correctly.
Paul Lammertsma
A: 

I've tried both suggestions, but its the same like before. the os.access returns a TRUE but the function cv.LoadImage produce the same error.

Any other solutions?

anyhow thanks fpr answer...

Dennis S.
You might want to respond to the answers by commenting, as it is somewhat unclear to which one(s) you are referring.
Paul Lammertsma
So now in a comment ;-)the repr function does its work but the cv.LoadImage funtion cant handle it, too.
Dennis S.
A: 

Try using the repr function when the exception happens.

Gabriele Cirulli