I'm very new to Python / Raspberry Pi and I'm trying to set up a time lapse camera.
Due to the number and size of images, I wish to save to USB.
At first the below program (copied and altered from the Raspberry Pi camera page) worked with a USB stick but the pictures were flipped horizontally. I searched and found the solution was to update my Raspberry Pi, which I did. It took several hours after which horizontally it was correct but vertically it had flipped (I added the rotation command because of this).
Now I get an error message (shown below). The program works fine when using the SD card (saving to home/pi/Pictures for example) but crashes with a USB. Once it's crashed with the USB, the program also ceases to work with the SD card.
Here's what I've tried: -
- 3 separate USB sticks, ranging from 4GB up to 32GB (all are FAT32, by the way)
- With and without the "camera.preview" command
- With and without camera.close() command as I'd read answers to a similar problem saying that the camera might not be closing
Could anybody point me in the right direction but at the same time keeping it as simple as possible?
Error message when running my program: -
Traceback (most recent call last): File "/home/pi/Desktop/camera_USBv2.py", line 4, in <module> camera = PiCamera(resolution=(1024, 768), framerate=30) File "/usr/lib/python3/dist-packages/picamera/camera.py", line 433, in __init__ self._init_preview() File "/usr/lib/python3/dist-packages/picamera/camera.py", line 513, in _init_preview self, self._camera.outputs[self.CAMERA_PREVIEW_PORT]) File "/usr/lib/python3/dist-packages/picamera/renderers.py", line 558, in __init__ self.renderer.inputs.connect(source).enable() File "/usr/lib/python3/dist-packages/picamera/mmalobj.py", line 2212, in enable prefix="Failed to enable connection") File "/usr/lib/python3/dist-packages/picamera/exc.py", line 184, in mmal_check raise PiCameraMMALError(status, prefix) picamera.exc.PiCameraMMALError: Failed to enable connection: Out of resources >>>
My program: -
from picamera import PiCamera from time import sleep camera = PiCamera(resolution=(1024, 768), framerate=30) # Set ISO to the desired value camera.iso = 100 # Turn image the right way up camera.rotation = 180 sleep(2) camera.start_preview() for i in range(3): sleep(5) camera.shutter_speed = camera.exposure_speed camera.exposure_mode = 'off' g = camera.awb_gains camera.awb_mode = 'off' camera.awb_gains = g camera.capture('/media/pi/114E-1713/image%04d.jpg' % i) camera.stop_preview()