프로젝트

일반

사용자정보

개정판 19d19912

ID19d19912715ac8894e20581a40f143f3d12ab96b
상위 6667bfb6
하위 1df9adbf

백흠경이(가) 약 6년 전에 추가함

issue #663:
- 인식된 심볼과 텍스트 표기

차이점 보기:

DTI_PID/DTI_PID/RecognitionDialog.py
63 63
    drawDetectedItems = pyqtSignal(list, list, list, QObject)
64 64
    drawDetectedLines = pyqtSignal(list, QObject)
65 65
    displayMessage = pyqtSignal(QListWidgetItem)
66
    updateProgress = pyqtSignal(int)
66
    updateProgress = pyqtSignal(int, str)
67 67
    displayLog = pyqtSignal(MessageType, str)
68 68

  
69 69
    def __init__(self):
......
666 666
            listWidget.addItem('Found Symbol   : ' + os.path.splitext(os.path.basename(symbolPath))[0] + ' - (' + str(foundSymbolCount) + ')')
667 667
            threadLock.release()
668 668
    
669
            worker.updateProgress.emit(maxProgressValue)
669
            worker.updateProgress.emit(maxProgressValue, symbolPath)
670 670
    
671 671
            return [symbol for symbol in searchedSymbolList if symbol.getName() == symbolName]
672 672
        except Exception as ex:
......
839 839
            listWidget.addItem('Found Symbol   : ' + os.path.splitext(os.path.basename(symbolPath))[0] + ' - (' + str(foundSymbolCount) + ')')
840 840
            threadLock.release()
841 841
    
842
            worker.updateProgress.emit(maxProgressValue)
842
            worker.updateProgress.emit(maxProgressValue, symbolPath)
843 843
    
844 844
            return [symbol for symbol in searchedSymbolList if symbol.getName() == symbolName]
845 845
        except Exception as ex:
......
1309 1309
        @author humkyung
1310 1310
        @date   2018.06.08
1311 1311
    '''
1312
    def updateProgress(self, maxValue):
1312
    def updateProgress(self, maxValue, image_path):
1313 1313
        self.ui.progressBar.setMaximum(maxValue)
1314 1314
        self.ui.progressBar.setValue(self.ui.progressBar.value() + 1)
1315
        
1316
        if image_path is not None and os.path.isfile(image_path):
1317
            self.ui.labelImage.setPixmap(QPixmap(image_path))
1318
        elif image_path is not None:
1319
            self.ui.labelImage.setText(image_path)
1315 1320

  
1316 1321
    '''
1317 1322
        @brief      display title
DTI_PID/DTI_PID/Recognition_UI.py
1 1
# -*- coding: utf-8 -*-
2 2

  
3
# Form implementation generated from reading ui file '.\UI\Recognition.ui'
3
# Form implementation generated from reading ui file '.\ui\Recognition.ui'
4 4
#
5 5
# Created by: PyQt5 UI code generator 5.11.3
6 6
#
......
12 12
    def setupUi(self, Recognition):
13 13
        Recognition.setObjectName("Recognition")
14 14
        Recognition.setWindowModality(QtCore.Qt.WindowModal)
15
        Recognition.resize(845, 453)
15
        Recognition.resize(878, 453)
16 16
        font = QtGui.QFont()
17 17
        font.setFamily("맑은 고딕")
18 18
        Recognition.setFont(font)
19 19
        self.gridLayout = QtWidgets.QGridLayout(Recognition)
20 20
        self.gridLayout.setObjectName("gridLayout")
21
        self.listWidget = QtWidgets.QListWidget(Recognition)
22
        self.listWidget.setObjectName("listWidget")
23
        self.gridLayout.addWidget(self.listWidget, 1, 0, 1, 1)
24 21
        self.gridLayout_2 = QtWidgets.QGridLayout()
25 22
        self.gridLayout_2.setObjectName("gridLayout_2")
26
        self.lineCheckBox = QtWidgets.QCheckBox(Recognition)
27
        self.lineCheckBox.setMaximumSize(QtCore.QSize(47, 16777215))
28
        self.lineCheckBox.setChecked(False)
29
        self.lineCheckBox.setObjectName("lineCheckBox")
30
        self.gridLayout_2.addWidget(self.lineCheckBox, 0, 2, 1, 1)
31
        self.checkBoxSymbol = QtWidgets.QCheckBox(Recognition)
32
        self.checkBoxSymbol.setMaximumSize(QtCore.QSize(103, 16777215))
33
        self.checkBoxSymbol.setChecked(True)
