Exemplo n.º 1
0
        time = (time.time() - start)
        iterations += 1

        """
        src = cv2.cvtColor(src, cv2.COLOR_BGR2RGB)
        draw(src, objects)
        if cvxhull is not None:
            cv2.drawContours(
                src, [cvxhull], -1, (255, 255, 255), 3, cv2.LINE_8)
        cv2.line(src, (itw + 320, 0), (itw + 320, 480), (0, 0, 0), 3)
        src = cv2.cvtColor(src, cv2.COLOR_RGB2BGR)
        cv2.putText(
            src, '{:.1f}fps'.format(n / total), (0, 20),
            cv2.FONT_HERSHEY_PLAIN, 1.0, (255, 255, 255))
        cv2.imwrite('{}.jpg'.format(x), src)
        """

        # Obstacle avoidance
        itw = in_the_way(objects)

        drivers.LED2.on()
        if(in_the_way(objects) != 0):
            drivers.move(drivers.RobotState(drivers.TURN, -1 * math.pi * 0.25))
        else:
            drivers.move(drivers.RobotState(drivers.DRIVE, 5))
        drivers.LED2.off()

    print("{} frames computed in {}s ({}fps)".format(n, total, n / total))

    camera.close()