我目前正在使用cv2将视频从我的网络摄像头显示到tkinter窗口。
import Tkinter as tk
from livestreamer import Livestreamer
import numpy as np
import cv2
from PIL import Image, ImageTk
from page import Page
class PageThree(Page):
def __init__(self, *args, **kwargs):
Page.__init__(self, *args, **kwargs)
session = Livestreamer()
stream = session.streams('http://www.twitch.tv/riotgames')
stream = stream['source']
fd = stream.open()
#Capture video frames
lmain = tk.Label(self)
lmain.grid(row=0, column=0)
cap = cv2.VideoCapture(0)
def show_frame():
_, frame = cap.read()
frame = cv2.flip(frame, 1)
cv2image = cv2.cvtColor(frame, cv2.COLOR_BGR2RGBA)
img = Image.fromarray(cv2image)
imgtk = ImageTk.PhotoImage(image=img)
lmain.imgtk = imgtk
lmain.configure(image=imgtk)
lmain.after(10, show_frame)
show_frame()
有没有办法让livestreamer能够将视频供稿作为来自Twitch用户livestreamer的流?