Exemple #1
0
    def connect(self):
        self.terminal = self.builder.get_object('terminal')
        try:
            # open VCP and configure the terminal
            self.fd = os.open(self.config.get("main", "serial_port"), os.O_RDWR)
            self.terminal.reset(True, True)
            self.terminal.set_size(80,24)
            self.terminal.set_pty(self.fd)
        except Exception as e:
            self.show_message_dialog(gtk.MESSAGE_ERROR, "Failed to connect to OpenMV\n%s"%e)
            return

        try:
            # init openmv
            openmv.init()

            # interrupt any running code
            openmv.stop_script()
            sleep(0.1)
        except Exception as e:
            self.show_message_dialog(gtk.MESSAGE_ERROR, "Failed to connect to OpenMV\n%s"%e)
            return

        self.connected = True
        self._update_title()
        self.connect_button.set_sensitive(False)
        map(lambda x:x.set_sensitive(True), self.controls)
Exemple #2
0
 def do_connect(self):
     if not self.connected:
         self.connected = True
         try:
             # init OpenMV
             openmv.init()
             sleep(0.2)
             # interrupt any running code
             openmv.stop_script()
             sleep(0.2)
             # first, check to see if self.serial_port is in the list of enumerated ports
             # then try to open it. If that fails, or if the port isn't in the enumerated
             # list, then prompt the user for a port
             ports = []
             for p in list_ports.comports():
                 name = p[0]
                 try:
                     ser = Serial(name, 115200, timeout=1)
                     ser.close()
                     ports.append(p)
                 except (IOError, OSError):
                     pass
             print(ports)
             self.serial = Serial(self.serial_port, 115200, timeout=1)
             self.terminal.start(self.serial)
         except IOError as e:
             print('error connecting OpenMV Cam: %s' % e)
             self.connected = False
         else:
             self.update_ui()
             self.statusBar().showMessage('OpenMV Cam connected.')
             self.framebuffer.start_updater()
Exemple #3
0
    def connect(self):
        connected = False
        openmv.disconnect()
        for i in range(10):
            try:
                # opens CDC port.
                # Set small timeout when connecting
                openmv.init(self.config.get("main", "serial_port"),
                            baudrate=self.baudrate,
                            timeout=0.050)
                connected = True
                break
            except Exception as e:
                connected = False
                sleep(0.100)

        if not connected:
            if platform.system() == "Linux" and not os.path.isfile(UDEV_PATH):
                error_msg = (
                    "Failed to open serial port.\n"
                    "Please install OpenMV's udev rules first:\n\n"
                    "sudo cp openmv/udev/50-openmv.rules /etc/udev/rules.d/\n"
                    "sudo udevadm control --reload-rules\n\n")
            else:
                error_msg = ("Failed to open serial port.\n"
                             "Please check the preferences Dialog.\n")

            self.show_message_dialog(gtk.MESSAGE_ERROR,
                                     "%s%s" % (error_msg, e))
            return

        # Set higher timeout after connecting for lengthy transfers.
        openmv.set_timeout(1 * 2)  # SD Cards can cause big hicups.

        # check firmware version
        fw_ver = openmv.fw_version()
        self.fw_version = fw_ver
        ide_ver = (FIRMWARE_VERSION_MAJOR, FIRMWARE_VERSION_MINOR,
                   FIRMWARE_VERSION_PATCH)

        if (fw_ver[0] != FIRMWARE_VERSION_MAJOR
                or fw_ver[1] != FIRMWARE_VERSION_MINOR):
            self.connected = False
            self.show_message_dialog(
                gtk.MESSAGE_ERROR, "Firmware version mismatch!\n"
                "Please update the firmware image and/or the IDE!")
        else:
            self.connected = True
            self._update_title()
            map(lambda x: x.set_sensitive(True), self.controls)

            # Interrupt running code
            openmv.stop_script()

            # Enable Framebuffer
            openmv.enable_fb(True)

        # Disable connect button
        self.connect_button.set_sensitive(False)
