and image.unlock

As far as i have understood it, when you call in the cvbpy library after acquiring image it sends reply to the buffer that the image has been received and the buffer then releases the image right?

Am i correct in thinking that image.unlock() does the same thing without saving the image?

Haven’t found the proper description of the methods in the namespace reference manual.


almost. In the ringbuffer lock mode auto, the buffer is locked when a new image is acquired and stays locked during getting the image via wait. The buffer is only unlocked when you don’t hold the image any more. In python that should be when either

  • the image runs out of scope
  • you call delete on the image
  • the image variable is overwritten

You’ll find a ringbuffer example in your CVB installation under %CVB%\Tutorial\Image Manager\VC\VCRingBuffer\x64\Release

Image unlock would only allow the ringbuffer to re-use this specific buffer again which means it is subject to change and should not be used for computations any more as the result might be anything between two images (image A, image B or image A being overwritten by X percent with image B).

For normal usage (99 % of all cases), the default ringbuffer lock mode auto is fine and you won’t need to worry about it. Only lock mode on would require you to manually unlock each buffer/image after you are done with it in order to get new image. Lock mode off would require you to make sure you process the images fast enough before they are overwritten.

Lets say i have a free running external hardware trigger and my loop is in a state where i don’t want to save the image, i know that i should stop the trigger but i would wanna release the image from the buffer the same way that .save() does it, is .unlock() the right way to go yes?

Another example would be if i were to use some other way to save the image, cv2 for example? should i then .unlock() the image after i have saved it with cv2?

Yes, if you don’t want the image you can call unlock on it. To not get confused on the state of the image in the python object I would suggest to delete the image object in python.

Yeah it gets deleted or overwritten on the next loop
Thanks for the clarification!