Parcourir la source

Capability to specify epsilon value by --epsilon 5.0 (11.0 default)

Kentaro Wada il y a 6 ans
Parent
commit
7e06a82bdd
3 fichiers modifiés avec 12 ajouts et 3 suppressions
  1. 9 1
      labelme/app.py
  2. 1 2
      labelme/canvas.py
  3. 2 0
      labelme/config/default_config.yaml

+ 9 - 1
labelme/app.py

@@ -202,7 +202,9 @@ class MainWindow(QtWidgets.QMainWindow, WindowMixin):
         self.zoomWidget = ZoomWidget()
         self.colorDialog = ColorDialog(parent=self)
 
-        self.canvas = self.labelList.canvas = Canvas()
+        self.canvas = self.labelList.canvas = Canvas(
+            epsilon=self._config['epsilon'],
+        )
         self.canvas.zoomRequest.connect(self.zoomRequest)
 
         scrollArea = QtWidgets.QScrollArea()
@@ -1341,6 +1343,12 @@ def main():
         help='keep annotation of previous frame',
         default=argparse.SUPPRESS,
     )
+    parser.add_argument(
+        '--epsilon',
+        type=float,
+        help='epsilon to find nearest vertex on canvas',
+        default=argparse.SUPPRESS,
+    )
     args = parser.parse_args()
 
     if args.version:

+ 1 - 2
labelme/canvas.py

@@ -33,9 +33,8 @@ class Canvas(QtWidgets.QWidget):
     # polygon, rectangle
     createMode = 'polygon'
 
-    epsilon = 11.0
-
     def __init__(self, *args, **kwargs):
+        self.epsilon = kwargs.pop('epsilon', 11.0)
         super(Canvas, self).__init__(*args, **kwargs)
         # Initialise local state.
         self.mode = self.EDIT

+ 2 - 0
labelme/config/default_config.yaml

@@ -8,6 +8,8 @@ sort_labels: true
 validate_label: null
 show_label_text_field: true
 
+epsilon: 11.0
+
 shortcuts:
   close: Ctrl+W
   open: Ctrl+O