Exemple #4
0
    def connect(self):
        try:
            # opens CDC port.
            openmv.init(self.config.get("main", "serial_port"), baudrate=self.baudrate, timeout=0.3)
        except Exception as e:
            # create fresh config if needed
            if platform.system() == "Linux" and not os.path.isfile(UDEV_PATH):
                error_msg = ("Failed to open serial port.\n"
                             "Please install OpenMV's udev rules first:\n\n"
                             "sudo cp openmv/udev/50-openmv.rules /etc/udev/rules.d/\n"
                             "sudo udevadm control --reload-rules\n\n")
            else:
                error_msg = ("Failed to open serial port.\n"
                             "Please check the preferences Dialog.\n")

            self.show_message_dialog(gtk.MESSAGE_ERROR,"%s%s"%(error_msg, e))

            return

        # add terminal update callback
        gobject.gobject.timeout_add(10, omvgtk.update_terminal)

        # check firmware version
        self.fw_mismatch = False
        fw_ver = openmv.fw_version()
        ide_ver = (FIRMWARE_VERSION_MAJOR,
                   FIRMWARE_VERSION_MINOR,
                   FIRMWARE_VERSION_PATCH)

        print("fw_version:" + str(fw_ver))
        print("ide_version:" + str(ide_ver))
        if (fw_ver[0] != FIRMWARE_VERSION_MAJOR):
            # If ABI versions don't match, nothing todo here...
            self.show_message_dialog(gtk.MESSAGE_ERROR,
                            "Firmware ABI version mismatch!\n"
                            "Please update the IDE and/or FW manually\n")
            return
        elif (FIRMWARE_VERSION_MINOR > fw_ver[1]
                or FIRMWARE_VERSION_PATCH > fw_ver[2]):
            self.fw_mismatch = True
            self.show_message_dialog(gtk.MESSAGE_ERROR,
                    "Firmware version mismatch!\n"
                    "An older firmware version has been detected.\n"
                    "Please update the firmware!")

        if (self.fw_mismatch):
            self.connected = True
            self.connect_button.set_sensitive(False)
            self.fwupdate_button.set_sensitive(True)
            return

        # interrupt any running code
        openmv.stop_script()

        self.connected = True
        self._update_title()
        self.connect_button.set_sensitive(False)
        map(lambda x:x.set_sensitive(True), self.controls)
    def connect(self):
        connected = False
        openmv.disconnect()
        for i in range(10):
            try:
                # opens CDC port.
                # Set small timeout when connecting
                openmv.init(self.config.get("main", "serial_port"), baudrate=self.baudrate, timeout=0.050)
                connected = True
                break
            except Exception as e:
                connected = False
                sleep(0.100)

        if not connected:
            if platform.system() == "Linux" and not os.path.isfile(UDEV_PATH):
                error_msg = ("Failed to open serial port.\n"
                             "Please install OpenMV's udev rules first:\n\n"
                             "sudo cp openmv/udev/50-openmv.rules /etc/udev/rules.d/\n"
                             "sudo udevadm control --reload-rules\n\n")
            else:
                error_msg = ("Failed to open serial port.\n"
                             "Please check the preferences Dialog.\n")

            self.show_message_dialog(gtk.MESSAGE_ERROR,"%s%s"%(error_msg, e))
            return

        # Set higher timeout after connecting for lengthy transfers.
        openmv.set_timeout(1*2) # SD Cards can cause big hicups.

        # check firmware version
        fw_ver = openmv.fw_version()
        self.fw_version = fw_ver
        ide_ver = (FIRMWARE_VERSION_MAJOR, FIRMWARE_VERSION_MINOR, FIRMWARE_VERSION_PATCH)

        if (fw_ver[0] != FIRMWARE_VERSION_MAJOR or fw_ver[1] != FIRMWARE_VERSION_MINOR):
            self.connected = False
            self.show_message_dialog(gtk.MESSAGE_ERROR,
                    "Firmware version mismatch!\n"
                    "Please update the firmware image and/or the IDE!")
        else:
            self.connected = True
            self._update_title()
            map(lambda x:x.set_sensitive(True), self.controls)

            # Interrupt running code
            openmv.stop_script()

            # Enable Framebuffer
            enable_fb_check = self.builder.get_object("enable_fb_check")
            self.fb_enabled = enable_fb_check.get_active()
            openmv.enable_fb(self.fb_enabled)

        # Disable connect button
        self.connect_button.set_sensitive(False)
Exemple #6
0
    def connect(self):
        init = False
        for i in range(0, 5):
            # init openmv
            init = openmv.init()
            if init:
                break
            sleep(0.200)

        if init == False:
            self.show_message_dialog(gtk.MESSAGE_ERROR, "Failed to connect to OpenMV")
            return

        # interrupt any running code
        openmv.stop_script()

        try:
            # open VCP and configure the terminal
            self.serial = serial.Serial(self.config.get("main", "serial_port"), 115200, timeout=0.001)
            gobject.gobject.idle_add(omvgtk.update_terminal)
        except Exception as e:
            self.show_message_dialog(gtk.MESSAGE_ERROR, "Failed to open serial port (check prefernces)\n%s"%e)
            return

        self.connected = True
        self._update_title()
        self.connect_button.set_sensitive(False)
        map(lambda x:x.set_sensitive(True), self.controls)
