一个非常简单的库,用于实时从远程Raspberry PI服务器流式传输视频。
rpistream的Python项目详细描述
Raspicameralivestream
一个非常简单的库,用于实时从远程Raspberry PI服务器流式传输视频。
如何安装:
MacOS或Linux:
打开终端并键入:
sudo python -m pip install rpistream
窗口:
以管理员身份打开命令并键入:
pip install rpistream
示例:
从网络摄像头流媒体
服务器
fromrpistream.cameraimportCamerafromrpistream.streamserverimportServerdefretrieveImage(cam,imgResize):image=cv2.resize(cam.image,(0,0),fx=imgResize,fy=imgResize)returnimagecam=Camera(mirror=True)scale=0.5server=Server(port=5000)server.serve()# Blocking; waits for a connection before continuingserver.startStream(retrieveImage,[cam,scale])# Calls retrieveImage(*args) every frame
客户
fromrpistream.streamclientimportClientclient=Client(serverIp="localhost",WriteFile=True)# Connects to the serverclient.startStream()# Starts recieving data and displaying the video