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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -5
app.py CHANGED
@@ -265,14 +265,19 @@ def get_detection_data(image_data):
265
  # Debug: Log center and vertices to verify resolution
266
  print(f"Debug - Object {idx}: Center = {center}, Vertices = {get_box_vertices([x1, y1, x2, y2])}")
267
 
268
- # Scale from 1536x1024 to 1512x1008
269
  scale_x = 1512 / 1536 # Width scaling factor
270
  scale_y = 1008 / 1024 # Height scaling factor
271
 
272
- # Scale center and vertices to 1512x1008
273
- scaled_center = (int(center[0] * scale_x), int(center[1] * scale_y))
274
- scaled_vertices = [[int(x * scale_x), int(y * scale_y)] for x, y in get_box_vertices([x1, y1, x2, y2])]
275
-
 
 
 
 
 
276
  # Debug: Log scaled center and vertices
277
  print(f"Debug - Object {idx}: Scaled Center = {scaled_center}, Scaled Vertices = {scaled_vertices}")
278
 
 
265
  # Debug: Log center and vertices to verify resolution
266
  print(f"Debug - Object {idx}: Center = {center}, Vertices = {get_box_vertices([x1, y1, x2, y2])}")
267
 
268
+ # Scale from 1536x1024 to 1512x1008, ensuring values fit within bounds
269
  scale_x = 1512 / 1536 # Width scaling factor
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