-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTestLabelledimage.py
67 lines (43 loc) · 1.59 KB
/
TestLabelledimage.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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Oct 9 14:01:04 2018
@author: MarcusF
"""
import sys
from qtpy.QtCore import *
from qtpy.QtGui import *
from qtpy.QtWidgets import *
import qimage2ndarray as qnd
from qtpy import QtWidgets,QtGui,QtCore
class Label(QtWidgets.QLabel):
def __init__(self, parent=None):
super(Label, self).__init__(parent=parent)
def paintEvent(self, e):
super().paintEvent(e)
qp = QtGui.QPainter(self)
img = qnd.gray2qimage(A.frames[1300],normalize = True)
qp.drawPixmap(img.rect(),QtGui.QPixmap.fromImage(img))
pen = QPen(Qt.red,12)
qp.setPen(pen)
for i in np.arange(len(A.trapgetter.trap_positions)):
pos = QPoint(A.trapgetter.trap_positions[i][1]-10,A.trapgetter.trap_positions[i][0]-15)
qp.drawText(pos,str(A.trapgetter.labels[i]))
pen = QPen(Qt.white,2)
qp.setPen(pen)
for i in np.arange(len(A.trapgetter.trap_positions)):
qp.drawRect(A.trapgetter.trap_positions[i][1]-10,A.trapgetter.trap_positions[i][0]-15,30,30)
qp.end()
class Window(QWidget):
def __init__(self):
super(Window, self).__init__()
layout = QHBoxLayout(self)
self.label = Label()
layout.addWidget(self.label)
if __name__ == '__main__':
if not QtWidgets.QApplication.instance():
app = QtWidgets.QApplication(sys.argv)
else:
app = QtWidgets.QApplication.instance()
window = Window()
window.show()