3

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 (I am 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
  • code looks fine to me though. may I know ls -l google-de02.jpg results? Commented Nov 20, 2009 at 17:52

3 Answers 3

2

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...

Sign up to request clarification or add additional context in comments.

2 Comments

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

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

1 Comment

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.
0

Try using the repr function when the exception happens.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.