Spaces:
Runtime error
Runtime error
update
Browse files- annotator/util.py +17 -0
annotator/util.py
CHANGED
@@ -36,3 +36,20 @@ def resize_image(input_image, resolution):
|
|
36 |
W = int(np.round(W / 64.0)) * 64
|
37 |
img = cv2.resize(input_image, (W, H), interpolation=cv2.INTER_LANCZOS4 if k > 1 else cv2.INTER_AREA)
|
38 |
return img
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
W = int(np.round(W / 64.0)) * 64
|
37 |
img = cv2.resize(input_image, (W, H), interpolation=cv2.INTER_LANCZOS4 if k > 1 else cv2.INTER_AREA)
|
38 |
return img
|
39 |
+
|
40 |
+
def resize_points(clicked_points, original_shape, resolution):
|
41 |
+
original_height, original_width, _ = original_shape
|
42 |
+
original_height = float(original_height)
|
43 |
+
original_width = float(original_width)
|
44 |
+
|
45 |
+
scale_factor = float(resolution) / min(original_height, original_width)
|
46 |
+
resized_points = []
|
47 |
+
|
48 |
+
for point in clicked_points:
|
49 |
+
x, y, lab = point
|
50 |
+
resized_x = int(round(x * scale_factor))
|
51 |
+
resized_y = int(round(y * scale_factor))
|
52 |
+
resized_point = (resized_x, resized_y, lab)
|
53 |
+
resized_points.append(resized_point)
|
54 |
+
|
55 |
+
return resized_points
|