Exemple #7
0
    def connect(self):
        init = False
        for i in range(0, 5):
            # init openmv
            init = openmv.init()
            if init:
                break
            sleep(0.200)

        if init == False:
            self.show_message_dialog(gtk.MESSAGE_ERROR, "Failed to connect to OpenMV")
            return

        # interrupt any running code
        openmv.stop_script()

        try:
            # open VCP and configure the terminal
            self.serial = serial.Serial(self.config.get("main", "serial_port"), 115200, timeout=0.001)
            gobject.gobject.idle_add(omvgtk.update_terminal)
        except Exception as e:
            self.show_message_dialog(gtk.MESSAGE_ERROR, "Failed to open serial port (check prefernces)\n%s"%e)
            return

        self.connected = True
        self._update_title()
        self.connect_button.set_sensitive(False)
        map(lambda x:x.set_sensitive(True), self.controls)
Exemple #8
0
    def connect(self):
        try:
            # open VCP and configure the terminal
            self.serial = serial.Serial(self.config.get("main", "serial_port"), 12000000, timeout=0.1)
            gobject.gobject.idle_add(omvgtk.update_terminal)
        except Exception as e:
            self.show_message_dialog(gtk.MESSAGE_ERROR, "Failed to open serial port (check prefernces)\n%s"%e)
            return

        openmv.init(self.serial)
        # interrupt any running code
        openmv.stop_script()

        self.connected = True
        self._update_title()
        self.connect_button.set_sensitive(False)
        map(lambda x:x.set_sensitive(True), self.controls)
Exemple #9
0
    def connect(self):
        try:
            # open VCP and configure the terminal
            self.serial = serial.Serial(self.config.get("main", "serial_port"),
                                        self.baudrate,
                                        timeout=0.3)
            gobject.gobject.timeout_add(10, omvgtk.update_terminal)
        except Exception as e:
            # create fresh config if needed
            if platform.system() == "Linux" and not os.path.isfile(UDEV_PATH):
                error_msg = (
                    "Failed to open serial port.\n"
                    "Please install OpenMV's udev rules first:\n\n"
                    "sudo cp openmv/udev/50-openmv.rules /etc/udev/rules.d/\n"
                    "sudo udevadm control --reload-rules\n\n")
            else:
                error_msg = ("Failed to open serial port.\n"
                             "Please check the preferences Dialog.\n")

            self.show_message_dialog(gtk.MESSAGE_ERROR,
                                     "%s%s" % (error_msg, e))

            return

        openmv.init(self.serial)

        # check firmware version
        fw_ver = openmv.fw_version()
        print("fw_version:" + str(fw_ver))
        if (fw_ver[0] != FIRMWARE_VERSION_MAJOR):
            self.show_message_dialog(
                gtk.MESSAGE_ERROR,
                "Firmware version mismatch! Please upgrade the firmware")
            return

        # interrupt any running code
        openmv.stop_script()

        self.connected = True
        self._update_title()
        self.connect_button.set_sensitive(False)
        map(lambda x: x.set_sensitive(True), self.controls)
Exemple #10
0
    def __init__(self):
        #Set the Glade file
        self.builder = gtk.Builder()
        self.builder.add_from_file("openmv-ide.glade")

        sourceview = self.builder.get_object('gtksourceview')

        self.buffer = gtksourceview.Buffer()
        mgr = gtksourceview.style_scheme_manager_get_default()
        style_scheme = mgr.get_scheme('classic')
        if style_scheme:
            self.buffer.set_style_scheme(style_scheme)
        lang_manager = gtksourceview.language_manager_get_default()
        self.buffer.set_highlight_syntax(True)
        self.buffer.set_language(lang_manager.get_language("python"))
        self.buffer.set_text(ex_source)
        sourceview.set_buffer(self.buffer)

        self.terminal = self.builder.get_object('terminal')
        self.fd = os.open("/dev/ttyACM0", os.O_RDWR)
        self.terminal.set_size(80,24)
        self.terminal.set_pty(self.fd)

        self.framebuffer = self.builder.get_object("framebuffer_image")
        # status bar stuff
        self.statusbar = self.builder.get_object("statusbar")
        self.statusbar_ctx = self.statusbar.get_context_id("default")

        # init openmv
        openmv.init()

        #connect signals
        signals = {
            "on_execute_clicked" : self.execute_clicked,
            "on_stop_clicked" : self.stop_clicked,
            "on_top_window_destroy" : self.quit,
            "on_motion_notify": self.motion_notify,
            "on_button_press": self.button_pressed
        }
        self.builder.connect_signals(signals)
        self.window = self.builder.get_object("top_window")
