This repository has been archived by the owner on Mar 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
main.py
123 lines (84 loc) · 3.09 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
@File : main.py
@License : (C)Copyright 2020
@Modify Time @Author @Version @Desciption
---------------- ------- -------- -----------
2020-07-01 14:02 yuyang 1.0 None
'''
# THIS FILE IS PART OF fakeCLP PROJECT
from core.template import Blue440x140, Yellow440x140, Green480x140, Yellow440x220
from core.augment import *
from core.utils import *
import os
import shutil
import tqdm
dir_path = 'fakeclp'
if os.path.isdir(dir_path):
shutil.rmtree(dir_path)
os.mkdir(dir_path)
os.mkdir(os.path.join(dir_path, 'yellow440x220'))
os.mkdir(os.path.join(dir_path, 'blue440x140'))
os.mkdir(os.path.join(dir_path, 'yellow440x140'))
os.mkdir(os.path.join(dir_path, 'green480x140'))
for _ in tqdm.tqdm(range(5000)):
code, plate = Yellow440x220()()
background = Background(width=1100, height=500)()
plate = random_distort(plate)
background = random_distort(background)
background = random_rotate(background)
img = putPatchOn(plate, background)
h, w = img.shape[:2]
img = randon_crop_and_zoom(img, (w, h))
img = random_perspective(img)
img = random_blur(img)
img = random_add_smu(img)
# cv2.imshow('img', img)
# cv2.waitKey()
cv_imwrite(os.path.join(os.path.join(dir_path, 'yellow440x220'), '{}.jpg'.format(code)), img)
for _ in tqdm.tqdm(range(5000)):
code, plate = Blue440x140()()
background = Background(width=1100, height=300)()
plate = random_distort(plate)
background = random_distort(background)
background = random_rotate(background)
img = putPatchOn(plate, background)
h, w = img.shape[:2]
img = randon_crop_and_zoom(img, (w, h))
img = random_perspective(img)
img = random_blur(img)
img = random_add_smu(img)
# cv2.imshow('img', img)
# cv2.waitKey()
cv_imwrite(os.path.join(os.path.join(dir_path, 'blue440x140'), '{}.jpg'.format(code)), img)
for _ in tqdm.tqdm(range(5000)):
code, plate = Yellow440x140()()
background = Background(width=1100, height=300)()
plate = random_distort(plate)
background = random_distort(background)
background = random_rotate(background)
img = putPatchOn(plate, background)
h, w = img.shape[:2]
img = randon_crop_and_zoom(img, (w, h))
img = random_perspective(img)
img = random_blur(img)
img = random_add_smu(img)
# cv2.imshow('img', img)
# cv2.waitKey()
cv_imwrite(os.path.join(os.path.join(dir_path, 'yellow440x140'), '{}.jpg'.format(code)), img)
for _ in tqdm.tqdm(range(5000)):
code, plate = Green480x140()()
background = Background(width=1100, height=300)()
plate = random_distort(plate)
background = random_distort(background)
background = random_rotate(background)
img = putPatchOn(plate, background)
h, w = img.shape[:2]
img = randon_crop_and_zoom(img, (w, h))
img = random_perspective(img)
img = random_blur(img)
img = random_add_smu(img)
# cv2.imshow('img', img)
# cv2.waitKey()
cv_imwrite(os.path.join(os.path.join(dir_path, 'green480x140'), '{}.jpg'.format(code)), img)