为了账号安全,请及时绑定邮箱和手机立即绑定

PyQt显示来自opencv的视频流

PyQt显示来自opencv的视频流

繁花如伊 2019-07-31 10:32:30
PyQt显示来自opencv的视频流尝试链接PyQt和Opencv视频源,无法理解如何应用while循环连续流式传输视频。它只需要一张照片。请任何人都可以帮助解决问题。PtQt = 5蟒蛇= 3.6.1class App(QWidget):     def __init__(self):         super().__init__()         self.title = 'PyQt5 Video'         self.left = 100         self.top = 100         self.width = 640         self.height = 480         self.initUI()     def initUI(self):         self.setWindowTitle(self.title)         self.setGeometry(self.left, self.top, self.width, self.height)         self.resize(1800, 1200)         #create a label         label = QLabel(self)         cap = cv2.VideoCapture(0)         ret, frame = cap.read()         rgbImage = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)         convertToQtFormat = QtGui.QImage(rgbImage.data, rgbImage.shape[1], rgbImage.shape[0],                                          QtGui.QImage.Format_RGB888)         convertToQtFormat = QtGui.QPixmap.fromImage(convertToQtFormat)         pixmap = QPixmap(convertToQtFormat)         resizeImage = pixmap.scaled(640, 480, QtCore.Qt.KeepAspectRatio)         QApplication.processEvents()         label.setPixmap(resizeImage)         self.show()if __name__ == '__main__':     app = QApplication(sys.argv)     ex = App()     sys.exit(app.exec_())
查看完整描述

2 回答

  • 2 回答
  • 0 关注
  • 1737 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信