Exemple #11
0
    def connect(self):
        try:
            # open VCP and configure the terminal
            self.serial = serial.Serial(self.config.get("main", "serial_port"),
                                        12000000,
                                        timeout=0.1)
            gobject.gobject.idle_add(omvgtk.update_terminal)
        except Exception as e:
            self.show_message_dialog(
                gtk.MESSAGE_ERROR,
                "Failed to open serial port (check prefernces)\n%s" % e)
            return

        openmv.init(self.serial)
        # interrupt any running code
        openmv.stop_script()

        self.connected = True
        self._update_title()
        self.connect_button.set_sensitive(False)
        map(lambda x: x.set_sensitive(True), self.controls)
    def task_init(self, state):
        openmv.disconnect()
        try:
            # Attempt to connect to bootloader
            openmv.init(self.port, baudrate=self.baud, timeout=0.050)
            if openmv.bootloader_start():
                openmv.set_timeout(1)
                state["next"] = self.task_erase
                state["bar"].set_text("Erasing...")
                self.cancel_button.set_sensitive(False)
        except Exception as e:
            openmv.disconnect()
            if self.flash_msg:
                state["bar"].set_text("Connecting to bootloader...\
                                       \n                              ")
            else:
                state["bar"].set_text("Connecting to bootloader...\
                                       \nDisconnect and re-connect cam!")
            self.flash_msg = self.flash_msg ^ 1
            sleep(0.100)

        return True
Exemple #13
0
    def task_init(self, state):
        openmv.disconnect()
        try:
            # Attempt to connect to bootloader
            openmv.init(self.port, baudrate=self.baud, timeout=0.050)
            if openmv.bootloader_start():
                openmv.set_timeout(1)
                state["next"] = self.task_erase
                state["bar"].set_text("Erasing...")
                self.cancel_button.set_sensitive(False)
        except Exception as e:
            openmv.disconnect()
            if self.flash_msg:
                state["bar"].set_text("Connecting to bootloader...\
                                       \n                              ")
            else:
                state["bar"].set_text("Connecting to bootloader...\
                                       \nDisconnect and re-connect cam!")
            self.flash_msg = self.flash_msg ^ 1
            sleep(0.100)

        return True
Exemple #14
0
    def connect(self):
        try:
            # open VCP and configure the terminal
            self.serial = serial.Serial(self.config.get("main", "serial_port"), self.baudrate, timeout=0.3)
            gobject.gobject.timeout_add(10, omvgtk.update_terminal)
        except Exception as e:
            # create fresh config if needed
            if platform.system() == "Linux" and not os.path.isfile(UDEV_PATH):
                error_msg = ("Failed to open serial port.\n"
                             "Please install OpenMV's udev rules first:\n\n"
                             "sudo cp openmv/udev/50-openmv.rules /etc/udev/rules.d/\n"
                             "sudo udevadm control --reload-rules\n\n")
            else:
                error_msg = ("Failed to open serial port.\n"
                             "Please check the preferences Dialog.\n")

            self.show_message_dialog(gtk.MESSAGE_ERROR,"%s%s"%(error_msg, e))

            return

        openmv.init(self.serial)

        # check firmware version
        fw_ver = openmv.fw_version()
        print("fw_version:" + str(fw_ver))
        if (fw_ver[0] != FIRMWARE_VERSION_MAJOR):
            self.show_message_dialog(gtk.MESSAGE_ERROR, "Firmware version mismatch! Please upgrade the firmware")
            return

        # interrupt any running code
        openmv.stop_script()

        self.connected = True
        self._update_title()
        self.connect_button.set_sensitive(False)
        map(lambda x:x.set_sensitive(True), self.controls)
Exemple #15
0
#!/usr/bin/env python
import sys
import usb.core
import usb.util
import numpy as np
import pygame
import openmv
from time import sleep

# init pygame
pygame.init()

# init openmv
openmv.init()

# init screen
screen = pygame.display.set_mode((160, 120), pygame.DOUBLEBUF, 32)

running = True
img_size = 160*120*2
Clock = pygame.time.Clock()
font = pygame.font.SysFont("monospace", 15)
while running:
    Clock.tick(60)

    # read framebuffer
    fb = openmv.dump_fb()

    if fb == None:
        continue
Exemple #16
0
#!/usr/bin/env python
import sys
import usb.core
import usb.util
import numpy as np
import pygame
import openmv
from time import sleep

