Beispiel #1
0
    def __init__(self, port="/dev/openmvcam"):
        self.port = port
        self.connected = False

        pyopenmv.disconnect()
        rospy.loginfo("Connecting...")
        for i in range(10):
            try:
                # opens CDC port.
                # Set small timeout when connecting
                pyopenmv.init(self.port, baudrate=921600, timeout=0.050)
                self.connected = True
                break
            except Exception as e:
                self.connected = False
                sleep(0.100)

        if not self.connected:
            rospy.logerr("Failed to connect to OpenMV's serial port.\n"
                        "Please install OpenMV's udev rules first:\n"
                        "sudo cp openmv/udev/50-openmv.rules /etc/udev/rules.d/\n"
                        "sudo udevadm control --reload-rules\n\n")
            return
        rospy.loginfo("Connected!")
        # Set higher timeout after connecting for lengthy transfers.
        pyopenmv.set_timeout(1*2)  # SD Cards can cause big hicups.
        pyopenmv.stop_script()
        pyopenmv.enable_fb(True)
        pyopenmv.exec_script(script)

        # init pub
        self.pub_image = rospy.Publisher("/image", Image, queue_size=10)

        # init thread
        self.running = False
        self.thread = Thread(target=self.run)
        self.thread.start()

        rospy.on_shutdown(self.shutdown)
Beispiel #2
0
def camera_connect():
    """
    Camera connection loop.
    """

    connected = False
    pyopenmv.disconnect()
    # try and connect
    for i in range(10):

        try:
            # opens CDC port.
            # Set small timeout when connecting
            pyopenmv.init(port_name, baudrate=921600, timeout=0.050)
            connected = True
            break
        except Exception as e:
            connected = False
            sleep(0.100)
    if not connected:
        print("Failed to connect to OpenMV's serial port.\n"
              "Please install OpenMV's udev rules first:\n"
              "sudo cp openmv/udev/50-openmv.rules /etc/udev/rules.d/\n"
              "sudo udevadm control --reload-rules\n\n")
        sys.exit(1)
    # Set higher timeout after connecting for lengthy transfers.
    pyopenmv.set_timeout(1 * 2)  # SD Cards can cause big hicups.
    pyopenmv.stop_script()
    pyopenmv.enable_fb(True)
    pyopenmv.exec_script(blob_script)

    # init screen
    running = True
    Clock = pygame.time.Clock()
    font = pygame.font.SysFont("monospace", 15)

    return running, Clock, font
Beispiel #3
0
while(True):
    img = sensor.snapshot()         # Take a picture and return the image.
    sensor.flush()
"""

# init pygame
pygame.init()

if len(sys.argv)!= 2:
    print ('usage: pyopenmv_fb.py <serial port>')
    sys.exit(1)

portname = sys.argv[1]
connected = False
pyopenmv.disconnect()
for i in range(10):
    try:
        # opens CDC port.
        # Set small timeout when connecting
        pyopenmv.init(portname, baudrate=921600, timeout=0.050)
        connected = True
        break
    except Exception as e:
        connected = False
        sleep(0.100)

if not connected:
    print ( "Failed to connect to OpenMV's serial port.\n"
            "Please install OpenMV's udev rules first:\n"
            "sudo cp openmv/udev/50-openmv.rules /etc/udev/rules.d/\n"
Beispiel #4
0
while(True):
    img = sensor.snapshot()         # Take a picture and return the image.
    sensor.flush()
"""

# init pygame
pygame.init()

if len(sys.argv)!= 2:
    print ('usage: pyopenmv_fb.py <serial port>')
    sys.exit(1)

portname = sys.argv[1]
connected = False
pyopenmv.disconnect()
for i in range(10):
    try:
        # opens CDC port.
        # Set small timeout when connecting
        pyopenmv.init(portname, baudrate=921600, timeout=0.050)
        connected = True
        break
    except Exception as e:
        connected = False
        sleep(0.100)

if not connected:
    print ( "Failed to connect to OpenMV's serial port.\n"
            "Please install OpenMV's udev rules first:\n"
            "sudo cp openmv/udev/50-openmv.rules /etc/udev/rules.d/\n"