-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_on_images2.py
95 lines (73 loc) · 2.94 KB
/
test_on_images2.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
import pickle, glob
import matplotlib.image as mpimg
import matplotlib.pyplot as plt
import numpy as np
from lesson_lib import *
# PARMAS====================================================
isJpeg = True
# ====================================================
with open('Models/model_YUV0_hog_hist_spa.pkl', 'rb') as f:
svc, X_scaler, params = pickle.load(f)
orient = params['orient']
pix_per_cell = params['pix_per_cell']
cell_per_block = params['cell_per_block']
hog_depth = params['hog_depth']
useColor = params['useColor']
useSpatial = params['useSpatial']
colorSpace = 'YUV'#params['colorSpace']
spatial_size = params['spatial_size']
hist_bins = params['hist_bins']
for image in glob.glob('test_images/*.jpg'):
image = mpimg.imread(image)
if isJpeg:
image = image.astype(np.float32) / 255.0
x_start_stop = [None, None]
y_start_stop = [390, None]
xy_overlap = [0.6, 0.5]
xy_window = [128, 128]
windows = slide_window(image,
x_start_stop=x_start_stop,
y_start_stop=y_start_stop,
xy_window=xy_window,
xy_overlap=xy_overlap)
x_start_stop = [None, None]
y_start_stop = [390, None]
xy_overlap = [0.6, 0.5]
xy_window = [96, 96]
windows += slide_window(image,
x_start_stop=x_start_stop,
y_start_stop=y_start_stop,
xy_window=xy_window,
xy_overlap=xy_overlap)
x_start_stop = [None, None]
y_start_stop = [390, None]
xy_overlap = [0.6, 0.5]
xy_window = [64, 64]
windows += slide_window(image,
x_start_stop=x_start_stop,
y_start_stop=y_start_stop,
xy_window=xy_window,
xy_overlap=xy_overlap)
x_start_stop = [None, None]
y_start_stop = [390, None]
xy_overlap = [0.6, 0.5]
xy_window = [96, 96]
windows += slide_window(image,
x_start_stop=x_start_stop,
y_start_stop=y_start_stop,
xy_window=xy_window,
xy_overlap=xy_overlap)
hot_windows = search_windows(image, windows, svc, X_scaler,
color_space=colorSpace,
spatial_size=spatial_size,
hist_bins=hist_bins,
orient=orient,
pix_per_cell=pix_per_cell,
cell_per_block=cell_per_block,
hog_channel=hog_depth,
spatial_feat=useSpatial,
hist_feat=useColor,
hog_feat=True)
draw_image = draw_boxes(image, hot_windows)
plt.imshow(draw_image)
plt.show()