개정판 fad6212a
issue #655: add margin, box chars
DTI_PID/DTI_PID/TrainingEditorDialog.py | ||
---|---|---|
14 | 14 |
import PlaceLineCommand |
15 | 15 |
|
16 | 16 |
class QTrainingEditorDialog(QDialog): |
17 |
def __init__(self, parent, trainingImgPath, trainingBoxPath, boundaryOcrData, cellItem):
|
|
17 |
def __init__(self, parent, trainingImgPath, trainingBoxPath, boundaryOcrData, dateItem, boxItem):
|
|
18 | 18 |
self.spinBoxFlag = False |
19 | 19 |
QDialog.__init__(self, parent) |
20 | 20 |
self.setWindowFlag(Qt.WindowMinMaxButtonsHint) |
... | ... | |
22 | 22 |
self.trainingImgPath = trainingImgPath |
23 | 23 |
self.trainingBoxPath = trainingBoxPath |
24 | 24 |
self.boundaryOcrData = boundaryOcrData |
25 |
self.cellItem = cellItem |
|
25 |
self.dateItem = dateItem |
|
26 |
self.boxItem = boxItem |
|
26 | 27 |
self.isChanged = False |
27 | 28 |
|
28 | 29 |
appDocData = AppDocData.instance() |
... | ... | |
229 | 230 |
fw.write(outBox) |
230 | 231 |
fw.close() |
231 | 232 |
modifiedTime = str(datetime.datetime.strptime(time.ctime(os.path.getmtime(self.trainingBoxPath)), "%a %b %d %H:%M:%S %Y")) |
232 |
self.cellItem.setText(modifiedTime) |
|
233 |
self.dateItem.setText(modifiedTime) |
|
234 |
|
|
235 |
boxContent = outBox.split('\n') |
|
236 |
boxContent = boxContent[:-1] |
|
237 |
boxchars = '' |
|
238 |
for char in boxContent: |
|
239 |
boxchars += char[0] |
|
240 |
self.boxItem.setText(boxchars) |
|
233 | 241 |
|
234 | 242 |
self.isChanged = False |
235 | 243 |
QMessageBox.about(self, "알림", '저장하였습니다.') |
DTI_PID/DTI_PID/TrainingImageListDialog.py | ||
---|---|---|
37 | 37 |
|
38 | 38 |
# for List |
39 | 39 |
self.ui.tableWidgetList.setSelectionMode(QAbstractItemView.SingleSelection) |
40 |
self.ui.tableWidgetList.setColumnCount(3)
|
|
40 |
self.ui.tableWidgetList.setColumnCount(4)
|
|
41 | 41 |
|
42 | 42 |
## column header 명 설정 |
43 |
self.ui.tableWidgetList.setHorizontalHeaderLabels(['No.', '이미지 목록', '박스 작업 상태'])
|
|
43 |
self.ui.tableWidgetList.setHorizontalHeaderLabels(['No.', '이미지 목록', '박스 수정 일자', '박스 내용'])
|
|
44 | 44 |
self.ui.tableWidgetList.horizontalHeaderItem(1).setToolTip('도면 이름') # header tooltip |
45 | 45 |
self.ui.tableWidgetList.horizontalHeaderItem(2).setToolTip('작업 상태') # header tooltip |
46 |
self.ui.tableWidgetList.horizontalHeaderItem(3).setToolTip('박스 내용') # header tooltip |
|
46 | 47 |
self.ui.tableWidgetList.horizontalHeaderItem(1).setSizeHint(QSize(30, 30)) |
47 | 48 |
self.ui.tableWidgetList.horizontalHeader().setSectionResizeMode(0, QHeaderView.ResizeToContents) |
48 | 49 |
self.ui.tableWidgetList.horizontalHeader().setSectionResizeMode(1, QHeaderView.Stretch) |
49 | 50 |
self.ui.tableWidgetList.horizontalHeader().setSectionResizeMode(2, QHeaderView.Stretch) |
51 |
self.ui.tableWidgetList.horizontalHeader().setSectionResizeMode(3, QHeaderView.Stretch) |
|
52 |
self.ui.tableWidgetList.resizeColumnsToContents() |
|
50 | 53 |
self.ui.tableWidgetList.setEditTriggers(QAbstractItemView.NoEditTriggers) |
51 | 54 |
|
52 | 55 |
self.listUpdate() |
... | ... | |
96 | 99 |
boxPath = os.path.join(project.getTrainingFilePath(), boxName) |
97 | 100 |
modifiedTime = str(datetime.datetime.strptime(time.ctime(os.path.getmtime(boxPath)), "%a %b %d %H:%M:%S %Y")) |
98 | 101 |
self.ui.tableWidgetList.setItem(row, 2, QTableWidgetItem(modifiedTime)) |
102 |
|
|
103 |
fw = open(boxPath, 'r', encoding='utf8') |
|
104 |
boxContent = fw.read() |
|
105 |
fw.close() |
|
106 |
boxContent = boxContent.split('\n') |
|
107 |
boxContent = boxContent[:-1] |
|
108 |
boxchars = '' |
|
109 |
for char in boxContent: |
|
110 |
boxchars += char[0] |
|
111 |
boxContent = QTableWidgetItem(boxchars) |
|
112 |
boxContent.setFont(QFont('Consolas', 9, QFont.Bold)) |
|
113 |
self.ui.tableWidgetList.setItem(row, 3, QTableWidgetItem(boxContent)) |
|
99 | 114 |
break |
100 | 115 |
else: |
101 | 116 |
self.ui.tableWidgetList.setItem(row, 2, QTableWidgetItem('')) |
117 |
self.ui.tableWidgetList.setItem(row, 3, QTableWidgetItem('')) |
|
102 | 118 |
row += 1 |
103 | 119 |
|
104 | 120 |
''' |
... | ... | |
526 | 542 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
527 | 543 |
|
528 | 544 |
try: |
529 |
dialog = QTrainingEditorDialog(self, drawingPath, trainingBoxPath, boundaryOcrData, self.ui.tableWidgetList.item(row, 2)) |
|
545 |
dialog = QTrainingEditorDialog(self, drawingPath, trainingBoxPath, boundaryOcrData, self.ui.tableWidgetList.item(row, 2), self.ui.tableWidgetList.item(row, 3))
|
|
530 | 546 |
dialog.exec_() |
531 | 547 |
#self.listUpdate() |
532 | 548 |
|
DTI_PID/DTI_PID/tesseract_ocr_module.py | ||
---|---|---|
125 | 125 |
text = pytesseract.image_to_string(cropped, config=conf, lang=oCRLang) |
126 | 126 |
|
127 | 127 |
if rect.height() >= minSize and rect.height() <= maxSize: |
128 |
text_rect = QRect(rect.left(), imgHeight - rect.bottom(), rect.width(), rect.height()) |
|
128 |
left = rect.left() - 2 if rect.left() - 2 >= 0 else rect.left() |
|
129 |
top = imgHeight - rect.bottom() - 2 if imgHeight - rect.bottom() - 2 >= 0 else imgHeight - rect.bottom() |
|
130 |
width = rect.width() + 4 if rect.width() + 4 <= im.size[0] else rect.width() |
|
131 |
height = rect.height() + 4 if rect.height() + 4 <= im.size[1] else rect.height() |
|
132 |
text_rect = QRect(left, top, width, height) |
|
129 | 133 |
if angle == 90 or angle == 270: |
130 | 134 |
transform = QTransform() |
131 | 135 |
transform.translate(imgHeight*0.5, imgWidth*0.5) |
내보내기 Unified diff