IOError with Python and OpenCV

I want to do some basic OpenCV operations using Python. My problem is that Pythoninterpreter says that the file I want to open with cv.LoadImage () does not exist. But, as you can see in my code and Interpreter output, this file exists and the program should be able to read it.

It seems like the answer is simple (I'm new to Python Programming!). Thanks for answers!

Here is 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 output of Pythoninterpreter:

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'
+3
source share
3 answers

I tried both sentences, but just as before. os.access returns TRUE, but the cv.LoadImage function produces the same error.

Any other solutions?

Anyway thanks fpr answer ...

+2

, , .\google-de02.jpg.

+1

repr, .

0

Source: https://habr.com/ru/post/1723491/


All Articles