sghosh1 commited on
Commit
6eeec18
·
1 Parent(s): 555dd5c

bounding box

Browse files
Files changed (1) hide show
  1. app.py +12 -0
app.py CHANGED
@@ -33,6 +33,18 @@ uploaded_file = st.file_uploader("Upload an image file", type=["jpg", "jpeg", "p
33
  # Variable to store extracted text from the image
34
  extracted_text = ""
35
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  # Check if an image file is uploaded
37
  if uploaded_file is not None:
38
  # Open the uploaded image using PIL
 
33
  # Variable to store extracted text from the image
34
  extracted_text = ""
35
 
36
+ def calculate_area(bbox):
37
+ # bbox is a list of 4 points: [(x1, y1), (x2, y2), (x3, y3), (x4, y4)]
38
+ # We can use the width and height of the bounding box to calculate the area
39
+ x1, y1 = bbox[0]
40
+ x2, y2 = bbox[1]
41
+ x3, y3 = bbox[2]
42
+ x4, y4 = bbox[3]
43
+
44
+ # Calculate the width and height of the bounding box
45
+ width = max(x1, x2, x3, x4) - min(x1, x2, x3, x4)
46
+ height = max(y1, y2, y3, y4) - min(y1, y2, y3, y4)
47
+
48
  # Check if an image file is uploaded
49
  if uploaded_file is not None:
50
  # Open the uploaded image using PIL