개정판 265a1e83
issue #655: train ui
DTI_PID/DTI_PID/App.py | ||
---|---|---|
79 | 79 |
app._mainWnd.show() |
80 | 80 |
sys.exit(app.exec_()) |
81 | 81 |
except Exception as ex: |
82 |
print('에러가 발생했습니다.\n', ex) |
|
82 |
print('에러가 발생했습니다.\n', ex) |
DTI_PID/DTI_PID/QtImageViewer.py | ||
---|---|---|
324 | 324 |
''' |
325 | 325 |
def mouseReleaseEvent(self, event): |
326 | 326 |
print('v') |
327 |
print(event.pos())
|
|
327 |
print(self.mapToScene(event.pos()))
|
|
328 | 328 |
try: |
329 | 329 |
if self.command is not None: |
330 | 330 |
scenePos = self.mapToScene(event.pos()) |
DTI_PID/DTI_PID/Shapes/TrainingBoxItem.py | ||
---|---|---|
32 | 32 |
self.angle = 0 # angle in radian |
33 | 33 |
self.conns = [] |
34 | 34 |
self._owner = None |
35 |
self.setFlags(QGraphicsItem.ItemIsSelectable|QGraphicsItem.ItemIsFocusable|QGraphicsItem.ItemIsMovable) |
|
35 |
self.setFlags(QGraphicsItem.ItemIsSelectable|QGraphicsItem.ItemIsFocusable)#|QGraphicsItem.ItemIsMovable)
|
|
36 | 36 |
self.setAcceptHoverEvents(True) |
37 | 37 |
self.setAcceptTouchEvents(True) |
38 | 38 |
|
... | ... | |
49 | 49 |
self.transfer = Transfer() |
50 | 50 |
|
51 | 51 |
def mouseReleaseEvent(self, event): |
52 |
QGraphicsRectItem.mouseReleaseEvent(self, event) |
|
53 |
x, y = round(event.pos().x()), round(event.pos().y()) |
|
52 |
""" |
|
53 |
|
|
54 |
self.setRect(QRectF(self.scenePos().x(), self.scenePos().y(), self.rect().width(), self.rect().height())) |
|
55 |
print(self.rect().x()) |
|
56 |
print(self.rect().y()) |
|
57 |
|
|
58 |
x, y = round(self.pos().x()), round(self.pos().y()) |
|
54 | 59 |
print(x) |
55 | 60 |
print(y) |
56 |
|
|
57 |
|
|
58 |
|
|
61 |
rect = self.rect() |
|
62 |
self.setRect(QRectF(rect.x() + x, rect.y() + y, rect.width(), rect.height())) |
|
63 |
self.setSelected(False) |
|
64 |
""" |
|
65 |
QGraphicsRectItem.mouseReleaseEvent(self, event) |
|
66 |
bouding_rect = self.rect() |
|
67 |
self.setRect(QRectF(bouding_rect.x(), bouding_rect.y(), bouding_rect.width(), bouding_rect.height())) |
|
68 |
print(self.rect()) |
|
69 |
print(self.sceneBoundingRect()) |
|
70 |
self.scene.update() |
|
59 | 71 |
# pen = QPen(Qt.SolidLine) |
60 | 72 |
# pen.setColor(Qt.blue) |
61 | 73 |
# pen.setWidthF(1) |
... | ... | |
80 | 92 |
#transform.scale(1, 1) |
81 | 93 |
|
82 | 94 |
#self.setTransform(transform) |
83 |
#print(self.boundingRect().x()) |
|
84 |
#print(self.boundingRect().y()) |
|
85 | 95 |
|
86 |
self.scene.update() |
|
96 |
#self.scene.update()
|
|
87 | 97 |
#QGraphicsRectItem.mouseReleaseEvent(self, event) |
88 | 98 |
|
89 | 99 |
def mousePressEvent(self, event): |
90 |
QGraphicsRectItem.mouseReleaseEvent(self, event) |
|
91 |
x, y = round(event.pos().x()), round(event.pos().y()) |
|
92 |
print(x) |
|
93 |
print(y) |
|
100 |
self.scene.clearSelection() |
|
101 |
#QGraphicsRectItem.mouseReleaseEvent(self, event) |
|
102 |
#x, y = round(self.pos().x()), round(self.pos().y()) |
|
103 |
#print(x) |
|
104 |
#print(y) |
|
105 |
|
|
94 | 106 |
#print('box') |
95 | 107 |
#x, y = round(event.pos().x()), round(event.pos().y()) |
96 | 108 |
#print(x) |
97 |
#print(self.boundingRect().x())
|
|
98 |
#print(self.boundingRect().y())
|
|
99 |
#QGraphicsRectItem.mousePressEvent(self, event)
|
|
109 |
print(self.sceneBoundingRect().x())
|
|
110 |
print(self.sceneBoundingRect().y())
|
|
111 |
QGraphicsRectItem.mousePressEvent(self, event) |
|
100 | 112 |
# pen = QPen(Qt.SolidLine) |
101 | 113 |
# pen.setColor(Qt.red) |
102 | 114 |
# pen.setWidthF(1) |
... | ... | |
129 | 141 |
|
130 | 142 |
QGraphicsRectItem.keyPressEvent(self, event) |
131 | 143 |
|
144 |
''' |
|
145 |
@brief override paint |
|
146 |
''' |
|
147 |
def paint(self, painter, options=None, widget=None): |
|
148 |
QGraphicsRectItem.paint(self, painter, options, widget) |
|
149 |
|
|
150 |
painter.setPen(self.pen()) |
|
151 |
painter.drawEllipse(QPointF(self.rect().x() , self.rect().y()), 3, 3) |
|
152 |
|
|
132 | 153 |
def addTextItemToScene(self, view): |
133 | 154 |
try: |
134 | 155 |
self.view = view |
DTI_PID/DTI_PID/TrainingEditorDialog.py | ||
---|---|---|
57 | 57 |
|
58 | 58 |
for box in boxList: |
59 | 59 |
boxComponent = box.split(' ') |
60 |
singleBox = QTrainingBoxItem(int(boxComponent[1]), cvImg.shape[0] - int(boxComponent[2]), int(boxComponent[3]) - int(boxComponent[1]), int(boxComponent[2]) - int(boxComponent[4]))
|
|
60 |
singleBox = QTrainingBoxItem(int(boxComponent[1]), cvImg.shape[0] - int(boxComponent[4]), int(boxComponent[3]) - int(boxComponent[1]), int(boxComponent[4]) - int(boxComponent[2]))
|
|
61 | 61 |
singleBox.loc = [int(boxComponent[1]), cvImg.shape[0] - int(boxComponent[2])] |
62 | 62 |
singleBox.size = [int(boxComponent[3]) - int(boxComponent[1]), int(boxComponent[2]) - int(boxComponent[4])] |
63 | 63 |
singleBox.angle = 0 |
DTI_PID/DTI_PID/TrainingEditor_UI.py | ||
---|---|---|
126 | 126 |
self.label_3 = QtWidgets.QLabel(TrainingEditorDialog) |
127 | 127 |
self.label_3.setObjectName("label_3") |
128 | 128 |
self.horizontalLayout_8.addWidget(self.label_3) |
129 |
self.spinBox_2 = QtWidgets.QSpinBox(TrainingEditorDialog)
|
|
129 |
self.spinBoxLeft = QtWidgets.QSpinBox(TrainingEditorDialog)
|
|
130 | 130 |
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Fixed) |
131 | 131 |
sizePolicy.setHorizontalStretch(0) |
132 | 132 |
sizePolicy.setVerticalStretch(0) |
133 |
sizePolicy.setHeightForWidth(self.spinBox_2.sizePolicy().hasHeightForWidth())
|
|
134 |
self.spinBox_2.setSizePolicy(sizePolicy)
|
|
135 |
self.spinBox_2.setMinimumSize(QtCore.QSize(70, 0))
|
|
136 |
self.spinBox_2.setObjectName("spinBox_2")
|
|
137 |
self.horizontalLayout_8.addWidget(self.spinBox_2)
|
|
133 |
sizePolicy.setHeightForWidth(self.spinBoxLeft.sizePolicy().hasHeightForWidth())
|
|
134 |
self.spinBoxLeft.setSizePolicy(sizePolicy)
|
|
135 |
self.spinBoxLeft.setMinimumSize(QtCore.QSize(70, 0))
|
|
136 |
self.spinBoxLeft.setObjectName("spinBoxLeft")
|
|
137 |
self.horizontalLayout_8.addWidget(self.spinBoxLeft)
|
|
138 | 138 |
self.label_6 = QtWidgets.QLabel(TrainingEditorDialog) |
139 | 139 |
self.label_6.setObjectName("label_6") |
140 | 140 |
self.horizontalLayout_8.addWidget(self.label_6) |
141 |
self.spinBox = QtWidgets.QSpinBox(TrainingEditorDialog) |
|
142 |
self.spinBox.setMinimumSize(QtCore.QSize(70, 0)) |
|
143 |
self.spinBox.setObjectName("spinBox")
|
|
144 |
self.horizontalLayout_8.addWidget(self.spinBox) |
|
141 |
self.spinBoxTop = QtWidgets.QSpinBox(TrainingEditorDialog)
|
|
142 |
self.spinBoxTop.setMinimumSize(QtCore.QSize(70, 0))
|
|
143 |
self.spinBoxTop.setObjectName("spinBoxTop")
|
|
144 |
self.horizontalLayout_8.addWidget(self.spinBoxTop)
|
|
145 | 145 |
self.verticalLayout_7.addLayout(self.horizontalLayout_8) |
146 | 146 |
spacerItem4 = QtWidgets.QSpacerItem(20, 10, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Fixed) |
147 | 147 |
self.verticalLayout_7.addItem(spacerItem4) |
... | ... | |
150 | 150 |
self.label_5 = QtWidgets.QLabel(TrainingEditorDialog) |
151 | 151 |
self.label_5.setObjectName("label_5") |
152 | 152 |
self.horizontalLayout_7.addWidget(self.label_5) |
153 |
self.spinBox_4 = QtWidgets.QSpinBox(TrainingEditorDialog)
|
|
154 |
self.spinBox_4.setMinimumSize(QtCore.QSize(70, 0))
|
|
155 |
self.spinBox_4.setObjectName("spinBox_4")
|
|
156 |
self.horizontalLayout_7.addWidget(self.spinBox_4)
|
|
153 |
self.spinBoxWidth = QtWidgets.QSpinBox(TrainingEditorDialog)
|
|
154 |
self.spinBoxWidth.setMinimumSize(QtCore.QSize(70, 0))
|
|
155 |
self.spinBoxWidth.setObjectName("spinBoxWidth")
|
|
156 |
self.horizontalLayout_7.addWidget(self.spinBoxWidth)
|
|
157 | 157 |
self.label_7 = QtWidgets.QLabel(TrainingEditorDialog) |
158 | 158 |
self.label_7.setObjectName("label_7") |
159 | 159 |
self.horizontalLayout_7.addWidget(self.label_7) |
160 |
self.spinBox_3 = QtWidgets.QSpinBox(TrainingEditorDialog)
|
|
161 |
self.spinBox_3.setMinimumSize(QtCore.QSize(70, 0))
|
|
162 |
self.spinBox_3.setObjectName("spinBox_3")
|
|
163 |
self.horizontalLayout_7.addWidget(self.spinBox_3)
|
|
160 |
self.spinBoxHeight = QtWidgets.QSpinBox(TrainingEditorDialog)
|
|
161 |
self.spinBoxHeight.setMinimumSize(QtCore.QSize(70, 0))
|
|
162 |
self.spinBoxHeight.setObjectName("spinBoxHeight")
|
|
163 |
self.horizontalLayout_7.addWidget(self.spinBoxHeight)
|
|
164 | 164 |
self.verticalLayout_7.addLayout(self.horizontalLayout_7) |
165 | 165 |
spacerItem5 = QtWidgets.QSpacerItem(20, 10, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Fixed) |
166 | 166 |
self.verticalLayout_7.addItem(spacerItem5) |
... | ... | |
173 | 173 |
self.spinBox_6.setMinimumSize(QtCore.QSize(70, 0)) |
174 | 174 |
self.spinBox_6.setObjectName("spinBox_6") |
175 | 175 |
self.horizontalLayout_6.addWidget(self.spinBox_6) |
176 |
self.label_8 = QtWidgets.QLabel(TrainingEditorDialog) |
|
177 |
self.label_8.setObjectName("label_8") |
|
178 |
self.horizontalLayout_6.addWidget(self.label_8) |
|
179 |
self.spinBox_5 = QtWidgets.QSpinBox(TrainingEditorDialog) |
|
180 |
self.spinBox_5.setMinimumSize(QtCore.QSize(70, 0)) |
|
181 |
self.spinBox_5.setObjectName("spinBox_5") |
|
182 |
self.horizontalLayout_6.addWidget(self.spinBox_5) |
|
183 | 176 |
self.verticalLayout_7.addLayout(self.horizontalLayout_6) |
184 | 177 |
spacerItem6 = QtWidgets.QSpacerItem(20, 30, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Fixed) |
185 | 178 |
self.verticalLayout_7.addItem(spacerItem6) |
... | ... | |
221 | 214 |
self.pushButton_12.setText(_translate("TrainingEditorDialog", "PushButton")) |
222 | 215 |
self.label_2.setText(_translate("TrainingEditorDialog", "TextLabel")) |
223 | 216 |
self.pushButton_11.setText(_translate("TrainingEditorDialog", "PushButton")) |
224 |
self.label_3.setText(_translate("TrainingEditorDialog", "TextLabel"))
|
|
225 |
self.label_6.setText(_translate("TrainingEditorDialog", "TextLabel"))
|
|
226 |
self.label_5.setText(_translate("TrainingEditorDialog", "TextLabel"))
|
|
227 |
self.label_7.setText(_translate("TrainingEditorDialog", "TextLabel"))
|
|
217 |
self.label_3.setText(_translate("TrainingEditorDialog", "Left"))
|
|
218 |
self.label_6.setText(_translate("TrainingEditorDialog", "Top"))
|
|
219 |
self.label_5.setText(_translate("TrainingEditorDialog", "Width"))
|
|
220 |
self.label_7.setText(_translate("TrainingEditorDialog", "Height"))
|
|
228 | 221 |
self.label_4.setText(_translate("TrainingEditorDialog", "TextLabel")) |
229 |
self.label_8.setText(_translate("TrainingEditorDialog", "TextLabel")) |
|
230 | 222 |
self.pushButton_14.setText(_translate("TrainingEditorDialog", "PushButton")) |
231 | 223 |
self.pushButton_13.setText(_translate("TrainingEditorDialog", "PushButton")) |
232 | 224 |
|
DTI_PID/DTI_PID/UI/TrainingEditor.ui | ||
---|---|---|
307 | 307 |
<item> |
308 | 308 |
<widget class="QLabel" name="label_3"> |
309 | 309 |
<property name="text"> |
310 |
<string>TextLabel</string>
|
|
310 |
<string>Left</string>
|
|
311 | 311 |
</property> |
312 | 312 |
</widget> |
313 | 313 |
</item> |
314 | 314 |
<item> |
315 |
<widget class="QSpinBox" name="spinBox_2">
|
|
315 |
<widget class="QSpinBox" name="spinBoxLeft">
|
|
316 | 316 |
<property name="sizePolicy"> |
317 | 317 |
<sizepolicy hsizetype="Minimum" vsizetype="Fixed"> |
318 | 318 |
<horstretch>0</horstretch> |
... | ... | |
330 | 330 |
<item> |
331 | 331 |
<widget class="QLabel" name="label_6"> |
332 | 332 |
<property name="text"> |
333 |
<string>TextLabel</string>
|
|
333 |
<string>Top</string>
|
|
334 | 334 |
</property> |
335 | 335 |
</widget> |
336 | 336 |
</item> |
337 | 337 |
<item> |
338 |
<widget class="QSpinBox" name="spinBox"> |
|
338 |
<widget class="QSpinBox" name="spinBoxTop">
|
|
339 | 339 |
<property name="minimumSize"> |
340 | 340 |
<size> |
341 | 341 |
<width>70</width> |
... | ... | |
367 | 367 |
<item> |
368 | 368 |
<widget class="QLabel" name="label_5"> |
369 | 369 |
<property name="text"> |
370 |
<string>TextLabel</string>
|
|
370 |
<string>Width</string>
|
|
371 | 371 |
</property> |
372 | 372 |
</widget> |
373 | 373 |
</item> |
374 | 374 |
<item> |
375 |
<widget class="QSpinBox" name="spinBox_4">
|
|
375 |
<widget class="QSpinBox" name="spinBoxWidth">
|
|
376 | 376 |
<property name="minimumSize"> |
377 | 377 |
<size> |
378 | 378 |
<width>70</width> |
... | ... | |
384 | 384 |
<item> |
385 | 385 |
<widget class="QLabel" name="label_7"> |
386 | 386 |
<property name="text"> |
387 |
<string>TextLabel</string>
|
|
387 |
<string>Height</string>
|
|
388 | 388 |
</property> |
389 | 389 |
</widget> |
390 | 390 |
</item> |
391 | 391 |
<item> |
392 |
<widget class="QSpinBox" name="spinBox_3">
|
|
392 |
<widget class="QSpinBox" name="spinBoxHeight">
|
|
393 | 393 |
<property name="minimumSize"> |
394 | 394 |
<size> |
395 | 395 |
<width>70</width> |
... | ... | |
435 | 435 |
</property> |
436 | 436 |
</widget> |
437 | 437 |
</item> |
438 |
<item> |
|
439 |
<widget class="QLabel" name="label_8"> |
|
440 |
<property name="text"> |
|
441 |
<string>TextLabel</string> |
|
442 |
</property> |
|
443 |
</widget> |
|
444 |
</item> |
|
445 |
<item> |
|
446 |
<widget class="QSpinBox" name="spinBox_5"> |
|
447 |
<property name="minimumSize"> |
|
448 |
<size> |
|
449 |
<width>70</width> |
|
450 |
<height>0</height> |
|
451 |
</size> |
|
452 |
</property> |
|
453 |
</widget> |
|
454 |
</item> |
|
455 | 438 |
</layout> |
456 | 439 |
</item> |
457 | 440 |
<item> |
내보내기 Unified diff