개정판 54096bc7
Configuration 에 Small Line Minimum Length 추가 후 LineDetector.detectLine() 에서 불러온 후 각 if 문에 적용
DTI_PID/DTI_PID/Configuration_UI.py | ||
---|---|---|
1 | 1 |
# -*- coding: utf-8 -*- |
2 | 2 |
|
3 |
# Form implementation generated from reading ui file '.\UI\Configuration.ui'
|
|
3 |
# Form implementation generated from reading ui file 'Configuration.ui' |
|
4 | 4 |
# |
5 |
# Created by: PyQt5 UI code generator 5.10.1
|
|
5 |
# Created by: PyQt5 UI code generator 5.6
|
|
6 | 6 |
# |
7 | 7 |
# WARNING! All changes made in this file will be lost! |
8 | 8 |
|
... | ... | |
23 | 23 |
self.Recognition = QtWidgets.QWidget() |
24 | 24 |
self.Recognition.setObjectName("Recognition") |
25 | 25 |
self.gridLayout_2 = QtWidgets.QGridLayout(self.Recognition) |
26 |
self.gridLayout_2.setContentsMargins(0, 0, 0, 0) |
|
26 | 27 |
self.gridLayout_2.setObjectName("gridLayout_2") |
27 | 28 |
self.groupBox = QtWidgets.QGroupBox(self.Recognition) |
28 | 29 |
self.groupBox.setObjectName("groupBox") |
... | ... | |
57 | 58 |
self.spinBoxHeight.setObjectName("spinBoxHeight") |
58 | 59 |
self.horizontalLayout.addWidget(self.spinBoxHeight) |
59 | 60 |
self.gridLayout_5.addLayout(self.horizontalLayout, 3, 0, 1, 1) |
61 |
self.horizontalLayout_12 = QtWidgets.QHBoxLayout() |
|
62 |
self.horizontalLayout_12.setObjectName("horizontalLayout_12") |
|
63 |
self.label_16 = QtWidgets.QLabel(self.groupBox) |
|
64 |
self.label_16.setObjectName("label_16") |
|
65 |
self.horizontalLayout_12.addWidget(self.label_16) |
|
66 |
self.smallLineMinLengthSpinBox = QtWidgets.QSpinBox(self.groupBox) |
|
67 |
self.smallLineMinLengthSpinBox.setObjectName("smallLineMinLengthSpinBox") |
|
68 |
self.horizontalLayout_12.addWidget(self.smallLineMinLengthSpinBox) |
|
69 |
self.gridLayout_5.addLayout(self.horizontalLayout_12, 4, 0, 1, 1) |
|
60 | 70 |
self.gridLayout_2.addWidget(self.groupBox, 1, 1, 1, 1) |
61 | 71 |
self.groupBoxLineNo = QtWidgets.QGroupBox(self.Recognition) |
62 | 72 |
self.groupBoxLineNo.setObjectName("groupBoxLineNo") |
... | ... | |
127 | 137 |
self.tabTagNoRule = QtWidgets.QWidget() |
128 | 138 |
self.tabTagNoRule.setObjectName("tabTagNoRule") |
129 | 139 |
self.gridLayout_7 = QtWidgets.QGridLayout(self.tabTagNoRule) |
140 |
self.gridLayout_7.setContentsMargins(0, 0, 0, 0) |
|
130 | 141 |
self.gridLayout_7.setObjectName("gridLayout_7") |
131 | 142 |
self.groupBox_2 = QtWidgets.QGroupBox(self.tabTagNoRule) |
132 | 143 |
self.groupBox_2.setObjectName("groupBox_2") |
... | ... | |
222 | 233 |
self.tabNominalPipeSize = QtWidgets.QWidget() |
223 | 234 |
self.tabNominalPipeSize.setObjectName("tabNominalPipeSize") |
224 | 235 |
self.gridLayout_4 = QtWidgets.QGridLayout(self.tabNominalPipeSize) |
236 |
self.gridLayout_4.setContentsMargins(0, 0, 0, 0) |
|
225 | 237 |
self.gridLayout_4.setObjectName("gridLayout_4") |
226 | 238 |
self.verticalLayout = QtWidgets.QVBoxLayout() |
227 | 239 |
self.verticalLayout.setObjectName("verticalLayout") |
... | ... | |
241 | 253 |
self.gridLayout.addWidget(self.buttonBox, 4, 0, 1, 1) |
242 | 254 |
|
243 | 255 |
self.retranslateUi(ConfigurationDialog) |
244 |
self.tabWidget.setCurrentIndex(1)
|
|
256 |
self.tabWidget.setCurrentIndex(0)
|
|
245 | 257 |
self.buttonBox.accepted.connect(ConfigurationDialog.accept) |
246 | 258 |
self.buttonBox.rejected.connect(ConfigurationDialog.reject) |
247 | 259 |
QtCore.QMetaObject.connectSlotsByName(ConfigurationDialog) |
... | ... | |
270 | 282 |
self.label_4.setText(_translate("ConfigurationDialog", "Small Object Size : ")) |
271 | 283 |
self.label_5.setText(_translate("ConfigurationDialog", " < Area < ")) |
272 | 284 |
self.label.setText(_translate("ConfigurationDialog", "Sliding Window Size(WxH) : ")) |
285 |
self.label_16.setText(_translate("ConfigurationDialog", "Small Line Minimum Length")) |
|
273 | 286 |
self.groupBoxLineNo.setTitle(_translate("ConfigurationDialog", "Line No")) |
274 | 287 |
self.label_3.setText(_translate("ConfigurationDialog", "Size Unit : ")) |
275 | 288 |
self.radioButtonMetric.setText(_translate("ConfigurationDialog", "Metric")) |
DTI_PID/DTI_PID/LineDetector.py | ||
---|---|---|
388 | 388 |
@author humkyung |
389 | 389 |
@date 2018.04 |
390 | 390 |
@history humkyung 2018.05.18 add parameter for thickness |
391 |
Jeongwoo 2018.05.18 Read LineLengthConfig and Comapare on if-statement |
|
391 | 392 |
''' |
392 | 393 |
def detectLine(self, pt, dir, thickness): |
393 | 394 |
from AppDocData import AppDocData |
394 | 395 |
|
396 |
lineLengthConfigs = AppDocData.instance().getConfigs('Small Line Minimum Length', 'Min Length') |
|
397 |
LINE_MIN_LENGTH = int(lineLengthConfigs[0].value) if 1 == len(lineLengthConfigs) else 10 |
|
398 |
|
|
395 | 399 |
try: |
396 | 400 |
white = [255] |
397 | 401 |
windowSize = AppDocData.instance().getSlidingWindowSize() |
... | ... | |
405 | 409 |
for i in range(imgWidth-windowSize[0]): |
406 | 410 |
window = image[0:windowSize[1], i:i+windowSize[0]] |
407 | 411 |
if (white == window[0:windowSize[1],0:windowSize[0]]).all(): break |
408 |
if i > windowSize[0]:
|
|
412 |
if i > LINE_MIN_LENGTH:
|
|
409 | 413 |
self._image[(pt[1]-yHalf):(pt[1]+yHalf), pt[0]:(pt[0]+i)] = white |
410 | 414 |
return [[pt[0], pt[1]], [pt[0] + i - round(thickness*0.5), pt[1]]] |
411 | 415 |
elif ([-1,0] == dir): |
... | ... | |
415 | 419 |
for i in range(imgWidth-windowSize[0], -1, -1): |
416 | 420 |
window = image[0:windowSize[1], i:i+windowSize[0]] |
417 | 421 |
if (white == window[0:windowSize[1],0:windowSize[0]]).all(): break |
418 |
if abs(pt[0] - i - windowSize[0]) > windowSize[0]:
|
|
422 |
if abs(pt[0] - i - windowSize[0]) > LINE_MIN_LENGTH:
|
|
419 | 423 |
self._image[int(pt[1]-yHalf):int(pt[1]+yHalf), (i+windowSize[0]+yHalf):pt[0]] = white |
420 | 424 |
return [[pt[0], pt[1]], [i+windowSize[0]+round(thickness*0.5), pt[1]]] |
421 | 425 |
elif ([0,1] == dir): |
... | ... | |
429 | 433 |
for i in range(imgHeight-windowSize[1]): |
430 | 434 |
window = image[i:i+windowSize[1], 0:windowSize[0]] |
431 | 435 |
if (white == window[0:windowSize[1],0:windowSize[0]]).all(): break |
432 |
if i > windowSize[1]:
|
|
436 |
if i > LINE_MIN_LENGTH:
|
|
433 | 437 |
self._image[(pt[1]):(pt[1]+i), (pt[0]-xHalf):(pt[0]+xHalf)] = white |
434 | 438 |
return [[pt[0], pt[1]], [pt[0], pt[1] + i - round(thickness*0.5)]] |
435 | 439 |
elif ([0,-1] == dir): |
... | ... | |
443 | 447 |
for i in range(imgHeight-windowSize[1], -1, -1): |
444 | 448 |
window = image[i:i+windowSize[1], 0:windowSize[0]] |
445 | 449 |
if (white == window[0:windowSize[1],0:windowSize[0]]).all(): break |
446 |
if abs(pt[1] - i - windowSize[1]) > windowSize[1]:
|
|
450 |
if abs(pt[1] - i - windowSize[1]) > LINE_MIN_LENGTH:
|
|
447 | 451 |
self._image[(i+windowSize[1]):pt[1], (pt[0]-xHalf):(pt[0]+xHalf)] = white |
448 | 452 |
return [[pt[0], pt[1]], [pt[0], i+windowSize[1]+round(thickness*0.5)]] |
449 | 453 |
except Exception as ex: |
DTI_PID/DTI_PID/QConfigurationDialog.py | ||
---|---|---|
43 | 43 |
''' |
44 | 44 |
@history humkyung 2018.05.05 read configuration for instrument and opc tag no rule |
45 | 45 |
humkyung 2018.05.09 read line no tag rule configuration |
46 |
Jeongwoo 2018.05.18 read Small Line Minimum Length |
|
46 | 47 |
''' |
47 | 48 |
def __init__(self, parent): |
48 | 49 |
QDialog.__init__(self, parent) |
... | ... | |
70 | 71 |
self.ui.spinBoxWidth.setValue(windowSize[0]) |
71 | 72 |
self.ui.spinBoxHeight.setValue(windowSize[1]) |
72 | 73 |
|
74 |
configs = docData.getConfigs('Small Line Minimum Length', 'Min Length') |
|
75 |
self.ui.smallLineMinLengthSpinBox.setValue(int(configs[0].value)) if 1 == len(configs) else self.ui.smallLineMinLengthSpinBox.setValue(10) |
|
76 |
|
|
73 | 77 |
configs = docData.getConfigs('Line No', 'Size Unit') |
74 | 78 |
if 1 == len(configs): |
75 | 79 |
self.ui.radioButtonMetric.setChecked(True) if 'Metric' == configs[0].value else self.ui.radioButtonInch.setChecked(True) |
... | ... | |
144 | 148 |
humkyung 2018.05.02 save size delimiter |
145 | 149 |
humkyung 2018.05.05 save instrument and opc tag no rule |
146 | 150 |
humkyung 2018.05.09 save line no tag rule |
151 |
Jeongwoo 2018.05.18 save Small Line Minimum Length |
|
147 | 152 |
''' |
148 | 153 |
def accept(self): |
149 | 154 |
try: |
... | ... | |
155 | 160 |
configs.append(Config('Small Object Size', 'Max Area', self.ui.spinBoxMaxArea.value())) |
156 | 161 |
configs.append(Config('Sliding Window', 'Width', self.ui.spinBoxWidth.value())) |
157 | 162 |
configs.append(Config('Sliding Window', 'Height', self.ui.spinBoxHeight.value())) |
163 |
configs.append(Config('Small Line Minimum Length', 'Min Length', self.ui.smallLineMinLengthSpinBox.value())) |
|
158 | 164 |
configs.append(Config('Line No', 'Size Unit', 'Metric' if self.ui.radioButtonMetric.isChecked() else 'Inch')) |
159 | 165 |
configs.append(Config('Line No', 'Delimiter', self.ui.lineEdit.text())) |
160 | 166 |
configs.append(Config('Line No Tag Rule', 'Tag Seq No', self.ui.lineEditLineNoTagSeqNo.text())) |
DTI_PID/DTI_PID/UI/Configuration.ui | ||
---|---|---|
85 | 85 |
</item> |
86 | 86 |
</layout> |
87 | 87 |
</item> |
88 |
<item row="4" column="0"> |
|
89 |
<layout class="QHBoxLayout" name="horizontalLayout_12"> |
|
90 |
<item> |
|
91 |
<widget class="QLabel" name="label_16"> |
|
92 |
<property name="text"> |
|
93 |
<string>Small Line Minimum Length</string> |
|
94 |
</property> |
|
95 |
</widget> |
|
96 |
</item> |
|
97 |
<item> |
|
98 |
<widget class="QSpinBox" name="smallLineMinLengthSpinBox"/> |
|
99 |
</item> |
|
100 |
</layout> |
|
101 |
</item> |
|
88 | 102 |
</layout> |
89 | 103 |
</widget> |
90 | 104 |
</item> |
내보내기 Unified diff