def look_for_exit(self, image, debug=False, unwarped=True):
""" Look for an exit from our position """
for row in range(1, image.shape[0]/10):
img = image.copy()
base_row = (row * 10) + 5
image_dump = os.environ.get("ZARJ_IMAGE_DUMP")
markup = debug or (image_dump is not None)
output = self.figure_path(img, base_row, markup, True)
if output is not None and output['right'] is not None and\
output['left'] is not None:
real_distance = self.unwarp_perspective((image.shape[1]/2,
base_row))
if unwarped:
base_row = real_distance
if markup:
txt = "({0:.2f})".format(real_distance)
cv2.putText(img, txt, (0, img.shape[0]-10),
cv2.FONT_HERSHEY_SIMPLEX, 1, (255, 255, 255))
if debug:
name = "_exit_decision_"
cv2.namedWindow(name, cv2.WINDOW_NORMAL)
cv2.resizeWindow(name, 500, 250)
cv2.imshow(name, img)
cv2.waitKey(1)
if image_dump is not None:
cv2.imwrite(image_dump + '/exit_{0}.png'.format(
debug_sequence()), img)
if real_distance > 1.8:
log('Wait a second! An exit {} away is too far away'.format(
real_distance))
return None
return base_row
return None
评论列表
文章目录