Merge pull request #110 from kwagyeman/master

Rearrange examples.
This commit is contained in:
Ibrahim Abd Elkader 2016-03-31 03:55:22 +02:00
commit 27d3ffe89e
48 changed files with 140 additions and 100 deletions

View File

@ -1,24 +0,0 @@
# Welcome to the OpenMV IDE.
# Click on the gears button to run this script!
import time, sensor
# Reset sensor
sensor.reset()
# Set sensor settings
sensor.set_contrast(1)
sensor.set_brightness(1)
sensor.set_saturation(1)
sensor.set_gainceiling(16)
sensor.set_framesize(sensor.QVGA)
sensor.set_pixformat(sensor.RGB565)
# FPS clock
clock = time.clock()
while (True):
clock.tick()
img = sensor.snapshot()
# Print FPS.
# Note: Actual FPS is higher, the IDE slows down streaming.
print(clock.fps())

View File

@ -1,14 +0,0 @@
import time, pyb
led = pyb.LED(3)
usb = pyb.USB_VCP()
while (usb.isconnected()==False):
led.on()
time.sleep(150)
led.off()
time.sleep(100)
led.on()
time.sleep(150)
led.off()
time.sleep(600)

View File

@ -0,0 +1,17 @@
# Hello World Example
#
# Welcome to the OpenMV IDE! Click on the gear button above to run the script!
import sensor, image, time
sensor.reset() # Initialize the camera sensor.
sensor.set_pixformat(sensor.RGB565) # or sensor.GRAYSCALE
sensor.set_framesize(sensor.QVGA) # or sensor.QQVGA (or others)
sensor.skip_frames() # Let new settings take affect.
clock = time.clock() # Tracks FPS.
while(True):
clock.tick() # Track elapsed milliseconds between snapshots().
img = sensor.snapshot() # Take a picture and return the image.
print(clock.fps()) # Note: Your OpenMV Cam runs about half as fast while
# connected to your computer. The FPS should increase once disconnected.

View File

@ -0,0 +1,21 @@
# Main Module Example
#
# When your OpenMV Cam is disconnected from your computer it will either run the
# main.py script on the SD card (if attached) or the main.py script on
# your OpenMV Cam's internal flash drive.
import time, pyb
led = pyb.LED(3) # Red LED = 1, Green LED = 2, Blue LED = 3, IR LEDs = 4.
usb = pyb.USB_VCP() # This is a serial port object that allows you to
# communciate with your computer. While it is not open the code below runs.
while(not usb.isconnected()):
led.on()
time.sleep(150)
led.off()
time.sleep(100)
led.on()
time.sleep(150)
led.off()
time.sleep(600)

View File

@ -0,0 +1,27 @@
# Save Image Example
#
# Note: You will need an SD card to run this demo.
#
# You can use your OpenMV Cam to save image files.
import sensor, image, pyb
RED_LED_PIN = 1
BLUE_LED_PIN = 3
sensor.reset() # Initialize the camera sensor.
sensor.set_pixformat(sensor.RGB565) # or sensor.GRAYSCALE
sensor.set_framesize(sensor.QVGA) # or sensor.QQVGA (or others)
sensor.skip_frames() # Let new settings take affect.
pyb.LED(RED_LED_PIN).on()
sensor.skip_frames(30) # Give the user time to get ready.
pyb.LED(RED_LED_PIN).off()
pyb.LED(BLUE_LED_PIN).on()
print("You're on camera!")
sensor.snapshot().save("demo.jpg") # or "demo.bmp" (or others)
pyb.LED(BLUE_LED_PIN).off()
print("Done! Reset the camera to see the saved recording.")

View File

@ -0,0 +1,37 @@
# GIF Video Recording Example
#
# Note: You will need an SD card to run this example.
#
# You can use your OpenMV Cam to record gif files. You can either feed the
# recorder object RGB565 frames or Grayscale frames. Use photo editing software
# like GIMP to compress and optimize the Gif before uploading it to the web.
import sensor, image, time, gif, pyb
RED_LED_PIN = 1
BLUE_LED_PIN = 3
sensor.reset() # Initialize the camera sensor.
sensor.set_pixformat(sensor.RGB565) # or sensor.GRAYSCALE
sensor.set_framesize(sensor.QQVGA) # or sensor.QVGA (or others)
sensor.skip_frames() # Let new settings take affect.
clock = time.clock() # Tracks FPS.
pyb.LED(RED_LED_PIN).on()
sensor.skip_frames(30) # Give the user time to get ready.
pyb.LED(RED_LED_PIN).off()
pyb.LED(BLUE_LED_PIN).on()
gif = gif.Gif("demo.gif", loop=True)
print("You're on camera!")
for i in range(100):
clock.tick()
# clock.avg() returns the milliseconds between frames - gif delay is in
gif.add_frame(sensor.snapshot(), delay=int(clock.avg()/10)) # centiseconds.
print(clock.fps())
gif.close()
pyb.LED(BLUE_LED_PIN).off()
print("Done! Reset the camera to see the saved recording.")

