Shohei Fujii пре 6 година
родитељ
комит
62bfea5428
3 измењених фајлова са 7 додато и 2 уклоњено
  1. 2 1
      labelme/shape.py
  2. 3 0
      labelme/utils/shape.py
  3. 2 1
      labelme/widgets/canvas.py

+ 2 - 1
labelme/shape.py

@@ -68,7 +68,8 @@ class Shape(object):
     def shape_type(self, value):
         if value is None:
             value = 'polygon'
-        if value not in ['polygon', 'rectangle', 'point', 'line', 'circle', 'linestrip']:
+        if value not in ['polygon', 'rectangle', 'point',
+           'line', 'circle', 'linestrip']:
             raise ValueError('Unexpected shape_type: {}'.format(value))
         self._shape_type = value
 

+ 3 - 0
labelme/utils/shape.py

@@ -26,6 +26,9 @@ def shape_to_mask(img_shape, points, shape_type=None):
     elif shape_type == 'rectangle' and len(points) == 2:
         xy = [tuple(point) for point in points]
         draw.rectangle(xy, outline=1, fill=1)
+    elif shape_type == 'linestrip':
+        xy = [tuple(point) for point in points]
+        draw.line(xy=xy, fill=0, width=3)
     else:
         xy = [tuple(point) for point in points]
         draw.polygon(xy=xy, outline=1, fill=1)

+ 2 - 1
labelme/widgets/canvas.py

@@ -84,7 +84,8 @@ class Canvas(QtWidgets.QWidget):
 
     @createMode.setter
     def createMode(self, value):
-        if value not in ['polygon', 'rectangle', 'circle', 'line', 'point', 'linestrip']:
+        if value not in ['polygon', 'rectangle', 'circle',
+           'line', 'point', 'linestrip']:
             raise ValueError('Unsupported createMode: %s' % value)
         self._createMode = value