Skip to content

Commit

Permalink
revert wrong formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Johannes-Thiel committed Dec 16, 2024
1 parent ae98c42 commit ff2a8c3
Showing 1 changed file with 10 additions and 20 deletions.
30 changes: 10 additions & 20 deletions field_friend/interface/components/monitoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,25 +187,17 @@ def to_svg(self, detections: rosys.vision.Detections) -> str:
cross_size = 20
for point in detections.points:
if point.category_name == 'person' and point.confidence > 0.3:
svg += f'<circle cx="{point.x / self.shrink_factor}" cy="{point.y /
self.shrink_factor}" r="8" fill="red" />'
svg += f'<text x="{point.x / self.shrink_factor-30}" y="{point.y /
self.shrink_factor+30}" font-size="20" fill="red">Person</text>'
svg += f'<circle cx="{point.x / self.shrink_factor}" cy="{point.y / self.shrink_factor}" r="8" fill="red" />'
svg += f'<text x="{point.x / self.shrink_factor-30}" y="{point.y / self.shrink_factor+30}" font-size="20" fill="red">Person</text>'
elif 'bird' in point.category_name and point.confidence > 0.3:
svg += f'<circle cx="{point.x / self.shrink_factor}" cy="{point.y /
self.shrink_factor}" r="8" fill="orange" />'
svg += f'<text x="{point.x / self.shrink_factor-30}" y="{point.y /
self.shrink_factor+30}" font-size="20" fill="blue">Bird</text>'
svg += f'<circle cx="{point.x / self.shrink_factor}" cy="{point.y / self.shrink_factor}" r="8" fill="orange" />'
svg += f'<text x="{point.x / self.shrink_factor-30}" y="{point.y / self.shrink_factor+30}" font-size="20" fill="blue">Bird</text>'
elif 'animal' in point.category_name and point.confidence > 0.3:
svg += f'<circle cx="{point.x / self.shrink_factor}" cy="{point.y /
self.shrink_factor}" r="8" fill="orange" />'
svg += f'<text x="{point.x / self.shrink_factor-30}" y="{point.y /
self.shrink_factor+30}" font-size="20" fill="green">Animal</text>'
svg += f'<circle cx="{point.x / self.shrink_factor}" cy="{point.y / self.shrink_factor}" r="8" fill="orange" />'
svg += f'<text x="{point.x / self.shrink_factor-30}" y="{point.y / self.shrink_factor+30}" font-size="20" fill="green">Animal</text>'
elif point.category_name in self.plant_locator.crop_category_names and point.confidence > self.plant_locator.minimum_crop_confidence:
svg += f'<circle cx="{point.x / self.shrink_factor}" cy="{point.y /
self.shrink_factor}" r="18" stroke-width="8" stroke="green" fill="none" />'
svg += f'<text x="{point.x / self.shrink_factor-30}" y="{point.y /
self.shrink_factor+30}" font-size="20" fill="green">Crop</text>'
svg += f'<circle cx="{point.x / self.shrink_factor}" cy="{point.y / self.shrink_factor}" r="18" stroke-width="8" stroke="green" fill="none" />'
svg += f'<text x="{point.x / self.shrink_factor-30}" y="{point.y / self.shrink_factor+30}" font-size="20" fill="green">Crop</text>'
elif point.category_name in self.plant_locator.weed_category_names and point.confidence > self.plant_locator.minimum_weed_confidence:
svg += f'''
<line x1="{point.x / self.shrink_factor - cross_size}" y1="{point.y / self.shrink_factor}" x2="{point.x / self.shrink_factor + cross_size}" y2="{point.y / self.shrink_factor}" stroke="red" stroke-width="8"
Expand All @@ -215,10 +207,8 @@ def to_svg(self, detections: rosys.vision.Detections) -> str:
<text x="{point.x / self.shrink_factor-30}" y="{point.y / self.shrink_factor+30}" font-size="20" fill="red">Weed</text>
'''
else:
svg += f'<circle cx="{point.x / self.shrink_factor}" cy="{point.y /
self.shrink_factor}" r="8" fill="yellow" />'
svg += f'<text x="{point.x / self.shrink_factor-30}" y="{point.y /
self.shrink_factor+30}" font-size="20" fill="yellow">{point.category_name}</text>'
svg += f'<circle cx="{point.x / self.shrink_factor}" cy="{point.y / self.shrink_factor}" r="8" fill="yellow" />'
svg += f'<text x="{point.x / self.shrink_factor-30}" y="{point.y / self.shrink_factor+30}" font-size="20" fill="yellow">{point.category_name}</text>'
return svg

def handle_key(self, e: events.KeyEventArguments) -> None:
Expand Down

0 comments on commit ff2a8c3

Please sign in to comment.