Python example GEVServer backend list and send image

I have taken the part BackEnd.gev_server_stream.send(image, image_release) “see red underlined” from the gevServer example. Here the method image_release(img) is called, but nothing is passed to it, so I assumed that another constructor exists in the streaminghandler class, but this is not called when I delete the method image_release(img), so I don’t understand which img is passed here.
Second question why is the list in the back_end needed, when the data from the device (in my case the CVMock.vin) could also be written directly into the RingBuffer of the initialised gevServer?

You register the image_release callback so when the gev_server decides to release the image, the callback is called with the image to be released.
You should be able to use the managed ringbuffer when you don’t set the lockmode to on. In this mode, you need to manually handle the ring buffer images. The tutorial shows this to help understanding the ring buffer lock mode and the handling of images.

I have changed the example and let the ring buffer switch automatically. So my question is more about why I need a list in the backend and why I need to call the method image_release in the method send to “unlock” the list in the backend I tried it without the list and it doesn’t work. Also, I don’t understand why I need to pass a parameter to the image_rlease method and where to pass it and when.

ok, let me try to explain.

  • why a list in the backend? - The image list is like the ring buffer. It is only for handling the images. If you removed it, maybe check
    1. That the self.stream.ring_buffer.lock_mode = cvb.RingBufferLockMode.Auto is set or it is not set at all (prefer not setting it)
      2.That the BackEnd.image_controller.refresh(image) still refreshes on an image
  • why call the method image_release in the method send to “unlock” the list in the backend, why pass a parameter to the image_release method, where to pass it and when?

I checked the doc and it seems that this specific part is missing in the python doc. I will see to it that we can get it in. If you take a look at the GevServer Stream C++ doc under Send [1/3] the function takes an image to send and an imageReleased callback. This callback is a function you define which is called by the GevServer when the image was successfully sent and is not needed any more. This callback is defined directly before the send call by

def image_release(img):
    img.unlock()
    BackEnd.img_list[BackEnd.buffer_index].unlock()
    print('Unlocked buffer at index ' + str(img.buffer_index))

The GevServer takes this function and after a successful send calls image_release with the successfully sent image as img argument. You would then see to it that the image is unlocked so the ringbuffer can re-use the image again.

Okay, but as it looks, I don’t need to run the image so “img.unlock()”, because even without that, the images are sent normally. Only when I delete the list in the buffer does it no longer work. I had tried to optimise the method away completely, but that hasn’t worked so far.
But if I now have to execute “img.unlock()” to release the image in the memory, I wonder why it works despite the missing code line.
I also don’t use an “image_controller” in my code and the “RingBufferLockMode” is set to Auto in my code.
But I can try again to delete the list in the BackEnd and try to get it to run without it. But I’m afraid it won’t work.

Maybe have a look at the C++ GevServer tutorial. It does not include the manual ring buffer management.