24 lines
591 B
Python
24 lines
591 B
Python
|
|
#!/usr/bin/env python
|
||
|
|
# -*- coding: utf-8 -*-
|
||
|
|
"""
|
||
|
|
Simple seal crop and save for manual OCR testing
|
||
|
|
"""
|
||
|
|
from PIL import Image
|
||
|
|
|
||
|
|
# Seal coordinates from layout detection
|
||
|
|
seal_box = [1034, 2758, 1468, 3197]
|
||
|
|
|
||
|
|
# Load image
|
||
|
|
img = Image.open("sanity_check.png")
|
||
|
|
|
||
|
|
# Crop with padding
|
||
|
|
padding = 30
|
||
|
|
x1 = max(0, seal_box[0] - padding)
|
||
|
|
y1 = max(0, seal_box[1] - padding)
|
||
|
|
x2 = min(img.width, seal_box[2] + padding)
|
||
|
|
y2 = min(img.height, seal_box[3] + padding)
|
||
|
|
|
||
|
|
seal_crop = img.crop((int(x1), int(y1), int(x2), int(y2)))
|
||
|
|
seal_crop.save("seal_cropped.png")
|
||
|
|
print(f"Saved seal_cropped.png: {seal_crop.size}")
|