프로젝트

일반

사용자정보

개정판 e34425c9

IDe34425c99031788c12d1bb0b92a72ec6c84ee43f
상위 b8d39c65
하위 86faa3db, 94d1ba82

humkyung 이(가) 약 6년 전에 추가함

issue #655:
- show training message

차이점 보기:

DTI_PID/DTI_PID/TrainingImageListDialog.py
169 169
        from PIL import Image
170 170
        import math
171 171
        try:
172
            qmsg = QMessageBox(QMessageBox.Information,'알림' ,'학습 파일을 생성중입니다.')
173
            qmsg.show()
172
            self.ui.labelProgress.setText('학습 파일을 생성중입니다.')
173

  
174 174
            appDocData = AppDocData.instance()
175 175
            project = appDocData.getCurrentProject()
176 176
            self.oCRLang = appDocData.getCurrentProject().getName()
......
295 295
            trainingTextImg.save(trainingImgPath, compression='tiff_lzw')
296 296
            fw = open(trainingBoxPath, 'w', encoding='utf8')
297 297
            fw.write(outBox)
298
            fw.close()        
299
 
298
            fw.close() 
299

  
300
            self.ui.labelProgress.setText('학습 이미지 파일을 생성했습니다.')
301
            QApplication.processEvents()
300 302
        except Exception as ex:
301 303
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
302 304
            from App import App
......
326 328
            scriptPath = ' --script_dir=//langdata-master'
327 329
            setUnicharsetPropertiesCmd = '\"' + set_unicharset_properties_cmd + '\" -U ' + inputUnicharset + ' -O ' + inputUnicharset + scriptPath# + ' &timeout 15'
328 330
            subprocess.call(setUnicharsetPropertiesCmd, shell = True)
329
        
331
            self.ui.labelProgress.setText('unicharset 파일을 생성했습니다.')
332
            QApplication.processEvents()
333

  
330 334
            # 4
331 335
            fontProperty = os.path.join(project.getTrainingFilePath(), 'font_properties')
332 336
            fw = open(fontProperty, 'w', encoding='utf8')
333 337
            fw.write('seed 0 0 0 0 0')
334 338
            fw.close()
339
            self.ui.labelProgress.setText('font properties 파일을 생성했습니다.')
340
            QApplication.processEvents()
335 341

  
336 342
            # 5
337 343
            trPath = trainingImgPath.replace('.tif', '.tr')
338 344
            fontProperty = self.get_short_path_name(fontProperty)
339 345
            shapeclusteringCmd = '\"' + shapeclustering_cmd + '\" -F ' + fontProperty + ' -U ' + inputUnicharset + ' ' + trPath# + ' &timeout 15'
340 346
            subprocess.call(shapeclusteringCmd, shell = True)
347
            self.ui.labelProgress.setText('cluster all the features of the trained font')
348
            QApplication.processEvents()
341 349

  
342 350
            # 6
343 351
            mftrainingCmd = '\"' + mftraining_cmd + '\" -F ' + fontProperty + ' -U ' + inputUnicharset + ' -O ' + inputUnicharset + ' ' + trPath# + ' &timeout 15'
344 352
            subprocess.call(mftrainingCmd, shell = True)
353
            self.ui.labelProgress.setText('Shapetable 파일을 생성했습니다.')
354
            QApplication.processEvents()
345 355

  
346 356
            # 7
347 357
            cntrainingCmd = '\"' + cntraining_cmd + '\" ' + trPath# + ' &timeout 15'
348 358
            subprocess.call(cntrainingCmd, shell = True)
359
            self.ui.labelProgress.setText('Normproto 파일을 생성했습니다.')
360
            QApplication.processEvents()
349 361

  
350 362
            self.deleteMidProcessFile()
351 363

  
......
363 375
            os.rename(os.path.join(dataPath, self.oCRLang + '.traineddata'), os.path.join(tesseractPath, self.oCRLang + '.traineddata'))
364 376

  
365 377
            self.deleteMidProcessFile()
366
            qmsg.close()
367 378
            QMessageBox.about(self, "알림", '성공적으로 적용하였습니다.')
368 379
            
369 380
        except Exception as ex:
370
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
371 381
            from App import App
372 382
            from AppDocData import MessageType
373 383

  
374 384
            message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
375 385
            App.mainWnd().addMessage.emit(MessageType.Error, message)
376 386
        finally:
