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:
Code: Select all
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
Edit: It happened at 15/10/2018 16:30 BST. This time I didn't get a single "camera crashed... restarting" but the camera stopped recording anyways for some reason. Here is the dmesg: pastebin.com/ZpHB4W1P