FPS for saving images is too small

Hello,

As there’re no requirements for saving the timestamps and the information of IMU, I did not record the images as the ‘*.svo’ format and directly use ZED2 as a webcam. I am using ZED2 as a webcam to save images.

The platform I am using is Jetson Nano. I followed the tutorials for catching images and saving the matrixes as the format of ‘*.npy’. I set fps as 30 but I only got the fps as around 4 frame/s.

My codes for recording and saving images as the ‘*.npy’ formats are in the ends.

My problem is, how can I record and save iamges or videos with a FPS around 20 f/s to 30 f/s and with a small saving space.

Thanks in advance. Looking forward to hearing from you.

Best regads,


import pyzed.sl as sl
import numpy as np
import os

def main():
path_l = ‘/home/Desktop/DataCollectionForStereocameras/image_capture/left/’
path_r = ‘/home/Desktop/DataCollectionForStereocameras/image_capture/right/’
if not os.path.exists(path_l):
os.mkdir(path_l)
print(“Left folder doesn’t exise, creating …”)
else:
print(“Directly recording …”)

if not os.path.exists(path_r):
    os.mkdir(path_r)
    print("Right folder doesn't exise, creating ...")
else:
    print("Directly recording ...")


# Create a Camera object
zed = sl.Camera()

# Create a InitParameters object and set configuration parameters
init_params = sl.InitParameters()
init_params.camera_resolution = sl.RESOLUTION.HD1080  # Use HD1080 video mode
init_params.camera_fps = 30 # Set fps at 30

# Open the camera
err = zed.open(init_params)
if err != sl.ERROR_CODE.SUCCESS:
    exit(1)
i = 0
image = sl.Mat()
image_r = sl.Mat()
runtime_parameters = sl.RuntimeParameters()
while (True):
    # Grab an image, a RuntimeParameters object must be given to grab()
    if zed.grab(runtime_parameters) == sl.ERROR_CODE.SUCCESS:
        # A new image is available if grab() returns SUCCESS
        zed.retrieve_image(image, sl.VIEW.LEFT)
        zed.retrieve_image(image_r, sl.VIEW.RIGHT)

        image_left = image.get_data()
        image_right = image_r.get_data()
        path_l_save = path_l + 'left_' + str(i) + '.npy'
        path_r_save = path_l + 'right_' + str(i) + '.npy'
        np.save(path_l_save, image_left)
        np.save(path_r_save, image_right)
        # print('Successfully save images.')
        i = i + 1

zed.close()

if name == “main”:
main()


Hi Sir,
thank you for reaching out.

You can use this example to record live images:
https://github.com/stereolabs/zed-examples/tree/21177250cfd96a735645dc12527fcb7daf41f5fa/svo%20recording/export

Best regards,

Walter
Stereolabs Support

Hi,

The format of svo costs to much space for storing. Are there any possibilities that I directly use ZED2 as a webcam and have a higher fps as 20 frames/s or even 30 frames/s?

Thanks in advance,

Qingwu

Hi Qingwu,
I suggested following the example, you can replace the “SVO input” with the “live input” and use the code to export the AVI.

Best regards,

Walter
Stereolabs Support

Hi Walter,

The storage of svo format is too large, how can I directly record as a video with the format avi? I also need to make sure that the fps is as higher as it can.

Thanks.

Hi Walter,

Do you mean following the code for recording svo? How can I replace the ‘SVO input’ with the ‘live input’? Is there the specific code in the stereolab library to replace sl.SVO_COMPRESSION_MODE.H264? Thanks.

If you remove those lines the ZED SDK will automatically open the connected camera instead of trying to open an SVO:

Hi,

I don’t mean svo exporting but I mean how to record images/videos without saving into the format as svo.

I would like to record images/videos with ZED not exporting…

Could you please take a look at the code I am using to record iamges?

Thanks,

Qingwu

The question is the fps is not good as I expected, it’s only around 4 to 5. I would like one as 20 to 30 instead.

Thanks.

Qingwu

@Qingwu I’ve seen your code, that’s why I suggested you look at the SVO exporting example.
In your code you are saving RAW data, that’s a heavy operation that requires a lot of available disk space.

Ok, I will try this. Thanks a lot for your help.

Best,

Qingwu

Hi,

I tried to mute line 87 and 88 of zed-examples/svo_export.py at master · stereolabs/zed-examples · GitHub, it is not automatically connected to ZED. There are no outputs because there are no input for converting into avi.

My problem is how to let the code automatically connect to the camera?

Thanks.

Qingwu

@Qingwu the zed-examples repository contains many examples and tutorials describing how to use the camera.
You can start from the tutorial 1 that illustrates how to open the camera.
The tutorial 2 explains how to retrieve the images.
The zed-opencv repository illustrates an easy way to display the retrieved images by using OpenCV.
Finally you can put everything together by modifying the sv-export tutorial in order to use live images as input instead of an SVO file.

@Myzhar I do tried to follow tutorial 1 and 2 to generate live images to save into a video. Then it came back to my previous question, I used opencv to read the sl.mat() and save it into images, fps is very low (about 3.7 frames/s). How can I have a higher fps? Thanks.

Please wait for a reply, do not create new posts if you already submitted a question:

The low FPS depends on many factors:

  • resolution
  • grab frame rate
  • write speed of the SD card used with the Jetson Nano
  • power mode used with the Jetson Nano
  • enabling status of the jetson_clocks script

Let’s start from 1 and 2, what are the resolution and the framerate that you are using?