def _generate_negative_patches(self, negative_image_files, window_size, step, pyramid_scale, threshold_prob):
widgets = ["Generating negative samples which represent high probability: ",
progressbar.Percentage(), " ", progressbar.Bar(), " ", progressbar.ETA()]
pbar = progressbar.ProgressBar(maxval=len(negative_image_files), widgets=widgets).start()
for i, image_file in enumerate(negative_image_files):
image = cv2.imread(image_file)
image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
# detect objects in the image
(boxes, probs) = self.run(image,
window_size, step, pyramid_scale,
threshold_prob,
do_nms=False,
show_result=False,
show_operation=False)
pbar.update(i)
for (y1, y2, x1, x2), prob in zip(boxes, probs):
negative_patch = cv2.resize(image[y1:y2, x1:x2], (window_size[1], window_size[0]), interpolation=cv2.INTER_AREA)
yield negative_patch, prob
pbar.finish()
# todo: code review
评论列表
文章目录