I am using Jetson nano with Stereolabs ZED Camera on our porject. I have a Python script using SDK Python API and I am reading images from ZED. I know from API documentation, that grabbing image takes about 1/FPS, thats ok. But problem is, when I obtain image and I save it to memory, which takes too long for me (10+ ms for VGA, 40+ ms for 720p, 90+ ms for 1080p). This effectively limits FPS for 720p to less than 25 FPS, not even considering any image processing. I tried to save it as numpy array, which is almost twice faster, but resulting files are too big, since it is uncompressed.
Goal is to save image data with timestamps to some memory, so they can be later used. Ideally with 50-60 FPS.
I am not expert on Jetson nor ZED SDK so I would appreciate any tips and reccomendation, how to deal with this problem. Thanks in advance!
Python code for measuring saving time:
#!/usr/bin/env python3
import pyzed.sl as sl
import time
import numpy as np
init = sl.InitParameters()
camera = sl.Camera()
if not camera.is_opened():
print("Opening ZED Camera...")
status = camera.open(init)
if status != sl.ERROR_CODE.SUCCESS:
print(repr(status))
mat = sl.Mat()
runtime = sl.RuntimeParameters()
init = sl.InitParameters()
init.camera_resolution = sl.RESOLUTION.RESOLUTION_VGA
#init.camera_resolution = sl.RESOLUTION.RESOLUTION_HD720
#init.camera_resolution = sl.RESOLUTION.RESOLUTION_HD1080
init.camera_linux_id = 0
init.camera_fps = 60 # The framerate is lowered to avoid any USB3 bandwidth issues
camera = sl.Camera()
cam_status = camera.open(init)
mat = sl.Mat()
while True:
# Obtain camera image and get timestamps
t1 = time.process_time()
err = camera.grab(runtime)
# If grabbing image successfull, save to buffer
if err == sl.ERROR_CODE.SUCCESS:
camera.retrieve_image(mat, sl.VIEW.VIEW_SIDE_BY_SIDE)
img = mat.get_data()
img_name = 'images/filename_{}.jpg'.format(time.time())
# Saving as numpy array
# t2 = time.process_time()
# np.save(img_name, img)
# print("np.save took {} ms".format((time.process_time()-t2)*1e3))
t1 = time.process_time()
img = sl.ERROR_CODE.ERROR_CODE_FAILURE
countdown = 5
while img != sl.ERROR_CODE.SUCCESS or countdown > 0:
img = mat.write(img_name)
countdown -= 1
if img == sl.ERROR_CODE.SUCCESS:
break
print("Saving file took {} ms".format((time.process_time()-t1)*1e3))