34
        self.checkBoxSymbol.setObjectName("checkBoxSymbol")
35
        self.gridLayout_2.addWidget(self.checkBoxSymbol, 0, 0, 1, 1)
23
        self.labelImage = QtWidgets.QLabel(Recognition)
24
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Ignored, QtWidgets.QSizePolicy.Ignored)
25
        sizePolicy.setHorizontalStretch(0)
26
        sizePolicy.setVerticalStretch(0)
27
        sizePolicy.setHeightForWidth(self.labelImage.sizePolicy().hasHeightForWidth())
28
        self.labelImage.setSizePolicy(sizePolicy)
29
        self.labelImage.setMinimumSize(QtCore.QSize(150, 150))
30
        self.labelImage.setMaximumSize(QtCore.QSize(150, 150))
31
        self.labelImage.setFrameShape(QtWidgets.QFrame.Box)
32
        self.labelImage.setText("")
33
        self.labelImage.setScaledContents(True)
34
        self.labelImage.setAlignment(QtCore.Qt.AlignCenter)
35
        self.labelImage.setObjectName("labelImage")
36
        self.gridLayout_2.addWidget(self.labelImage, 1, 5, 1, 1)
37
        spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
38
        self.gridLayout_2.addItem(spacerItem, 0, 3, 1, 1)
36 39
        self.recognizeButton = QtWidgets.QPushButton(Recognition)
40
        self.recognizeButton.setMinimumSize(QtCore.QSize(150, 0))
41
        self.recognizeButton.setMaximumSize(QtCore.QSize(150, 16777215))
37 42
        self.recognizeButton.setObjectName("recognizeButton")
38 43
        self.gridLayout_2.addWidget(self.recognizeButton, 0, 5, 1, 1, QtCore.Qt.AlignRight)
44
        self.checkBoxText = QtWidgets.QCheckBox(Recognition)
45
        self.checkBoxText.setMaximumSize(QtCore.QSize(103, 16777215))
46
        self.checkBoxText.setChecked(True)
47
        self.checkBoxText.setObjectName("checkBoxText")
48
        self.gridLayout_2.addWidget(self.checkBoxText, 0, 1, 1, 1)
39 49
        self.labelTitle = QtWidgets.QLabel(Recognition)
40 50
        palette = QtGui.QPalette()
41 51
        brush = QtGui.QBrush(QtGui.QColor(0, 0, 255))
......
56 66
        self.labelTitle.setAlignment(QtCore.Qt.AlignCenter)
57 67
        self.labelTitle.setObjectName("labelTitle")
58 68
        self.gridLayout_2.addWidget(self.labelTitle, 0, 4, 1, 1)
59
        spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
60
        self.gridLayout_2.addItem(spacerItem, 0, 3, 1, 1)
61
        self.checkBoxText = QtWidgets.QCheckBox(Recognition)
62
        self.checkBoxText.setMaximumSize(QtCore.QSize(103, 16777215))
63
        self.checkBoxText.setChecked(True)
64
        self.checkBoxText.setObjectName("checkBoxText")
65
        self.gridLayout_2.addWidget(self.checkBoxText, 0, 1, 1, 1)
66
        self.gridLayout.addLayout(self.gridLayout_2, 0, 0, 1, 1)
67
        self.horizontalLayout = QtWidgets.QHBoxLayout()
68
        self.horizontalLayout.setObjectName("horizontalLayout")
69
        self.progressBar = QtWidgets.QProgressBar(Recognition)
70
        self.progressBar.setProperty("value", 0)
71
        self.progressBar.setObjectName("progressBar")
72
        self.horizontalLayout.addWidget(self.progressBar)
69
        self.lineCheckBox = QtWidgets.QCheckBox(Recognition)
70
        self.lineCheckBox.setMaximumSize(QtCore.QSize(47, 16777215))
71
        self.lineCheckBox.setChecked(False)
72
        self.lineCheckBox.setObjectName("lineCheckBox")
73
        self.gridLayout_2.addWidget(self.lineCheckBox, 0, 2, 1, 1)
74
        self.checkBoxSymbol = QtWidgets.QCheckBox(Recognition)
75
        self.checkBoxSymbol.setMaximumSize(QtCore.QSize(103, 16777215))
76
        self.checkBoxSymbol.setChecked(True)
77
        self.checkBoxSymbol.setObjectName("checkBoxSymbol")
78
        self.gridLayout_2.addWidget(self.checkBoxSymbol, 0, 0, 1, 1)
79
        self.listWidget = QtWidgets.QListWidget(Recognition)
80
        self.listWidget.setObjectName("listWidget")
