Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ def startup_routine_3MP(self):
# Leave the shutter open for some time seconds (i.e. take a few photos without saving)
if self.debug_text_enabled: print('Running 3MP startup routine')
self.capture_jpg()
self.saveJPG('dummy_image.jpg')
self.save_jpg('dummy_image.jpg')
uos.remove('dummy_image.jpg')
if self.debug_text_enabled: print('Finished 3MP startup routine')

Expand Down Expand Up @@ -276,7 +276,7 @@ def _update_progress(self, progress, bar_length=20):
bar = '#' * filled_length + '-' * (bar_length - filled_length)
print("Progress: |{}| {}%".format(bar, int(progress * 100)), end='\r')

def save_JPG(self, filename="image.jpg", progress_bar=True): # From the amazing - @chrisrothwell1 - https://github.com/CoreElectronics/CE-Arducam-MicroPython/issues/9
def save_jpg(self, filename="image.jpg", progress_bar=True): # From the amazing - @chrisrothwell1 - https://github.com/CoreElectronics/CE-Arducam-MicroPython/issues/9
jpg_to_write = open(filename,'ab')
recv_len = self.received_length
starting_len = recv_len
Expand Down Expand Up @@ -317,7 +317,7 @@ def resolution(self, new_resolution):
input_string_lower = new_resolution.lower()
if self.camera_idx == '3MP':
if input_string_lower in self.valid_3mp_resolutions:
self.current_resolution_setting = self.valid_5mp_resolutions[input_string_lower]
self.current_resolution_setting = self.valid_3mp_resolutions[input_string_lower]
else:
raise ValueError("Invalid resolution provided for {}, please select from {}".format(self.camera_idx, list(self.valid_3mp_resolutions.keys())))

Expand Down
38 changes: 38 additions & 0 deletions examples/multiple_cameras.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
from machine import Pin, SPI, reset
from camera import *
fm = FileManager()

# Configuration for ESP 32S (NodeMCU) using VSPI w/ CS pins 16, 17, and 4
spi = SPI(2, baudrate=800000, polarity=0, phase=0, bits=8, firstbit=0, sck=Pin(18), mosi=Pin(23), miso=Pin(19))
cs_pins = [ Pin(16, Pin.OUT), Pin(17, Pin.OUT), Pin(4, Pin.OUT) ]
onboard_LED = Pin(2, Pin.OUT)

# This example uses 3 cameras at the noted CS pins, however feel free to add/remove.
# All that is required is turning ON/OFF the other CS pins for multiple cameras to work at once.

# Initialize cameras at pins
cams = [
Camera(spi, cs_pins[0], debug_text_enabled=True),
Camera(spi, cs_pins[1], debug_text_enabled=True),
Camera(spi, cs_pins[2], debug_text_enabled=True)
]

# Take captures with all cameras, in succession
def captureAll(cams):
for current_cam_index, cam_to_capture in enumerate(cams):
for i, cam_to_disable in enumerate(cams):
if i != current_cam_index: cam_to_disable.cs.on() # Make all CS pins on/high except the camera taking the image
sleep_ms(50)
cam_to_capture.capture_jpg()

def saveAll(cams):
for current_cam_index, cam_to_save in enumerate(cams):
for i, cam_to_disable in enumerate(cams):
if i != current_cam_index: cam_to_disable.cs.on() # Make all CS pins on/high except the camera taking the image
cam_to_save.save_jpg(fm.new_jpg_filename('image'))


onboard_LED.on()
captureAll(cams)
saveAll(cams)
onboard_LED.off()
29 changes: 24 additions & 5 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,16 @@
MISO - RX - GP13 - brown
MOSI - TX - GP11 - yellow
CS - GP17 - orange
'''

Camera pin - ESP32S (NodeMCU)
VCC - 3V3 - red
GND - GND - black
SPI - VSPI - 2
SCK - GP18 - white
MISO - RX - GP19 - brown
MOSI - TX - GP23 - yellow
CS - GP15 - orange
'''

################################################################## CODE ACTUAL ##################################################################
#Pi pico
Expand All @@ -35,18 +43,28 @@
# button = Pin(15, Pin.IN,Pin.PULL_UP)
onboard_LED = Pin(25, Pin.OUT)
'''

#ESP 32 S3
'''
spi = SPI(2,sck=Pin(12), miso=Pin(13), mosi=Pin(11), baudrate=8000000)
cs = Pin(17, Pin.OUT)

# button = Pin(15, Pin.IN,Pin.PULL_UP)
onboard_LED = Pin(48, Pin.OUT)
'''

#ESP 32S (NodeMCU)
spi = SPI(2, baudrate=800000, polarity=0, phase=0, bits=8, firstbit=0, sck=Pin(18), mosi=Pin(23), miso=Pin(19))
cs = Pin(16, Pin.OUT)

#Adds _# to end of filename, is same file name is used more than once images are stacked in the same file and only the first image renders while the size grows
# button = Pin(15, Pin.IN,Pin.PULL_UP)
onboard_LED = Pin(2, Pin.OUT)

#Adds _# to end of filename, is samjpge file name is used more than once images are stacked in the same file and only the first image renders while the size grows
fm = FileManager()

cam = Camera(spi, cs, debug_information=True)
cam.resolution = '320X240'
cam = Camera(spi, cs, debug_text_enabled=True)
cam.resolution = '320x240'
#cam.resolution = '640x480'
# cam.set_filter(cam.SPECIAL_REVERSE)
cam.set_brightness_level(cam.BRIGHTNESS_PLUS_4)
Expand All @@ -57,7 +75,7 @@
cam.capture_jpg()
sleep_ms(50)
#cam.saveJPG('image.jpg') #fixed name
cam.saveJPG(fm.new_jpg_fn('image')) #updating name
cam.save_jpg(fm.new_jpg_filename('image')) #updating name
onboard_LED.off()


Expand All @@ -68,3 +86,4 @@
- Increased speed (8000000), cam.resolution = '640X480', no burst read (camera pointed at roof) ==== TIME: ~7.3 seconds

'''