# init pygame
pygame.init()

# init openmv
openmv.init()

# init screen
screen = pygame.display.set_mode((160, 120), pygame.DOUBLEBUF, 32)

running = True
img_size = 160 * 120 * 2
Clock = pygame.time.Clock()
font = pygame.font.SysFont("monospace", 15)
while running:
    Clock.tick(60)

    # read framebuffer
    fb = openmv.dump_fb()

    if fb == None:
        continue
Exemple #17
0
        s.close()
        sys.stdout.write(
            "OPENMV: ERROR: Could not connect to Blender, exiting now\n")
        sys.exit(0)

    # init openmv
    if 'darwin' in sys.platform:
        portnames = glob.glob("/dev/cu.usbmodem*")
        if len(portnames):
            portname = portnames[0]
        else:
            portname = None
    else:
        portname = "/dev/openmvcam"

    openmv.init(portname)
    openmv.stop_script()
    openmv.enable_fb(True)
    openmv.exec_script(script)

    # init OpenCV window
    win = cv2.namedWindow('OpenMV')
    cv2.moveWindow("OpenMV", 1280, 0)

    fb = None

    writer = None
    f_timestamps = None
    nframes = 0
    while True:
        datadec = ""
Exemple #18
0
    def connect(self):
        try:
            # opens CDC port.
            openmv.init(self.config.get("main", "serial_port"),
                        baudrate=self.baudrate,
                        timeout=0.3)
        except Exception as e:
            # create fresh config if needed
            if platform.system() == "Linux" and not os.path.isfile(UDEV_PATH):
                error_msg = (
                    "Failed to open serial port.\n"
                    "Please install OpenMV's udev rules first:\n\n"
                    "sudo cp openmv/udev/50-openmv.rules /etc/udev/rules.d/\n"
                    "sudo udevadm control --reload-rules\n\n")
            else:
                error_msg = ("Failed to open serial port.\n"
                             "Please check the preferences Dialog.\n")

            self.show_message_dialog(gtk.MESSAGE_ERROR,
                                     "%s%s" % (error_msg, e))

            return

        # add terminal update callback
        gobject.gobject.timeout_add(10, omvgtk.update_terminal)

        # check firmware version
        self.fw_mismatch = False
        fw_ver = openmv.fw_version()
        ide_ver = (FIRMWARE_VERSION_MAJOR, FIRMWARE_VERSION_MINOR,
                   FIRMWARE_VERSION_PATCH)

        print("fw_version:" + str(fw_ver))
        print("ide_version:" + str(ide_ver))
        if (fw_ver[0] != FIRMWARE_VERSION_MAJOR):
            # If ABI versions don't match, nothing todo here...
            self.show_message_dialog(
                gtk.MESSAGE_ERROR, "Firmware ABI version mismatch!\n"
                "Please update the IDE and/or FW manually\n")
            return
        elif (FIRMWARE_VERSION_MINOR > fw_ver[1]
              or FIRMWARE_VERSION_PATCH > fw_ver[2]):
            self.fw_mismatch = True
            self.show_message_dialog(
                gtk.MESSAGE_ERROR, "Firmware version mismatch!\n"
                "An older firmware version has been detected.\n"
                "Please update the firmware!")

        if (self.fw_mismatch):
            self.connected = True
            self.connect_button.set_sensitive(False)
            self.fwupdate_button.set_sensitive(True)
            return

        # interrupt any running code
        openmv.stop_script()

        self.connected = True
        self._update_title()
        self.connect_button.set_sensitive(False)
        map(lambda x: x.set_sensitive(True), self.controls)
Exemple #19
0
# init pygame
pygame.init()

# init openmv
if 'darwin' in sys.platform:
    portname = "/dev/cu.usbmodem14221"
else:
    portname = "/dev/openmvcam"

connected = False
openmv.disconnect()
for i in range(10):
    try:
        # opens CDC port.
        # Set small timeout when connecting
        openmv.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"
          "sudo udevadm control --reload-rules\n\n")
    sys.exit(1)

