Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Stops image acquisition.
:return: None
"""
if self.is_acquiring_images:
#
self._is_acquiring_images = False
#
if self.thread_image_acquisition.is_running:
self.thread_image_acquisition.stop()
if self.thread_statistics_measurement.is_running:
self.thread_statistics_measurement.stop()
with MutexLocker(self.thread_image_acquisition):
#
self.device.node_map.AcquisitionStop.execute()
for data_stream in self._data_streams:
# Stop image acquisition.
try:
data_stream.stop_acquisition(
ACQ_STOP_FLAGS_LIST.ACQ_STOP_FLAGS_KILL
)
except ResourceInUseException:
# Device throw RESOURCE_IN_USE exception
# if the acquisition has already terminated or
# it has not been started.
pass
except TimeoutException as e:
print(e)
:param timeout_ms: Set timeout value in ms.
:return: A :class:`~harvesters.buffer.Buffer` object.
"""
if not self.is_acquiring_images:
return None
watch_timeout = True if timeout_ms > 0 else False
buffer= None
base = time.time()
while buffer is None:
if watch_timeout and (time.time() - base) > timeout_ms:
break
else:
with MutexLocker(self.thread_image_acquisition):
if len(self._fetched_buffers) > 0:
buffer = self._fetched_buffers.pop(0)
return buffer
def timeout_for_image_acquisition(self, ms):
with MutexLocker(self.thread_image_acquisition):
self._timeout_for_image_acquisition = ms
def _worker_acquisition_statistics(self):
if not self.is_acquiring_images:
return
time.sleep(self._statistics_update_cycle)
with MutexLocker(self.thread_statistics_measurement):
#
if self._frontend:
#
message_config = 'W: {0} x H: {1}, {2}, '.format(
self._current_width,
self._current_height,
self._current_pixel_format,
)
#
message_latest = ''
if self._statistics_latest.num_images > 0:
message_latest = '{0:.1f} fps in the last {1:.1f} s, '.format(
self._statistics_latest.fps,
self._statistics_update_cycle
)
node_map=self.device.node_map
)
except AttributeError:
buffer = Buffer(
buffer=event_manager.buffer,
data_stream=self._data_streams[0],
node_map=self.device.node_map
)
#
self._update_statistics(buffer)
if buffer:
# We've got a new image so now we can reuse the buffer that
# we had kept.
with MutexLocker(self.thread_image_acquisition):
if not self._is_acquiring_images:
return
if len(self._fetched_buffers) >= self._num_images_to_hold:
# We have a buffer now so we queue it; it's discarded
# before being used.
self._fetched_buffers.pop(0).queue()
# Append the recently fetched buffer.
# Then one buffer remains for our client.
self._fetched_buffers.append(buffer)
#
if self._num_images_to_acquire >= 1:
self._num_images_to_acquire -= 1