Um, so, keep in mind I’m only comfortable now opening this feature set up with the H7. The idea of having multiple images in RAM before was not really possible when we first started coding this on the M4. There just wasn’t space. The memory architecture behind the scenes is kinda messed up in this regard but I think I can work through all the problems.
Anyway, for creating a blank image there’s no mehod for this now. I will add one however. You can also allocate frame buffers in the sensor module using the extra_fb_alloc() method. These are large and blank. You can also copy an image and then clear it.
…
Note about the memory architecture. So, back on the M4 the heap was ultra tiny and you couldn’t really fit any images on it. On the M7 it was only marginally increased because we had to stick a lot of DMA buffers in the same RAM as it. On the H7 the heap is for the first time as large as the frame buffer.
Anyway, from a computing perspective the heap and the stack share the same RAM and grow towards each other.
Next, the key insight that made the OpenMV Cam possible on the M4 was the idea of a frame buffer stack. Basically, the frame buffer is a region in RAM that is very large where snapshot drops it’s images. It grows up while the frame buffer stack grows down. Both of these data structures are in a different memory segment on the chip versus the heap and stack. The frame buffer stack allows us to allocate lots of RAM real quick for large data structures to do iamge processing.
Now, the original idea was that you’d only have one image in memory at a time. However, we kept adding features that violates all of this to get more sales. So, the Frankenstein we’ve ended up with means an image can be in the heap, or in the frame buffer, or on the frame buffer stack.
I’ve written copy() to deal with this all and will update all the methods that can create copies to deal with these issues behind the scenes so that you can easily move images around. All the ram is addressed the same so it’s not too much of an issue to deal with but things can get tricky when I have to handle in place operations and etc.