11 lines
427 B
Python
11 lines
427 B
Python
import sys
|
|
import cv2
|
|
from hbc.config import GridConfig
|
|
|
|
image_path, level, r, c, out = sys.argv[1], int(sys.argv[2]), int(sys.argv[3]), int(sys.argv[4]), sys.argv[5]
|
|
img = cv2.imread(image_path)
|
|
grid = GridConfig.load_json(f"layouts/level{level}.json").for_image(img.shape[1], img.shape[0])
|
|
x, y, w, h = grid.cell_box(r, c)
|
|
cv2.imwrite(out, img[y:y + h, x:x + w])
|
|
print("saved", out, "from cell", (r, c), "box", (x, y, w, h))
|