-
Notifications
You must be signed in to change notification settings - Fork 1
/
maplive.py
68 lines (53 loc) · 1.62 KB
/
maplive.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# -*- coding: utf-8 -*-
"""
Demonstrates very basic use of ImageItem to display image data
inside a ViewBox.
"""
import sys,getopt # trans the parameter
from pyqtgraph.Qt import QtCore, QtGui
import numpy as np
import pyqtgraph as pg
import pyqtgraph.ptime as ptime
import map
app = QtGui.QApplication([])
pg.setConfigOption('background','b')
#pg.setConfigOption('useOpenGL',True)
## Create window with GraphicsView widget
win = pg.GraphicsLayoutWidget()
view = win.addViewBox(enableMouse=False, lockAspect=True)
view.disableAutoRange()
win.setCentralWidget(view) # close the edge bettwen img and window
win.setGeometry(10,10,1024,768)
win.setWindowTitle('Live-iGEM 2017')
win.show()# show widget alone in its own window
## Fullscreen or windos
if sys.argv[1] == "-pre":
win.show()# show widget alone in its own window
elif sys.argv[1] in ("-full"):
win.showFullScreen()
## Create image item
img = pg.ImageItem(border='w')
img.setPxMode(True)
view.addItem(img)
view.setLimits(xMin=0,xMax=1024,yMin=-768,yMax=0)
# Set the initial point is (0,0)
# Video Player
i = 0
updateTime = ptime.time()
fps = 0
def updateData():
global img, data, i, updateTime, fps
## Display the data
img.setImage(map.getImage())
QtCore.QTimer.singleShot(1, updateData)
now = ptime.time()
fps2 = 1.0 / (now-updateTime)
updateTime = now
fps = fps * 0.9 + fps2 * 0.1
print ("%0.1f fps" % fps)
updateData()
## Start Qt event loop unless running in interactive mode.
if __name__ == '__main__':
import sys
if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
QtGui.QApplication.instance().exec_()