개정판 905f8163
issue #000: add dilate size config
Change-Id: I0b910d957d22a80cc0d52c6eae84d2d636541e87
DTI_PID/DTI_PID/AppDocData.py | ||
---|---|---|
278 | 278 |
@property |
279 | 279 |
def imgSrc(self): |
280 | 280 |
import cv2 |
281 |
import numpy as np |
|
281 | 282 |
|
282 | 283 |
if self._imgSrc is None and self._imgFilePath is not None and os.path.isfile(self._imgFilePath): |
283 | 284 |
self._imgSrc = cv2.cvtColor(cv2.imread(self._imgFilePath), cv2.COLOR_BGR2GRAY) |
... | ... | |
289 | 290 |
#smooth = cv2.addWeighted(blur, 1.5, self._imgSrc, -0.5, 0) |
290 | 291 |
#self._imgSrc = cv2.threshold(smooth, 0, 255, cv2.THRESH_BINARY+cv2.THRESH_OTSU)[1] |
291 | 292 |
self._imgSrc = cv2.threshold(self._imgSrc, 0, 255, cv2.THRESH_BINARY+cv2.THRESH_OTSU)[1] |
292 |
|
|
293 |
|
|
294 |
configs = AppDocData.instance().getConfigs('Filter', 'DilateSize') |
|
295 |
if 1 == len(configs): |
|
296 |
size = int(configs[0].value) |
|
297 |
kernel = np.ones((size, size), np.uint8) |
|
298 |
self._imgSrc = cv2.erode(self._imgSrc, kernel, iterations=1) |
|
299 |
|
|
293 | 300 |
return self._imgSrc |
294 | 301 |
|
295 | 302 |
''' |
DTI_PID/DTI_PID/ConfigurationDialog.py | ||
---|---|---|
83 | 83 |
|
84 | 84 |
configs = docData.getConfigs('Filter', 'MinimumSize') |
85 | 85 |
self.ui.spinBoxMinimumSize.setValue(int(configs[0].value)) if 1 == len(configs) else self.ui.spinBoxMinimumSize.setValue(30) |
86 |
configs = docData.getConfigs('Filter', 'DilateSize') |
|
87 |
self.ui.spinBoxDilateSize.setValue(int(configs[0].value)) if 1 == len(configs) else self.ui.spinBoxDilateSize.setValue(0) |
|
86 | 88 |
|
87 | 89 |
# set min,max area for small object |
88 | 90 |
configs = docData.getConfigs('Small Object Size', 'Min Area') |
... | ... | |
643 | 645 |
configs.append(Config('Flow Mark', 'Position', self.ui.spinBoxFlowMarkPosition.value())) |
644 | 646 |
configs.append(Config('Flow Mark', 'Length', self.ui.spinBoxFlowMarkLength.value())) |
645 | 647 |
configs.append(Config('Filter', 'MinimumSize', self.ui.spinBoxMinimumSize.value())) |
648 |
configs.append(Config('Filter', 'DilateSize', self.ui.spinBoxDilateSize.value())) |
|
646 | 649 |
configs.append(Config('Small Object Size', 'Min Area', self.ui.spinBoxMinArea.value())) |
647 | 650 |
configs.append(Config('Small Object Size', 'Max Area', self.ui.spinBoxMaxArea.value())) |
648 | 651 |
configs.append(Config('Sliding Window', 'Width', self.ui.spinBoxWidth.value())) |
DTI_PID/DTI_PID/Configuration_UI.py | ||
---|---|---|
283 | 283 |
self.spinBoxMinimumSize.setObjectName("spinBoxMinimumSize") |
284 | 284 |
self.horizontalLayout_16.addWidget(self.spinBoxMinimumSize) |
285 | 285 |
self.verticalLayout_9.addLayout(self.horizontalLayout_16) |
286 |
self.horizontalLayout_6 = QtWidgets.QHBoxLayout() |
|
287 |
self.horizontalLayout_6.setObjectName("horizontalLayout_6") |
|
288 |
self.label_29 = QtWidgets.QLabel(self.groupBoxFilter) |
|
289 |
self.label_29.setMaximumSize(QtCore.QSize(155, 16777215)) |
|
290 |
self.label_29.setObjectName("label_29") |
|
291 |
self.horizontalLayout_6.addWidget(self.label_29) |
|
292 |
self.spinBoxDilateSize = QtWidgets.QSpinBox(self.groupBoxFilter) |
|
293 |
self.spinBoxDilateSize.setMaximum(10) |
|
294 |
self.spinBoxDilateSize.setObjectName("spinBoxDilateSize") |
|
295 |
self.horizontalLayout_6.addWidget(self.spinBoxDilateSize) |
|
296 |
self.verticalLayout_9.addLayout(self.horizontalLayout_6) |
|
286 | 297 |
self.gridLayout_8.addLayout(self.verticalLayout_9, 0, 0, 1, 1) |
287 | 298 |
self.gridLayout_2.addWidget(self.groupBoxFilter, 2, 1, 1, 1) |
288 | 299 |
self.tabWidget.addTab(self.Recognition, "") |
... | ... | |
565 | 576 |
self.label_22.setText(_translate("ConfigurationDialog", "Merge Size : ")) |
566 | 577 |
self.groupBoxFilter.setTitle(_translate("ConfigurationDialog", "Filter")) |
567 | 578 |
self.label_10.setText(_translate("ConfigurationDialog", "Minimum Detection Size : ")) |
579 |
self.label_29.setText(_translate("ConfigurationDialog", "Drawing Dilate Size : ")) |
|
568 | 580 |
self.tabWidget.setTabText(self.tabWidget.indexOf(self.Recognition), _translate("ConfigurationDialog", "Recognition")) |
569 | 581 |
self.groupBox_8.setTitle(_translate("ConfigurationDialog", "Nozzle Name Rule")) |
570 | 582 |
self.label_27.setText(_translate("ConfigurationDialog", "Nozzle Name : ")) |
DTI_PID/DTI_PID/QtImageViewer.py | ||
---|---|---|
191 | 191 |
''' |
192 | 192 |
def loadImageFromFile(self, folder='', fileName=""): |
193 | 193 |
import cv2 |
194 |
|
|
194 |
import numpy as np |
|
195 |
from AppDocData import AppDocData |
|
195 | 196 |
""" Load an image from file. |
196 | 197 |
Without any arguments, loadImageFromFile() will popup a file dialog to choose the image file. |
197 | 198 |
With a fileName argument, loadImageFromFile(fileName) will attempt to load the specified image file directly. |
... | ... | |
208 | 209 |
cvImg = cv2.cvtColor(cv2.imread(fileName), cv2.COLOR_BGR2GRAY) |
209 | 210 |
#blur = cv2.GaussianBlur(cvImg, (5,5),0) |
210 | 211 |
cvImg = cv2.threshold(cvImg, 0, 255, cv2.THRESH_BINARY+cv2.THRESH_OTSU)[1] |
212 |
|
|
213 |
configs = AppDocData.instance().getConfigs('Filter', 'DilateSize') |
|
214 |
if 1 == len(configs): |
|
215 |
size = int(configs[0].value) |
|
216 |
kernel = np.ones((size, size), np.uint8) |
|
217 |
cvImg = cv2.erode(cvImg, kernel, iterations=1) |
|
218 |
|
|
211 | 219 |
bytesPerLine = cvImg.shape[1] |
212 | 220 |
image = QImage(cvImg.data, cvImg.shape[1], cvImg.shape[0], bytesPerLine, QImage.Format_Indexed8) |
213 | 221 |
self.setImage(image) |
DTI_PID/DTI_PID/UI/Configuration.ui | ||
---|---|---|
627 | 627 |
</item> |
628 | 628 |
</layout> |
629 | 629 |
</item> |
630 |
<item> |
|
631 |
<layout class="QHBoxLayout" name="horizontalLayout_6"> |
|
632 |
<item> |
|
633 |
<widget class="QLabel" name="label_29"> |
|
634 |
<property name="maximumSize"> |
|
635 |
<size> |
|
636 |
<width>155</width> |
|
637 |
<height>16777215</height> |
|
638 |
</size> |
|
639 |
</property> |
|
640 |
<property name="text"> |
|
641 |
<string>Drawing Dilate Size : </string> |
|
642 |
</property> |
|
643 |
</widget> |
|
644 |
</item> |
|
645 |
<item> |
|
646 |
<widget class="QSpinBox" name="spinBoxDilateSize"> |
|
647 |
<property name="maximum"> |
|
648 |
<number>10</number> |
|
649 |
</property> |
|
650 |
</widget> |
|
651 |
</item> |
|
652 |
</layout> |
|
653 |
</item> |
|
630 | 654 |
</layout> |
631 | 655 |
</item> |
632 | 656 |
</layout> |
내보내기 Unified diff