1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
| from PyQt5.QtWidgets import QGraphicsScene,QMainWindow,QFileDialog,QMessageBox,QApplication,QActionGroup,QAction,QWidget,QGraphicsView,QLineEdit,QCheckBox,QComboBox,QPushButton,QLabel,QSlider,QVBoxLayout,QHBoxLayout,QGroupBox,QRadioButton,QGridLayout
from PyQt5.QtCore import Qt,QByteArray,QBuffer,QIODevice,QCoreApplication,QSize
from PyQt5.QtGui import QPen,QFont,QColor,QIcon,QPixmap,QBrush,QPainter,QPixmap
from PyQt5.QtMultimedia import QCamera,QCameraImageCapture
from PyQt5.QtMultimediaWidgets import QVideoWidget
from datetime import datetime
#from PIL import ImageEnhance,Image,ImageFilter
#from PIL.ImageQt import ImageQt
from io import BytesIO
import os,sys,time,os.path
from os.path import expanduser
from numpy import sqrt
import cv2
import argparse
from pyqtgraph import ImageView
class fenPrincipale(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)
fenetre_widget = QWidget()
fenetre_widget.setStyleSheet("background-image: url(espace-lumiere-bleue.jpg)")
self.camera=cv2.VideoCapture(0)
self.image_view = ImageView()
#Boutons
self.bouton_play = QPushButton("Lancer")
self.bouton_play.setIconSize(QSize(70,70))
self.bouton_play.setFixedWidth(70)
#Intégration
layoutverticalglobal=QVBoxLayout()
layouthorizontal1 = QHBoxLayout()
layoutverticalglobal.addLayout(layouthorizontal1)
layouthorizontal1.addWidget(self.image_view)
layouthorizontal1.addWidget(self.bouton_play)
fenetre_widget.setLayout(layoutverticalglobal)
self.setCentralWidget(fenetre_widget)
#Fonctions Connect
self.bouton_play.clicked.connect(self.play)
self.showMaximized()
def play(self):
while True:
ret, self.last_frame = self.camera.read()
self.image_view.setImage(self.last_frame.T)
if cv2.waitKey(1) & 0xFF == ord('q'):
self.camera.release()
break
def main(args):
appli=QApplication(args)
fenetre=fenPrincipale()
fenetre.show()
r=appli.exec_()
return r
if __name__=="__main__":
main(sys.argv) |
Partager