Alessio Grancini commited on
Commit
d12591c
·
verified ·
1 Parent(s): 6ecf97d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -270,17 +270,18 @@ def get_detection_data(image_data):
270
  scale_y = 1008 / 1024 # Height scaling factor
271
 
272
  # Scale and clamp center and vertices to 1512x1008
 
 
273
  scaled_center = (
274
- int(min(max(center[0] * scale_x, 0), 1511)), # Clamp to [0, 1511]
275
- int(min(max(center[1] * scale_y, 0), 1007)) # Clamp to [0, 1007]
276
  )
277
  scaled_vertices = [
278
  [int(min(max(x * scale_x, 0), 1511)), int(min(max(y * scale_y, 0), 1007))]
279
  for x, y in get_box_vertices([x1, y1, x2, y2])
280
  ]
281
- # Debug: Log scaled center and vertices
282
- print(f"Debug - Object {idx}: Scaled Center = {scaled_center}, Scaled Vertices = {scaled_vertices}")
283
-
284
  # Convert BGR to RGB
285
  color_rgb = (int(color_bgr[2]), int(color_bgr[1]), int(color_bgr[0]))
286
 
 
270
  scale_y = 1008 / 1024 # Height scaling factor
271
 
272
  # Scale and clamp center and vertices to 1512x1008
273
+ scaled_x = center[0] * scale_x
274
+ scaled_y = center[1] * scale_y
275
  scaled_center = (
276
+ int(min(max(scaled_x, 0), 1511)), # Clamp to [0, 1511]
277
+ int(min(max(scaled_y, 0), 1007)) # Clamp to [0, 1007]
278
  )
279
  scaled_vertices = [
280
  [int(min(max(x * scale_x, 0), 1511)), int(min(max(y * scale_y, 0), 1007))]
281
  for x, y in get_box_vertices([x1, y1, x2, y2])
282
  ]
283
+ # Debug: Log scaled (before and after clamping) and clamped center and vertices
284
+ print(f"Debug - Object {idx}: Pre-Clamp Scaled Center = ({scaled_x}, {scaled_y}), Clamped Center = {scaled_center}, Clamped Vertices = {scaled_vertices}")
 
285
  # Convert BGR to RGB
286
  color_rgb = (int(color_bgr[2]), int(color_bgr[1]), int(color_bgr[0]))
287