# Set higher timeout after connecting for lengthy transfers.
openmv.set_timeout(1 * 2)  # SD Cards can cause big hicups.
Exemple #20
0
def main():
    # CMD args parser
    parser = argparse.ArgumentParser(description='openmv stress test')
    parser.add_argument("-j",
                        "--disable_fb",
                        action="store_true",
                        help="Disable FB JPEG compression")
    parser.add_argument("-p",
                        "--port",
                        action="store",
                        help="OpenMV serial port")
    parser.add_argument("-t",
                        "--time",
                        action="store",
                        default=100,
                        help="Max time before stopping the script")
    parser.add_argument("-s",
                        "--script",
                        action="store",
                        default="examples/01-Basics/helloworld.py",
                        help="OpenMV script file")

    # Parse CMD args
    args = parser.parse_args()

    # init openmv
    if (args.port):
        portname = args.port
    elif 'darwin' in sys.platform:
        portname = "/dev/cu.usbmodem14221"
    else:
        portname = "/dev/openmvcam"

    print("\n>>>Reading script: %s\n" % (args.script))
    with open(args.script, "r") as f:
        script = f.read()
    print("%s\n" % (script))

    connected = False
    for i in range(10):
        try:
            # Open serial port.
            # Set small timeout when connecting
            openmv.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"
              "sudo udevadm control --reload-rules\n\n")
        sys.exit(1)

    # Set higher timeout after connecting.
    openmv.set_timeout(0.500)

    # Enable/Disable framebuffer compression.
    print(">>>Enable FB JPEG compression %s" % (str(not args.disable_fb)))
    openmv.enable_fb(not args.disable_fb)

    # Interrupt running script.
    openmv.stop_script()
    max_timeout = int(args.time)
    for i in xrange(1000):
        openmv.exec_script(script)
        sleep(randint(0, max_timeout) / 1000)
        openmv.stop_script()
Exemple #21
0
    def __init__(self):
        #Set the Glade file
        self.builder = gtk.Builder()
        self.builder.add_from_file("openmv-ide.glade")

        # get top window
        self.window = self.builder.get_object("top_window")

        # status bar stuff
        self.statusbar = self.builder.get_object("statusbar")
        self.statusbar_ctx = self.statusbar.get_context_id("default")

        #save toolbutton
        self.save_button = self.builder.get_object('save_file_toolbutton')
        self.save_button.set_sensitive(False)

        #configure gtksourceview
        sourceview = self.builder.get_object('gtksourceview')
        self.buffer = gtksourceview.Buffer()
        mgr = gtksourceview.style_scheme_manager_get_default()
        style_scheme = mgr.get_scheme('classic')
        if style_scheme:
            self.buffer.set_style_scheme(style_scheme)
        lang_manager = gtksourceview.language_manager_get_default()
        self.buffer.set_highlight_syntax(True)
        self.buffer.set_language(lang_manager.get_language("python"))
        self.buffer.connect("changed", self.text_changed)

        # open last opened file
        if os.path.isfile(config_path):
            with open(config_path, "r") as file:
                self.file_path = file.read()
            if os.path.isfile(self.file_path):
                with open(self.file_path, "r") as file:
                    self.buffer.set_text(file.read())
                    self.window.set_title(os.path.basename(self.file_path))
            else:
                self.file_path = None

        sourceview.set_buffer(self.buffer)

        # open VCP and configure the terminal
        self.terminal = self.builder.get_object('terminal')
        self.fd = os.open("/dev/ttyACM0", os.O_RDWR)
        self.terminal.set_size(80, 24)
        self.terminal.set_pty(self.fd)

        self.framebuffer = self.builder.get_object("framebuffer_image")

        #connect signals
        signals = {
            "on_top_window_destroy": self.quit,
            "on_execute_clicked": self.execute_clicked,
            "on_stop_clicked": self.stop_clicked,
            "on_motion_notify": self.motion_notify,
            "on_button_press": self.button_pressed,
            "on_open_file": self.open_file,
            "on_save_file": self.save_file,
            "on_save_file_as": self.save_file_as,
        }
        self.builder.connect_signals(signals)

        # init openmv
        openmv.init()
