Spaces:
Sleeping
Sleeping
Commit
·
adea4a9
1
Parent(s):
a7f0aae
Better cropping
Browse files
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 |
-
|
| 13 |
-
|
|
|
|
| 14 |
roi = card_img[
|
| 15 |
-
|
| 16 |
-
|
| 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
|