Advertisement
DoctorRaccoon

Test

Nov 4th, 2020
1,826
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.28 KB | None | 0 0
  1. import sys
  2. import cv2
  3. import os
  4.  
  5. from datetime import datetime
  6.  
  7. from PyQt5.QtWidgets import QApplication, QMainWindow
  8. from PyQt5 import uic
  9. from PyQt5.QtGui import QPixmap, QImage
  10. from PyQt5.QtCore import QTimer
  11.  
  12.  
  13. class Videolink(QMainWindow):
  14.     def __init__(self):
  15.         super().__init__()
  16.         uic.loadUi('videolink_main.ui', self)
  17.  
  18.         self.timerVideo = QTimer(self)
  19.  
  20.         self.startbtn.clicked.connect(self.startTime)
  21.         self.endbtn.clicked.connect(self.endTime)
  22.         self.cap = cv2.VideoCapture(cv2.CAP_DSHOW, 0)
  23.         self.cap.set(3, 480)
  24.         self.cap.set(4, 640)
  25.         self.cap.set(5, 30)
  26.  
  27.     def viewCam(self):
  28.         ret, image = self.cap.read()
  29.         im = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
  30.         height, width, channel = im.shape
  31.         step = channel * width
  32.         qImg = QImage(im.data, width, height, step, QImage.Format_RGB888)
  33.         self.ui.screen.setPixmap(QPixmap.fromImage(qImg))
  34.  
  35.     def startTime(self):
  36.         self.timerVideo.start()
  37.         self.timerVideo.timeout.connect(self.viewCam)
  38.  
  39.     def endTime(self):
  40.         self.timerVideo.stop()
  41.         self.screen.clear()
  42.  
  43. if __name__ == "__main__":
  44.     app = QApplication(sys.argv)
  45.     exe = Videolink()
  46.     exe.show()
  47.     sys.exit(app.exec())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement