You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
As of version 0.2.2, ImageAcquirer provides limited ways of checking filled buffers those are being internally held. One is calling fetch_buffer or another is probing the num_holding_filled_buffers property. Both ways are necessary and useful for most cases but they are not suitable if the application concerns the cost of polling.
Describe the solution you'd like
Support a callback method that is called every time when a new buffer arrived. Having this method, the application is released from the concern on polling. The method should be able to get registered through a property and it would be nice if we could name the property on_new_buffer_arrival.
Describe alternatives you've considered
None.
Additional context
Due to the nature of the callback method that is called in the image acquisition thread worker, you should minimize the duration you spend in the callback function as much as possible. If it takes too long, then the thread could drop images those should have been acquired if you didn't take such a long time.
In addition, note that the callback is just telling you that a new buffer has arrived. It doesn't mean the ImageAcqurier object is holding just one buffer at the moment or the new buffer has still been held. Depending on the configuration of the ImageAcquirer object, it may be holding one or more buffers or the new buffer might have been already discarded. If you want to know the number of buffers that it's holding, just refer the num_holding_filled_buffers property.
The text was updated successfully, but these errors were encountered:
The on_new_buffer_arrival property can be used as follows:
def test_issue_61(self):
if not self.is_running_with_default_target():
return
# Connect to the first camera in the list.
self.ia = self.harvester.create_image_acquirer(0)
# Register a call back method:
self.ia.on_new_buffer_arrival = self._callback_on_new_buffer_arrival
# We turn software tirrger on:
self.setup_camera()
# We have not fetched any buffer:
self.assertEqual(0, len(self._buffers))
# Start image acquisition:
self.ia.start_image_acquisition()
# Trigger the target device:
num_images = self.ia.num_buffers
self.assertTrue(num_images > 0)
# Trigger the target device:
for _ in range(num_images):
self.generate_software_trigger()
# Note that we should have another reliable way to confirm
# FRAME_TRIGGER_WAIT.
time.sleep(0.01)
# If the callback method was called, then we should have the same
# number of buffers with num_images:
self.assertEqual(num_images, len(self._buffers))
# Release the buffers before stopping image acquisition:
for buffer in self._buffers:
buffer.queue()
self._buffers.clear()
# Then stop image acquisition:
self.ia.stop_image_acquisition()
def _callback_on_new_buffer_arrival(self):
# Fetch a buffer and keep it:
self._buffers.append(self.ia.fetch_buffer())
Is your feature request related to a problem? Please describe.
As of version
0.2.2
,ImageAcquirer
provides limited ways of checking filled buffers those are being internally held. One is callingfetch_buffer
or another is probing thenum_holding_filled_buffers
property. Both ways are necessary and useful for most cases but they are not suitable if the application concerns the cost of polling.Describe the solution you'd like
Support a callback method that is called every time when a new buffer arrived. Having this method, the application is released from the concern on polling. The method should be able to get registered through a property and it would be nice if we could name the property
on_new_buffer_arrival
.Describe alternatives you've considered
None.
Additional context
Due to the nature of the callback method that is called in the image acquisition thread worker, you should minimize the duration you spend in the callback function as much as possible. If it takes too long, then the thread could drop images those should have been acquired if you didn't take such a long time.
In addition, note that the callback is just telling you that a new buffer has arrived. It doesn't mean the
ImageAcqurier
object is holding just one buffer at the moment or the new buffer has still been held. Depending on the configuration of theImageAcquirer
object, it may be holding one or more buffers or the new buffer might have been already discarded. If you want to know the number of buffers that it's holding, just refer thenum_holding_filled_buffers
property.The text was updated successfully, but these errors were encountered: