프로젝트

일반

사용자정보

개정판 695442ff

ID695442ff8d93d7d4477a155fe128ac58812be776
상위 1f9e0182
하위 a01d4b3c

함의성이(가) 4년 이상 전에 추가함

issue #663: add equipment package symbol detection option

Change-Id: I401bf0231ceef57d51275583b00414f8fb9d8e64

차이점 보기:

DTI_PID/DTI_PID/ConfigurationDialog.py
197 197
            self.ui.radioButtonBackTextYes.setChecked(True)
198 198
            self.ui.radioButtonBackTextNo.setChecked(False)
199 199

  
200
        configs = docData.getConfigs('Symbol', 'Detect Inside Package')
201
        if configs:
202
            size = int(configs[0].value)
203
            self.ui.radioButtonDetectPackageYes.setChecked(True if size == 1 else False)
204
            self.ui.radioButtonDetectPackageNo.setChecked(True if size == -1 else False)
205
        else:
206
            self.ui.radioButtonDetectPackageYes.setChecked(True)
207
            self.ui.radioButtonDetectPackageNo.setChecked(False)
208

  
200 209
        configs = docData.getConfigs('Default', 'Flange')
201 210
        self.ui.lineEditFlange.setText(configs[0].value) if 1 == len(configs) else \
202 211
        self.ui.lineEditFlange.setText('flange')
......
991 1000
            configs.append(Config('Line', 'Diagonal', '1' if self.ui.radioButtonDiagonalYes.isChecked() else '-1'))
992 1001
            configs.append(Config('Line', 'Gap', '1' if self.ui.radioButtonGapYes.isChecked() else '-1'))
993 1002
            configs.append(Config('Text', 'Background', '1' if self.ui.radioButtonBackTextYes.isChecked() else '-1'))
1003
            configs.append(Config('Symbol', 'Detect Inside Package', '1' if self.ui.radioButtonDetectPackageYes.isChecked() else '-1'))
994 1004
            configs.append(Config('Note No Tag Rule', 'Note No Expression', self.ui.lineEditNoteNoExpression.text()))
995 1005
            configs.append(Config('Note No Tag Rule', 'Note No Symbol Name', self.ui.lineEditNoteNoSymbolName.text()))
996 1006
            configs.append(Config('OPC Tag Rule', 'From Prefix', self.ui.lineEditOPCFromPrefix.text()))
DTI_PID/DTI_PID/Configuration_UI.py
21 21
        ConfigurationDialog.setModal(True)
22 22
        self.gridLayout = QtWidgets.QGridLayout(ConfigurationDialog)
23 23
        self.gridLayout.setObjectName("gridLayout")
24
        self.buttonBox = QtWidgets.QDialogButtonBox(ConfigurationDialog)
25
        self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
26
        self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok)
27
        self.buttonBox.setObjectName("buttonBox")
28
        self.gridLayout.addWidget(self.buttonBox, 4, 0, 1, 1)
24 29
        self.tabWidget = QtWidgets.QTabWidget(ConfigurationDialog)
25 30
        self.tabWidget.setObjectName("tabWidget")
26 31
        self.Recognition = QtWidgets.QWidget()
......
402 407
        self.gridLayout_40.setObjectName("gridLayout_40")
403 408
        self.gridLayout_39 = QtWidgets.QGridLayout()
404 409
        self.gridLayout_39.setObjectName("gridLayout_39")
405
        self.label_52 = QtWidgets.QLabel(self.groupBoxSymbol)
406
        self.label_52.setObjectName("label_52")
407
        self.gridLayout_39.addWidget(self.label_52, 0, 0, 1, 1)
410
        self.horizontalLayout_10 = QtWidgets.QHBoxLayout()
411
        self.horizontalLayout_10.setObjectName("horizontalLayout_10")
412
        self.radioButtonDetectPackageYes = QtWidgets.QRadioButton(self.groupBoxSymbol)
413
        self.radioButtonDetectPackageYes.setObjectName("radioButtonDetectPackageYes")
414
        self.buttonGroup_8 = QtWidgets.QButtonGroup(ConfigurationDialog)
415
        self.buttonGroup_8.setObjectName("buttonGroup_8")
416
        self.buttonGroup_8.addButton(self.radioButtonDetectPackageYes)
417
        self.horizontalLayout_10.addWidget(self.radioButtonDetectPackageYes)
418
        self.radioButtonDetectPackageNo = QtWidgets.QRadioButton(self.groupBoxSymbol)
419
        self.radioButtonDetectPackageNo.setObjectName("radioButtonDetectPackageNo")
420
        self.buttonGroup_8.addButton(self.radioButtonDetectPackageNo)
421
        self.horizontalLayout_10.addWidget(self.radioButtonDetectPackageNo)
422
        self.gridLayout_39.addLayout(self.horizontalLayout_10, 1, 1, 1, 1)
423
        self.label_53 = QtWidgets.QLabel(self.groupBoxSymbol)
424
        self.label_53.setObjectName("label_53")
425
        self.gridLayout_39.addWidget(self.label_53, 1, 0, 1, 1)
408 426
        self.lineEditFlange = QtWidgets.QLineEdit(self.groupBoxSymbol)
409 427
        self.lineEditFlange.setObjectName("lineEditFlange")
410
        self.gridLayout_39.addWidget(self.lineEditFlange, 0, 1, 1, 1)
428
        self.gridLayout_39.addWidget(self.lineEditFlange, 2, 1, 1, 1)
429
        spacerItem3 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
430
        self.gridLayout_39.addItem(spacerItem3, 2, 2, 1, 1)
431
        self.label_52 = QtWidgets.QLabel(self.groupBoxSymbol)
432
        self.label_52.setObjectName("label_52")
433
        self.gridLayout_39.addWidget(self.label_52, 2, 0, 1, 1)
411 434
        self.gridLayout_40.addLayout(self.gridLayout_39, 0, 0, 1, 1)
412 435
        self.gridLayout_21.addWidget(self.groupBoxSymbol, 1, 1, 1, 1)
413 436
        self.tabWidget.addTab(self.Recognition2, "")
......
511 534
        self.formLayout_5.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.lineEditOPCToPrefix)
512 535
        self.gridLayout_20.addLayout(self.formLayout_5, 0, 0, 1, 1)
513 536
        self.gridLayout_7.addWidget(self.groupBox_10, 1, 0, 1, 1)
514
        spacerItem3 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
515
        self.gridLayout_7.addItem(spacerItem3, 5, 0, 1, 1)
537
        spacerItem4 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
538
        self.gridLayout_7.addItem(spacerItem4, 5, 0, 1, 1)
516 539
        self.tabWidget.addTab(self.tabTagNoRule, "")
517 540
        self.tabDisplayOption = QtWidgets.QWidget()
518 541
        self.tabDisplayOption.setObjectName("tabDisplayOption")
......
588 611
        self.fontComboBox = QtWidgets.QFontComboBox(self.groupBox_5)
589 612
        self.fontComboBox.setObjectName("fontComboBox")
590 613
        self.gridLayout_29.addWidget(self.fontComboBox, 0, 1, 1, 2)
591
        spacerItem4 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
592
        self.gridLayout_29.addItem(spacerItem4, 0, 3, 1, 1)
614
        spacerItem5 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
615
        self.gridLayout_29.addItem(spacerItem5, 0, 3, 1, 1)
593 616
        self.gridLayout_15.addLayout(self.gridLayout_29, 0, 0, 1, 1)
594 617
        self.verticalLayout.addWidget(self.groupBox_5)
595 618
        self.gridLayout_4.addLayout(self.verticalLayout, 0, 0, 1, 1)
......
642 665
        self.gridLayout_24.setObjectName("gridLayout_24")
643 666
        self.gridLayout_32 = QtWidgets.QGridLayout()
644 667
        self.gridLayout_32.setObjectName("gridLayout_32")
645
        spacerItem5 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
646
        self.gridLayout_32.addItem(spacerItem5, 0, 2, 1, 1)
668
        spacerItem6 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
669
        self.gridLayout_32.addItem(spacerItem6, 0, 2, 1, 1)
647 670
        self.label_36 = QtWidgets.QLabel(self.groupBox_12)
648 671
        self.label_36.setMinimumSize(QtCore.QSize(200, 0))
649 672
        self.label_36.setObjectName("label_36")
......
691 714
        self.label_34 = QtWidgets.QLabel(self.groupBox_11)
692 715
        self.label_34.setObjectName("label_34")
693 716
        self.gridLayout_31.addWidget(self.label_34, 2, 0, 1, 1)
694
        spacerItem6 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
695
        self.gridLayout_31.addItem(spacerItem6, 1, 2, 1, 1)
717
        spacerItem7 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
718
        self.gridLayout_31.addItem(spacerItem7, 1, 2, 1, 1)
696 719
        self.label_30 = QtWidgets.QLabel(self.groupBox_11)
697 720
        self.label_30.setObjectName("label_30")
698 721
        self.gridLayout_31.addWidget(self.label_30, 1, 0, 1, 1)
......
760 783
        self.label_46.setMinimumSize(QtCore.QSize(200, 0))
761 784
        self.label_46.setObjectName("label_46")
762 785
        self.gridLayout_37.addWidget(self.label_46, 1, 0, 1, 1)
763
        spacerItem7 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
764
        self.gridLayout_37.addItem(spacerItem7, 1, 2, 1, 1)
786
        spacerItem8 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
787
        self.gridLayout_37.addItem(spacerItem8, 1, 2, 1, 1)
765 788
        self.label_48 = QtWidgets.QLabel(self.groupBox_13)
766 789
        self.label_48.setObjectName("label_48")
767 790
        self.gridLayout_37.addWidget(self.label_48, 0, 0, 1, 1)
......
793 816
        self.gridLayout_38.addLayout(self.gridLayout_37, 0, 0, 1, 1)
794 817
        self.gridLayout_21.addWidget(self.groupBox_13, 2, 0, 1, 1)
795 818
        self.gridLayout_22.addLayout(self.gridLayout_21, 0, 0, 1, 1)
796
        spacerItem8 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
797
        self.gridLayout_22.addItem(spacerItem8, 3, 0, 1, 1)
819
        spacerItem9 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
820
        self.gridLayout_22.addItem(spacerItem9, 3, 0, 1, 1)
798 821
        self.tabWidget.addTab(self.tabETC, "")
799 822
        self.gridLayout.addWidget(self.tabWidget, 0, 0, 1, 1)
800
        self.buttonBox = QtWidgets.QDialogButtonBox(ConfigurationDialog)
801
        self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
802
        self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok)
803
        self.buttonBox.setObjectName("buttonBox")
804
        self.gridLayout.addWidget(self.buttonBox, 4, 0, 1, 1)
805 823

  
806 824
        self.retranslateUi(ConfigurationDialog)
807 825
        self.tabWidget.setCurrentIndex(0)
......
937 955
        self.label_9.setText(_translate("ConfigurationDialog", "Length to Connect Line : "))
938 956
        self.radioButtonGapNo.setText(_translate("ConfigurationDialog", "No"))
939 957
        self.groupBoxSymbol.setTitle(_translate("ConfigurationDialog", "Symbol"))
958
        self.radioButtonDetectPackageYes.setText(_translate("ConfigurationDialog", "Yes"))
959
        self.radioButtonDetectPackageNo.setText(_translate("ConfigurationDialog", "No"))
960
        self.label_53.setText(_translate("ConfigurationDialog", "Detect Inside Equipment Package : "))
940 961
        self.label_52.setText(_translate("ConfigurationDialog", "Defualt Flange : "))
941 962
        self.tabWidget.setTabText(self.tabWidget.indexOf(self.Recognition2), _translate("ConfigurationDialog", "Recognition"))
942 963
        self.groupBox_4.setTitle(_translate("ConfigurationDialog", "Note No Tag Rule"))
DTI_PID/DTI_PID/MainWindow.py
150 150
        self.toolBar.insertSeparator(self.actionOCR)
151 151

  
152 152
        self.packageComboBox = QComboBox(self.toolBar)
153
        self.packageComboBox.addItems(['Vendor Package', 'Equipment Package'])
153
        self.packageComboBox.addItems(['Equipment Package', 'Vendor Package'])
154 154
        self.toolBar.insertWidget(self.actionValidate, self.packageComboBox)
155 155

  
156 156
        self._scene = QtImageViewerScene(self)
DTI_PID/DTI_PID/RecognitionDialog.py
26 26
from EngineeringLineNoTextItem import QEngineeringLineNoTextItem
27 27
from GraphicsBoundingBoxItem import QGraphicsBoundingBoxItem
28 28
from QEngineeringOPCItem import QEngineeringOPCItem
29
from EngineeringVendorItem import QEngineeringVendorItem
29 30
from LineDetector import LineDetector
30 31
from symbol import Symbol
31 32
from Drawing import Drawing
......
864 865
                    area.not_img = cv2.bitwise_not(area.img)
865 866
                    area.contours, area.hierachy = cv2.findContours(area.not_img, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
866 867

  
868
                # remove Equipment Package area
869
                configs = app_doc_data.getConfigs('Symbol', 'Detect Inside Package')
870
                if (configs and int(configs[0].value) == -1):
871
                    Worker.remove_equipment_package(worker.scene, area)
872

  
867 873
                maxProgressValue = 0
868 874
                start_time = timeit.default_timer()
869 875
                listWidget.addItem(f"Start recognition {datetime.now().strftime('%Y-%m-%d %H:%M:%S')} : {mainRes}")
......
929 935
                    #cv2.imwrite('c:\\temp\\before-imgSrc.png', area.img)
930 936
                    ## save original image before remove symbol
931 937
                    #worker.copy_imgSrc = app_doc_data.imgSrc.copy()
938

  
939
                    # roll back because equipment package was deleted from image
940
                    app_doc_data.imgSrc = app_doc_data.activeDrawing.image_origin
941

  
932 942
                    searchedTextSymList = []
933 943
                    for sym in searchedSymbolList:
934 944
                        Worker.remove_detected_symbol_image(sym, app_doc_data.imgSrc)
......
1361 1371
        from EngineeringTextItem import QEngineeringTextItem
1362 1372
        from EngineeringLineItem import QEngineeringLineItem
1363 1373
        from LineDetector import LineDetector
1364
        from EngineeringVendorItem import QEngineeringVendorItem
1365 1374

  
1366 1375
        try:
1367 1376
            listWidget.addItem('Starting line recognition')
......
1378 1387
                area.img = app_doc_data.imgSrc[round(area.y + 1):round(area.y + area.height),
1379 1388
                            round(area.x + 1):round(area.x + area.width)]
1380 1389

  
1381
                for item in worker.scene.items():
1382
                    if issubclass(type(item), QEngineeringVendorItem) and item.pack_type =='Equipment Package':
1383
                        points = []
1384
                        for conn in item.connectors:
1385
                            points.append([conn.center()[0] - area.x, conn.center()[1] - area.y])
1386
                        
1387
                        points = np.array(points, np.int32)
1388
                        cv2.fillConvexPoly(area.img, points, 255)
1390
            Worker.remove_equipment_package(worker.scene, area)
1389 1391

  
1390 1392
            area.img = worker.remove_small_objects(area.img)
1391 1393
            detector = LineDetector(area.img)
......
2704 2706
            canvas[symbolSp[1]:symbolSp[1] + h, symbolSp[0]:symbolSp[0] + w], symImg)
2705 2707

  
2706 2708
    @staticmethod
2709
    def remove_equipment_package(scene, area):
2710
        """ remove equipment package area from drawing image """
2711
        for item in scene.items():
2712
            if issubclass(type(item), QEngineeringVendorItem) and item.pack_type =='Equipment Package':
2713
                points = []
2714
                for conn in item.connectors:
2715
                    points.append([conn.center()[0] - area.x, conn.center()[1] - area.y])
2716
                
2717
                points = np.array(points, np.int32)
2718
                cv2.fillConvexPoly(area.img, points, 255)
2719

  
2720
    @staticmethod
2707 2721
    def remove_detected_symbol_image(sym, imgSrc, lock=True):
2708 2722
        """remove detected symbol image from drawing image"""
2709 2723
        if lock:
......
3204 3218

  
3205 3219
    def add_detected_items_to_scene(self, scene, flanges) -> None:
3206 3220
        """add detected items to scene"""
3207
        from EngineeringVendorItem import QEngineeringVendorItem
3208 3221
        from App import App
3209 3222

  
3210 3223
        app_doc_data = AppDocData.instance()
DTI_PID/DTI_PID/UI/Configuration.ui
26 26
   <bool>true</bool>
27 27
  </property>
28 28
  <layout class="QGridLayout" name="gridLayout">
29
   <item row="4" column="0">
30
    <widget class="QDialogButtonBox" name="buttonBox">
31
     <property name="orientation">
32
      <enum>Qt::Horizontal</enum>
33
     </property>
34
     <property name="standardButtons">
35
      <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
36
     </property>
37
    </widget>
38
   </item>
29 39
   <item row="0" column="0">
30 40
    <widget class="QTabWidget" name="tabWidget">
31 41
     <property name="currentIndex">
......
878 888
         <layout class="QGridLayout" name="gridLayout_40">
879 889
          <item row="0" column="0">
880 890
           <layout class="QGridLayout" name="gridLayout_39">
881
            <item row="0" column="0">
882
             <widget class="QLabel" name="label_52">
891
            <item row="1" column="1">
892
             <layout class="QHBoxLayout" name="horizontalLayout_10">
893
              <item>
894
               <widget class="QRadioButton" name="radioButtonDetectPackageYes">
895
                <property name="text">
896
                 <string>Yes</string>
897
                </property>
898
                <attribute name="buttonGroup">
899
                 <string notr="true">buttonGroup_8</string>
900
                </attribute>
901
               </widget>
902
              </item>
903
              <item>
904
               <widget class="QRadioButton" name="radioButtonDetectPackageNo">
905
                <property name="text">
906
                 <string>No</string>
907
                </property>
908
                <attribute name="buttonGroup">
909
                 <string notr="true">buttonGroup_8</string>
910
                </attribute>
911
               </widget>
912
              </item>
913
             </layout>
914
            </item>
915
            <item row="1" column="0">
916
             <widget class="QLabel" name="label_53">
883 917
              <property name="text">
884
               <string>Defualt Flange : </string>
918
               <string>Detect Inside Equipment Package : </string>
885 919
              </property>
886 920
             </widget>
887 921
            </item>
888
            <item row="0" column="1">
922
            <item row="2" column="1">
889 923
             <widget class="QLineEdit" name="lineEditFlange"/>
890 924
            </item>
925
            <item row="2" column="2">
926
             <spacer name="horizontalSpacer_7">
927
              <property name="orientation">
928
               <enum>Qt::Horizontal</enum>
929
              </property>
930
              <property name="sizeHint" stdset="0">
931
               <size>
932
                <width>40</width>
933
                <height>20</height>
934
               </size>
935
              </property>
936
             </spacer>
937
            </item>
938
            <item row="2" column="0">
939
             <widget class="QLabel" name="label_52">
940
              <property name="text">
941
               <string>Defualt Flange : </string>
942
              </property>
943
             </widget>
944
            </item>
891 945
           </layout>
892 946
          </item>
893 947
         </layout>
......
1703 1757
     </widget>
1704 1758
    </widget>
1705 1759
   </item>
1706
   <item row="4" column="0">
1707
    <widget class="QDialogButtonBox" name="buttonBox">
1708
     <property name="orientation">
1709
      <enum>Qt::Horizontal</enum>
1710
     </property>
1711
     <property name="standardButtons">
1712
      <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
1713
     </property>
1714
    </widget>
1715
   </item>
1716 1760
  </layout>
1717 1761
 </widget>
1718 1762
 <tabstops>
......
1824 1868
  </connection>
1825 1869
 </connections>
1826 1870
 <buttongroups>
1871
  <buttongroup name="buttonGroup"/>
1872
  <buttongroup name="buttonGroup_2"/>
1873
  <buttongroup name="buttonGroup_7"/>
1827 1874
  <buttongroup name="buttonGroup_6"/>
1828 1875
  <buttongroup name="buttonGroup_4"/>
1829
  <buttongroup name="buttonGroup_5"/>
1830 1876
  <buttongroup name="buttonGroup_3"/>
1831
  <buttongroup name="buttonGroup_7"/>
1832
  <buttongroup name="buttonGroup_2"/>
1833
  <buttongroup name="buttonGroup"/>
1877
  <buttongroup name="buttonGroup_5"/>
1878
  <buttongroup name="buttonGroup_8"/>
1834 1879
 </buttongroups>
1835 1880
</ui>

내보내기 Unified diff

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