개정판 c46d2c90
issue #503:
- Typical 영역 설정 기능 추가
DTI_PID/DTI_PID/ConfigurationAreaDialog.py | ||
---|---|---|
127 | 127 |
self.ui.tableWidgetTitleBlockArea.setItem(row, 2, item) |
128 | 128 |
row += 1 |
129 | 129 |
|
130 |
#self.ui.pushButtonAdd.setStyleSheet('background-color: darkGray') |
|
131 |
|
|
132 | 130 |
section = '{} Equipment Desc Area'.format(docData.imgName) |
133 | 131 |
configs = docData.getConfigs(section) |
134 | 132 |
self.ui.tableWidgetEquipmentDescArea.setRowCount(len(configs)) |
... | ... | |
152 | 150 |
|
153 | 151 |
row += 1 |
154 | 152 |
|
153 |
# load typical area |
|
154 |
self.ui.tableWidgetTypicalArea.setHorizontalHeaderLabels(['Drawing Name', 'Name', 'Area']) |
|
155 |
self.ui.tableWidgetTypicalArea.hideColumn(0) |
|
156 |
section = '{} Typical Area'.format(docData.imgName) |
|
157 |
configs = docData.getConfigs(section) |
|
158 |
self.ui.tableWidgetTypicalArea.setRowCount(len(configs)) |
|
159 |
row = 0 |
|
160 |
for config in configs: |
|
161 |
area = Area('') |
|
162 |
area.parse(config.value) |
|
163 |
|
|
164 |
boundingBox = QGraphicsBoundingBoxItem(area.x, area.y, area.width, area.height) |
|
165 |
boundingBox.transfer.onSizeChanged.connect(self.onBoundingBoxChanged) |
|
166 |
boundingBox.setPen(QPen(Qt.darkGray, THICKNESS, Qt.SolidLine)) |
|
167 |
self.parent().graphicsView.scene.addItem(boundingBox) |
|
168 |
|
|
169 |
item = QTableWidgetItem(docData.imgName) |
|
170 |
item.setFlags(Qt.ItemIsEnabled) |
|
171 |
self.ui.tableWidgetTypicalArea.setItem(row, 0, item) |
|
172 |
item = QTableWidgetItem(area.name) |
|
173 |
self.ui.tableWidgetTypicalArea.setItem(row, 1, item) |
|
174 |
item = QTableWidgetItem('({},{}),({},{})'.format(area.x, area.y, area.width, area.height)) |
|
175 |
item.setFlags(Qt.ItemIsEnabled) |
|
176 |
item.tag = boundingBox |
|
177 |
self.ui.tableWidgetTypicalArea.setItem(row, 2, item) |
|
178 |
|
|
179 |
row += 1 |
|
180 |
|
|
155 | 181 |
if self.ui.tableWidgetEquipmentDescArea.rowCount() is not 0: |
156 | 182 |
self.ui.tableWidgetEquipmentDescArea.resizeColumnsToContents() |
157 | 183 |
if self.ui.tableWidgetTitleBlockArea.rowCount() is not 0: |
158 | 184 |
self.ui.tableWidgetTitleBlockArea.resizeColumnsToContents() |
185 |
if self.ui.tableWidgetTypicalArea.rowCount() is not 0: |
|
186 |
self.ui.tableWidgetTypicalArea.resizeColumnsToContents() |
|
159 | 187 |
|
160 | 188 |
self.ui.pushButtonDrawingArea.clicked.connect(self.selectDrawingArea) |
161 | 189 |
self.ui.pushButtonNoteArea.clicked.connect(self.selectNoteArea) |
... | ... | |
174 | 202 |
self.ui.pushButtonDelTitleBlockProp.clicked.connect(self.onDeleteTitleBlockArea) |
175 | 203 |
self.ui.pushButtonAdd.clicked.connect(self.onSelectEquipmentDescArea) |
176 | 204 |
self.ui.pushButtonDel.clicked.connect(self.onDeleteEquipmentDescArea) |
205 |
self.ui.pushButtonAddTypicalArea.clicked.connect(self.onSelectTypicalArea) |
|
206 |
self.ui.pushButtonDelTypicalArea.clicked.connect(self.onDeleteTypicalArea) |
|
177 | 207 |
|
178 | 208 |
def deleteArea(self, event): |
179 | 209 |
''' |
... | ... | |
298 | 328 |
self._cmd.tag = self.ui.lineEditEquipmentDescArea |
299 | 329 |
self.parent().graphicsView.command = self._cmd |
300 | 330 |
|
331 |
def onSelectTypicalArea(self): |
|
332 |
''' |
|
333 |
@brief select typical area |
|
334 |
@author humkyung |
|
335 |
@date 2018.12.14 |
|
336 |
''' |
|
337 |
self._cmd.tag = self.ui.lineEditTypicalArea |
|
338 |
self.parent().graphicsView.command = self._cmd |
|
339 |
|
|
301 | 340 |
''' |
302 | 341 |
@brief remove box area from scene |
303 | 342 |
@author humkyung |
... | ... | |
326 | 365 |
self.removeArea(self.ui.tableWidgetEquipmentDescArea.item(row, 1).tag) |
327 | 366 |
self.ui.tableWidgetEquipmentDescArea.removeRow(row) |
328 | 367 |
except Exception as ex: |
329 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
|
368 |
from App import App |
|
369 |
from AppDocData import MessageType |
|
370 |
|
|
371 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
372 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
|
373 |
|
|
374 |
def onDeleteTypicalArea(self): |
|
375 |
''' |
|
376 |
@brief delete selected typical area |
|
377 |
@author humkyung |
|
378 |
@date 2018.12.14 |
|
379 |
''' |
|
380 |
try: |
|
381 |
row = self.ui.tableWidgetTypicalArea.currentRow() |
|
382 |
if row is -1: |
|
383 |
return |
|
384 |
self.removeArea(self.ui.tableWidgetTypicalArea.item(row, 1).tag) |
|
385 |
self.ui.tableWidgetTypicalArea.removeRow(row) |
|
386 |
except Exception as ex: |
|
387 |
from App import App |
|
388 |
from AppDocData import MessageType |
|
389 |
|
|
390 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
391 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
|
330 | 392 |
|
331 | 393 |
''' |
332 | 394 |
@brief called when area is created |
... | ... | |
452 | 514 |
self.ui.tableWidgetTitleBlockArea.setItem(row, 2, item) |
453 | 515 |
self.ui.tableWidgetTitleBlockArea.resizeColumnsToContents() |
454 | 516 |
# up to here |
517 |
elif self._cmd.tag is self.ui.lineEditTypicalArea: |
|
518 |
x, y = round(x), round(y) |
|
519 |
width, height = round(width), round(height) |
|
520 |
|
|
521 |
boundingBox = QGraphicsBoundingBoxItem(x, y, width, height) |
|
522 |
boundingBox.transfer.onSizeChanged.connect(self.onBoundingBoxChanged) |
|
523 |
boundingBox.setPen(QPen(Qt.darkCyan, THICKNESS, Qt.SolidLine)) |
|
524 |
self.parent().graphicsView.scene.addItem(boundingBox) |
|
525 |
|
|
526 |
# add item to table widget |
|
527 |
docData = AppDocData.instance() |
|
528 |
row = self.ui.tableWidgetTypicalArea.rowCount() |
|
529 |
self.ui.tableWidgetTypicalArea.setRowCount(row + 1) |
|
530 |
item = QTableWidgetItem(docData.imgName) |
|
531 |
self.ui.tableWidgetTypicalArea.setItem(row, 0, item) |
|
532 |
item = QTableWidgetItem(str(uuid.uuid4())) |
|
533 |
item.setFlags(Qt.ItemIsEnabled|Qt.ItemIsEditable) |
|
534 |
self.ui.tableWidgetTypicalArea.setItem(row, 1, item) |
|
535 |
strArea = '({},{}),({},{})'.format(x, y, width, height) |
|
536 |
item = QTableWidgetItem(strArea) |
|
537 |
item.setFlags(Qt.ItemIsEnabled) |
|
538 |
item.tag = boundingBox |
|
539 |
self.ui.tableWidgetTypicalArea.setItem(row, 2, item) |
|
540 |
self.ui.tableWidgetTypicalArea.resizeColumnsToContents() |
|
541 |
# up to here |
|
455 | 542 |
|
456 | 543 |
self.parent().graphicsView.command = None |
457 | 544 |
|
... | ... | |
577 | 664 |
self.removeArea(self.ui.tableWidgetTitleBlockArea.item(row, 2).tag) |
578 | 665 |
docData.updateTitleBlockProperties(titleBlockProps) |
579 | 666 |
# up to here |
667 |
|
|
668 |
# save typical area |
|
669 |
section = '{} Typical Area'.format(docData.imgName) |
|
670 |
docData.deleteConfigs(section) |
|
671 |
|
|
672 |
configs = [] |
|
673 |
for row in range(self.ui.tableWidgetTypicalArea.rowCount()): |
|
674 |
name = self.ui.tableWidgetTypicalArea.item(row, 1).text() |
|
675 |
area = Area('Typical Area') |
|
676 |
area.parse(self.ui.tableWidgetTypicalArea.item(row, 2).text()) |
|
677 |
configs.append(Config(section, name, area.toString())) |
|
678 |
|
|
679 |
self.removeArea(self.ui.tableWidgetTypicalArea.item(row, 2).tag) |
|
680 |
# up to here |
|
681 |
|
|
580 | 682 |
docData.saveConfigs(configs) |
581 | 683 |
|
582 | 684 |
self.isAccepted = True |
... | ... | |
615 | 717 |
for row in range(self.ui.tableWidgetTitleBlockArea.rowCount()): |
616 | 718 |
self.removeArea(self.ui.tableWidgetTitleBlockArea.item(row, 2).tag) |
617 | 719 |
|
720 |
for row in range(self.ui.tableWidgetTypicalArea.rowCount()): |
|
721 |
self.removeArea(self.ui.tableWidgetTypicalArea.item(row, 2).tag) |
|
722 |
|
|
618 | 723 |
QDialog.reject(self) |
DTI_PID/DTI_PID/Configuration_Area_UI.py | ||
---|---|---|
1 | 1 |
# -*- coding: utf-8 -*- |
2 | 2 |
|
3 |
# Form implementation generated from reading ui file './UI/Configuration_Area.ui'
|
|
3 |
# Form implementation generated from reading ui file '.\UI\Configuration_Area.ui'
|
|
4 | 4 |
# |
5 | 5 |
# Created by: PyQt5 UI code generator 5.11.3 |
6 | 6 |
# |
... | ... | |
11 | 11 |
class Ui_AreaDialog(object): |
12 | 12 |
def setupUi(self, AreaDialog): |
13 | 13 |
AreaDialog.setObjectName("AreaDialog") |
14 |
AreaDialog.resize(598, 544)
|
|
14 |
AreaDialog.resize(598, 750)
|
|
15 | 15 |
font = QtGui.QFont() |
16 | 16 |
font.setFamily("맑은 고딕") |
17 | 17 |
AreaDialog.setFont(font) |
... | ... | |
152 | 152 |
self.verticalLayout.addLayout(self.horizontalLayout_2) |
153 | 153 |
self.gridLayout_3.addLayout(self.verticalLayout, 0, 0, 1, 1) |
154 | 154 |
self.gridLayout.addWidget(self.groupBoxEquipmentDesc, 3, 0, 1, 1) |
155 |
self.buttonBox = QtWidgets.QDialogButtonBox(AreaDialog) |
|
156 |
self.buttonBox.setOrientation(QtCore.Qt.Horizontal) |
|
157 |
self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok) |
|
158 |
self.buttonBox.setObjectName("buttonBox") |
|
159 |
self.gridLayout.addWidget(self.buttonBox, 4, 0, 1, 1) |
|
160 | 155 |
self.groupBoxTitleBlock = QtWidgets.QGroupBox(AreaDialog) |
161 | 156 |
self.groupBoxTitleBlock.setObjectName("groupBoxTitleBlock") |
162 | 157 |
self.gridLayout_4 = QtWidgets.QGridLayout(self.groupBoxTitleBlock) |
... | ... | |
188 | 183 |
self.horizontalLayout_3.addWidget(self.pushButtonDelTitleBlockProp) |
189 | 184 |
self.gridLayout_4.addLayout(self.horizontalLayout_3, 0, 0, 1, 1) |
190 | 185 |
self.gridLayout.addWidget(self.groupBoxTitleBlock, 2, 0, 1, 1) |
186 |
self.buttonBox = QtWidgets.QDialogButtonBox(AreaDialog) |
|
187 |
self.buttonBox.setOrientation(QtCore.Qt.Horizontal) |
|
188 |
self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok) |
|
189 |
self.buttonBox.setObjectName("buttonBox") |
|
190 |
self.gridLayout.addWidget(self.buttonBox, 5, 0, 1, 1) |
|
191 |
self.groupBoxTypicalArea = QtWidgets.QGroupBox(AreaDialog) |
|
192 |
self.groupBoxTypicalArea.setObjectName("groupBoxTypicalArea") |
|
193 |
self.gridLayout_5 = QtWidgets.QGridLayout(self.groupBoxTypicalArea) |
|
194 |
self.gridLayout_5.setObjectName("gridLayout_5") |
|
195 |
self.verticalLayout_2 = QtWidgets.QVBoxLayout() |
|
196 |
self.verticalLayout_2.setObjectName("verticalLayout_2") |
|
197 |
self.horizontalLayout_5 = QtWidgets.QHBoxLayout() |
|
198 |
self.horizontalLayout_5.setObjectName("horizontalLayout_5") |
|
199 |
self.lineEditTypicalArea = QtWidgets.QLineEdit(self.groupBoxTypicalArea) |
|
200 |
self.lineEditTypicalArea.setObjectName("lineEditTypicalArea") |
|
201 |
self.horizontalLayout_5.addWidget(self.lineEditTypicalArea) |
|
202 |
self.pushButtonAddTypicalArea = QtWidgets.QPushButton(self.groupBoxTypicalArea) |
|
203 |
self.pushButtonAddTypicalArea.setMinimumSize(QtCore.QSize(22, 0)) |
|
204 |
self.pushButtonAddTypicalArea.setMaximumSize(QtCore.QSize(22, 16777215)) |
|
205 |
self.pushButtonAddTypicalArea.setObjectName("pushButtonAddTypicalArea") |
|
206 |
self.horizontalLayout_5.addWidget(self.pushButtonAddTypicalArea) |
|
207 |
self.pushButtonDelTypicalArea = QtWidgets.QPushButton(self.groupBoxTypicalArea) |
|
208 |
self.pushButtonDelTypicalArea.setMinimumSize(QtCore.QSize(22, 0)) |
|
209 |
self.pushButtonDelTypicalArea.setMaximumSize(QtCore.QSize(22, 16777215)) |
|
210 |
self.pushButtonDelTypicalArea.setObjectName("pushButtonDelTypicalArea") |
|
211 |
self.horizontalLayout_5.addWidget(self.pushButtonDelTypicalArea) |
|
212 |
self.verticalLayout_2.addLayout(self.horizontalLayout_5) |
|
213 |
self.horizontalLayout_6 = QtWidgets.QHBoxLayout() |
|
214 |
self.horizontalLayout_6.setObjectName("horizontalLayout_6") |
|
215 |
self.tableWidgetTypicalArea = QtWidgets.QTableWidget(self.groupBoxTypicalArea) |
|
216 |
self.tableWidgetTypicalArea.setColumnCount(3) |
|
217 |
self.tableWidgetTypicalArea.setObjectName("tableWidgetTypicalArea") |
|
218 |
self.tableWidgetTypicalArea.setRowCount(0) |
|
219 |
self.horizontalLayout_6.addWidget(self.tableWidgetTypicalArea) |
|
220 |
self.verticalLayout_2.addLayout(self.horizontalLayout_6) |
|
221 |
self.gridLayout_5.addLayout(self.verticalLayout_2, 0, 0, 1, 1) |
|
222 |
self.gridLayout.addWidget(self.groupBoxTypicalArea, 4, 0, 1, 1) |
|
191 | 223 |
|
192 | 224 |
self.retranslateUi(AreaDialog) |
193 | 225 |
self.buttonBox.accepted.connect(AreaDialog.accept) |
... | ... | |
222 | 254 |
self.groupBoxTitleBlock.setTitle(_translate("AreaDialog", "Title Block")) |
223 | 255 |
self.pushButtonAddTitleBlockProp.setText(_translate("AreaDialog", "+")) |
224 | 256 |
self.pushButtonDelTitleBlockProp.setText(_translate("AreaDialog", "-")) |
257 |
self.groupBoxTypicalArea.setTitle(_translate("AreaDialog", "Typical 영역")) |
|
258 |
self.pushButtonAddTypicalArea.setText(_translate("AreaDialog", "+")) |
|
259 |
self.pushButtonDelTypicalArea.setText(_translate("AreaDialog", "-")) |
|
225 | 260 |
|
226 | 261 |
import MainWindow_rc |
227 | 262 |
|
DTI_PID/DTI_PID/TrainingImageListDialog.py | ||
---|---|---|
23 | 23 |
tesseract_cmd = os.path.join(dataPath, 'Tesseract-OCR', 'tesseract.exe') |
24 | 24 |
unicharset_extractor_cmd = os.path.join(dataPath, 'Tesseract-OCR', 'unicharset_extractor.exe') |
25 | 25 |
set_unicharset_properties_cmd = os.path.join(dataPath, 'Tesseract-OCR', 'set_unicharset_properties.exe') |
26 |
#langDataPath = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'Tesseract-OCR', 'set_unicharset_properties.exe') |
|
27 | 26 |
shapeclustering_cmd = os.path.join(dataPath, 'Tesseract-OCR', 'shapeclustering.exe') |
28 | 27 |
mftraining_cmd = os.path.join(dataPath, 'Tesseract-OCR', 'mftraining.exe') |
29 | 28 |
cntraining_cmd = os.path.join(dataPath, 'Tesseract-OCR', 'cntraining.exe') |
... | ... | |
696 | 695 |
|
697 | 696 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
698 | 697 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
699 |
return None |
|
700 |
|
|
701 |
|
|
702 |
|
|
698 |
return None |
DTI_PID/DTI_PID/tesseract_ocr_module.py | ||
---|---|---|
32 | 32 |
humkyung 2018.08.13 set tesseract executable path to relative of this file path |
33 | 33 |
euisung set tesseract executable path to ProgramData |
34 | 34 |
''' |
35 |
#pytesseract.pytesseract.tesseract_cmd = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'Tesseract-OCR', 'tesseract.exe') |
|
36 | 35 |
pytesseract.pytesseract.tesseract_cmd = os.path.join(os.getenv('ALLUSERSPROFILE'), 'Digital PID', 'Tesseract-OCR', 'tesseract.exe') |
37 | 36 |
|
38 | 37 |
tesseract_path = os.path.join(os.getenv('ALLUSERSPROFILE'), 'Digital PID', 'Tesseract-OCR') |
내보내기 Unified diff