forked from ant-trullo/SegmentTrack_v4.0
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPopUpTool.py
49 lines (32 loc) · 1.23 KB
/
PopUpTool.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
"""This function provides only a pg.image frame with frame number.
"""
import pyqtgraph as pg
class PopUpTool:
"""Update frame number text on a image without colormap"""
def __init__(self, img, img_title):
w = pg.image(img, title=img_title)
lx = []
for t in range(img.shape[0]):
lx.append(pg.TextItem(str(t), color='r', anchor=(0, 1)))
w.addItem(lx[0])
self.current = 0
def upadateframe():
w.removeItem(lx[self.current])
w.addItem(lx[w.currentIndex])
self.current = w.currentIndex
w.timeLine.sigPositionChanged.connect(upadateframe)
class PopUpToolWithMap:
"""Update frame number text on a image with colormap"""
def __init__(self, img, img_title, cmap):
w = pg.image(img, title=img_title)
w.setColorMap(cmap)
lx = []
for t in range(img.shape[0]):
lx.append(pg.TextItem(str(t), color='r', anchor=(0, 1)))
w.addItem(lx[0])
self.current = 0
def upadateframe():
w.removeItem(lx[self.current])
w.addItem(lx[w.currentIndex])
self.current = w.currentIndex
w.timeLine.sigPositionChanged.connect(upadateframe)