navigation.py 文件源码

python
阅读 30 收藏 0 点赞 0 评论 0

项目:srcsim2017 作者: ZarjRobotics 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号