diff --git a/tools/pyopenmv_fb.py b/tools/pyopenmv_fb.py index e5335719f..69a57a790 100755 --- a/tools/pyopenmv_fb.py +++ b/tools/pyopenmv_fb.py @@ -1,10 +1,8 @@ #!/usr/bin/env python2 import sys -# import usb.core -# import usb.util import numpy as np import pygame -import openmv +import pyopenmv from time import sleep script = """ @@ -35,12 +33,12 @@ else: portname = "/dev/openmvcam" connected = False -openmv.disconnect() +pyopenmv.disconnect() for i in range(10): try: # opens CDC port. # Set small timeout when connecting - openmv.init(portname, baudrate=921600, timeout=0.050) + pyopenmv.init(portname, baudrate=921600, timeout=0.050) connected = True break except Exception as e: @@ -55,10 +53,10 @@ if not connected: sys.exit(1) # Set higher timeout after connecting for lengthy transfers. -openmv.set_timeout(1*2) # SD Cards can cause big hicups. -openmv.stop_script() -openmv.enable_fb(True) -openmv.exec_script(script) +pyopenmv.set_timeout(1*2) # SD Cards can cause big hicups. +pyopenmv.stop_script() +pyopenmv.enable_fb(True) +pyopenmv.exec_script(script) # init screen running = True @@ -69,7 +67,7 @@ while running: Clock.tick(100) # read framebuffer - fb = openmv.fb_dump() + fb = pyopenmv.fb_dump() if fb == None: continue @@ -101,4 +99,4 @@ while running: pygame.quit() -openmv.stop_script() +pyopenmv.stop_script() diff --git a/tools/pyopenmv_test.py b/tools/pyopenmv_test.py index 29f4f584a..4aa9b0507 100755 --- a/tools/pyopenmv_test.py +++ b/tools/pyopenmv_test.py @@ -1,6 +1,6 @@ #!/usr/bin/env python2 import sys, os -import openmv +import pyopenmv import argparse from time import sleep from random import randint @@ -11,7 +11,8 @@ def main(): 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") + parser.add_argument("-s", "--script", action = "store",\ + default="../scripts/examples/01-Basics/helloworld.py", help = "OpenMV script file") # Parse CMD args args = parser.parse_args() @@ -34,7 +35,7 @@ def main(): try: # Open serial port. # Set small timeout when connecting - openmv.init(portname, baudrate=921600, timeout=0.050) + pyopenmv.init(portname, baudrate=921600, timeout=0.050) connected = True break except Exception as e: @@ -49,19 +50,19 @@ def main(): sys.exit(1) # Set higher timeout after connecting. - openmv.set_timeout(0.500) + pyopenmv.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) + pyopenmv.enable_fb(not args.disable_fb) # Interrupt running script. - openmv.stop_script() + pyopenmv.stop_script() max_timeout = int(args.time) for i in xrange(1000): - openmv.exec_script(script) + pyopenmv.exec_script(script) sleep(randint(0, max_timeout)/1000) - openmv.stop_script() + pyopenmv.stop_script() if __name__ == '__main__': main()