I am still a little bit confused what RBBufferSeq and using NumBuffers - 1.
The original question was:
Does RBBufferSeq return the oldest image or oldest unprocessed image in the buffer when the sequence number is BufferCount-1?
There the answer was:
The ring buffer uses a locking mechanism which is dependent on the RINGBUFFER_LOCKMODE.
By default the lock mode is set to RINGBUFFER_LOCKMODE_AUTO: In that case a buffer is locked, once it is filled with a new image from the camera and unlocked upon retrieval when using the function G2Wait. After being unlocked the buffer is free to be filled with new images by the camera.
The function G2Wait returns the oldest locked buffer (and unlocks that buffer afterwards).
Alternative lock modes are:
RINGBUFFER_LOCKMODE_OFF (all buffers are always unlocked and can be used to be refilled with new images anytime)
RINGBUFFER_LOCKMODE_ON (unlocking of buffers have to be done manually with RBUnlock)
In the function RBBufferSeq the IBufferIndex is relative to the last call of G2Wait.
IBufferIndex = 0: The returned buffer is identical to the last one received with the G2Wait call.
IBufferIndex = 1: The returned buffer contains the previous image. This is useful for arithmetic oparations (eg. Image subtraction)
IBufferIndex = bufferCount -1: Content of the returned buffer might be undefined, depending on the application
The usage of this function is very dependent on the application. In the worst case the “oldest Buffer”( bufferCount -1) might be the newest buffer.
This makes sense. But I am not sure where the bufferCount -1 actually points to. Please consider following scenarios.
- blue buffers have been read and are unlocked
- green buffers are acquired but have not been called yet by G2Wait (they are locked).
- red buffer is the last buffer read by G2Wait.
- white buffers have never been written yet by acqusition (e.g., as the acquisition has just started and the buffer hasn’t been filled yet).
- The G2Wait call (IBufferIndex = 0) points to buffer 3. So far so good.
- IBufferIndex = 1 would point to buffer 2.
- … and so on…
- Does IBufferIndex = bufferCount - 1 return the next buffer after G2Wait, e.g., buffer 4 for both scenarios?
- Or does it differ depending which buffers have been written beforehand and which buffers are currently locked?
Thank you for your help.