Exemple #22
0
    def __init__(self):
        #Set the Glade file
        self.builder = gtk.Builder()
        self.builder.add_from_file(ui_path)

        # get top window
        self.window = self.builder.get_object("top_window")

        # status bar stuff
        self.statusbar = self.builder.get_object("statusbar")
        self.statusbar_ctx = self.statusbar.get_context_id("default")

        #save toolbutton
        self.save_button = self.builder.get_object('save_file_toolbutton')
        self.save_button.set_sensitive(False)

        #configure gtksourceview
        sourceview = self.builder.get_object('gtksourceview')
        self.buffer = gtksourceview.Buffer()
        mgr = gtksourceview.style_scheme_manager_get_default()
        style_scheme = mgr.get_scheme('classic')
        if style_scheme:
            self.buffer.set_style_scheme(style_scheme)
        lang_manager = gtksourceview.language_manager_get_default()
        self.buffer.set_highlight_syntax(True)
        self.buffer.set_language(lang_manager.get_language("python"))
        self.buffer.connect("changed", self.text_changed)

        # open last opened file
        if os.path.isfile(config_path):
            with open(config_path, "r") as file:
                self.file_path = file.read()
            if os.path.isfile(self.file_path):
                with open(self.file_path, "r") as file:
                    self.buffer.set_text(file.read())
                    self.window.set_title(os.path.basename(self.file_path))
            else:
                self.file_path = None

        sourceview.set_buffer(self.buffer)

        # open VCP and configure the terminal
        self.terminal = self.builder.get_object('terminal')
        self.fd = os.open("/dev/ttyACM0", os.O_RDWR)
        self.terminal.set_size(80,24)
        self.terminal.set_pty(self.fd)

        # get drawingarea
        self.pixbuf = None
        self.drawingarea = self.builder.get_object("drawingarea")
        self.da_menu = self.builder.get_object("da_menu")

        # selection coords
        self.x1 =0
        self.y1 =0
        self.x2 =0
        self.y2 =0
        self.selection_started=False
        self.sel_ended=False

        # set control scales attributes
        self.builder.get_object("contrast_adjust").attr=    openmv.ATTR_CONTRAST
        self.builder.get_object("brightness_adjust").attr=  openmv.ATTR_BRIGHTNESS
        self.builder.get_object("saturation_adjust").attr=  openmv.ATTR_SATURATION
        self.builder.get_object("gainceiling_adjust").attr= openmv.ATTR_GAINCEILING

        #connect signals
        signals = {
            "on_top_window_destroy" : self.quit,
            "on_execute_clicked"    : self.execute_clicked,
            "on_stop_clicked"       : self.stop_clicked,
            "on_motion_notify"      : self.motion_notify,
            "on_button_press"       : self.button_pressed,
            "on_button_release"     : self.button_released,
            "on_open_file"          : self.open_file,
            "on_save_file"          : self.save_file,
            "on_save_file_as"       : self.save_file_as,
            "on_save_template_activate" : self.save_template,
            "on_ctrl_scale_value_changed" : self.on_ctrl_scale_value_changed,
        }
        self.builder.connect_signals(signals)

        # init openmv
        openmv.init()

        # interrupt any running code
        openmv.stop_script()
        sleep(0.1)
Exemple #23
0
    if datapath is None:
        s.close()
        sys.stdout.write("OPENMV: ERROR: Could not connect to Blender, exiting now\n")
        sys.exit(0)

    # init openmv
    if 'darwin' in sys.platform:
        portnames = glob.glob("/dev/cu.usbmodem*")
        if len(portnames):
            portname = portnames[0]
        else:
            portname = None
    else:
        portname = "/dev/openmvcam"

    openmv.init(portname)
    openmv.stop_script()
    openmv.enable_fb(True)
    openmv.exec_script(script)

    # init OpenCV window
    win = cv2.namedWindow('OpenMV')
    cv2.moveWindow("OpenMV", 1280, 0)

    fb = None

        
    writer = None
    f_timestamps = None
    nframes = 0
    while True:
Exemple #24
0
    def __init__(self):
        #Set the Glade file
        self.builder = gtk.Builder()
        self.builder.add_from_file("openmv-ide.glade")

        # get top window
        self.window = self.builder.get_object("top_window")

        # status bar stuff
        self.statusbar = self.builder.get_object("statusbar")
        self.statusbar_ctx = self.statusbar.get_context_id("default")

        #save toolbutton
        self.save_button = self.builder.get_object('save_file_toolbutton')
        self.save_button.set_sensitive(False)

        #configure gtksourceview
        sourceview = self.builder.get_object('gtksourceview')
        self.buffer = gtksourceview.Buffer()
        mgr = gtksourceview.style_scheme_manager_get_default()
        style_scheme = mgr.get_scheme('classic')
        if style_scheme:
            self.buffer.set_style_scheme(style_scheme)
        lang_manager = gtksourceview.language_manager_get_default()
        self.buffer.set_highlight_syntax(True)
        self.buffer.set_language(lang_manager.get_language("python"))
        self.buffer.connect("changed", self.text_changed)

        # open last opened file
        if os.path.isfile(config_path):
            with open(config_path, "r") as file:
                self.file_path = file.read()
            if os.path.isfile(self.file_path):
                with open(self.file_path, "r") as file:
                    self.buffer.set_text(file.read())
                    self.window.set_title(os.path.basename(self.file_path))
            else:
                self.file_path = None

        sourceview.set_buffer(self.buffer)

        # open VCP and configure the terminal
        self.terminal = self.builder.get_object('terminal')
        self.fd = os.open("/dev/ttyACM0", os.O_RDWR)
        self.terminal.set_size(80,24)
        self.terminal.set_pty(self.fd)

        self.framebuffer = self.builder.get_object("framebuffer_image")

        #connect signals
        signals = {
            "on_top_window_destroy" : self.quit,
            "on_execute_clicked"    : self.execute_clicked,
            "on_stop_clicked"       : self.stop_clicked,
            "on_motion_notify"      : self.motion_notify,
            "on_button_press"       : self.button_pressed,
            "on_open_file"          : self.open_file,
            "on_save_file"          : self.save_file,
            "on_save_file_as"       : self.save_file_as,
        }
        self.builder.connect_signals(signals)

        # init openmv
        openmv.init()
