Advertisement
Guest User

Untitled

a guest
Sep 19th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.12 KB | None | 0 0
  1. import socket
  2. import sys
  3. import threading
  4. import time
  5. from PIL import Image
  6. from PyQt4 import QtCore, QtGui
  7. from PyQt4.QtCore import *
  8. from PyQt4.QtGui import *
  9. import PyQt4.uic
  10. import PyQt4.Qt as qt
  11. import ImageQt
  12. app = QtGui.QApplication([])
  13.  
  14. class cam(qt.QThread):
  15.     def __init__(self,srv):
  16.         qt.QThread.__init__(self)
  17.         self.dlg = PyQt4.uic.loadUi("troja1.ui")
  18.         self.pic = QPixmap()
  19.         self.srv = srv
  20.         self.dlg.show()
  21.        
  22.     def run(self):
  23.         while 1:
  24.             aaa = self.srv[0].recvfrom(9999)[0]
  25.             if aaa:
  26.                 slika = Image.fromstring("RGB",(400,300),aaa)
  27.                 QtImage1 = ImageQt.ImageQt(slika)
  28.                 QtImage2 = QtGui.QImage(QtImage1)
  29.                 pixmap = QtGui.QPixmap.fromImage(QtImage2)
  30.                 pixmap2 = pixmap.scaled(QSize(400,300),Qt.KeepAspectRatio)
  31.                 self.dlg.label.setPixmap(pixmap2)          
  32. s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  33. host = socket.gethostname()  
  34. port = 444
  35. s.bind((host,port))
  36. s.listen(5)
  37. addr = s.accept()
  38. a = cam(addr)
  39. a.start()
  40. app.exec_()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement