Hi there,
I have a Teledyne Dalsa Genie Nano (C4030) and with aravis/aravis-viewer-0.8, streaming works very well.
I did not find a way to display the raw images I stored with the repective button in aravis-viewer, so I wrote a very simple python-script to display the raw image stored from aravis-viewer. I cannot upload a file, pls. find the code in the footer of this message.
There was a bit of trial and error with my code, because always, the file-size of the raw image is 256 byte larger than the bytes of the cam’s payload. In my code, I decided to cut the last 256 bytes and everything works very well. The cut bytes seem to be all 0.
Could someone please explain to me the format of the raw files written from aravis-viewer? What are the trailing bytes? I had a quite long look into the project’s git, but I am still left with many questionmarks.
Thank you a lot!
Benjamin
#!/usr/bin/python3
import numpy as np
import cv2
from matplotlib import pyplot as plt
# Teledyne Dalsa Genie Nano with Sony IMX,
# values as reported from the cam’s features.
SENSOR_WIDTH = 4112
SENSOR_HEIGHT = 2176
N_PAYLOAD_BYTES = SENSOR_WIDTH * SENSOR_HEIGHT
# Desired output dimensions
SCALE = 1/5
target_dim = (int(SENSOR_WIDTH * SCALE), int(SENSOR_HEIGHT * SCALE))
# FQFN to a raw file stored before.
IMG_PATH = "/home/user/bla.raw"
# Open the files in binary mode, no
# interpretation.
fd = open(IMG_PATH,‘rb’)
raw_bytes_buffered = fd.read()
fd.close()
# Interpret all bytes as uint8 and put them into
# a 1D numpy array.
raw_bytes_as_int_array = np.frombuffer(raw_bytes_buffered, np.uint8)
# There are some additional (leading?) bytes. Why?(???)
payload_bytes = raw_bytes_as_int_array[:n_payload_bytes]
# Reshape the 1D array to a @d array with the dimensions of the sensor (cf. payload bytes).
img_bytes = payload_bytes.reshape(sensor_height, sensor_width)
# Demosaicing, resizing, rotating. It is very
# important to demosaic first, since we rely
# on the arrangement of the Bayer filter.
img_bytes = cv2.cvtColor(img_bytes, cv2.COLOR_BayerRG2RGB)
img_bytes = cv2.resize(img_bytes, target_dim)
img_bytes = cv2.rotate(img_bytes, cv2.ROTATE_180)
# Finally, display the image!
cv2.imshow(“Raw image’s contents!”, img_bytes)
cv2.waitKey()