ローカルディレクトリに画像を保存し、そのディレクトリから画像を読み取るプログラムがあります。
しかし、私は画像を保存したくありません。URLから直接読みたい。
これが私のコードです:
import cv2.cv as cv
import urllib2
url = "http://cache2.allpostersimages.com/p/LRG/18/1847/M5G8D00Z/posters/curious-cat.jpg"
filename = "my_test_image" + url[-4:]
print filename
opener = urllib2.build_opener()
page = opener.open(url)
img= page.read()
abc = open(filename, "wb")
abc.write(img)
abc.close()
img = cv.LoadImage(filename)
cv.ShowImage("Optical Flow", img)
cv.WaitKey(30)
次のように変更した場合:
img = cv.LoadImage(img)
これにより、次のエラーが発生します。
引数1は、strではなくnullバイトを含まない文字列である必要があります
私に何ができる?