3morrrrr commited on
Commit
20c77f6
·
verified ·
1 Parent(s): 0aee31b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -2
app.py CHANGED
@@ -84,8 +84,8 @@ def process_image(image, text):
84
  white_paper_width = obj['width']
85
  white_paper_height = obj['height']
86
 
87
- padding_x = int(white_paper_width * 0.2) # 5% padding horizontally
88
- padding_y = int(white_paper_height * 0.2) # 5% padding vertically
89
 
90
  box_width = white_paper_width - 2 * padding_x
91
  box_height = white_paper_height - 2 * padding_y
@@ -97,6 +97,10 @@ def process_image(image, text):
97
  x2_padded = int(obj['x'] + white_paper_width / 2 - padding_x)
98
  y2_padded = int(obj['y'] + white_paper_height / 2 - padding_y)
99
 
 
 
 
 
100
  # Draw bounding box for debugging purposes
101
  debug_layer = pil_image.copy()
102
  debug_draw = ImageDraw.Draw(debug_layer)
@@ -231,3 +235,4 @@ if __name__ == "__main__":
231
 
232
 
233
 
 
 
84
  white_paper_width = obj['width']
85
  white_paper_height = obj['height']
86
 
87
+ padding_x = int(white_paper_width * 0.05) # 5% padding horizontally
88
+ padding_y = int(white_paper_height * 0.05) # 5% padding vertically
89
 
90
  box_width = white_paper_width - 2 * padding_x
91
  box_height = white_paper_height - 2 * padding_y
 
97
  x2_padded = int(obj['x'] + white_paper_width / 2 - padding_x)
98
  y2_padded = int(obj['y'] + white_paper_height / 2 - padding_y)
99
 
100
+ # Detect paper angle
101
+ angle = detect_paper_angle(np.array(image), (x1_padded, y1_padded, x2_padded, y2_padded))
102
+ logging.debug(f"Detected paper angle: {angle} degrees.")
103
+
104
  # Draw bounding box for debugging purposes
105
  debug_layer = pil_image.copy()
106
  debug_draw = ImageDraw.Draw(debug_layer)
 
235
 
236
 
237
 
238
+