-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
37 lines (28 loc) · 1.1 KB
/
Copy pathmain.py
File metadata and controls
37 lines (28 loc) · 1.1 KB
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
from tools import DataCropper
import time
import cv2
import matplotlib
import os
import os.path
from os import path
for obj in os.listdir(imdir):
if not obj.endswith('.xml') and path.exists(imdir + '/' + obj.replace('.jpg','.xml')):
a = DataCropper()
a.load(imdir + '/' + obj.replace('.jpg', '').replace('.JPG', ''))
y = a.get_maxmin()
c = a.get_boxes()
a.boxes = c
for item in c:
item.append(False)
yt = a.find_local(c, 640, .1)
b1 = yt[0]
for i in range(len(yt)):
print(i)
bigbox = a.maxmin(yt[i])
dict_format = [['vis', {'xmin': bigbox[0][0], 'ymin': bigbox[0][1], 'xmax': bigbox[1][0], 'ymax': bigbox[1][1]}]]
bnds = a.get_bounds(dict_format, upscaling=1.05, offset=20.0)
dx, dy = bigbox[1][0] - bigbox[0][0], bigbox[1][1] - bigbox[0][1]
pixels = dx * dy
if pixels >= 300 * 300 and dx/dy >= 0.6 and dx/dy < 1.67:
a.save_slice(bnds, yt[i], i, 'stfd_640')
time.sleep(0.01)