View File

@ -0,0 +1,37 @@
# MJPEG Video Recording Example
#
# Note: You will need an SD card to run this demo.
#
# You can use your OpenMV Cam to record mjpeg files. You can either feed the
# recorder object JPEG frames or RGB565/Grayscale frames. Once you've finished
# recording a Mjpeg file you can use VLC to play it. If you are on Ubuntu then
# the built-in video player will work too.
import sensor, image, time, mjpeg, pyb
RED_LED_PIN = 1
BLUE_LED_PIN = 3
sensor.reset() # Initialize the camera sensor.
sensor.set_pixformat(sensor.RGB565) # or sensor.GRAYSCALE
sensor.set_framesize(sensor.QVGA) # or sensor.QQVGA (or others)
sensor.skip_frames() # Let new settings take affect.
clock = time.clock() # Tracks FPS.
pyb.LED(RED_LED_PIN).on()
sensor.skip_frames(30) # Give the user time to get ready.
pyb.LED(RED_LED_PIN).off()
pyb.LED(BLUE_LED_PIN).on()
mjpeg = mjpeg.Mjpeg("demo.mjpeg")
print("You're on camera!")
for i in range(200):
clock.tick()
mjpeg.add_frame(sensor.snapshot())
print(clock.fps())
mjpeg.close(clock.fps())
pyb.LED(BLUE_LED_PIN).off()
print("Done! Reset the camera to see the saved recording.")

View File

@ -1,30 +0,0 @@
# Gif recording example:
#
# You can use your OpenMV Cam to record gif files. You can either feed the
# recorder object RGB565 frames or Grayscale frames. Use photo editing software
# like GIMP to compress and optimize the Gif before uploading it to the web.
import sensor, image, time, gif
sensor.reset()
sensor.set_framesize(sensor.QQVGA)
sensor.set_pixformat(sensor.RGB565) # you can also use grayscale
# Warm up the cam
for i in range(10):
sensor.snapshot()
# FPS clock
clock = time.clock()
gif = gif.Gif("/test.gif", loop=True) # video setup to use current resolution
for i in range(30):
clock.tick()
img = sensor.snapshot()
gif.add_frame(img, delay=10) # centi seconds
# Print FPS.
# Note: Actual FPS is higher, the IDE slows down streaming.
print(clock.fps())
gif.close()
print("done")

View File

@ -1,31 +0,0 @@
# Mjpeg recording example:
#
# You can use your OpenMV Cam to record mjpeg files. You can either feed the
# recorder object JPEG frames or RGB565/Grayscale frames. Once you've finished
# recording a Mjpeg file you can use VLC to play it. If you are on Ubuntu then
# the built-in video player will work too.
import sensor, image, time, mjpeg
sensor.reset()
sensor.set_framesize(sensor.QVGA)
sensor.set_pixformat(sensor.RGB565) # you can also use grayscale
# Warm up the cam
for i in range(10):
sensor.snapshot()
# FPS clock
clock = time.clock()
mjpeg = mjpeg.Mjpeg("/test.mjpeg") # video setup to use current resolution
for i in range(100):
clock.tick()
img = sensor.snapshot()
mjpeg.add_frame(img)
# Print FPS.
# Note: Actual FPS is higher, the IDE slows down streaming.
print(clock.fps())
mjpeg.close(clock.fps())
print("done")

View File

@ -293,7 +293,7 @@ class OMVGtk:
self.enable_jpeg = self.config.get("main", "enable_jpeg") == 'True'
# load helloworld.py
self._load_file(os.path.join(EXAMPLES_DIR, "00-Basics", "helloworld.py"))
self._load_file(os.path.join(EXAMPLES_DIR, "01-Basics", "helloworld.py"))
self.save_button.set_sensitive(False)
def show_message_dialog(self, msg_type, msg):