|
1 |
| -# VC0706 image capture to local storage. |
2 |
| -# You must wire up the VC0706 to a USB or hardware serial port. |
3 |
| -# Primarily for use with Linux/Raspberry Pi but also can work with Mac/Windows |
| 1 | +"""VC0706 image capture to local storage. |
| 2 | +You must wire up the VC0706 to a USB or hardware serial port. |
| 3 | +Primarily for use with Linux/Raspberry Pi but also can work with Mac/Windows""" |
4 | 4 |
|
5 | 5 | import time
|
6 |
| -import serial |
| 6 | +import busio |
| 7 | +import board |
7 | 8 | import adafruit_vc0706
|
8 | 9 |
|
9 |
| -# Configuration: |
10 |
| -IMAGE_FILE = 'image.jpg' # Full path to file name to save captured image. |
11 |
| - # Will overwrite! |
| 10 | +# Set this to the full path to the file name to save the captured image. WILL OVERWRITE! |
| 11 | +# CircuitPython internal filesystem configuration: |
| 12 | +IMAGE_FILE = '/image.jpg' |
| 13 | +# USB to serial adapter configuration: |
| 14 | +# IMAGE_FILE = 'image.jpg' # Full path to file name to save captured image. Will overwrite! |
| 15 | +# Raspberry Pi configuration: |
| 16 | +# IMAGE_FILE = '/home/pi/image.jpg' # Full path to file name to save image. Will overwrite! |
12 | 17 |
|
13 |
| -# Create a serial connection for the VC0706 connection, speed is auto-detected. |
| 18 | + |
| 19 | +# Create a serial connection for the VC0706 connection. |
| 20 | +uart = busio.UART(board.TX, board.RX, baudrate=115200, timeout=0.25) |
14 | 21 | # Update the serial port name to match the serial connection for the camera!
|
15 |
| -uart = serial.Serial("/dev/ttyUSB0", timeout=0.25) |
| 22 | +# For use with USB to serial adapter: |
| 23 | +# import serial |
| 24 | +# uart = serial.Serial("/dev/ttyUSB0", baudrate=115200, timeout=0.25) |
| 25 | +# For use with Raspberry Pi: |
| 26 | +# import serial |
| 27 | +# uart = serial.Serial("/dev/ttyS0", baudrate=115200, timeout=0.25) |
16 | 28 |
|
17 | 29 | # Setup VC0706 camera
|
18 | 30 | vc0706 = adafruit_vc0706.VC0706(uart)
|
|
21 | 33 | print('VC0706 version:')
|
22 | 34 | print(vc0706.version)
|
23 | 35 |
|
24 |
| -# Set the baud rate to 115200 for fastest transfer (its the max speed) |
25 |
| -vc0706.baudrate = 115200 |
26 |
| - |
27 | 36 | # Set the image size.
|
28 |
| -vc0706.image_size = adafruit_vc0706.IMAGE_SIZE_640x480 # Or set IMAGE_SIZE_320x240 or |
29 |
| - # IMAGE_SIZE_160x120 |
| 37 | +vc0706.image_size = adafruit_vc0706.IMAGE_SIZE_640x480 |
| 38 | +# Or set IMAGE_SIZE_320x240 or IMAGE_SIZE_160x120 |
| 39 | + |
30 | 40 | # Note you can also read the property and compare against those values to
|
31 | 41 | # see the current size:
|
32 | 42 | size = vc0706.image_size
|
|
0 commit comments