81
        self.gridLayout_2.addWidget(self.listWidget, 1, 0, 1, 5)
73 82
        self.buttonBox = QtWidgets.QDialogButtonBox(Recognition)
74 83
        self.buttonBox.setEnabled(False)
75 84
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
......
77 86
        sizePolicy.setVerticalStretch(0)
78 87
        sizePolicy.setHeightForWidth(self.buttonBox.sizePolicy().hasHeightForWidth())
79 88
        self.buttonBox.setSizePolicy(sizePolicy)
89
        self.buttonBox.setMinimumSize(QtCore.QSize(150, 0))
90
        self.buttonBox.setMaximumSize(QtCore.QSize(150, 16777215))
80 91
        self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
81 92
        self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Close)
82 93
        self.buttonBox.setObjectName("buttonBox")
83
        self.horizontalLayout.addWidget(self.buttonBox, 0, QtCore.Qt.AlignRight)
84
        self.gridLayout.addLayout(self.horizontalLayout, 4, 0, 1, 1)
94
        self.gridLayout_2.addWidget(self.buttonBox, 2, 5, 1, 1)
95
        self.progressBar = QtWidgets.QProgressBar(Recognition)
96
        self.progressBar.setProperty("value", 0)
97
        self.progressBar.setObjectName("progressBar")
98
        self.gridLayout_2.addWidget(self.progressBar, 2, 0, 1, 5)
99
        self.gridLayout.addLayout(self.gridLayout_2, 0, 1, 1, 1)
85 100

  
86 101
        self.retranslateUi(Recognition)
87 102
        self.buttonBox.clicked['QAbstractButton*'].connect(Recognition.accept)
......
90 105
    def retranslateUi(self, Recognition):
91 106
        _translate = QtCore.QCoreApplication.translate
92 107
        Recognition.setWindowTitle(_translate("Recognition", "설계정보 인식"))
93
        self.lineCheckBox.setText(_translate("Recognition", "라인"))
94
        self.checkBoxSymbol.setText(_translate("Recognition", "심볼"))
95 108
        self.recognizeButton.setText(_translate("Recognition", "정보 인식"))
96 109
        self.checkBoxText.setText(_translate("Recognition", "텍스트"))
97

  
98

  
99
if __name__ == "__main__":
100
    import sys
101
    app = QtWidgets.QApplication(sys.argv)
102
    Recognition = QtWidgets.QDialog()
103
    ui = Ui_Recognition()
104
    ui.setupUi(Recognition)
105
    Recognition.show()
106
    sys.exit(app.exec_())
110
        self.lineCheckBox.setText(_translate("Recognition", "라인"))
111
        self.checkBoxSymbol.setText(_translate("Recognition", "심볼"))
107 112

  
DTI_PID/DTI_PID/Shapes/EngineeringTextItem.py
41 41
        self.setAcceptTouchEvents(True)
42 42

  
43 43
        self.setColor(self._color)
44
        self._savedColor = self.getColor()
45
        
44
        self._savedColor = None        
45

  
46 46
        self.delimiter = '"'
47 47

  
48 48
        self.attribute = ''
......
105 105
        @date       2018.08.27
106 106
    '''
107 107
    def setHightlight(self):
108
        if self._savedColor is None:
109
            self._savedColor = self.getColor()
108 110
        self.setColor(QEngineeringTextItem.HIGHLIGHT)
111

  
109 112
        self.update()
110 113

  
111 114
    '''
DTI_PID/DTI_PID/Shapes/TrainingBoxItem.py
46 46
        self.scene.clearSelection()
47 47
        #QGraphicsRectItem.mousePressEvent(self, event)
48 48
        self.setSelected(True)
49
        if self.textShowBox is not None:
50
            self.textShowBox.setSelected(True)
49 51
        
50 52
        rect = self.rect()
51 53
        self.ui.spinBoxLeft.setValue(round(rect.x()))
......
72 74
        QGraphicsRectItem.paint(self, painter, options, widget)
73 75
        if self.isSelected():
74 76
            self.drawFocusRect(painter)
77
            self.textShowBox.setDefaultTextColor(Qt.blue)
78
        else:
79
            self.textShowBox.setDefaultTextColor(Qt.green)
75 80

  
76 81
    def addTextItemToScene(self, ui, view, leftSideView, spinBoxFlag):
77 82
        try:
......
90 95
            self.textShowBox = QGraphicsTextItem(self.char)
91 96
            self.textShowBox.setDefaultTextColor(Qt.green)
