Hi
I've got a very specific application that I'm trying to implement: a 60Hz precise strobing application for imaging in neuroscience applications. The 3 key things are: (i) 60Hz acquisition 256x256 or 128x128; (ii) strobing two different lights alternating at 60Hz; and (iii) saving up to 20min recording or longer (to USB hard disk (non-SSD)) with little or no dropped/skipped frames.
It seems that acquiring continuously with the picam and saving to disk leads to periodic (random?) freezes in acquisition for some reason. We've done many tests and recordings as short as 30 seconds (but certainly for a few minutes) at >30fps can have up to a few hundred milliseconds of missing data (this has also been documented by others). We've even seen freezes of up to 7seconds during a 10minute recording. However, saving to memory (e.g. using a python list and saving the frames to disk after recording is complete) seems to reduce all (or almost all) frame drops. But that is limited by the raspberry pi 3 memory, so ~45seconds (for recording a 256 x 256 window @ 60Hz) and about 3.5mins for 128x128.
So I wrote 2 C-based modules to call using python threading: (1) to do light strobing (i.e. flash a light at the beginning of every frame) and (2) implement a parallel save function that essentially accumulates 100-500 frames and then saves them to disk "without" interupting the encoders.py acqusition loop in _callback_write().
(1) Strobbing code is working surprisingly well. So using a shared variable (using python ctypes) between C and python, my C-based strobing code (above (1)) is mostly on time and lighting every single frame usually within 15usec or less of a new frame.
(2) C-based saving does not work so well. It seems that despite saving being passed to a 2nd thread, there continue to be periodic hangups. The errors are less than before - and the hangups are usually much shorter. If anyone is interested in this code, let me know.
I would like to better understand why saving to disk - even using a "2nd" core - continues to interfere with the picam grabbing frames from the GPU. My best guess is that the GPU->CPU pipeline somehow overlaps with the CPU->USB pipeline, or something along those lines.
Thanks!
