feat: correct definition of body boxes
Browse files
app/assets/fonts/LiberationSans-Regular.ttf
ADDED
Binary file (134 kB). View file
|
|
app/assets/images/bird_boxed.png
CHANGED
![]() |
![]() |
app/boxes_define.py
CHANGED
@@ -3,21 +3,21 @@ from shapely.geometry import box
|
|
3 |
|
4 |
bounding_boxes = [
|
5 |
# 'Head incl. eyes',
|
6 |
-
box(250, 375, 350,
|
7 |
# 'Beak and mouth region',
|
8 |
-
box(200, 450, 250,
|
9 |
-
# 'Feathers/Wings',
|
10 |
-
box(
|
11 |
# 'Legs',
|
12 |
-
box(325,
|
13 |
# 'Body'
|
14 |
-
box(
|
15 |
]
|
16 |
|
17 |
# Create a GeoDataFrame from these boxes
|
18 |
gdf = gpd.GeoDataFrame({'geometry': bounding_boxes,
|
19 |
'name': ['Head incl. eyes',
|
20 |
-
'Beak
|
21 |
-
'Feathers/Wings',
|
22 |
'Legs',
|
23 |
'Body']})
|
|
|
3 |
|
4 |
bounding_boxes = [
|
5 |
# 'Head incl. eyes',
|
6 |
+
box(250, 375, 350, 485),
|
7 |
# 'Beak and mouth region',
|
8 |
+
box(200, 450, 250, 485),
|
9 |
+
# 'Feathers/Wings/Tail',
|
10 |
+
box(50, 100, 725, 355),
|
11 |
# 'Legs',
|
12 |
+
box(325, 585, 450, 675),
|
13 |
# 'Body'
|
14 |
+
box(275, 510, 500, 565)
|
15 |
]
|
16 |
|
17 |
# Create a GeoDataFrame from these boxes
|
18 |
gdf = gpd.GeoDataFrame({'geometry': bounding_boxes,
|
19 |
'name': ['Head incl. eyes',
|
20 |
+
'Beak',
|
21 |
+
'Feathers/Wings/Tail',
|
22 |
'Legs',
|
23 |
'Body']})
|
app/boxes_map.py
CHANGED
@@ -9,16 +9,18 @@ def draw_bounding_boxes(image_path, gdf):
|
|
9 |
draw = ImageDraw.Draw(image)
|
10 |
|
11 |
# Optional: Load a font (requires a TTF file)
|
12 |
-
try:
|
13 |
-
|
14 |
-
|
15 |
-
|
|
|
|
|
16 |
|
17 |
# Draw each bounding box on the image
|
18 |
for _, row in gdf.iterrows():
|
19 |
xmin, ymin, xmax, ymax = row['geometry'].bounds
|
20 |
-
draw.rectangle([xmin, ymin, xmax, ymax], outline="
|
21 |
-
draw.text((xmin, ymin-
|
22 |
|
23 |
image.save(image_path+'bird_boxed.png', "PNG")
|
24 |
|
|
|
9 |
draw = ImageDraw.Draw(image)
|
10 |
|
11 |
# Optional: Load a font (requires a TTF file)
|
12 |
+
# try:
|
13 |
+
font = ImageFont.truetype("assets/fonts/LiberationSans-Regular.ttf",
|
14 |
+
20)
|
15 |
+
# except IOError:
|
16 |
+
# print("default")
|
17 |
+
# font = ImageFont.load_default()
|
18 |
|
19 |
# Draw each bounding box on the image
|
20 |
for _, row in gdf.iterrows():
|
21 |
xmin, ymin, xmax, ymax = row['geometry'].bounds
|
22 |
+
draw.rectangle([xmin, ymin, xmax, ymax], outline="purple", width=2)
|
23 |
+
draw.text((xmin, ymin-22), row['name'], fill="black", font=font)
|
24 |
|
25 |
image.save(image_path+'bird_boxed.png', "PNG")
|
26 |
|