FIFO implementation on OpenMV H7 plus

Hi! I’d like to implement system which works as follows.
When trigger signal is enable, then record image before trigger and after trigger signal and play this image.This means when trigger signal is disabled then record image at ringbuffer(for example 100 frame) and after trigger signal is enabled, record image at framebuffer more(100frame). And play before trigger image and after trigger image at once. How can I implement this?

Um… not sure what you want to do…

But, with the latest firmware we have the ability to do an image fifo.

Just do:

set_frame

Hi!

I am Korean so I am not good in English.

What I want to do is when Trigger signal (Reading from GPIO) goes Low then

Record before Trigger 100 frame and after Trigger 100 frame and Play them all at once.

I hope you can understand this.

For example, if something hits my car, my camera(Black box) which is located in front of my car records before hit situation and after hit situation

and play to me so I can see what happened.

Yes, so. Use: sensor — camera sensor — MicroPython 1.15 documentation

sensor.set_frame_buffers(100)
sensor.disable_full_flush(True)

When you call snasphot() after setting the above the camera will automatically capture the next 100 frames without you doing anything. Each next call of snapshot() will return the next frame out of that 100. E.g. there’s an interrupt process method that will just capture the next 100 frames.

Note that after you return the 100 frames you want… you’ll want to set the frame buffer count back to 3 and turn full flushing on again. Otherwise… frames will be very old in the image fifo. This is because each time you call snapshot the camera will try to put a new frame into the frame buffer fifo. However, now there’s a time delay so any frames being added now aren’t perfectly in sync.

The above just gives you the info after the trigger. If you want the frames before the trigger then you need to do something like a memory fifo using the ImageWriter class. This requires you to code it up. I don’t have example code. However, the ImageWriter can create an array of fast random access image buffers in RAM you can store frames to. This will allow you to do what you want.

stream = image.ImageIO()
stream.wrtie(sensor.snapshot())

Is this ImageWrite class that You are saying?

See this example: openmv/imageio_memory.py at master · openmv/openmv · GitHub

The documentation isn’t up to date but you have full seek support. So, you can place images into the buffer before and after an event in your code: openmv/py_imageio.c at master · openmv/openmv · GitHub