This repository was archived by the owner on Oct 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebcam_viewer.py
48 lines (41 loc) · 1.47 KB
/
webcam_viewer.py
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
from PyQt4 import uic
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from libemussa import callbacks as cb
import cyemussa
ym = cyemussa.CyEmussa.Instance()
class WebcamViewer(QWidget):
def __init__(self, parent):
super(WebcamViewer, self).__init__()
self.parent = parent
ym.register_callback(
cb.EMUSSA_CALLBACK_WEBCAM_IMAGE_READY,
self.show_image)
self.widget = uic.loadUi('ui/webcam.ui')
self.widget.closeEvent = self._closed
self.widget.buttonBox.clicked.connect(self.close)
self.widget.setWindowTitle(
'Webcam for {0}'.format(self.parent.cybuddy.yahoo_id)
)
self.widget.statusBar().showMessage('Waiting for permission...')
self.widget.show()
pass
def _closed(self, event):
ym.unregister_callback(
cb.EMUSSA_CALLBACK_WEBCAM_IMAGE_READY,
self.show_image)
def show_image(self, ym, wr):
cdate = QDate.currentDate().toString()
ctime = QTime.currentTime().toString()
self.widget.statusBar().showMessage(
'Last image received at ({0} {1})'.format(cdate, ctime)
)
if wr.image:
pixmap = QPixmap()
pixmap.loadFromData(wr.image)
self.widget.webcamImageLabel.setPixmap(pixmap)
def close(self, button):
ym.unregister_callback(
cb.EMUSSA_CALLBACK_WEBCAM_IMAGE_READY,
self.show_image)
self.widget.close()