Skip to content

Commit

Permalink
use computed area instead 1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
spytensor authored Nov 2, 2019
1 parent 2e59ffd commit eff2543
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion csv2coco.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def _annotation(self, shape,label):
annotation['segmentation'] = self._get_seg(points)
annotation['bbox'] = self._get_box(points)
annotation['iscrowd'] = 0
annotation['area'] = 1.0
annotation['area'] = self._get_area(points)
return annotation

# COCO的格式: [x1,y1,w,h] 对应COCO的bbox格式
Expand All @@ -96,6 +96,13 @@ def _get_box(self, points):
max_x = points[2]
max_y = points[3]
return [min_x, min_y, max_x - min_x, max_y - min_y]
# 计算面积
def _get_area(self, points):
min_x = points[0]
min_y = points[1]
max_x = points[2]
max_y = points[3]
return (max_x - min_x+1) * (max_y - min_y+1)
# segmentation
def _get_seg(self, points):
min_x = points[0]
Expand Down

0 comments on commit eff2543

Please sign in to comment.