diff --git a/usr/examples/00-Basics/helloworld.py b/usr/examples/00-Basics/helloworld.py deleted file mode 100644 index 28ef85b75..000000000 --- a/usr/examples/00-Basics/helloworld.py +++ /dev/null @@ -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()) diff --git a/usr/examples/00-Basics/main.py b/usr/examples/00-Basics/main.py deleted file mode 100644 index 0e269e6c1..000000000 --- a/usr/examples/00-Basics/main.py +++ /dev/null @@ -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) \ No newline at end of file diff --git a/usr/examples/01-Basics/helloworld.py b/usr/examples/01-Basics/helloworld.py new file mode 100644 index 000000000..b1ef8e439 --- /dev/null +++ b/usr/examples/01-Basics/helloworld.py @@ -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. diff --git a/usr/examples/01-Basics/main.py b/usr/examples/01-Basics/main.py new file mode 100644 index 000000000..0a93da4df --- /dev/null +++ b/usr/examples/01-Basics/main.py @@ -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) diff --git a/usr/examples/17-LCD/lcd_py.py b/usr/examples/02-Board-Control/lcd_py.py similarity index 100% rename from usr/examples/17-LCD/lcd_py.py rename to usr/examples/02-Board-Control/lcd_py.py diff --git a/usr/examples/05-Drawing/drawing.py b/usr/examples/03-Drawing/drawing.py similarity index 100% rename from usr/examples/05-Drawing/drawing.py rename to usr/examples/03-Drawing/drawing.py diff --git a/usr/examples/05-Drawing/set_pixel.py b/usr/examples/03-Drawing/set_pixel.py similarity index 100% rename from usr/examples/05-Drawing/set_pixel.py rename to usr/examples/03-Drawing/set_pixel.py diff --git a/usr/examples/08-Convolution/edge_detection.py b/usr/examples/04-Image-Filters/edge_detection.py similarity index 100% rename from usr/examples/08-Convolution/edge_detection.py rename to usr/examples/04-Image-Filters/edge_detection.py diff --git a/usr/examples/14-Misc/filters.py b/usr/examples/04-Image-Filters/filters.py similarity index 100% rename from usr/examples/14-Misc/filters.py rename to usr/examples/04-Image-Filters/filters.py diff --git a/usr/examples/08-Convolution/median.py b/usr/examples/04-Image-Filters/median.py similarity index 100% rename from usr/examples/08-Convolution/median.py rename to usr/examples/04-Image-Filters/median.py diff --git a/usr/examples/12-Jpeg/compress.py b/usr/examples/05-Picture-Taking/compress.py similarity index 100% rename from usr/examples/12-Jpeg/compress.py rename to usr/examples/05-Picture-Taking/compress.py diff --git a/usr/examples/05-Picture-Taking/save.py b/usr/examples/05-Picture-Taking/save.py new file mode 100644 index 000000000..83162ec10 --- /dev/null +++ b/usr/examples/05-Picture-Taking/save.py @@ -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.") diff --git a/usr/examples/13-Write/write_jpeg.py b/usr/examples/05-Picture-Taking/write_jpeg.py similarity index 100% rename from usr/examples/13-Write/write_jpeg.py rename to usr/examples/05-Picture-Taking/write_jpeg.py diff --git a/usr/examples/13-Write/write_ppm.py b/usr/examples/05-Picture-Taking/write_ppm.py similarity index 100% rename from usr/examples/13-Write/write_ppm.py rename to usr/examples/05-Picture-Taking/write_ppm.py diff --git a/usr/examples/06-Video-Recording/gif.py b/usr/examples/06-Video-Recording/gif.py new file mode 100644 index 000000000..725a009fd --- /dev/null +++ b/usr/examples/06-Video-Recording/gif.py @@ -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.") diff --git a/usr/examples/06-Video-Recording/mjpeg.py b/usr/examples/06-Video-Recording/mjpeg.py new file mode 100644 index 000000000..64d325e62 --- /dev/null +++ b/usr/examples/06-Video-Recording/mjpeg.py @@ -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.") diff --git a/usr/examples/11-Video/mjpeg_py.py b/usr/examples/06-Video-Recording/mjpeg_py.py similarity index 100% rename from usr/examples/11-Video/mjpeg_py.py rename to usr/examples/06-Video-Recording/mjpeg_py.py diff --git a/usr/examples/03-Blob/blob_detection.py b/usr/examples/08-Feature-Detection/blob_detection.py similarity index 100% rename from usr/examples/03-Blob/blob_detection.py rename to usr/examples/08-Feature-Detection/blob_detection.py diff --git a/usr/examples/02-Face/face_detection.py b/usr/examples/08-Feature-Detection/face_detection.py similarity index 100% rename from usr/examples/02-Face/face_detection.py rename to usr/examples/08-Feature-Detection/face_detection.py diff --git a/usr/examples/02-Face/face_eye_detection.py b/usr/examples/08-Feature-Detection/face_eye_detection.py similarity index 100% rename from usr/examples/02-Face/face_eye_detection.py rename to usr/examples/08-Feature-Detection/face_eye_detection.py diff --git a/usr/examples/02-Face/face_tracking.py b/usr/examples/08-Feature-Detection/face_tracking.py similarity index 100% rename from usr/examples/02-Face/face_tracking.py rename to usr/examples/08-Feature-Detection/face_tracking.py diff --git a/usr/examples/10-Descriptor/freak.py b/usr/examples/08-Feature-Detection/freak.py similarity index 100% rename from usr/examples/10-Descriptor/freak.py rename to usr/examples/08-Feature-Detection/freak.py diff --git a/usr/examples/04-Iris/iris_detection.py b/usr/examples/08-Feature-Detection/iris_detection.py similarity index 100% rename from usr/examples/04-Iris/iris_detection.py rename to usr/examples/08-Feature-Detection/iris_detection.py diff --git a/usr/examples/10-Descriptor/lbp.py b/usr/examples/08-Feature-Detection/lbp.py similarity index 100% rename from usr/examples/10-Descriptor/lbp.py rename to usr/examples/08-Feature-Detection/lbp.py diff --git a/usr/examples/07-Template/template_matching.py b/usr/examples/08-Feature-Detection/template_matching.py similarity index 100% rename from usr/examples/07-Template/template_matching.py rename to usr/examples/08-Feature-Detection/template_matching.py diff --git a/usr/examples/09-Gif/gif.py b/usr/examples/09-Gif/gif.py deleted file mode 100644 index 1730f3ca1..000000000 --- a/usr/examples/09-Gif/gif.py +++ /dev/null @@ -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") diff --git a/usr/examples/06-Motion/motion_detection.py b/usr/examples/09-Miscellaneous/motion_detection.py similarity index 100% rename from usr/examples/06-Motion/motion_detection.py rename to usr/examples/09-Miscellaneous/motion_detection.py diff --git a/usr/examples/01-Tests/colorbar.py b/usr/examples/10-Tests/colorbar.py similarity index 100% rename from usr/examples/01-Tests/colorbar.py rename to usr/examples/10-Tests/colorbar.py diff --git a/usr/examples/01-Tests/selftest.py b/usr/examples/10-Tests/selftest.py similarity index 100% rename from usr/examples/01-Tests/selftest.py rename to usr/examples/10-Tests/selftest.py diff --git a/usr/tests/test_binary_1.py b/usr/examples/10-Tests/test_binary_1.py similarity index 100% rename from usr/tests/test_binary_1.py rename to usr/examples/10-Tests/test_binary_1.py diff --git a/usr/tests/test_binary_2.py b/usr/examples/10-Tests/test_binary_2.py similarity index 100% rename from usr/tests/test_binary_2.py rename to usr/examples/10-Tests/test_binary_2.py diff --git a/usr/tests/test_drawing_1.py b/usr/examples/10-Tests/test_drawing_1.py similarity index 100% rename from usr/tests/test_drawing_1.py rename to usr/examples/10-Tests/test_drawing_1.py diff --git a/usr/tests/test_drawing_2.py b/usr/examples/10-Tests/test_drawing_2.py similarity index 100% rename from usr/tests/test_drawing_2.py rename to usr/examples/10-Tests/test_drawing_2.py diff --git a/usr/tests/test_erode_and_dilate.py b/usr/examples/10-Tests/test_erode_and_dilate.py similarity index 100% rename from usr/tests/test_erode_and_dilate.py rename to usr/examples/10-Tests/test_erode_and_dilate.py diff --git a/usr/tests/test_save.py b/usr/examples/10-Tests/test_save.py similarity index 100% rename from usr/tests/test_save.py rename to usr/examples/10-Tests/test_save.py diff --git a/usr/examples/17-LCD/lcd.py b/usr/examples/11-LCD-Shield/lcd.py similarity index 100% rename from usr/examples/17-LCD/lcd.py rename to usr/examples/11-LCD-Shield/lcd.py diff --git a/usr/examples/11-Video/mjpeg.py b/usr/examples/11-Video/mjpeg.py deleted file mode 100644 index 7d8848992..000000000 --- a/usr/examples/11-Video/mjpeg.py +++ /dev/null @@ -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") diff --git a/usr/examples/16-FIR/fir.py b/usr/examples/12-Thermopile-Shield/fir.py similarity index 100% rename from usr/examples/16-FIR/fir.py rename to usr/examples/12-Thermopile-Shield/fir.py diff --git a/usr/examples/16-FIR/fir_lcd.py b/usr/examples/12-Thermopile-Shield/fir_lcd.py similarity index 100% rename from usr/examples/16-FIR/fir_lcd.py rename to usr/examples/12-Thermopile-Shield/fir_lcd.py diff --git a/usr/examples/15-BLE/ble.py b/usr/examples/13-BLE-Shield/ble.py similarity index 100% rename from usr/examples/15-BLE/ble.py rename to usr/examples/13-BLE-Shield/ble.py diff --git a/usr/examples/18-WIFI/connect.py b/usr/examples/14-WiFi-Shield/connect.py similarity index 100% rename from usr/examples/18-WIFI/connect.py rename to usr/examples/14-WiFi-Shield/connect.py diff --git a/usr/examples/18-WIFI/dns.py b/usr/examples/14-WiFi-Shield/dns.py similarity index 100% rename from usr/examples/18-WIFI/dns.py rename to usr/examples/14-WiFi-Shield/dns.py diff --git a/usr/examples/18-WIFI/echo_server.py b/usr/examples/14-WiFi-Shield/echo_server.py similarity index 100% rename from usr/examples/18-WIFI/echo_server.py rename to usr/examples/14-WiFi-Shield/echo_server.py diff --git a/usr/examples/18-WIFI/mjpeg_streamer.py b/usr/examples/14-WiFi-Shield/mjpeg_streamer.py similarity index 100% rename from usr/examples/18-WIFI/mjpeg_streamer.py rename to usr/examples/14-WiFi-Shield/mjpeg_streamer.py diff --git a/usr/examples/18-WIFI/ntp.py b/usr/examples/14-WiFi-Shield/ntp.py similarity index 100% rename from usr/examples/18-WIFI/ntp.py rename to usr/examples/14-WiFi-Shield/ntp.py diff --git a/usr/examples/18-WIFI/scan.py b/usr/examples/14-WiFi-Shield/scan.py similarity index 100% rename from usr/examples/18-WIFI/scan.py rename to usr/examples/14-WiFi-Shield/scan.py diff --git a/usr/examples/18-WIFI/tcp_client.py b/usr/examples/14-WiFi-Shield/tcp_client.py similarity index 100% rename from usr/examples/18-WIFI/tcp_client.py rename to usr/examples/14-WiFi-Shield/tcp_client.py diff --git a/usr/openmv-ide.py b/usr/openmv-ide.py index 0b69d64f6..0ae5e72db 100755 --- a/usr/openmv-ide.py +++ b/usr/openmv-ide.py @@ -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):