jupyter run for " labels = label(heatmap)" in search_classify.ipynb, Had a bug.
molyswu opened this issue · 1 comments
Hi,ksakmann!
jupyter run to" labels = label(heatmap)" in search_classify.ipynb, Had a bug as follows:
labels = label(heatmap)
labels = label(heatmap)
print(labels[1], 'cars found')
plt.imshow(labels[0], cmap='gray')
plt.show()
NameError Traceback (most recent call last)
in ()
----> 1 labels = label(heatmap)
2 print(labels[1], 'cars found')
3 plt.imshow(labels[0], cmap='gray')
4 plt.show()
NameError: name 'heatmap' is not defined
ERROR! Session/line number was not unique in database. History logging moved to new session 33
Thank you!
molyswu
ksakmann!
Jupyter run on this code all the time:
images = sorted(glob.glob('E:/study/123/Vehicle-Detection/CarND-Vehicle-Detection/heatmap/*.png'))
boxes = BoundingBoxes(n=6)
for file in images[0:6]:
image = mpimg.imread(file)
#image = image.astype(np.float32)/255
draw_image = np.copy(image)
t=time.time()
hot_windows,all_windows = search_all_scales(image)
t2 = time.time()
print(round(t2-t, 2), 'Seconds to search windows ...')
boxes.update(hot_windows)
#print(np.array(all_windows).shape)
window_img = draw_boxes(draw_image, hot_windows, color=(0, 0, 1), thick=4)
allwindows_img = draw_image
for ind,win_list in enumerate(all_windows):
if ind==0: color= (0,0,1)
if ind==1: color= (0,1,0)
if ind==2: color= (1,0,0)
if ind==3: color= (1,1,1)
allwindows_img = draw_boxes(allwindows_img, all_windows[ind], color=color, thick=6)
# Read in the last image shown above
heatmap = np.zeros_like(image[:,:,0]).astype(np.float)
heatmap = add_heat(heatmap, boxes.allboxes)
heatmap = apply_threshold(heatmap,3)
plt.figure()
# Plot the result
f, (ax1,ax2,ax3) = plt.subplots(1, 3, figsize=(24, 9))
f.tight_layout()
ax1.imshow(window_img)
ax1.set_title('Detected windows', fontsize=40)
ax2.imshow(allwindows_img)
ax2.set_title('All windows', fontsize=40)
ax3.imshow(heatmap)
ax3.set_title('Heatmap', fontsize=40)
plt.show()
0.7 Seconds to search windows ...
0.7 Seconds to search windows ...
0.69 Seconds to search windows ...
0.7 Seconds to search windows ...
0.7 Seconds to search windows ...
0.7 Seconds to search windows ...
labels = label(heatmap)
print(labels[1], 'cars found')
plt.imshow(labels[0], cmap='gray')
plt.show()
Thank you!