def saveAverageImage(kitti_base, pos_labels, shape, fname, avg_num=None):
num_images = float(len(pos_labels))
avg_num = min(avg_num, num_images)
if avg_num is None:
avg_num = num_images
# avg_img = np.zeros((shape[0],shape[1],3), np.float32)
avg_img = np.zeros(shape, np.float32)
progressbar = ProgressBar('Averaging ' + fname, max=len(pos_labels))
num = 0
for label in pos_labels:
if num >= avg_num:
break
num += 1
progressbar.next()
sample = getCroppedSampleFromLabel(kitti_base, label)
# sample = np.float32(sample)
resized = resizeSample(sample, shape, label)
resized = auto_canny(resized)
resized = np.float32(resized)
avg_img = cv2.add(avg_img, resized / float(avg_num))
progressbar.finish()
cv2.imwrite(fname, avg_img)
评论列表
文章目录