from PyQt5 import QtCore, QtGui, QtWidgets
import cv2
import urllib
class Ui_adm(object):
def startwebcam(self):
url='http://192.168.43.1:8080/videofeed'
self.cam = cv2.VideoCapture(url)
self.cam.set(cv2.CAP_PROP_FRAME_HEIGHT,480)
self.cam.set(cv2.CAP_PROP_FRAME_WIDTH,640)
while(1):
ret, self.fr = self.cam.read()
self.fr=cv2.flip(self.fr,1)
self.displayImage(self.fr,1)
def displayImage(self,img,window=1):
qformat=QtGui.QImage.Format_Indexed8
if len(img.shape)==3:
if img.shape[2]==4:
qformat=QtGui.QImage.Format_RGBA8888
else:
qformat=QtGui.QImage.Format_RGB888
outImage=QtGui.QImage(img,img.shape[1],img.shape[0],img.strides[0],qformat)
outImage=outImage.rgbSwapped()
while window==1:
self.label.setPixmap(QtGui.QPixmap.fromImage(outImage))
self.label.setScaledContents(True)
> 我一直试图将我的webcamlive流显示在qtdesigned对话框中的特定标签上。我已经在qlabel上尝试了youtube视频网络摄像头,但是它没有帮助,因为这是视频中经过修改的代码。当您忽略while(1)时,此至少显示快照。请使用此代码或qlabel上的视频网络摄像头中的代码帮助我