You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
2.0 KiB
60 lines
2.0 KiB
#!/usr/bin/env python3
|
|
"""REGION_MAP 시각 검증용 — region 16종 각 1장씩 합성 (yellow + green)."""
|
|
|
|
import random
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
import cv2
|
|
|
|
sys.path.insert(0, str(Path(__file__).parent.parent / "data_gen"))
|
|
from generate_synthetic import LPGenerator, REGION_MAP, HANGUL_CHAR_MAP # noqa: E402
|
|
|
|
|
|
def gen_with_region(gen, plate_bg, num_src, char_src, region_src, rkey):
|
|
plate = cv2.resize(plate_bg, (336, 170))
|
|
num1 = gen._resize_dict(num_src, 44, 60)
|
|
num2 = gen._resize_dict(num_src, 64, 90)
|
|
region = gen._resize_dict(region_src, 88, 60)
|
|
char = gen._resize_dict(char_src, 64, 62)
|
|
|
|
d = [random.choice("0123456789") for _ in range(2)]
|
|
ch = random.choice(list(HANGUL_CHAR_MAP))
|
|
e = [random.choice("0123456789") for _ in range(4)]
|
|
|
|
row, col = 8, 76
|
|
plate[row:row+60, col:col+88] = region[rkey]; col += 88 + 8
|
|
for x in d:
|
|
plate[row:row+60, col:col+44] = num1[x]; col += 44
|
|
|
|
row, col = 72, 8
|
|
plate[row:row+62, col:col+64] = char[ch]; col += 64
|
|
for x in e:
|
|
plate[row:row+90, col:col+64] = num2[x]; col += 64
|
|
return plate
|
|
|
|
|
|
def main():
|
|
random.seed(0)
|
|
asset_dir = Path("/workspace/kr_lp_pgnet/data_gen/Korean-license-plate-Generator")
|
|
out_root = Path("/workspace/train_data")
|
|
|
|
gen = LPGenerator(asset_dir)
|
|
|
|
for color, plate_bg, num_src, char_src, region_src in [
|
|
("y", gen.plate_y, gen.num_y, gen.char_y, gen.region_y_imgs),
|
|
("g", gen.plate_g, gen.num_g, gen.char_g, gen.region_g_imgs),
|
|
]:
|
|
out = out_root / f"region_check_{color}"
|
|
out.mkdir(parents=True, exist_ok=True)
|
|
for k in sorted(region_src.keys()):
|
|
img = gen_with_region(gen, plate_bg, num_src, char_src, region_src, k)
|
|
label = REGION_MAP.get(k, "?")
|
|
name = f"{color}_{k}_OUR_GUESS={label}.jpg"
|
|
cv2.imwrite(str(out / name), img)
|
|
print(f" {color}: {len(region_src)} 장 → {out}")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|