92 97
            self.textShowBox.setPos(self.rect().x() + round(self.rect().width() / 2), self.rect().y() - round(self.rect().height() / 2))
93
            
94
            self.scene.addItem(self.textShowBox)
98
            self.textShowBox.setParentItem(self)
95 99

  
100
            self.scene.addItem(self.textShowBox)
96 101
        except Exception as ex:
97 102
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
98 103

  
DTI_PID/DTI_PID/TextDetector.py
201 201
            else:
202 202
                pass
203 203

  
204
            if worker is not None: worker.updateProgress.emit(maxProgressValue)
204
            if worker is not None: worker.updateProgress.emit(maxProgressValue, resultTextInfo[0].getText())
205 205
        except Exception as ex:
206 206
            message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
207 207
            worker.displayLog.emit(MessageType.Error, message)
......
257 257
                        texts = TOCR.getTextInfo(area.img, (area.x, area.y))
258 258
                        self.otherTextInfoList.append([area.name, texts])
259 259

  
260
            if worker is not None: worker.updateProgress.emit(maxProgressValue)
260
            if worker is not None: worker.updateProgress.emit(maxProgressValue, None)
261 261
        except Exception as ex:
262 262
            message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
263 263
            worker.displayLog.emit(MessageType.Error, message)
DTI_PID/DTI_PID/TrainingEditorDialog.py
13 13
import AreaZoomCommand
14 14
import PlaceLineCommand
15 15

  
16

  
17

  
18 16
class QTrainingEditorDialog(QDialog):
19 17
    def __init__(self, parent, trainingImgPath, trainingBoxPath, boundaryOcrData, cellItem):
20 18
        self.spinBoxFlag = False
......
95 93
                singleBox = QTrainingBoxItem(str(boxComponent[0]), int(boxComponent[1]), cvImg.shape[0] - int(boxComponent[4]), int(boxComponent[3]) - int(boxComponent[1]), int(boxComponent[4]) - int(boxComponent[2]))
96 94
                singleBox.transfer.onRemoved.connect(self.itemRemoved)
97 95
                singleBox.addTextItemToScene(self.ui, self.graphicsViewTrainingDrawing, self.graphicsViewZoomDrawing, self.spinBoxFlag)
98
            
99 96
        except Exception as ex:
100 97
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
101 98

  
DTI_PID/DTI_PID/UI/Recognition.ui
9 9
   <rect>
10 10
    <x>0</x>
11 11
    <y>0</y>
12
    <width>845</width>
12
    <width>878</width>
13 13
    <height>453</height>
14 14
   </rect>
15 15
  </property>
......
22 22
   <string>설계정보 인식</string>
23 23
  </property>
24 24
  <layout class="QGridLayout" name="gridLayout">
25
   <item row="1" column="0">
26
    <widget class="QListWidget" name="listWidget"/>
27
   </item>
28
   <item row="0" column="0">
25
   <item row="0" column="1">
29 26
    <layout class="QGridLayout" name="gridLayout_2">
30
     <item row="0" column="2">
31
      <widget class="QCheckBox" name="lineCheckBox">
27
     <item row="1" column="5">
28
      <widget class="QLabel" name="labelImage">
29
       <property name="sizePolicy">
30
        <sizepolicy hsizetype="Ignored" vsizetype="Ignored">
31
         <horstretch>0</horstretch>
32
         <verstretch>0</verstretch>
33
        </sizepolicy>
34
       </property>
35
       <property name="minimumSize">
36
        <size>
37
         <width>150</width>
38
         <height>150</height>
39
        </size>
40
       </property>
32 41
       <property name="maximumSize">
33 42
        <size>
34
         <width>47</width>
35
         <height>16777215</height>
43
         <width>150</width>
44
         <height>150</height>
36 45
        </size>
37 46
       </property>
47
       <property name="frameShape">
48
        <enum>QFrame::Box</enum>
49
       </property>
38 50
       <property name="text">
39
        <string>라인</string>
51
        <string/>
40 52
       </property>
41
       <property name="checked">
42
        <bool>false</bool>
53
       <property name="scaledContents">
54
        <bool>true</bool>
55
       </property>
56
       <property name="alignment">
57
        <set>Qt::AlignCenter</set>
43 58
       </property>
44 59
      </widget>
45 60
     </item>
46
     <item row="0" column="0">
47
      <widget class="QCheckBox" name="checkBoxSymbol">
61
     <item row="0" column="3">
62
      <spacer name="horizontalSpacer">
63
       <property name="orientation">
64
        <enum>Qt::Horizontal</enum>
65
       </property>
66
       <property name="sizeHint" stdset="0">
