Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 8013

Troubleshooting • Photos sometimes fail to save, 0 bytes

$
0
0
I have a couple of camera projects I've been working on and I use this method to take photos:

Code:

def take_photo(self):    img_path = self.img_base_path + str(time.time()).split(".")[0] + ".jpg"    self.change_mode("full")    self.picam2.capture_file(img_path)    self.change_mode(self.last_mode)
The filename uses a timestamp which I am not sure if when the pi is turned on/off multiple times, that timestamp can go backwards?

I had thought of alternatives eg. random alphanum string generator, counting files... I want chronological sorting in a file view when exported/downloaded

Anyway this could be an XY problem situation too these are the full codebases/context

Right now I don't have a "make sure file actually saved" post process/check. My next approach would be to prewrite the file, I saw this as a solution

https://github.com/jdc-cunningham/pi-ze ... /camera.py

https://github.com/jdc-cunningham/modul ... /camera.py

Thanks for any thoughts, these codebases are amateur so if you have feedback/thoughts I'd be open too as I'm merging the two/making a new one
0bytes.JPG

Statistics: Posted by jcun4128 — Fri Mar 15, 2024 11:52 am



Viewing all articles
Browse latest Browse all 8013

Trending Articles