PaulMartrenchar commited on
Commit
adea4a9
·
1 Parent(s): a7f0aae

Better cropping

Browse files
Files changed (1) hide show
  1. app.py +7 -4
app.py CHANGED
@@ -8,12 +8,15 @@ import gradio as gr
8
  VALID_PATTERN = re.compile(r"-?\d+")
9
 
10
  def extract_skyjo_value(card_img):
 
 
11
  # Crop the top-left corner (adjust these values based on your card layout)
12
- crop_margin = 20 # pixels from the top and left edges
13
- crop_size = 100 # size of the cropped region (square)
 
14
  roi = card_img[
15
- crop_margin:crop_margin + crop_size,
16
- crop_margin:crop_margin + crop_size
17
  ]
18
 
19
  # Preprocess the cropped region
 
8
  VALID_PATTERN = re.compile(r"-?\d+")
9
 
10
  def extract_skyjo_value(card_img):
11
+ h, w, _ = card_img.shape
12
+
13
  # Crop the top-left corner (adjust these values based on your card layout)
14
+ crop_margin_top = h / 11 # pixels from the top edges
15
+ crop_margin_left = w / 7 # pixels from the left edges
16
+ crop_size = w / 3 # size of the cropped region (square)
17
  roi = card_img[
18
+ crop_margin_top:crop_margin_top + crop_size,
19
+ crop_margin_left:crop_margin_left + crop_size
20
  ]
21
 
22
  # Preprocess the cropped region