67
        <size>
68
         <width>40</width>
69
         <height>20</height>
70
        </size>
71
       </property>
72
      </spacer>
73
     </item>
74
     <item row="0" column="5" alignment="Qt::AlignRight">
75
      <widget class="QPushButton" name="recognizeButton">
76
       <property name="minimumSize">
77
        <size>
78
         <width>150</width>
79
         <height>0</height>
80
        </size>
81
       </property>
48 82
       <property name="maximumSize">
49 83
        <size>
50
         <width>103</width>
84
         <width>150</width>
51 85
         <height>16777215</height>
52 86
        </size>
53 87
       </property>
54 88
       <property name="text">
55
        <string>심볼</string>
56
       </property>
57
       <property name="checked">
58
        <bool>true</bool>
89
        <string>정보 인식</string>
59 90
       </property>
60 91
      </widget>
61 92
     </item>
62
     <item row="0" column="5" alignment="Qt::AlignRight">
63
      <widget class="QPushButton" name="recognizeButton">
93
     <item row="0" column="1">
94
      <widget class="QCheckBox" name="checkBoxText">
95
       <property name="maximumSize">
96
        <size>
97
         <width>103</width>
98
         <height>16777215</height>
99
        </size>
100
       </property>
64 101
       <property name="text">
65
        <string>정보 인식</string>
102
        <string>텍스트</string>
103
       </property>
104
       <property name="checked">
105
        <bool>true</bool>
66 106
       </property>
67 107
      </widget>
68 108
     </item>
......
119 159
       </property>
120 160
      </widget>
121 161
     </item>
122
     <item row="0" column="3">
123
      <spacer name="horizontalSpacer">
124
       <property name="orientation">
125
        <enum>Qt::Horizontal</enum>
126
       </property>
127
       <property name="sizeHint" stdset="0">
162
     <item row="0" column="2">
163
      <widget class="QCheckBox" name="lineCheckBox">
164
       <property name="maximumSize">
128 165
        <size>
129
         <width>40</width>
130
         <height>20</height>
166
         <width>47</width>
167
         <height>16777215</height>
131 168
        </size>
132 169
       </property>
133
      </spacer>
170
       <property name="text">
171
        <string>라인</string>
172
       </property>
173
       <property name="checked">
174
        <bool>false</bool>
175
       </property>
176
      </widget>
134 177
     </item>
135
     <item row="0" column="1">
136
      <widget class="QCheckBox" name="checkBoxText">
178
     <item row="0" column="0">
179
      <widget class="QCheckBox" name="checkBoxSymbol">
137 180
       <property name="maximumSize">
138 181
        <size>
139 182
         <width>103</width>
......
141 184
        </size>
142 185
       </property>
143 186
       <property name="text">
144
        <string>텍스트</string>
187
        <string>심볼</string>
145 188
       </property>
146 189
       <property name="checked">
147 190
        <bool>true</bool>
148 191
       </property>
149 192
      </widget>
150 193
     </item>
151
    </layout>
152
   </item>
153
   <item row="4" column="0">
154
    <layout class="QHBoxLayout" name="horizontalLayout">
155
     <item>
156
      <widget class="QProgressBar" name="progressBar">
157
       <property name="value">
158
        <number>0</number>
159
       </property>
160
      </widget>
194
     <item row="1" column="0" colspan="5">
195
      <widget class="QListWidget" name="listWidget"/>
161 196
     </item>
162
     <item alignment="Qt::AlignRight">
197
     <item row="2" column="5">
163 198
      <widget class="QDialogButtonBox" name="buttonBox">
164 199
       <property name="enabled">
165 200
        <bool>false</bool>
......
170 205
         <verstretch>0</verstretch>
171 206
        </sizepolicy>
172 207
       </property>
208
       <property name="minimumSize">
209
        <size>
210
         <width>150</width>
211
         <height>0</height>
212
        </size>
213
       </property>
214
       <property name="maximumSize">
215
        <size>
216
         <width>150</width>
217
         <height>16777215</height>
218
        </size>
219
       </property>
173 220
       <property name="orientation">
174 221
        <enum>Qt::Horizontal</enum>
175 222
       </property>
......
178 225
       </property>
179 226
      </widget>
180 227
     </item>
228
     <item row="2" column="0" colspan="5">
229
      <widget class="QProgressBar" name="progressBar">
230
       <property name="value">
231
        <number>0</number>
232
       </property>
233
      </widget>
234
     </item>
181 235
    </layout>
182 236
   </item>
183 237
  </layout>

내보내기 Unified diff

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