387
            self.ui.labelProgress.setText('Normproto 파일을 생성했습니다.')
377 388
            self.deleteMidProcessFile()
378
            qmsg.close()
379 389
            os.chdir(originPath)
380 390

  
381 391
    '''
DTI_PID/DTI_PID/TrainingImageList_UI.py
1 1
# -*- coding: utf-8 -*-
2 2

  
3
# Form implementation generated from reading ui file '.\ui\TrainingImageList.ui'
3
# Form implementation generated from reading ui file '.\UI\TrainingImageList.ui'
4 4
#
5 5
# Created by: PyQt5 UI code generator 5.11.3
6 6
#
......
12 12
    def setupUi(self, TraingingImageListDialog):
13 13
        TraingingImageListDialog.setObjectName("TraingingImageListDialog")
14 14
        TraingingImageListDialog.resize(943, 535)
15
        font = QtGui.QFont()
16
        font.setFamily("맑은 고딕")
17
        font.setBold(True)
18
        font.setWeight(75)
19
        TraingingImageListDialog.setFont(font)
15 20
        self.gridLayout = QtWidgets.QGridLayout(TraingingImageListDialog)
16 21
        self.gridLayout.setObjectName("gridLayout")
17 22
        self.verticalLayout = QtWidgets.QVBoxLayout()
......
53 58
        self.horizontalLayout.addWidget(self.pushButtonMakeTrainingData)
54 59
        spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
55 60
        self.horizontalLayout.addItem(spacerItem1)
61
        self.labelProgress = QtWidgets.QLabel(TraingingImageListDialog)
62
        font = QtGui.QFont()
63
        font.setFamily("맑은 고딕")
64
        font.setBold(False)
65
        font.setWeight(50)
66
        self.labelProgress.setFont(font)
67
        self.labelProgress.setText("")
68
        self.labelProgress.setObjectName("labelProgress")
69
        self.horizontalLayout.addWidget(self.labelProgress)
70
        spacerItem2 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
71
        self.horizontalLayout.addItem(spacerItem2)
56 72
        self.pushButtonClose = QtWidgets.QPushButton(TraingingImageListDialog)
57 73
        self.pushButtonClose.setAutoDefault(False)
58 74
        self.pushButtonClose.setObjectName("pushButtonClose")
......
73 89
        self.pushButtonMakeTrainingData.setText(_translate("TraingingImageListDialog", "학습 데이터 생성"))
74 90
        self.pushButtonClose.setText(_translate("TraingingImageListDialog", "닫기"))
75 91

  
76

  
77
if __name__ == "__main__":
78
    import sys
79
    app = QtWidgets.QApplication(sys.argv)
80
    TraingingImageListDialog = QtWidgets.QDialog()
81
    ui = Ui_TraingingImageListDialog()
82
    ui.setupUi(TraingingImageListDialog)
83
    TraingingImageListDialog.show()
84
    sys.exit(app.exec_())
85

  
DTI_PID/DTI_PID/UI/TrainingImageList.ui
10 10
    <height>535</height>
11 11
   </rect>
12 12
  </property>
13
  <property name="font">
14
   <font>
15
    <family>맑은 고딕</family>
16
    <weight>75</weight>
17
    <bold>true</bold>
18
   </font>
19
  </property>
13 20
  <property name="windowTitle">
14 21
   <string>Training Image List</string>
15 22
  </property>
......
98 105
        </widget>
99 106
       </item>
100 107
       <item>
108
        <spacer name="horizontalSpacer_3">
109
         <property name="orientation">
110
          <enum>Qt::Horizontal</enum>
111
         </property>
112
         <property name="sizeHint" stdset="0">
113
          <size>
114
           <width>40</width>
115
           <height>20</height>
116
          </size>
117
         </property>
118
        </spacer>
119
       </item>
120
       <item>
121
        <widget class="QLabel" name="labelProgress">
122
         <property name="font">
123
          <font>
124
           <family>맑은 고딕</family>
125
           <weight>50</weight>
126
           <bold>false</bold>
127
          </font>
128
         </property>
129
         <property name="text">
130
          <string/>
131
         </property>
132
        </widget>
133
       </item>
134
       <item>
101 135
        <spacer name="horizontalSpacer">
102 136
         <property name="orientation">
103 137
          <enum>Qt::Horizontal</enum>

내보내기 Unified diff

클립보드 이미지 추가 (최대 크기: 500 MB)