Commit 9e675d61 authored by liyuanhong's avatar liyuanhong

增加了帧实时预览功能

parent 49a92319
......@@ -7,6 +7,7 @@ import time
import traceback
import platform
import cv2
import subprocess
import requests
import wx
......@@ -118,9 +119,11 @@ class CameraArea():
self.frame.Bind(wx.EVT_BUTTON, lambda evt: self.disConnect(evt),
disConnectButton)
playStreamVideoButton = wx.Button(ctrView, label="播放流地址", pos=(5, 95))
self.frame.Bind(wx.EVT_BUTTON, lambda evt: self.playFrame(evt),
playStreamVideoButton)
showFrameButton = wx.Button(ctrView, label="实时显示帧画面", pos=(120, 95))
self.frame.Bind(wx.EVT_BUTTON, lambda evt: self.showFrame(evt), showFrameButton)
StopPlayStreamVideoButton = wx.Button(ctrView, label="停止播放", pos=(5, 125))
# StopPlayStreamVideoButton = wx.Button(ctrView, label="停止播放", pos=(5, 125))
stopShowFrameButton = wx.Button(ctrView, label="停止显示帧画面", pos=(120, 125))
self.frame.Bind(wx.EVT_BUTTON, lambda evt: self.stopShowFrame(evt), stopShowFrameButton)
......@@ -157,11 +160,9 @@ class CameraArea():
boxSizer_ctrArea.Add(ctrPanel,100, flag=wx.EXPAND | wx.ALL)
ctrArea.SetSizer(boxSizer_ctrArea)
boxSizer_bottom.Add(logArea,60,flag=wx.EXPAND | wx.ALL)
boxSizer_bottom.Add(ctrArea, 40, flag=wx.EXPAND | wx.LEFT,border=10)
bottomPanel.SetSizer(boxSizer_bottom)
return bottomPanel
#################################################
......@@ -223,7 +224,6 @@ class CameraArea():
else:
timeCur = self.getCurTime()
self.logTextCtr.WriteText(timeCur + "已连网!\n")
def doConnect(self):
host = self.pushHostText.GetValue()
port = self.pushPortText.GetValue()
......@@ -364,7 +364,7 @@ class CameraArea():
def showFrame(self,evt):
sys.stdout = self.logTextCtr
sys.stderr = self.logTextCtr
threadObj = threading.Thread(target=self.doShowFrame())
threadObj = threading.Thread(target=self.doShowFrame)
threadObj.start()
def doShowFrame(self):
self.isShowFrame = 1
......@@ -373,8 +373,8 @@ class CameraArea():
res = requests.post(self.getGetPlayUrl, data=json.dumps({'devId': devId, 'chan': str(channel)})).text
res = json.loads(res)
pullUrl = res["data"]["url"]
cap = cv2.VideoCapture(pullUrl)
try:
cap = cv2.VideoCapture(pullUrl)
timeCur = self.getCurTime()
self.logTextCtr.WriteText(timeCur + "帧预览开始!\n")
while (cap.isOpened()):
......@@ -399,7 +399,7 @@ class CameraArea():
def stopShowFrame(self,evt):
sys.stdout = self.logTextCtr
sys.stderr = self.logTextCtr
threadObj = threading.Thread(target=self.stopDoShowFrame())
threadObj = threading.Thread(target=self.stopDoShowFrame)
threadObj.start()
def stopDoShowFrame(self):
self.isShowFrame = 0
......@@ -407,6 +407,19 @@ class CameraArea():
####################################################
# 播放视频地址
###################################################
def playFrame(self):
pass
def playFrame(self,evt):
sys.stdout = self.logTextCtr
sys.stderr = self.logTextCtr
threadObj = threading.Thread(target=self.doPlayFrame)
threadObj.start()
timeCur = self.getCurTime()
self.logTextCtr.WriteText(timeCur + "开始播放视频!\n")
def doPlayFrame(self):
devId = self.devIdText.GetValue()
channel = self.channelText.GetValue()
res = requests.post(self.getGetPlayUrl, data=json.dumps({'devId': devId, 'chan': str(channel)})).text
res = json.loads(res)
url = res["data"]["url"]
m_command = ["ffplay.exe", url]
subprocess.run(m_command)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment