I am having trouble getting chunk data from the Aravis Project Python library.
The code confirms I am enabling the chunk data, yet when I grab a frame from the stream and try to read its chunk data contents, there seems to be no chunk data.
Unfortunately I have not come across any examples that show my particular use case in the C or Python - so I have been using this Symbol Mapping document for mapping the C functions to Python for my attempts.
If anyone has experience with either bindings, some guidance would be much appreciated.
import sys
import gi
gi.require_version ('Aravis', '0.8')
from gi.repository import Aravis
# Attempt to find the connected camera
try:
camera = Aravis.Camera.new (None)
except TypeError:
print ("No camera found")
exit ()
# Configure the camera
camera.set_region (0,0,128,128)
camera.set_frame_rate (15.0)
camera.set_pixel_format (Aravis.PIXEL_FORMAT_MONO_8)
# Check if software trigger capture is supported by camera
if camera.is_software_trigger_supported():
print("Software trigger available. Attempting to configure...")
camera.set_trigger_source("Software")
# Confirm
trigger = camera.get_trigger_source()
if trigger == "Software":
print("Software trigger confirmed.")
else:
print("Software trigger failed. Trigger is: ",trigger )
else:
print("Software trigger unavailable.")
# Create chunk parser
chunk_parser = camera.create_chunk_parser()
# Enable chunk data: Timestamp - Wes, you can add more chunk data here into the array "Timestamp,Mo-Data-You-Want,..."
if camera.are_chunks_available():
camera.set_chunks("Timestamp")
#Confirm
if camera.get_chunk_mode():
print("Chunk mode confirmed.")
if camera.get_chunk_state("Timestamp"):
print("Timestamp enabled.")
else:
print("Failed to confirm chunk mode.")
else:
print("Chunk data not available for this camera")
# Print camera info
print ("Camera vendor : %s" %(camera.get_vendor_name ()))
print ("Camera model : %s" %(camera.get_model_name ()))
print ("Frame rate : %d" %(camera.get_frame_rate()))
stream = camera.create_stream (None, None)
# Create a pool of buffers for capture
payload = camera.get_payload ()
for i in range(0,5):
stream.push_buffer(Aravis.Buffer.new_allocate (payload))
print ("Starting...")
camera.start_acquisition()
#Enter main loop to gather frame and chunk data and print data to screen
try:
for i in range(0,5):
# Get the buffer
buffer = stream.pop_buffer()
print(buffer)
if buffer:
# If the image has chunk data lets handle it.
if buffer.has_chunks():
ts = chunk_parser.get_float_value(buffer, "Timestamp")
print("Timestamp: ", ts)
else:
print("No chunk data.")
stream.push_buffer (buffer)
else:
print("No buffer.")
except Exception as error:
print(error)
finally:
print ("Stopping.")
camera.stop_acquisition ()
Resulting output:
root@imx8qm:/test/bin# python3 arv-chunk-test.py
Software trigger available. Attempting to configure...
Software trigger confirmed.
Chunk mode confirmed.
Timestamp enabled.
Camera vendor : FLIR
Camera model : Blackfly S BFS-U3-120S4C
Frame rate : 15
Starting...
<Aravis.Buffer object at 0xffffa6499a00 (ArvBuffer at 0xaaaaf3205220)>
No chunk data.
<Aravis.Buffer object at 0xffffa6499ac0 (ArvBuffer at 0xaaaaf32052b0)>
No chunk data.
<Aravis.Buffer object at 0xffffa6499b00 (ArvBuffer at 0xaaaaf3205340)>
No chunk data.
<Aravis.Buffer object at 0xffffa6499b40 (ArvBuffer at 0xaaaaf32053d0)>
No chunk data.
<Aravis.Buffer object at 0xffffa6499b80 (ArvBuffer at 0xaaaaf3205460)>
No chunk data.
Stopping.