我有一个程序将图像保存在本地目录中,然后从该目录中读取图像.
但我不想保存图像.我想直接从网址上阅读.
这是我的代码:
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)
Run Code Online (Sandbox Code Playgroud)
如果我改为:
img = cv.LoadImage(img)
Run Code Online (Sandbox Code Playgroud)
这会给我这个错误:
参数1必须是没有空字节的字符串,而不是str
我能做什么?
我目前在我的android上安装了Droid cam应用程序,它已被检测到并通过wifi(Droid Cam客户端)在Skype上流式传输。但是,无论我输入什么数字,它都不会流到OpenCV。
cap=cv2.VideoCapture()
Run Code Online (Sandbox Code Playgroud)
除此之外,我还有一个IP地址,请问有什么方法可以实现此目的,以便OpenCV可以从摄像机无线读取过程图像?我知道它甚至还没有开始读取相机,因为我已经使用以下代码对其进行了测试,每次运行它都会返回FALSE。
cap=cv2.Videocapture(0) #Use default cam
i=0
while(i<50):
ret,frame=cap.read()
print ret
Run Code Online (Sandbox Code Playgroud)
不断返回false,表示无法识别相机:L