├── num ├── 0.jpg ├── 1.jpg ├── 2.jpg ├── 3.jpg ├── 4.jpg ├── 5.jpg ├── 6.jpg ├── 7.jpg ├── 8.jpg └── 9.jpg ├── plate.jpg ├── char1 ├── ah.jpg ├── aj.jpg ├── ak.jpg ├── an.jpg ├── dh.jpg ├── dj.jpg ├── dk.jpg ├── dn.jpg ├── eh.jpg ├── ej.jpg ├── ek.jpg ├── en.jpg ├── fh.jpg ├── fj.jpg ├── fk.jpg ├── fn.jpg ├── gj.jpg ├── qh.jpg ├── qj.jpg ├── qk.jpg ├── qn.jpg ├── rh.jpg ├── rj.jpg ├── rk.jpg ├── rn.jpg ├── sh.jpg ├── sj.jpg ├── sk.jpg ├── sn.jpg ├── th.jpg ├── tj.jpg ├── tk.jpg ├── tn.jpg ├── wh.jpg ├── wj.jpg ├── wk.jpg └── wn.jpg ├── num_g ├── 0.jpg ├── 1.jpg ├── 2.jpg ├── 3.jpg ├── 4.jpg ├── 5.jpg ├── 6.jpg ├── 7.jpg ├── 8.jpg └── 9.jpg ├── num_y ├── 0.jpg ├── 1.jpg ├── 2.jpg ├── 3.jpg ├── 4.jpg ├── 5.jpg ├── 6.jpg ├── 7.jpg ├── 8.jpg └── 9.jpg ├── plate_g.jpg ├── plate_y.jpg ├── char1_g ├── ah.jpg ├── aj.jpg ├── ak.jpg ├── an.jpg ├── dh.jpg ├── dj.jpg ├── dk.jpg ├── dn.jpg ├── eh.jpg ├── ej.jpg ├── ek.jpg ├── en.jpg ├── fh.jpg ├── fj.jpg ├── fk.jpg ├── fn.jpg ├── gj.jpg ├── qh.jpg ├── qj.jpg ├── qk.jpg ├── qn.jpg ├── rh.jpg ├── rj.jpg ├── rk.jpg ├── rn.jpg ├── sh.jpg ├── sj.jpg ├── sk.jpg ├── sn.jpg ├── th.jpg ├── tj.jpg ├── tk.jpg ├── tn.jpg ├── wh.jpg ├── wj.jpg ├── wk.jpg └── wn.jpg ├── char1_y ├── ah.jpg ├── aj.jpg ├── ak.jpg ├── an.jpg ├── dh.jpg ├── dj.jpg ├── dk.jpg ├── dn.jpg ├── eh.jpg ├── ej.jpg ├── ek.jpg ├── en.jpg ├── fh.jpg ├── fj.jpg ├── fk.jpg ├── fn.jpg ├── gj.jpg ├── qh.jpg ├── qj.jpg ├── qk.jpg ├── qn.jpg ├── rh.jpg ├── rj.jpg ├── rk.jpg ├── rn.jpg ├── sh.jpg ├── sj.jpg ├── sk.jpg ├── sn.jpg ├── th.jpg ├── tj.jpg ├── tk.jpg ├── tn.jpg ├── wh.jpg ├── wj.jpg ├── wk.jpg └── wn.jpg ├── region_g ├── A.jpg ├── B.jpg ├── C.jpg ├── D.jpg ├── E.jpg ├── F.jpg ├── G.jpg ├── H.jpg ├── I.jpg ├── J.jpg ├── K.jpg ├── L.jpg ├── M.jpg ├── N.jpg ├── O.jpg └── P.jpg ├── region_y ├── A.jpg ├── B.jpg ├── C.jpg ├── D.jpg ├── E.jpg ├── F.jpg ├── G.jpg ├── H.jpg ├── I.jpg ├── J.jpg ├── K.jpg ├── L.jpg ├── M.jpg ├── N.jpg ├── O.jpg └── P.jpg ├── LICENSE ├── README.md ├── Generator_original.py ├── Generator_perspective.py └── Generator_augmentation.py /num/0.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/num/0.jpg -------------------------------------------------------------------------------- /num/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/num/1.jpg -------------------------------------------------------------------------------- /num/2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/num/2.jpg -------------------------------------------------------------------------------- /num/3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/num/3.jpg -------------------------------------------------------------------------------- /num/4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/num/4.jpg -------------------------------------------------------------------------------- /num/5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/num/5.jpg -------------------------------------------------------------------------------- /num/6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/num/6.jpg -------------------------------------------------------------------------------- /num/7.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/num/7.jpg -------------------------------------------------------------------------------- /num/8.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/num/8.jpg -------------------------------------------------------------------------------- /num/9.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/num/9.jpg -------------------------------------------------------------------------------- /plate.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/plate.jpg -------------------------------------------------------------------------------- /char1/ah.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1/ah.jpg -------------------------------------------------------------------------------- /char1/aj.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1/aj.jpg -------------------------------------------------------------------------------- /char1/ak.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1/ak.jpg -------------------------------------------------------------------------------- /char1/an.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1/an.jpg -------------------------------------------------------------------------------- /char1/dh.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1/dh.jpg -------------------------------------------------------------------------------- /char1/dj.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1/dj.jpg -------------------------------------------------------------------------------- /char1/dk.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1/dk.jpg -------------------------------------------------------------------------------- /char1/dn.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1/dn.jpg -------------------------------------------------------------------------------- /char1/eh.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1/eh.jpg -------------------------------------------------------------------------------- /char1/ej.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1/ej.jpg -------------------------------------------------------------------------------- /char1/ek.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1/ek.jpg -------------------------------------------------------------------------------- /char1/en.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1/en.jpg -------------------------------------------------------------------------------- /char1/fh.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1/fh.jpg -------------------------------------------------------------------------------- /char1/fj.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1/fj.jpg -------------------------------------------------------------------------------- /char1/fk.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1/fk.jpg -------------------------------------------------------------------------------- /char1/fn.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1/fn.jpg -------------------------------------------------------------------------------- /char1/gj.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1/gj.jpg -------------------------------------------------------------------------------- /char1/qh.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1/qh.jpg -------------------------------------------------------------------------------- /char1/qj.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1/qj.jpg -------------------------------------------------------------------------------- /char1/qk.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1/qk.jpg -------------------------------------------------------------------------------- /char1/qn.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1/qn.jpg -------------------------------------------------------------------------------- /char1/rh.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1/rh.jpg -------------------------------------------------------------------------------- /char1/rj.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1/rj.jpg -------------------------------------------------------------------------------- /char1/rk.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1/rk.jpg -------------------------------------------------------------------------------- /char1/rn.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1/rn.jpg -------------------------------------------------------------------------------- /char1/sh.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1/sh.jpg -------------------------------------------------------------------------------- /char1/sj.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1/sj.jpg -------------------------------------------------------------------------------- /char1/sk.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1/sk.jpg -------------------------------------------------------------------------------- /char1/sn.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1/sn.jpg -------------------------------------------------------------------------------- /char1/th.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1/th.jpg -------------------------------------------------------------------------------- /char1/tj.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1/tj.jpg -------------------------------------------------------------------------------- /char1/tk.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1/tk.jpg -------------------------------------------------------------------------------- /char1/tn.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1/tn.jpg -------------------------------------------------------------------------------- /char1/wh.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1/wh.jpg -------------------------------------------------------------------------------- /char1/wj.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1/wj.jpg -------------------------------------------------------------------------------- /char1/wk.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1/wk.jpg -------------------------------------------------------------------------------- /char1/wn.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1/wn.jpg -------------------------------------------------------------------------------- /num_g/0.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/num_g/0.jpg -------------------------------------------------------------------------------- /num_g/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/num_g/1.jpg -------------------------------------------------------------------------------- /num_g/2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/num_g/2.jpg -------------------------------------------------------------------------------- /num_g/3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/num_g/3.jpg -------------------------------------------------------------------------------- /num_g/4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/num_g/4.jpg -------------------------------------------------------------------------------- /num_g/5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/num_g/5.jpg -------------------------------------------------------------------------------- /num_g/6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/num_g/6.jpg -------------------------------------------------------------------------------- /num_g/7.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/num_g/7.jpg -------------------------------------------------------------------------------- /num_g/8.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/num_g/8.jpg -------------------------------------------------------------------------------- /num_g/9.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/num_g/9.jpg -------------------------------------------------------------------------------- /num_y/0.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/num_y/0.jpg -------------------------------------------------------------------------------- /num_y/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/num_y/1.jpg -------------------------------------------------------------------------------- /num_y/2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/num_y/2.jpg -------------------------------------------------------------------------------- /num_y/3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/num_y/3.jpg -------------------------------------------------------------------------------- /num_y/4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/num_y/4.jpg -------------------------------------------------------------------------------- /num_y/5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/num_y/5.jpg -------------------------------------------------------------------------------- /num_y/6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/num_y/6.jpg -------------------------------------------------------------------------------- /num_y/7.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/num_y/7.jpg -------------------------------------------------------------------------------- /num_y/8.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/num_y/8.jpg -------------------------------------------------------------------------------- /num_y/9.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/num_y/9.jpg -------------------------------------------------------------------------------- /plate_g.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/plate_g.jpg -------------------------------------------------------------------------------- /plate_y.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/plate_y.jpg -------------------------------------------------------------------------------- /char1_g/ah.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1_g/ah.jpg -------------------------------------------------------------------------------- /char1_g/aj.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1_g/aj.jpg -------------------------------------------------------------------------------- /char1_g/ak.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1_g/ak.jpg -------------------------------------------------------------------------------- /char1_g/an.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1_g/an.jpg -------------------------------------------------------------------------------- /char1_g/dh.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1_g/dh.jpg -------------------------------------------------------------------------------- /char1_g/dj.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1_g/dj.jpg -------------------------------------------------------------------------------- /char1_g/dk.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1_g/dk.jpg -------------------------------------------------------------------------------- /char1_g/dn.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1_g/dn.jpg -------------------------------------------------------------------------------- /char1_g/eh.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1_g/eh.jpg -------------------------------------------------------------------------------- /char1_g/ej.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1_g/ej.jpg -------------------------------------------------------------------------------- /char1_g/ek.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1_g/ek.jpg -------------------------------------------------------------------------------- /char1_g/en.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1_g/en.jpg -------------------------------------------------------------------------------- /char1_g/fh.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1_g/fh.jpg -------------------------------------------------------------------------------- /char1_g/fj.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1_g/fj.jpg -------------------------------------------------------------------------------- /char1_g/fk.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1_g/fk.jpg -------------------------------------------------------------------------------- /char1_g/fn.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1_g/fn.jpg -------------------------------------------------------------------------------- /char1_g/gj.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1_g/gj.jpg -------------------------------------------------------------------------------- /char1_g/qh.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1_g/qh.jpg -------------------------------------------------------------------------------- /char1_g/qj.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1_g/qj.jpg -------------------------------------------------------------------------------- /char1_g/qk.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1_g/qk.jpg -------------------------------------------------------------------------------- /char1_g/qn.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1_g/qn.jpg -------------------------------------------------------------------------------- /char1_g/rh.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1_g/rh.jpg -------------------------------------------------------------------------------- /char1_g/rj.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1_g/rj.jpg -------------------------------------------------------------------------------- /char1_g/rk.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1_g/rk.jpg -------------------------------------------------------------------------------- /char1_g/rn.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1_g/rn.jpg -------------------------------------------------------------------------------- /char1_g/sh.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1_g/sh.jpg -------------------------------------------------------------------------------- /char1_g/sj.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1_g/sj.jpg -------------------------------------------------------------------------------- /char1_g/sk.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1_g/sk.jpg -------------------------------------------------------------------------------- /char1_g/sn.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1_g/sn.jpg -------------------------------------------------------------------------------- /char1_g/th.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1_g/th.jpg -------------------------------------------------------------------------------- /char1_g/tj.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1_g/tj.jpg -------------------------------------------------------------------------------- /char1_g/tk.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1_g/tk.jpg -------------------------------------------------------------------------------- /char1_g/tn.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1_g/tn.jpg -------------------------------------------------------------------------------- /char1_g/wh.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1_g/wh.jpg -------------------------------------------------------------------------------- /char1_g/wj.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1_g/wj.jpg -------------------------------------------------------------------------------- /char1_g/wk.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1_g/wk.jpg -------------------------------------------------------------------------------- /char1_g/wn.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1_g/wn.jpg -------------------------------------------------------------------------------- /char1_y/ah.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1_y/ah.jpg -------------------------------------------------------------------------------- /char1_y/aj.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1_y/aj.jpg -------------------------------------------------------------------------------- /char1_y/ak.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1_y/ak.jpg -------------------------------------------------------------------------------- /char1_y/an.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1_y/an.jpg -------------------------------------------------------------------------------- /char1_y/dh.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1_y/dh.jpg -------------------------------------------------------------------------------- /char1_y/dj.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1_y/dj.jpg -------------------------------------------------------------------------------- /char1_y/dk.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1_y/dk.jpg -------------------------------------------------------------------------------- /char1_y/dn.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1_y/dn.jpg -------------------------------------------------------------------------------- /char1_y/eh.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1_y/eh.jpg -------------------------------------------------------------------------------- /char1_y/ej.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1_y/ej.jpg -------------------------------------------------------------------------------- /char1_y/ek.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1_y/ek.jpg -------------------------------------------------------------------------------- /char1_y/en.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1_y/en.jpg -------------------------------------------------------------------------------- /char1_y/fh.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1_y/fh.jpg -------------------------------------------------------------------------------- /char1_y/fj.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1_y/fj.jpg -------------------------------------------------------------------------------- /char1_y/fk.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1_y/fk.jpg -------------------------------------------------------------------------------- /char1_y/fn.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1_y/fn.jpg -------------------------------------------------------------------------------- /char1_y/gj.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1_y/gj.jpg -------------------------------------------------------------------------------- /char1_y/qh.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1_y/qh.jpg -------------------------------------------------------------------------------- /char1_y/qj.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1_y/qj.jpg -------------------------------------------------------------------------------- /char1_y/qk.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1_y/qk.jpg -------------------------------------------------------------------------------- /char1_y/qn.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1_y/qn.jpg -------------------------------------------------------------------------------- /char1_y/rh.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1_y/rh.jpg -------------------------------------------------------------------------------- /char1_y/rj.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1_y/rj.jpg -------------------------------------------------------------------------------- /char1_y/rk.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1_y/rk.jpg -------------------------------------------------------------------------------- /char1_y/rn.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1_y/rn.jpg -------------------------------------------------------------------------------- /char1_y/sh.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1_y/sh.jpg -------------------------------------------------------------------------------- /char1_y/sj.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1_y/sj.jpg -------------------------------------------------------------------------------- /char1_y/sk.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1_y/sk.jpg -------------------------------------------------------------------------------- /char1_y/sn.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1_y/sn.jpg -------------------------------------------------------------------------------- /char1_y/th.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1_y/th.jpg -------------------------------------------------------------------------------- /char1_y/tj.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1_y/tj.jpg -------------------------------------------------------------------------------- /char1_y/tk.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1_y/tk.jpg -------------------------------------------------------------------------------- /char1_y/tn.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1_y/tn.jpg -------------------------------------------------------------------------------- /char1_y/wh.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1_y/wh.jpg -------------------------------------------------------------------------------- /char1_y/wj.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1_y/wj.jpg -------------------------------------------------------------------------------- /char1_y/wk.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1_y/wk.jpg -------------------------------------------------------------------------------- /char1_y/wn.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/char1_y/wn.jpg -------------------------------------------------------------------------------- /region_g/A.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/region_g/A.jpg -------------------------------------------------------------------------------- /region_g/B.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/region_g/B.jpg -------------------------------------------------------------------------------- /region_g/C.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/region_g/C.jpg -------------------------------------------------------------------------------- /region_g/D.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/region_g/D.jpg -------------------------------------------------------------------------------- /region_g/E.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/region_g/E.jpg -------------------------------------------------------------------------------- /region_g/F.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/region_g/F.jpg -------------------------------------------------------------------------------- /region_g/G.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/region_g/G.jpg -------------------------------------------------------------------------------- /region_g/H.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/region_g/H.jpg -------------------------------------------------------------------------------- /region_g/I.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/region_g/I.jpg -------------------------------------------------------------------------------- /region_g/J.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/region_g/J.jpg -------------------------------------------------------------------------------- /region_g/K.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/region_g/K.jpg -------------------------------------------------------------------------------- /region_g/L.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/region_g/L.jpg -------------------------------------------------------------------------------- /region_g/M.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/region_g/M.jpg -------------------------------------------------------------------------------- /region_g/N.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/region_g/N.jpg -------------------------------------------------------------------------------- /region_g/O.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/region_g/O.jpg -------------------------------------------------------------------------------- /region_g/P.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/region_g/P.jpg -------------------------------------------------------------------------------- /region_y/A.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/region_y/A.jpg -------------------------------------------------------------------------------- /region_y/B.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/region_y/B.jpg -------------------------------------------------------------------------------- /region_y/C.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/region_y/C.jpg -------------------------------------------------------------------------------- /region_y/D.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/region_y/D.jpg -------------------------------------------------------------------------------- /region_y/E.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/region_y/E.jpg -------------------------------------------------------------------------------- /region_y/F.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/region_y/F.jpg -------------------------------------------------------------------------------- /region_y/G.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/region_y/G.jpg -------------------------------------------------------------------------------- /region_y/H.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/region_y/H.jpg -------------------------------------------------------------------------------- /region_y/I.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/region_y/I.jpg -------------------------------------------------------------------------------- /region_y/J.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/region_y/J.jpg -------------------------------------------------------------------------------- /region_y/K.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/region_y/K.jpg -------------------------------------------------------------------------------- /region_y/L.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/region_y/L.jpg -------------------------------------------------------------------------------- /region_y/M.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/region_y/M.jpg -------------------------------------------------------------------------------- /region_y/N.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/region_y/N.jpg -------------------------------------------------------------------------------- /region_y/O.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/region_y/O.jpg -------------------------------------------------------------------------------- /region_y/P.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjadud1994/Korean-license-plate-Generator/HEAD/region_y/P.jpg -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Beomyoung Kim 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Korean-license-plate-Generator 2 | 3 | Generate Synthetic Korea License Plate. 4 | 5 | - You can use this generator when there is insufficient data on the license plate. 6 | 7 | - This image generator may be used in a [character recognition model like 'CRNN'](https://github.com/qjadud1994/CRNN-Keras.git) 8 | 9 | - I recommend pre-training with synthetic images and fine-tune with real data. 10 | 11 | ## Types of Korean license plates 12 | 13 | - You can create synthetic license plate pictures by selecting the plate of the desired type. 14 | 15 | ![Type of license plate](https://github.com/qjadud1994/CRNN-Keras/blob/master/photo/license%20plate.jpg) 16 | 17 | 18 | 19 | 20 | ## Labeling 21 | 22 | - The name of the photo shows the letters and numbers on the license plate. 23 | 24 | - Hangul in the plate was translated into English with the following rules. 25 | 26 | - Region : 서울 -> A, 인천 -> B ...
27 | - Hangul : 나 -> sk, 너 -> sj, 다 -> ek, 도 -> eh ...
28 | 29 | 30 | ## File Description 31 | 32 | - os : Ubuntu 16.04.4 LTS 33 | - Python : 3.5.2 34 | 35 | 36 | | File |Description | 37 | |--------------------|--------------------------------------------------| 38 | |Generator_original.py | generate images without any image distortion/augmentation. | 39 | |Generator_augmentation.py | generate images with image augmentations such as random brightness. | 40 | |Generator_perspective.py | generate images with perspective transform. | 41 | -------------------------------------------------------------------------------- /Generator_original.py: -------------------------------------------------------------------------------- 1 | import os, random 2 | import cv2, argparse 3 | import numpy as np 4 | 5 | def random_bright(img): 6 | img = cv2.cvtColor(img, cv2.COLOR_RGB2HSV) 7 | img = np.array(img, dtype=np.float64) 8 | random_bright = .5 + np.random.uniform() 9 | img[:, :, 2] = img[:, :, 2] * random_bright 10 | img[:, :, 2][img[:, :, 2] > 255] = 255 11 | img = np.array(img, dtype=np.uint8) 12 | img = cv2.cvtColor(img, cv2.COLOR_HSV2RGB) 13 | return img 14 | 15 | class ImageGenerator: 16 | def __init__(self, save_path): 17 | self.save_path = save_path 18 | # Plate 19 | self.plate = cv2.imread("plate.jpg") 20 | self.plate2 = cv2.imread("plate_y.jpg") 21 | self.plate3 = cv2.imread("plate_g.jpg") 22 | 23 | # loading Number 24 | file_path = "./num/" 25 | file_list = os.listdir(file_path) 26 | self.Number = list() 27 | self.number_list = list() 28 | for file in file_list: 29 | img_path = os.path.join(file_path, file) 30 | img = cv2.imread(img_path) 31 | self.Number.append(img) 32 | self.number_list.append(file[0:-4]) 33 | 34 | # loading Char 35 | file_path = "./char1/" 36 | file_list = os.listdir(file_path) 37 | self.char_list = list() 38 | self.Char1 = list() 39 | for file in file_list: 40 | img_path = os.path.join(file_path, file) 41 | img = cv2.imread(img_path) 42 | self.Char1.append(img) 43 | self.char_list.append(file[0:-4]) 44 | 45 | # loading Number ==================== yellow-two-line ========================== 46 | file_path = "./num_y/" 47 | file_list = os.listdir(file_path) 48 | self.Number_y = list() 49 | self.number_list_y = list() 50 | for file in file_list: 51 | img_path = os.path.join(file_path, file) 52 | img = cv2.imread(img_path) 53 | self.Number_y.append(img) 54 | self.number_list_y.append(file[0:-4]) 55 | 56 | # loading Char 57 | file_path = "./char1_y/" 58 | file_list = os.listdir(file_path) 59 | self.char_list_y = list() 60 | self.Char1_y = list() 61 | for file in file_list: 62 | img_path = os.path.join(file_path, file) 63 | img = cv2.imread(img_path) 64 | self.Char1_y.append(img) 65 | self.char_list_y.append(file[0:-4]) 66 | 67 | # loading Resion 68 | file_path = "./region_y/" 69 | file_list = os.listdir(file_path) 70 | self.Resion_y = list() 71 | self.resion_list_y = list() 72 | for file in file_list: 73 | img_path = os.path.join(file_path, file) 74 | img = cv2.imread(img_path) 75 | self.Resion_y.append(img) 76 | self.resion_list_y.append(file[0:-4]) 77 | #========================================================================= 78 | 79 | # loading Number ==================== green-two-line ========================== 80 | file_path = "./num_g/" 81 | file_list = os.listdir(file_path) 82 | self.Number_g = list() 83 | self.number_list_g = list() 84 | for file in file_list: 85 | img_path = os.path.join(file_path, file) 86 | img = cv2.imread(img_path) 87 | self.Number_g.append(img) 88 | self.number_list_g.append(file[0:-4]) 89 | 90 | # loading Char 91 | file_path = "./char1_g/" 92 | file_list = os.listdir(file_path) 93 | self.char_list_g = list() 94 | self.Char1_g = list() 95 | for file in file_list: 96 | img_path = os.path.join(file_path, file) 97 | img = cv2.imread(img_path) 98 | self.Char1_g.append(img) 99 | self.char_list_g.append(file[0:-4]) 100 | 101 | # loading Resion 102 | file_path = "./region_g/" 103 | file_list = os.listdir(file_path) 104 | self.Resion_g = list() 105 | self.resion_list_g = list() 106 | for file in file_list: 107 | img_path = os.path.join(file_path, file) 108 | img = cv2.imread(img_path) 109 | self.Resion_g.append(img) 110 | self.resion_list_g.append(file[0:-4]) 111 | #========================================================================= 112 | 113 | 114 | def Type_1(self, num, save=False): 115 | number = [cv2.resize(number, (56, 83)) for number in self.Number] 116 | char = [cv2.resize(char1, (60, 83)) for char1 in self.Char1] 117 | Plate = cv2.resize(self.plate, (520, 110)) 118 | 119 | for i, Iter in enumerate(range(num)): 120 | Plate = cv2.resize(self.plate, (520, 110)) 121 | label = "Z" 122 | # row -> y , col -> x 123 | row, col = 13, 35 # row + 83, col + 56 124 | # number 1 125 | rand_int = random.randint(0, 9) 126 | label += self.number_list[rand_int] 127 | Plate[row:row + 83, col:col + 56, :] = number[rand_int] 128 | col += 56 129 | 130 | # number 2 131 | rand_int = random.randint(0, 9) 132 | label += self.number_list[rand_int] 133 | Plate[row:row + 83, col:col + 56, :] = number[rand_int] 134 | col += 56 135 | 136 | # character 3 137 | label += self.char_list[i%37] 138 | Plate[row:row + 83, col:col + 60, :] = char[i%37] 139 | col += (60 + 36) 140 | 141 | # number 4 142 | rand_int = random.randint(0, 9) 143 | label += self.number_list[rand_int] 144 | Plate[row:row + 83, col:col + 56, :] = number[rand_int] 145 | col += 56 146 | 147 | # number 5 148 | rand_int = random.randint(0, 9) 149 | label += self.number_list[rand_int] 150 | Plate[row:row + 83, col:col + 56, :] = number[rand_int] 151 | col += 56 152 | 153 | # number 6 154 | rand_int = random.randint(0, 9) 155 | label += self.number_list[rand_int] 156 | Plate[row:row + 83, col:col + 56, :] = number[rand_int] 157 | col += 56 158 | 159 | # number 7 160 | rand_int = random.randint(0, 9) 161 | label += self.number_list[rand_int] 162 | Plate[row:row + 83, col:col + 56, :] = number[rand_int] 163 | col += 56 164 | Plate = random_bright(Plate) 165 | if save: 166 | cv2.imwrite(self.save_path + label + ".jpg", Plate) 167 | else: 168 | cv2.imshow(label, Plate) 169 | cv2.waitKey(0) 170 | cv2.destroyAllWindows() 171 | 172 | def Type_2(self, num, save=False): 173 | number = [cv2.resize(number, (45, 83)) for number in self.Number] 174 | char = [cv2.resize(char1, (49, 70)) for char1 in self.Char1] 175 | Plate = cv2.resize(self.plate, (355, 155)) 176 | 177 | for i, Iter in enumerate(range(num)): 178 | Plate = cv2.resize(self.plate, (355, 155)) 179 | label = "Z" 180 | row, col = 46, 10 # row + 83, col + 56 181 | 182 | # number 1 183 | rand_int = random.randint(0, 9) 184 | label += self.number_list[rand_int] 185 | Plate[row:row + 83, col:col + 45, :] = number[rand_int] 186 | col += 45 187 | 188 | # number 2 189 | rand_int = random.randint(0, 9) 190 | label += self.number_list[rand_int] 191 | Plate[row:row + 83, col:col + 45, :] = number[rand_int] 192 | col += 45 193 | 194 | # number 3 195 | label += self.char_list[i%37] 196 | Plate[row + 12:row + 82, col + 2:col + 49 + 2, :] = char[i%37] 197 | col += 49 + 2 198 | 199 | # number 4 200 | rand_int = random.randint(0, 9) 201 | label += self.number_list[rand_int] 202 | Plate[row:row + 83, col + 2:col + 45 + 2, :] = number[rand_int] 203 | col += 45 + 2 204 | 205 | # number 5 206 | rand_int = random.randint(0, 9) 207 | label += self.number_list[rand_int] 208 | Plate[row:row + 83, col:col + 45, :] = number[rand_int] 209 | col += 45 210 | 211 | # number 6 212 | rand_int = random.randint(0, 9) 213 | label += self.number_list[rand_int] 214 | Plate[row:row + 83, col:col + 45, :] = number[rand_int] 215 | col += 45 216 | 217 | # number 7 218 | rand_int = random.randint(0, 9) 219 | label += self.number_list[rand_int] 220 | Plate[row:row + 83, col:col + 45, :] = number[rand_int] 221 | col += 45 222 | Plate = random_bright(Plate) 223 | if save: 224 | cv2.imwrite(self.save_path + label + ".jpg", Plate) 225 | else: 226 | cv2.imshow(label, Plate) 227 | cv2.waitKey(0) 228 | cv2.destroyAllWindows() 229 | 230 | def Type_3(self, num, save=False): 231 | number1 = [cv2.resize(number, (44, 60)) for number in self.Number_y] 232 | number2 = [cv2.resize(number, (64, 90)) for number in self.Number_y] 233 | resion = [cv2.resize(resion, (88, 60)) for resion in self.Resion_y] 234 | char = [cv2.resize(char1, (64, 62)) for char1 in self.Char1_y] 235 | 236 | for i, Iter in enumerate(range(num)): 237 | Plate = cv2.resize(self.plate2, (336, 170)) 238 | 239 | label = str() 240 | # row -> y , col -> x 241 | row, col = 8, 76 242 | 243 | # resion 244 | label += self.resion_list_y[i % 16] 245 | Plate[row:row + 60, col:col + 88, :] = resion[i % 16] 246 | col += 88 + 8 247 | 248 | # number 1 249 | rand_int = random.randint(0, 9) 250 | label += self.number_list_y[rand_int] 251 | Plate[row:row + 60, col:col + 44, :] = number1[rand_int] 252 | col += 44 253 | 254 | # number 2 255 | rand_int = random.randint(0, 9) 256 | label += self.number_list_y[rand_int] 257 | Plate[row:row + 60, col:col + 44, :] = number1[rand_int] 258 | 259 | row, col = 72, 8 260 | 261 | # character 3 262 | label += self.char_list_y[i % 37] 263 | Plate[row:row + 62, col:col + 64, :] = char[i % 37] 264 | col += 64 265 | 266 | # number 4 267 | rand_int = random.randint(0, 9) 268 | label += self.number_list_y[rand_int] 269 | Plate[row:row + 90, col:col + 64, :] = number2[rand_int] 270 | col += 64 271 | 272 | # number 5 273 | rand_int = random.randint(0, 9) 274 | label += self.number_list_y[rand_int] 275 | Plate[row:row + 90, col:col + 64, :] = number2[rand_int] 276 | col += 64 277 | 278 | # number 6 279 | rand_int = random.randint(0, 9) 280 | label += self.number_list_y[rand_int] 281 | Plate[row:row + 90, col:col + 64, :] = number2[rand_int] 282 | col += 64 283 | 284 | # number 7 285 | rand_int = random.randint(0, 9) 286 | label += self.number_list_y[rand_int] 287 | Plate[row:row + 90, col:col + 64, :] = number2[rand_int] 288 | Plate = random_bright(Plate) 289 | if save: 290 | cv2.imwrite(self.save_path + label + ".jpg", Plate) 291 | else: 292 | cv2.imshow(label, Plate) 293 | cv2.waitKey(0) 294 | cv2.destroyAllWindows() 295 | 296 | def Type_4(self, num, save=False): 297 | number1 = [cv2.resize(number, (44, 60)) for number in self.Number_g] 298 | number2 = [cv2.resize(number, (64, 90)) for number in self.Number_g] 299 | resion = [cv2.resize(resion, (88, 60)) for resion in self.Resion_g] 300 | char = [cv2.resize(char1, (64, 62)) for char1 in self.Char1_g] 301 | 302 | for i, Iter in enumerate(range(num)): 303 | Plate = cv2.resize(self.plate3, (336, 170)) 304 | 305 | label = str() 306 | # row -> y , col -> x 307 | row, col = 8, 76 308 | 309 | # resion 310 | label += self.resion_list_g[i % 16] 311 | Plate[row:row + 60, col:col + 88, :] = resion[i % 16] 312 | col += 88 + 8 313 | 314 | # number 1 315 | rand_int = random.randint(0, 9) 316 | label += self.number_list_g[rand_int] 317 | Plate[row:row + 60, col:col + 44, :] = number1[rand_int] 318 | col += 44 319 | 320 | # number 2 321 | rand_int = random.randint(0, 9) 322 | label += self.number_list_g[rand_int] 323 | Plate[row:row + 60, col:col + 44, :] = number1[rand_int] 324 | 325 | row, col = 72, 8 326 | 327 | # character 3 328 | label += self.char_list_g[i % 37] 329 | Plate[row:row + 62, col:col + 64, :] = char[i % 37] 330 | col += 64 331 | 332 | # number 4 333 | rand_int = random.randint(0, 9) 334 | label += self.number_list_g[rand_int] 335 | Plate[row:row + 90, col:col + 64, :] = number2[rand_int] 336 | col += 64 337 | 338 | # number 5 339 | rand_int = random.randint(0, 9) 340 | label += self.number_list_g[rand_int] 341 | Plate[row:row + 90, col:col + 64, :] = number2[rand_int] 342 | col += 64 343 | 344 | # number 6 345 | rand_int = random.randint(0, 9) 346 | label += self.number_list_g[rand_int] 347 | Plate[row:row + 90, col:col + 64, :] = number2[rand_int] 348 | col += 64 349 | 350 | # number 7 351 | rand_int = random.randint(0, 9) 352 | label += self.number_list_g[rand_int] 353 | Plate[row:row + 90, col:col + 64, :] = number2[rand_int] 354 | Plate = random_bright(Plate) 355 | if save: 356 | cv2.imwrite(self.save_path + label + ".jpg", Plate) 357 | else: 358 | cv2.imshow(label, Plate) 359 | cv2.waitKey(0) 360 | cv2.destroyAllWindows() 361 | 362 | def Type_5(self, num, save=False): 363 | number1 = [cv2.resize(number, (60, 65)) for number in self.Number_g] 364 | number2 = [cv2.resize(number, (80, 90)) for number in self.Number_g] 365 | char = [cv2.resize(char1, (60, 65)) for char1 in self.Char1_g] 366 | 367 | for i, Iter in enumerate(range(num)): 368 | Plate = cv2.resize(self.plate3, (336, 170)) 369 | random_width, random_height = 336, 170 370 | label = "Z" 371 | 372 | # row -> y , col -> x 373 | row, col = 8, 78 374 | 375 | # number 1 376 | rand_int = random.randint(0, 9) 377 | label += self.number_list_g[rand_int] 378 | Plate[row:row + 65, col:col + 60, :] = number1[rand_int] 379 | col += 60 380 | 381 | # number 2 382 | rand_int = random.randint(0, 9) 383 | label += self.number_list_g[rand_int] 384 | Plate[row:row + 65, col:col + 60, :] = number1[rand_int] 385 | col += 60 386 | 387 | # character 3 388 | label += self.char_list_g[i%37] 389 | Plate[row:row + 65, col:col + 60, :] = char[i%37] 390 | row, col = 75, 8 391 | 392 | # number 4 393 | rand_int = random.randint(0, 9) 394 | label += self.number_list_g[rand_int] 395 | Plate[row:row + 90, col:col + 80, :] = number2[rand_int] 396 | col += 80 397 | 398 | 399 | # number 5 400 | rand_int = random.randint(0, 9) 401 | label += self.number_list_g[rand_int] 402 | Plate[row:row + 90, col:col + 80, :] = number2[rand_int] 403 | col += 80 404 | 405 | # number 6 406 | rand_int = random.randint(0, 9) 407 | label += self.number_list_g[rand_int] 408 | Plate[row:row + 90, col:col + 80, :] = number2[rand_int] 409 | col += 80 410 | 411 | # number 7 412 | rand_int = random.randint(0, 9) 413 | label += self.number_list_g[rand_int] 414 | Plate[row:row + 90, col:col + 80, :] = number2[rand_int] 415 | 416 | Plate = random_bright(Plate) 417 | 418 | if save: 419 | cv2.imwrite(self.save_path + label + ".jpg", Plate) 420 | else: 421 | cv2.imshow(label, Plate) 422 | cv2.waitKey(0) 423 | cv2.destroyAllWindows() 424 | 425 | 426 | parser = argparse.ArgumentParser() 427 | parser.add_argument("-i", "--img_dir", help="save image directory", 428 | type=str, default="../CRNN/DB/") 429 | parser.add_argument("-n", "--num", help="number of image", 430 | type=int) 431 | parser.add_argument("-s", "--save", help="save or imshow", 432 | type=bool, default=True) 433 | args = parser.parse_args() 434 | 435 | 436 | img_dir = args.img_dir 437 | A = ImageGenerator(img_dir) 438 | 439 | num_img = args.num 440 | Save = args.save 441 | 442 | A.Type_1(num_img, save=Save) 443 | print("Type 1 finish") 444 | A.Type_2(num_img, save=Save) 445 | print("Type 2 finish") 446 | A.Type_3(num_img, save=Save) 447 | print("Type 3 finish") 448 | A.Type_4(num_img, save=Save) 449 | print("Type 4 finish") 450 | A.Type_5(num_img, save=Save) 451 | print("Type 5 finish") 452 | -------------------------------------------------------------------------------- /Generator_perspective.py: -------------------------------------------------------------------------------- 1 | import os, random 2 | import cv2, argparse 3 | import numpy as np 4 | 5 | def image_augmentation(img, type2=False): 6 | # perspective 7 | w, h, _ = img.shape 8 | pts1 = np.float32([[0, 0], [0, w], [h, 0], [h, w]]) 9 | # 좌표의 이동점 10 | begin, end = 30, 90 11 | pts2 = np.float32([[random.randint(begin, end), random.randint(begin, end)], 12 | [random.randint(begin, end), w - random.randint(begin, end)], 13 | [h - random.randint(begin, end), random.randint(begin, end)], 14 | [h - random.randint(begin, end), w - random.randint(begin, end)]]) 15 | M = cv2.getPerspectiveTransform(pts1, pts2) 16 | 17 | img = cv2.warpPerspective(img, M, (h, w)) 18 | 19 | # Brightness 20 | img = cv2.cvtColor(img, cv2.COLOR_RGB2HSV) 21 | img = np.array(img, dtype=np.float64) 22 | random_bright = .4 + np.random.uniform() 23 | img[:, :, 2] = img[:, :, 2] * random_bright 24 | img[:, :, 2][img[:, :, 2] > 255] = 255 25 | img = np.array(img, dtype=np.uint8) 26 | img = cv2.cvtColor(img, cv2.COLOR_HSV2RGB) 27 | 28 | # Blur 29 | blur_value = random.randint(0,4) * 2 + 1 30 | img = cv2.blur(img,(blur_value, blur_value)) 31 | if type2: 32 | return img[130:280, 180:600, :] 33 | return img[130:280, 120:660, :] 34 | 35 | 36 | class ImageGenerator: 37 | def __init__(self, save_path): 38 | self.save_path = save_path 39 | # Plate 40 | self.plate = cv2.imread("plate.jpg") 41 | self.plate2 = cv2.imread("plate_y.jpg") 42 | self.plate3 = cv2.imread("plate_g.jpg") 43 | 44 | # loading Number ==================== white-one-line ========================== 45 | file_path = "./num/" 46 | file_list = os.listdir(file_path) 47 | self.Number = list() 48 | self.number_list = list() 49 | for file in file_list: 50 | img_path = os.path.join(file_path, file) 51 | img = cv2.imread(img_path) 52 | self.Number.append(img) 53 | self.number_list.append(file[0:-4]) 54 | 55 | # loading Char 56 | file_path = "./char1/" 57 | file_list = os.listdir(file_path) 58 | self.char_list = list() 59 | self.Char1 = list() 60 | for file in file_list: 61 | img_path = os.path.join(file_path, file) 62 | img = cv2.imread(img_path) 63 | self.Char1.append(img) 64 | self.char_list.append(file[0:-4]) 65 | 66 | # loading Number ==================== yellow-two-line ========================== 67 | file_path = "./num_y/" 68 | file_list = os.listdir(file_path) 69 | self.Number_y = list() 70 | self.number_list_y = list() 71 | for file in file_list: 72 | img_path = os.path.join(file_path, file) 73 | img = cv2.imread(img_path) 74 | self.Number_y.append(img) 75 | self.number_list_y.append(file[0:-4]) 76 | 77 | # loading Char 78 | file_path = "./char1_y/" 79 | file_list = os.listdir(file_path) 80 | self.char_list_y = list() 81 | self.Char1_y = list() 82 | for file in file_list: 83 | img_path = os.path.join(file_path, file) 84 | img = cv2.imread(img_path) 85 | self.Char1_y.append(img) 86 | self.char_list_y.append(file[0:-4]) 87 | 88 | # loading Resion 89 | file_path = "./region_y/" 90 | file_list = os.listdir(file_path) 91 | self.Resion_y = list() 92 | self.resion_list_y = list() 93 | for file in file_list: 94 | img_path = os.path.join(file_path, file) 95 | img = cv2.imread(img_path) 96 | self.Resion_y.append(img) 97 | self.resion_list_y.append(file[0:-4]) 98 | #========================================================================= 99 | 100 | # loading Number ==================== green-two-line ========================== 101 | file_path = "./num_g/" 102 | file_list = os.listdir(file_path) 103 | self.Number_g = list() 104 | self.number_list_g = list() 105 | for file in file_list: 106 | img_path = os.path.join(file_path, file) 107 | img = cv2.imread(img_path) 108 | self.Number_g.append(img) 109 | self.number_list_g.append(file[0:-4]) 110 | 111 | # loading Char 112 | file_path = "./char1_g/" 113 | file_list = os.listdir(file_path) 114 | self.char_list_g = list() 115 | self.Char1_g = list() 116 | for file in file_list: 117 | img_path = os.path.join(file_path, file) 118 | img = cv2.imread(img_path) 119 | self.Char1_g.append(img) 120 | self.char_list_g.append(file[0:-4]) 121 | 122 | # loading Resion 123 | file_path = "./region_g/" 124 | file_list = os.listdir(file_path) 125 | self.Resion_g = list() 126 | self.resion_list_g = list() 127 | for file in file_list: 128 | img_path = os.path.join(file_path, file) 129 | img = cv2.imread(img_path) 130 | self.Resion_g.append(img) 131 | self.resion_list_g.append(file[0:-4]) 132 | #========================================================================= 133 | 134 | 135 | 136 | def Type_1(self, num, save=False): 137 | number = [cv2.resize(number, (56, 83)) for number in self.Number] 138 | char = [cv2.resize(char1, (60, 83)) for char1 in self.Char1] 139 | 140 | for i, Iter in enumerate(range(num)): 141 | Plate = cv2.resize(self.plate, (520, 110)) 142 | b_width ,b_height = 400, 800 143 | random_R, random_G, random_B = random.randint(0,255), random.randint(0,255), random.randint(0,255) 144 | background = np.zeros((b_width, b_height, 3), np.uint8) 145 | cv2.rectangle(background, (0, 0), (b_height, b_width), (random_R, random_G, random_B), -1) 146 | 147 | label = "Z" 148 | # row -> y , col -> x 149 | row, col = 13, 35 # row + 83, col + 56 150 | # number 1 151 | rand_int = random.randint(0, 9) 152 | label += self.number_list[rand_int] 153 | Plate[row:row + 83, col:col + 56, :] = number[rand_int] 154 | col += 56 155 | 156 | # number 2 157 | rand_int = random.randint(0, 9) 158 | label += self.number_list[rand_int] 159 | Plate[row:row + 83, col:col + 56, :] = number[rand_int] 160 | col += 56 161 | 162 | # character 3 163 | label += self.char_list[i%37] 164 | Plate[row:row + 83, col:col + 60, :] = char[i%37] 165 | col += (60 + 36) 166 | 167 | # number 4 168 | rand_int = random.randint(0, 9) 169 | label += self.number_list[rand_int] 170 | Plate[row:row + 83, col:col + 56, :] = number[rand_int] 171 | col += 56 172 | 173 | # number 5 174 | rand_int = random.randint(0, 9) 175 | label += self.number_list[rand_int] 176 | Plate[row:row + 83, col:col + 56, :] = number[rand_int] 177 | col += 56 178 | 179 | # number 6 180 | rand_int = random.randint(0, 9) 181 | label += self.number_list[rand_int] 182 | Plate[row:row + 83, col:col + 56, :] = number[rand_int] 183 | col += 56 184 | 185 | # number 7 186 | rand_int = random.randint(0, 9) 187 | label += self.number_list[rand_int] 188 | Plate[row:row + 83, col:col + 56, :] = number[rand_int] 189 | col += 56 190 | 191 | s_width, s_height = int((400-110)/2), int((800-520)/2) 192 | background[s_width:110 + s_width, s_height:520 + s_height, :] = Plate 193 | background = image_augmentation(background) 194 | 195 | if save: 196 | cv2.imwrite(self.save_path + label + ".jpg", background) 197 | else: 198 | cv2.imshow(label, background) 199 | cv2.waitKey(0) 200 | cv2.destroyAllWindows() 201 | 202 | def Type_2(self, num, save=False): 203 | number = [cv2.resize(number, (45, 83)) for number in self.Number] 204 | char = [cv2.resize(char1, (49, 70)) for char1 in self.Char1] 205 | for i, Iter in enumerate(range(num)): 206 | Plate = cv2.resize(self.plate, (360, 160)) 207 | b_width, b_height = 400, 800 208 | random_R, random_G, random_B = random.randint(0, 255), random.randint(0, 255), random.randint(0, 255) 209 | background = np.zeros((b_width, b_height, 3), np.uint8) 210 | cv2.rectangle(background, (0, 0), (b_height, b_width), (random_R, random_G, random_B), -1) 211 | 212 | label = "Z" 213 | row, col = 46, 10 # row + 83, col + 56 214 | 215 | # number 1 216 | rand_int = random.randint(0, 9) 217 | label += self.number_list[rand_int] 218 | Plate[row:row + 83, col:col + 45, :] = number[rand_int] 219 | col += 45 220 | 221 | # number 2 222 | rand_int = random.randint(0, 9) 223 | label += self.number_list[rand_int] 224 | Plate[row:row + 83, col:col + 45, :] = number[rand_int] 225 | col += 45 226 | 227 | # number 3 228 | label += self.char_list[i%37] 229 | Plate[row + 12:row + 82, col + 2:col + 49 + 2, :] = char[i%37] 230 | col += 49 + 2 231 | 232 | # number 4 233 | rand_int = random.randint(0, 9) 234 | label += self.number_list[rand_int] 235 | Plate[row:row + 83, col + 2:col + 45 + 2, :] = number[rand_int] 236 | col += 45 + 2 237 | 238 | # number 5 239 | rand_int = random.randint(0, 9) 240 | label += self.number_list[rand_int] 241 | Plate[row:row + 83, col:col + 45, :] = number[rand_int] 242 | col += 45 243 | 244 | # number 6 245 | rand_int = random.randint(0, 9) 246 | label += self.number_list[rand_int] 247 | Plate[row:row + 83, col:col + 45, :] = number[rand_int] 248 | col += 45 249 | 250 | # number 7 251 | rand_int = random.randint(0, 9) 252 | label += self.number_list[rand_int] 253 | Plate[row:row + 83, col:col + 45, :] = number[rand_int] 254 | col += 45 255 | 256 | s_width, s_height = int((400 - 160) / 2), int((800 - 360) / 2) 257 | background[s_width:160 + s_width, s_height:360 + s_height, :] = Plate 258 | background = image_augmentation(background, type2=True) 259 | 260 | if save: 261 | cv2.imwrite(self.save_path + label + ".jpg", background) 262 | else: 263 | cv2.imshow(label, background) 264 | cv2.waitKey(0) 265 | cv2.destroyAllWindows() 266 | 267 | def Type_3(self, num, save=False): 268 | number1 = [cv2.resize(number, (44, 60)) for number in self.Number_y] 269 | number2 = [cv2.resize(number, (64, 90)) for number in self.Number_y] 270 | resion = [cv2.resize(resion, (88, 60)) for resion in self.Resion_y] 271 | char = [cv2.resize(char1, (64, 62)) for char1 in self.Char1_y] 272 | 273 | for i, Iter in enumerate(range(num)): 274 | Plate = cv2.resize(self.plate2, (336, 170)) 275 | b_width, b_height = 400, 800 276 | random_R, random_G, random_B = random.randint(0, 255), random.randint(0, 255), random.randint(0, 255) 277 | background = np.zeros((b_width, b_height, 3), np.uint8) 278 | cv2.rectangle(background, (0, 0), (b_height, b_width), (random_R, random_G, random_B), -1) 279 | 280 | label = str() 281 | # row -> y , col -> x 282 | row, col = 8, 76 283 | 284 | # resion 285 | label += self.resion_list_y[i % 16] 286 | Plate[row:row + 60, col:col + 88, :] = resion[i % 16] 287 | col += 88 + 8 288 | 289 | # number 1 290 | rand_int = random.randint(0, 9) 291 | label += self.number_list_y[rand_int] 292 | Plate[row:row + 60, col:col + 44, :] = number1[rand_int] 293 | col += 44 294 | 295 | # number 2 296 | rand_int = random.randint(0, 9) 297 | label += self.number_list_y[rand_int] 298 | Plate[row:row + 60, col:col + 44, :] = number1[rand_int] 299 | 300 | row, col = 72, 8 301 | 302 | # character 3 303 | label += self.char_list_y[i % 37] 304 | Plate[row:row + 62, col:col + 64, :] = char[i % 37] 305 | col += 64 306 | 307 | # number 4 308 | rand_int = random.randint(0, 9) 309 | label += self.number_list_y[rand_int] 310 | Plate[row:row + 90, col:col + 64, :] = number2[rand_int] 311 | col += 64 312 | 313 | # number 5 314 | rand_int = random.randint(0, 9) 315 | label += self.number_list_y[rand_int] 316 | Plate[row:row + 90, col:col + 64, :] = number2[rand_int] 317 | col += 64 318 | 319 | # number 6 320 | rand_int = random.randint(0, 9) 321 | label += self.number_list_y[rand_int] 322 | Plate[row:row + 90, col:col + 64, :] = number2[rand_int] 323 | col += 64 324 | 325 | # number 7 326 | rand_int = random.randint(0, 9) 327 | label += self.number_list_y[rand_int] 328 | Plate[row:row + 90, col:col + 64, :] = number2[rand_int] 329 | 330 | s_width, s_height = int((400 - 170) / 2), int((800 - 336) / 2) 331 | background[s_width:170 + s_width, s_height:336 + s_height, :] = Plate 332 | background = image_augmentation(background, type2=True) 333 | 334 | if save: 335 | cv2.imwrite(self.save_path + label + ".jpg", background) 336 | else: 337 | cv2.imshow(label, background) 338 | cv2.waitKey(0) 339 | cv2.destroyAllWindows() 340 | 341 | def Type_4(self, num, save=False): 342 | number1 = [cv2.resize(number, (44, 60)) for number in self.Number_g] 343 | number2 = [cv2.resize(number, (64, 90)) for number in self.Number_g] 344 | resion = [cv2.resize(resion, (88, 60)) for resion in self.Resion_g] 345 | char = [cv2.resize(char1, (64, 62)) for char1 in self.Char1_g] 346 | 347 | for i, Iter in enumerate(range(num)): 348 | Plate = cv2.resize(self.plate3, (336, 170)) 349 | b_width, b_height = 400, 800 350 | random_R, random_G, random_B = random.randint(0, 255), random.randint(0, 255), random.randint(0, 255) 351 | background = np.zeros((b_width, b_height, 3), np.uint8) 352 | cv2.rectangle(background, (0, 0), (b_height, b_width), (random_R, random_G, random_B), -1) 353 | 354 | label = str() 355 | # row -> y , col -> x 356 | row, col = 8, 76 357 | 358 | # resion 359 | label += self.resion_list_g[i % 16] 360 | Plate[row:row + 60, col:col + 88, :] = resion[i % 16] 361 | col += 88 + 8 362 | 363 | # number 1 364 | rand_int = random.randint(0, 9) 365 | label += self.number_list_g[rand_int] 366 | Plate[row:row + 60, col:col + 44, :] = number1[rand_int] 367 | col += 44 368 | 369 | # number 2 370 | rand_int = random.randint(0, 9) 371 | label += self.number_list_g[rand_int] 372 | Plate[row:row + 60, col:col + 44, :] = number1[rand_int] 373 | 374 | row, col = 72, 8 375 | 376 | # character 3 377 | label += self.char_list_g[i % 37] 378 | Plate[row:row + 62, col:col + 64, :] = char[i % 37] 379 | col += 64 380 | 381 | # number 4 382 | rand_int = random.randint(0, 9) 383 | label += self.number_list_g[rand_int] 384 | Plate[row:row + 90, col:col + 64, :] = number2[rand_int] 385 | col += 64 386 | 387 | # number 5 388 | rand_int = random.randint(0, 9) 389 | label += self.number_list_g[rand_int] 390 | Plate[row:row + 90, col:col + 64, :] = number2[rand_int] 391 | col += 64 392 | 393 | # number 6 394 | rand_int = random.randint(0, 9) 395 | label += self.number_list_g[rand_int] 396 | Plate[row:row + 90, col:col + 64, :] = number2[rand_int] 397 | col += 64 398 | 399 | # number 7 400 | rand_int = random.randint(0, 9) 401 | label += self.number_list_g[rand_int] 402 | Plate[row:row + 90, col:col + 64, :] = number2[rand_int] 403 | 404 | s_width, s_height = int((400 - 170) / 2), int((800 - 336) / 2) 405 | background[s_width:170 + s_width, s_height:336 + s_height, :] = Plate 406 | background = image_augmentation(background, type2=True) 407 | 408 | if save: 409 | cv2.imwrite(self.save_path + label + ".jpg", background) 410 | else: 411 | cv2.imshow(label, background) 412 | cv2.waitKey(0) 413 | cv2.destroyAllWindows() 414 | 415 | def Type_5(self, num, save=False): 416 | number1 = [cv2.resize(number, (60, 65)) for number in self.Number_g] 417 | number2 = [cv2.resize(number, (80, 90)) for number in self.Number_g] 418 | char = [cv2.resize(char1, (60, 65)) for char1 in self.Char1_g] 419 | 420 | for i, Iter in enumerate(range(num)): 421 | Plate = cv2.resize(self.plate3, (336, 170)) 422 | random_width, random_height = 400, 800 423 | random_R, random_G, random_B = random.randint(0, 255), random.randint(0, 255), random.randint(0, 255) 424 | background = np.zeros((random_width, random_height, 3), np.uint8) 425 | cv2.rectangle(background, (0, 0), (random_height, random_width), (random_R, random_G, random_B), -1) 426 | label = "Z" 427 | 428 | # row -> y , col -> x 429 | row, col = 8, 78 430 | 431 | # number 1 432 | rand_int = random.randint(0, 9) 433 | label += self.number_list_g[rand_int] 434 | Plate[row:row + 65, col:col + 60, :] = number1[rand_int] 435 | col += 60 436 | 437 | # number 2 438 | rand_int = random.randint(0, 9) 439 | label += self.number_list_g[rand_int] 440 | Plate[row:row + 65, col:col + 60, :] = number1[rand_int] 441 | col += 60 442 | 443 | # character 3 444 | label += self.char_list_g[i%37] 445 | Plate[row:row + 65, col:col + 60, :] = char[i%37] 446 | row, col = 75, 8 447 | 448 | # number 4 449 | rand_int = random.randint(0, 9) 450 | label += self.number_list_g[rand_int] 451 | Plate[row:row + 90, col:col + 80, :] = number2[rand_int] 452 | col += 80 453 | 454 | 455 | # number 5 456 | rand_int = random.randint(0, 9) 457 | label += self.number_list_g[rand_int] 458 | Plate[row:row + 90, col:col + 80, :] = number2[rand_int] 459 | col += 80 460 | 461 | # number 6 462 | rand_int = random.randint(0, 9) 463 | label += self.number_list_g[rand_int] 464 | Plate[row:row + 90, col:col + 80, :] = number2[rand_int] 465 | col += 80 466 | 467 | # number 7 468 | rand_int = random.randint(0, 9) 469 | label += self.number_list_g[rand_int] 470 | Plate[row:row + 90, col:col + 80, :] = number2[rand_int] 471 | 472 | s_width, s_height = int((400 - 170) / 2), int((800 - 336) / 2) 473 | background[s_width:170 + s_width, s_height:336 + s_height, :] = Plate 474 | 475 | background = image_augmentation(background, type2=True) 476 | 477 | if save: 478 | cv2.imwrite(self.save_path + label + ".jpg", background) 479 | else: 480 | cv2.imshow(label, background) 481 | cv2.waitKey(0) 482 | cv2.destroyAllWindows() 483 | 484 | 485 | parser = argparse.ArgumentParser() 486 | parser.add_argument("-i", "--img_dir", help="save image directory", 487 | type=str, default="../CRNN/DB/") 488 | parser.add_argument("-n", "--num", help="number of image", 489 | type=int) 490 | parser.add_argument("-s", "--save", help="save or imshow", 491 | type=bool, default=True) 492 | args = parser.parse_args() 493 | 494 | 495 | img_dir = args.img_dir 496 | A = ImageGenerator(img_dir) 497 | 498 | num_img = args.num 499 | Save = args.save 500 | 501 | A.Type_1(num_img, save=Save) 502 | print("Type 1 finish") 503 | A.Type_2(num_img, save=Save) 504 | print("Type 2 finish") 505 | A.Type_3(num_img, save=Save) 506 | print("Type 3 finish") 507 | A.Type_4(num_img, save=Save) 508 | print("Type 4 finish") 509 | A.Type_5(num_img, save=Save) 510 | print("Type 5 finish") 511 | -------------------------------------------------------------------------------- /Generator_augmentation.py: -------------------------------------------------------------------------------- 1 | import os, random 2 | import cv2 3 | import numpy as np 4 | import argparse 5 | 6 | def image_augmentation(img, ang_range=6, shear_range=3, trans_range=3): 7 | # Rotation 8 | ang_rot = np.random.uniform(ang_range) - ang_range / 2 9 | rows, cols, ch = img.shape 10 | Rot_M = cv2.getRotationMatrix2D((cols / 2, rows / 2), ang_rot, 0.9) 11 | 12 | # Translation 13 | tr_x = trans_range * np.random.uniform() - trans_range / 2 14 | tr_y = trans_range * np.random.uniform() - trans_range / 2 15 | Trans_M = np.float32([[1, 0, tr_x], [0, 1, tr_y]]) 16 | 17 | # Shear 18 | pts1 = np.float32([[5, 5], [20, 5], [5, 20]]) 19 | 20 | pt1 = 5 + shear_range * np.random.uniform() - shear_range / 2 21 | pt2 = 20 + shear_range * np.random.uniform() - shear_range / 2 22 | pts2 = np.float32([[pt1, 5], [pt2, pt1], [5, pt2]]) 23 | shear_M = cv2.getAffineTransform(pts1, pts2) 24 | 25 | img = cv2.warpAffine(img, Rot_M, (cols, rows)) 26 | img = cv2.warpAffine(img, Trans_M, (cols, rows)) 27 | img = cv2.warpAffine(img, shear_M, (cols, rows)) 28 | 29 | # Brightness 30 | img = cv2.cvtColor(img, cv2.COLOR_RGB2HSV) 31 | img = np.array(img, dtype=np.float64) 32 | random_bright = .4 + np.random.uniform() 33 | img[:, :, 2] = img[:, :, 2] * random_bright 34 | img[:, :, 2][img[:, :, 2] > 255] = 255 35 | img = np.array(img, dtype=np.uint8) 36 | img = cv2.cvtColor(img, cv2.COLOR_HSV2RGB) 37 | 38 | # Blur 39 | blur_value = random.randint(0,5) * 2 + 1 40 | img = cv2.blur(img,(blur_value, blur_value)) 41 | 42 | return img 43 | 44 | 45 | class ImageGenerator: 46 | def __init__(self, save_path): 47 | self.save_path = save_path 48 | # Plate 49 | self.plate = cv2.imread("plate.jpg") 50 | self.plate2 = cv2.imread("plate_y.jpg") 51 | self.plate3 = cv2.imread("plate_g.jpg") 52 | 53 | # loading Number ==================== white-one-line ========================== 54 | file_path = "./num/" 55 | file_list = os.listdir(file_path) 56 | self.Number = list() 57 | self.number_list = list() 58 | for file in file_list: 59 | img_path = os.path.join(file_path, file) 60 | img = cv2.imread(img_path) 61 | self.Number.append(img) 62 | self.number_list.append(file[0:-4]) 63 | 64 | # loading Char 65 | file_path = "./char1/" 66 | file_list = os.listdir(file_path) 67 | self.char_list = list() 68 | self.Char1 = list() 69 | for file in file_list: 70 | img_path = os.path.join(file_path, file) 71 | img = cv2.imread(img_path) 72 | self.Char1.append(img) 73 | self.char_list.append(file[0:-4]) 74 | 75 | # loading Number ==================== yellow-two-line ========================== 76 | file_path = "./num_y/" 77 | file_list = os.listdir(file_path) 78 | self.Number_y = list() 79 | self.number_list_y = list() 80 | for file in file_list: 81 | img_path = os.path.join(file_path, file) 82 | img = cv2.imread(img_path) 83 | self.Number_y.append(img) 84 | self.number_list_y.append(file[0:-4]) 85 | 86 | # loading Char 87 | file_path = "./char1_y/" 88 | file_list = os.listdir(file_path) 89 | self.char_list_y = list() 90 | self.Char1_y = list() 91 | for file in file_list: 92 | img_path = os.path.join(file_path, file) 93 | img = cv2.imread(img_path) 94 | self.Char1_y.append(img) 95 | self.char_list_y.append(file[0:-4]) 96 | 97 | # loading Resion 98 | file_path = "./region_y/" 99 | file_list = os.listdir(file_path) 100 | self.Resion_y = list() 101 | self.resion_list_y = list() 102 | for file in file_list: 103 | img_path = os.path.join(file_path, file) 104 | img = cv2.imread(img_path) 105 | self.Resion_y.append(img) 106 | self.resion_list_y.append(file[0:-4]) 107 | # ========================================================================= 108 | 109 | # loading Number ==================== green-two-line ========================== 110 | file_path = "./num_g/" 111 | file_list = os.listdir(file_path) 112 | self.Number_g = list() 113 | self.number_list_g = list() 114 | for file in file_list: 115 | img_path = os.path.join(file_path, file) 116 | img = cv2.imread(img_path) 117 | self.Number_g.append(img) 118 | self.number_list_g.append(file[0:-4]) 119 | 120 | # loading Char 121 | file_path = "./char1_g/" 122 | file_list = os.listdir(file_path) 123 | self.char_list_g = list() 124 | self.Char1_g = list() 125 | for file in file_list: 126 | img_path = os.path.join(file_path, file) 127 | img = cv2.imread(img_path) 128 | self.Char1_g.append(img) 129 | self.char_list_g.append(file[0:-4]) 130 | 131 | # loading Resion 132 | file_path = "./region_g/" 133 | file_list = os.listdir(file_path) 134 | self.Resion_g = list() 135 | self.resion_list_g = list() 136 | for file in file_list: 137 | img_path = os.path.join(file_path, file) 138 | img = cv2.imread(img_path) 139 | self.Resion_g.append(img) 140 | self.resion_list_g.append(file[0:-4]) 141 | # ========================================================================= 142 | 143 | 144 | def Type_1(self, num, save=False): 145 | number = [cv2.resize(number, (56, 83)) for number in self.Number] 146 | char = [cv2.resize(char1, (60, 83)) for char1 in self.Char1] 147 | 148 | for i, Iter in enumerate(range(num)): 149 | Plate = cv2.resize(self.plate, (520, 110)) 150 | random_width = random.randint(140, 230) 151 | random_height = random.randint(550, 720) 152 | random_R, random_G, random_B = random.randint(0,255), random.randint(0,255), random.randint(0,255) 153 | background = np.zeros((random_width, random_height, 3), np.uint8) 154 | cv2.rectangle(background, (0, 0), (random_height, random_width), (random_R, random_G, random_B), -1) 155 | 156 | label = "Z" 157 | # row -> y , col -> x 158 | row, col = 13, 35 # row + 83, col + 56 159 | # number 1 160 | rand_int = random.randint(0, 9) 161 | label += self.number_list[rand_int] 162 | Plate[row:row + 83, col:col + 56, :] = number[rand_int] 163 | col += 56 164 | 165 | # number 2 166 | rand_int = random.randint(0, 9) 167 | label += self.number_list[rand_int] 168 | Plate[row:row + 83, col:col + 56, :] = number[rand_int] 169 | col += 56 170 | 171 | # character 3 172 | label += self.char_list[i%37] 173 | Plate[row:row + 83, col:col + 60, :] = char[i%37] 174 | col += (60 + 36) 175 | 176 | # number 4 177 | rand_int = random.randint(0, 9) 178 | label += self.number_list[rand_int] 179 | Plate[row:row + 83, col:col + 56, :] = number[rand_int] 180 | col += 56 181 | 182 | # number 5 183 | rand_int = random.randint(0, 9) 184 | label += self.number_list[rand_int] 185 | Plate[row:row + 83, col:col + 56, :] = number[rand_int] 186 | col += 56 187 | 188 | # number 6 189 | rand_int = random.randint(0, 9) 190 | label += self.number_list[rand_int] 191 | Plate[row:row + 83, col:col + 56, :] = number[rand_int] 192 | col += 56 193 | 194 | # number 7 195 | rand_int = random.randint(0, 9) 196 | label += self.number_list[rand_int] 197 | Plate[row:row + 83, col:col + 56, :] = number[rand_int] 198 | col += 56 199 | 200 | random_w = random.randint(0, random_width - 110) 201 | random_h = random.randint(0, random_height - 520) 202 | background[random_w:110+random_w, random_h:520+random_h, :] = Plate 203 | background = image_augmentation(background) 204 | 205 | if save: 206 | cv2.imwrite(self.save_path + label + ".jpg", background) 207 | else: 208 | cv2.imshow(label, background) 209 | cv2.waitKey(0) 210 | cv2.destroyAllWindows() 211 | 212 | def Type_2(self, num, save=False): 213 | number = [cv2.resize(number, (45, 83)) for number in self.Number] 214 | char = [cv2.resize(char1, (49, 70)) for char1 in self.Char1] 215 | for i, Iter in enumerate(range(num)): 216 | Plate = cv2.resize(self.plate, (355, 155)) 217 | random_width = random.randint(185, 275) 218 | random_height = random.randint(380, 555) 219 | random_R, random_G, random_B = random.randint(0, 255), random.randint(0, 255), random.randint(0, 255) 220 | background = np.zeros((random_width, random_height, 3), np.uint8) 221 | cv2.rectangle(background, (0, 0), (random_height, random_width), (random_R, random_G, random_B), -1) 222 | 223 | label = "Z" 224 | row, col = 46, 10 # row + 83, col + 56 225 | 226 | # number 1 227 | rand_int = random.randint(0, 9) 228 | label += self.number_list[rand_int] 229 | Plate[row:row + 83, col:col + 45, :] = number[rand_int] 230 | col += 45 231 | 232 | # number 2 233 | rand_int = random.randint(0, 9) 234 | label += self.number_list[rand_int] 235 | Plate[row:row + 83, col:col + 45, :] = number[rand_int] 236 | col += 45 237 | 238 | # number 3 239 | label += self.char_list[i%37] 240 | Plate[row + 12:row + 82, col + 2:col + 49 + 2, :] = char[i%37] 241 | col += 49 + 2 242 | 243 | # number 4 244 | rand_int = random.randint(0, 9) 245 | label += self.number_list[rand_int] 246 | Plate[row:row + 83, col + 2:col + 45 + 2, :] = number[rand_int] 247 | col += 45 + 2 248 | 249 | # number 5 250 | rand_int = random.randint(0, 9) 251 | label += self.number_list[rand_int] 252 | Plate[row:row + 83, col:col + 45, :] = number[rand_int] 253 | col += 45 254 | 255 | # number 6 256 | rand_int = random.randint(0, 9) 257 | label += self.number_list[rand_int] 258 | Plate[row:row + 83, col:col + 45, :] = number[rand_int] 259 | col += 45 260 | 261 | # number 7 262 | rand_int = random.randint(0, 9) 263 | label += self.number_list[rand_int] 264 | Plate[row:row + 83, col:col + 45, :] = number[rand_int] 265 | col += 45 266 | 267 | random_w = random.randint(0, random_width - 155) 268 | random_h = random.randint(0, random_height - 355) 269 | background[random_w:155 + random_w, random_h:355 + random_h, :] = Plate 270 | background = image_augmentation(background) 271 | 272 | if save: 273 | cv2.imwrite(self.save_path + label + ".jpg", background) 274 | else: 275 | cv2.imshow(label, background) 276 | cv2.waitKey(0) 277 | cv2.destroyAllWindows() 278 | 279 | def Type_3(self, num, save=False): 280 | number1 = [cv2.resize(number, (44, 60)) for number in self.Number_y] 281 | number2 = [cv2.resize(number, (64, 90)) for number in self.Number_y] 282 | resion = [cv2.resize(resion, (88, 60)) for resion in self.Resion_y] 283 | char = [cv2.resize(char1, (64, 62)) for char1 in self.Char1_y] 284 | 285 | for i, Iter in enumerate(range(num)): 286 | Plate = cv2.resize(self.plate2, (336, 170)) 287 | random_width = random.randint(200, 290) 288 | random_height = random.randint(360, 536) 289 | random_R, random_G, random_B = random.randint(0, 255), random.randint(0, 255), random.randint(0, 255) 290 | background = np.zeros((random_width, random_height, 3), np.uint8) 291 | cv2.rectangle(background, (0, 0), (random_height, random_width), (random_R, random_G, random_B), -1) 292 | 293 | label = str() 294 | # row -> y , col -> x 295 | row, col = 8, 76 296 | 297 | # resion 298 | label += self.resion_list_y[i % 16] 299 | Plate[row:row + 60, col:col + 88, :] = resion[i % 16] 300 | col += 88 + 8 301 | 302 | # number 1 303 | rand_int = random.randint(0, 9) 304 | label += self.number_list_y[rand_int] 305 | Plate[row:row + 60, col:col + 44, :] = number1[rand_int] 306 | col += 44 307 | 308 | # number 2 309 | rand_int = random.randint(0, 9) 310 | label += self.number_list_y[rand_int] 311 | Plate[row:row + 60, col:col + 44, :] = number1[rand_int] 312 | 313 | row, col = 72, 8 314 | 315 | # character 3 316 | label += self.char_list_y[i % 37] 317 | Plate[row:row + 62, col:col + 64, :] = char[i % 37] 318 | col += 64 319 | 320 | # number 4 321 | rand_int = random.randint(0, 9) 322 | label += self.number_list_y[rand_int] 323 | Plate[row:row + 90, col:col + 64, :] = number2[rand_int] 324 | col += 64 325 | 326 | # number 5 327 | rand_int = random.randint(0, 9) 328 | label += self.number_list_y[rand_int] 329 | Plate[row:row + 90, col:col + 64, :] = number2[rand_int] 330 | col += 64 331 | 332 | # number 6 333 | rand_int = random.randint(0, 9) 334 | label += self.number_list_y[rand_int] 335 | Plate[row:row + 90, col:col + 64, :] = number2[rand_int] 336 | col += 64 337 | 338 | # number 7 339 | rand_int = random.randint(0, 9) 340 | label += self.number_list_y[rand_int] 341 | Plate[row:row + 90, col:col + 64, :] = number2[rand_int] 342 | 343 | s_width, s_height = int((random_width - 170) / 2), int((random_height - 336) / 2) 344 | background[s_width:170 + s_width, s_height:336 + s_height, :] = Plate 345 | background = image_augmentation(background) 346 | 347 | if save: 348 | cv2.imwrite(self.save_path + label + ".jpg", background) 349 | else: 350 | cv2.imshow(label, background) 351 | cv2.waitKey(0) 352 | cv2.destroyAllWindows() 353 | 354 | def Type_4(self, num, save=False): 355 | number1 = [cv2.resize(number, (44, 60)) for number in self.Number_g] 356 | number2 = [cv2.resize(number, (64, 90)) for number in self.Number_g] 357 | resion = [cv2.resize(resion, (88, 60)) for resion in self.Resion_g] 358 | char = [cv2.resize(char1, (64, 62)) for char1 in self.Char1_g] 359 | 360 | for i, Iter in enumerate(range(num)): 361 | Plate = cv2.resize(self.plate3, (336, 170)) 362 | random_width = random.randint(200, 290) 363 | random_height = random.randint(360, 536) 364 | random_R, random_G, random_B = random.randint(0, 255), random.randint(0, 255), random.randint(0, 255) 365 | background = np.zeros((random_width, random_height, 3), np.uint8) 366 | cv2.rectangle(background, (0, 0), (random_height, random_width), (random_R, random_G, random_B), -1) 367 | 368 | label = str() 369 | # row -> y , col -> x 370 | row, col = 8, 76 371 | 372 | # resion 373 | label += self.resion_list_g[i % 16] 374 | Plate[row:row + 60, col:col + 88, :] = resion[i % 16] 375 | col += 88 + 8 376 | 377 | # number 1 378 | rand_int = random.randint(0, 9) 379 | label += self.number_list_g[rand_int] 380 | Plate[row:row + 60, col:col + 44, :] = number1[rand_int] 381 | col += 44 382 | 383 | # number 2 384 | rand_int = random.randint(0, 9) 385 | label += self.number_list_g[rand_int] 386 | Plate[row:row + 60, col:col + 44, :] = number1[rand_int] 387 | 388 | row, col = 72, 8 389 | 390 | # character 3 391 | label += self.char_list_g[i % 37] 392 | Plate[row:row + 62, col:col + 64, :] = char[i % 37] 393 | col += 64 394 | 395 | # number 4 396 | rand_int = random.randint(0, 9) 397 | label += self.number_list_g[rand_int] 398 | Plate[row:row + 90, col:col + 64, :] = number2[rand_int] 399 | col += 64 400 | 401 | # number 5 402 | rand_int = random.randint(0, 9) 403 | label += self.number_list_g[rand_int] 404 | Plate[row:row + 90, col:col + 64, :] = number2[rand_int] 405 | col += 64 406 | 407 | # number 6 408 | rand_int = random.randint(0, 9) 409 | label += self.number_list_g[rand_int] 410 | Plate[row:row + 90, col:col + 64, :] = number2[rand_int] 411 | col += 64 412 | 413 | # number 7 414 | rand_int = random.randint(0, 9) 415 | label += self.number_list_g[rand_int] 416 | Plate[row:row + 90, col:col + 64, :] = number2[rand_int] 417 | 418 | s_width, s_height = int((random_width - 170) / 2), int((random_height - 336) / 2) 419 | background[s_width:170 + s_width, s_height:336 + s_height, :] = Plate 420 | background = image_augmentation(background) 421 | 422 | if save: 423 | cv2.imwrite(self.save_path + label + ".jpg", background) 424 | else: 425 | cv2.imshow(label, background) 426 | cv2.waitKey(0) 427 | cv2.destroyAllWindows() 428 | 429 | def Type_5(self, num, save=False): 430 | number1 = [cv2.resize(number, (60, 65)) for number in self.Number_g] 431 | number2 = [cv2.resize(number, (80, 90)) for number in self.Number_g] 432 | char = [cv2.resize(char1, (60, 65)) for char1 in self.Char1_g] 433 | 434 | for i, Iter in enumerate(range(num)): 435 | Plate = cv2.resize(self.plate3, (336, 170)) 436 | random_width = random.randint(200, 290) 437 | random_height = random.randint(360, 536) 438 | random_R, random_G, random_B = random.randint(0, 255), random.randint(0, 255), random.randint(0, 255) 439 | background = np.zeros((random_width, random_height, 3), np.uint8) 440 | cv2.rectangle(background, (0, 0), (random_height, random_width), (random_R, random_G, random_B), -1) 441 | label = "Z" 442 | 443 | # row -> y , col -> x 444 | row, col = 8, 78 445 | 446 | # number 1 447 | rand_int = random.randint(0, 9) 448 | label += self.number_list_g[rand_int] 449 | Plate[row:row + 65, col:col + 60, :] = number1[rand_int] 450 | col += 60 451 | 452 | # number 2 453 | rand_int = random.randint(0, 9) 454 | label += self.number_list_g[rand_int] 455 | Plate[row:row + 65, col:col + 60, :] = number1[rand_int] 456 | col += 60 457 | 458 | # character 3 459 | label += self.char_list_g[i%37] 460 | Plate[row:row + 65, col:col + 60, :] = char[i%37] 461 | row, col = 75, 8 462 | 463 | # number 4 464 | rand_int = random.randint(0, 9) 465 | label += self.number_list_g[rand_int] 466 | Plate[row:row + 90, col:col + 80, :] = number2[rand_int] 467 | col += 80 468 | 469 | 470 | # number 5 471 | rand_int = random.randint(0, 9) 472 | label += self.number_list_g[rand_int] 473 | Plate[row:row + 90, col:col + 80, :] = number2[rand_int] 474 | col += 80 475 | 476 | # number 6 477 | rand_int = random.randint(0, 9) 478 | label += self.number_list_g[rand_int] 479 | Plate[row:row + 90, col:col + 80, :] = number2[rand_int] 480 | col += 80 481 | 482 | # number 7 483 | rand_int = random.randint(0, 9) 484 | label += self.number_list_g[rand_int] 485 | Plate[row:row + 90, col:col + 80, :] = number2[rand_int] 486 | 487 | random_w = random.randint(0, random_width - 170) 488 | random_h = random.randint(0, random_height - 336) 489 | background[random_w:170 + random_w, random_h:336 + random_h, :] = Plate 490 | 491 | background = image_augmentation(background) 492 | 493 | if save: 494 | cv2.imwrite(self.save_path + label + ".jpg", background) 495 | else: 496 | cv2.imshow(label, background) 497 | cv2.waitKey(0) 498 | cv2.destroyAllWindows() 499 | 500 | parser = argparse.ArgumentParser() 501 | parser.add_argument("-i", "--img_dir", help="save image directory", 502 | type=str, default="../CRNN/DB/") 503 | parser.add_argument("-n", "--num", help="number of image", 504 | type=int) 505 | parser.add_argument("-s", "--save", help="save or imshow", 506 | type=bool, default=True) 507 | args = parser.parse_args() 508 | 509 | 510 | img_dir = args.img_dir 511 | A = ImageGenerator(img_dir) 512 | 513 | num_img = args.num 514 | Save = args.save 515 | 516 | A.Type_1(num_img, save=Save) 517 | print("Type 1 finish") 518 | A.Type_2(num_img, save=Save) 519 | print("Type 2 finish") 520 | A.Type_3(num_img, save=Save) 521 | print("Type 3 finish") 522 | A.Type_4(num_img, save=Save) 523 | print("Type 4 finish") 524 | A.Type_5(num_img, save=Save) 525 | print("Type 5 finish") 526 | --------------------------------------------------------------------------------