My raspberry pi camera 1.3 is connected to a Rpi 3B+ and I have a script that has the camera take a picture every 5 minutes and save it to a network location. Once in a while, the camera will crash which will be brought back to life by my script. After a couple crashes though, the script doesn't seem to be able to bring the camera back online (but the script doesn't throw an exception for some reason).
I close the script, kill all relevant processes then run the script again but the camera stays dead. I thought maybe the GPU memory was the issue but it is set at 256MB and apparently that should be more than enough.
The only way to fix this seems to be to reboot the pi but obviously that is not ideal.
The script I am running is here:
from picamera import PiCamera from time import sleep from datetime import datetime import am2320 def main(): flag = 0 camera = PiCamera() camera.resolution = (2592, 1944) while 1: dateString = datetime.strftime(datetime.now(), '%Y%m%d') timeString = datetime.strftime(datetime.now(), '%H%M') flag = getPicture(camera, dateString, timeString) while flag == 1: sleep(5) camera = PiCamera() camera.resolution = (2592, 1944) flag = getPicture(camera, dateString, timeString) for x in range(1, 5): #90*20 = 1800seconds sleep(60) def getPicture(camera, ds, ts): try: camera.start_preview() sleep(5) camera.capture('PATH' % (ds, ts)) camera.stop_preview() return 0 except: print("camera crashed... restarting") camera.close() return 1
PS. another thing is when this happens and I reboot the pi, the pi boots into a camera preview and refuses VNC connection, which means I have to pull the power on the pi to get it to restart