我有一个用Tkinter制作的GUI,我正在尝试将http://192.168.0.4:8081/(流在任何浏览器上都能完美工作)的网络流包含到我的python GUI中
camera = cv2.VideoCapture(0)
cameraLabel = tk.Label(root)
cameraLabel.place(x=640,y=380)
videoLoop()
如果我使用上面的代码,我会从我的笔记本电脑摄像头中获取视频
camera = cv2.VideoCapture("http://192.168.0.6:8081/")
cameraLabel = tk.Label(root)
cameraLabel.place(x=640,y=380)
videoLoop()
如果我使用上面的代码,它就不会运行,并给出一个错误,即cv2.VideoCapture attribute error
videoLoop功能如下:
def videoLoop():
ret, frame = camera.read()
if ret:
scale_percent = 70 # percent of original size
width = int(frame.shape[1] * scale_percent / 100)
height = int(frame.shape[0] * scale_percent / 100)
dim = (width, height)
resized = cv2.resize(frame, dim, interpolation = cv2.INTER_AREA)
cv2image = cv2.cvtColor(resized, cv2.COLOR_BGR2RGBA)
img = Image.fromarray(cv2image)
imgtk = ImageTk.PhotoImage(image=img)
cameraLabel.imgtk = imgtk
cameraLabel.configure(image=imgtk)
cameraLabel.after(1, videoLoop)
目前没有回答
相关问题 更多 >
编程相关推荐