Exemple #25
0
    def __init__(self):
        #Set the Glade file
        self.builder = gtk.Builder()
        self.builder.add_from_file(ui_path)

        # get top window
        self.window = self.builder.get_object("top_window")

        # status bar stuff
        self.statusbar = self.builder.get_object("statusbar")
        self.statusbar_ctx = self.statusbar.get_context_id("default")

        #save toolbutton
        self.save_button = self.builder.get_object('save_file_toolbutton')
        self.save_button.set_sensitive(False)

        #configure gtksourceview
        sourceview = self.builder.get_object('gtksourceview')
        self.buffer = gtksourceview.Buffer()
        mgr = gtksourceview.style_scheme_manager_get_default()
        style_scheme = mgr.get_scheme('classic')
        if style_scheme:
            self.buffer.set_style_scheme(style_scheme)
        lang_manager = gtksourceview.language_manager_get_default()
        self.buffer.set_highlight_syntax(True)
        self.buffer.set_language(lang_manager.get_language("python"))
        self.buffer.connect("changed", self.text_changed)

        # open last opened file
        if os.path.isfile(config_path):
            with open(config_path, "r") as file:
                self.file_path = file.read()
            if os.path.isfile(self.file_path):
                with open(self.file_path, "r") as file:
                    self.buffer.set_text(file.read())
                    self.window.set_title(os.path.basename(self.file_path))
            else:
                self.file_path = None

        sourceview.set_buffer(self.buffer)

        # open VCP and configure the terminal
        self.terminal = self.builder.get_object('terminal')
        self.fd = os.open("/dev/ttyACM0", os.O_RDWR)
        self.terminal.set_size(80, 24)
        self.terminal.set_pty(self.fd)

        # get drawingarea
        self.pixbuf = None
        self.drawingarea = self.builder.get_object("drawingarea")
        self.da_menu = self.builder.get_object("da_menu")

        # selection coords
        self.x1 = 0
        self.y1 = 0
        self.x2 = 0
        self.y2 = 0
        self.selection_started = False
        self.sel_ended = False

        # set control scales attributes
        self.builder.get_object("contrast_adjust").attr = openmv.ATTR_CONTRAST
        self.builder.get_object(
            "brightness_adjust").attr = openmv.ATTR_BRIGHTNESS
        self.builder.get_object(
            "saturation_adjust").attr = openmv.ATTR_SATURATION
        self.builder.get_object(
            "gainceiling_adjust").attr = openmv.ATTR_GAINCEILING

        #connect signals
        signals = {
            "on_top_window_destroy": self.quit,
            "on_execute_clicked": self.execute_clicked,
            "on_stop_clicked": self.stop_clicked,
            "on_motion_notify": self.motion_notify,
            "on_button_press": self.button_pressed,
            "on_button_release": self.button_released,
            "on_open_file": self.open_file,
            "on_save_file": self.save_file,
            "on_save_file_as": self.save_file_as,
            "on_save_template_activate": self.save_template,
            "on_ctrl_scale_value_changed": self.on_ctrl_scale_value_changed,
        }
        self.builder.connect_signals(signals)

        # init openmv
        openmv.init()

        # interrupt any running code
        openmv.stop_script()
        sleep(0.1)
Exemple #26
0
# init pygame
pygame.init()

# init openmv
if 'darwin' in sys.platform:
    portname = "/dev/cu.usbmodem14221"
else:
    portname = "/dev/openmvcam"

connected = False
openmv.disconnect()
for i in range(10):
    try:
        # opens CDC port.
        # Set small timeout when connecting
        openmv.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"
            "sudo udevadm control --reload-rules\n\n")
    sys.exit(1)

# Set higher timeout after connecting for lengthy transfers.
openmv.set_timeout(1*2) # SD Cards can cause big hicups.