Spaces:
Runtime error
Runtime error
Niv Sardi
commited on
Commit
·
e34b2c2
1
Parent(s):
60ec487
fix debug lines leaking into main images
Browse filesSigned-off-by: Niv Sardi <[email protected]>
- python/imtool.py +9 -6
python/imtool.py
CHANGED
|
@@ -74,6 +74,7 @@ def crop(id, fn, logos):
|
|
| 74 |
pathlib.Path(txt_out).mkdir(parents=True, exist_ok=True)
|
| 75 |
|
| 76 |
im = cv2.imread(fn)
|
|
|
|
| 77 |
|
| 78 |
(h, w, c) = im.shape
|
| 79 |
(tw, th) = (min(w, TILE_SIZE), min(h, TILE_SIZE))
|
|
@@ -102,7 +103,7 @@ def crop(id, fn, logos):
|
|
| 102 |
start = floor_point(f.x, f.y)
|
| 103 |
end = floor_point(f.x + f.w, f.y + f.h)
|
| 104 |
|
| 105 |
-
|
| 106 |
li = []
|
| 107 |
for l in logos:
|
| 108 |
def intersect():
|
|
@@ -139,6 +140,7 @@ def crop(id, fn, logos):
|
|
| 139 |
c = (255, 0, 0)
|
| 140 |
|
| 141 |
nim = im[start[1]:end[1], start[0]:end[0]]
|
|
|
|
| 142 |
img_name =f"{img_out}/{basename}-x{x}y{y}.jpg"
|
| 143 |
txt_name =f"{txt_out}/{basename}-x{x}y{y}.txt"
|
| 144 |
|
|
@@ -146,13 +148,14 @@ def crop(id, fn, logos):
|
|
| 146 |
if len(li):
|
| 147 |
with open(txt_name, 'w') as f:
|
| 148 |
for p in li:
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
|
|
|
|
|
|
|
|
|
| 152 |
c,
|
| 153 |
5)
|
| 154 |
-
cx = p.w/2 + p.x
|
| 155 |
-
cy = p.h/2 + p.y
|
| 156 |
|
| 157 |
a = f"{int(id)} {cx/TILE_SIZE} {cy/TILE_SIZE} {p.w/TILE_SIZE} {p.h/TILE_SIZE}\n"
|
| 158 |
f.write(a)
|
|
|
|
| 74 |
pathlib.Path(txt_out).mkdir(parents=True, exist_ok=True)
|
| 75 |
|
| 76 |
im = cv2.imread(fn)
|
| 77 |
+
rim = cv2.imread(fn)
|
| 78 |
|
| 79 |
(h, w, c) = im.shape
|
| 80 |
(tw, th) = (min(w, TILE_SIZE), min(h, TILE_SIZE))
|
|
|
|
| 103 |
start = floor_point(f.x, f.y)
|
| 104 |
end = floor_point(f.x + f.w, f.y + f.h)
|
| 105 |
|
| 106 |
+
rim = cv2.rectangle(rim, start, end, color, 10)
|
| 107 |
li = []
|
| 108 |
for l in logos:
|
| 109 |
def intersect():
|
|
|
|
| 140 |
c = (255, 0, 0)
|
| 141 |
|
| 142 |
nim = im[start[1]:end[1], start[0]:end[0]]
|
| 143 |
+
rnim = rim[start[1]:end[1], start[0]:end[0]]
|
| 144 |
img_name =f"{img_out}/{basename}-x{x}y{y}.jpg"
|
| 145 |
txt_name =f"{txt_out}/{basename}-x{x}y{y}.txt"
|
| 146 |
|
|
|
|
| 148 |
if len(li):
|
| 149 |
with open(txt_name, 'w') as f:
|
| 150 |
for p in li:
|
| 151 |
+
cx = p.x
|
| 152 |
+
cy = p.y
|
| 153 |
+
|
| 154 |
+
dim = cv2.rectangle(rnim,
|
| 155 |
+
floor_point(cx - p.w/2, cy - p.h/2),
|
| 156 |
+
floor_point(cx + p.w/2, cy + p.h/2),
|
| 157 |
c,
|
| 158 |
5)
|
|
|
|
|
|
|
| 159 |
|
| 160 |
a = f"{int(id)} {cx/TILE_SIZE} {cy/TILE_SIZE} {p.w/TILE_SIZE} {p.h/TILE_SIZE}\n"
|
| 161 |
f.write(a)
|