Zed.grab() skips frames in case of process delay

I don’t know if it’s a bug or feature in the SDK, but when I call zed.grab() to retrieve frames from an SVO file, it skips some frames if there is a slow process within the while loop. In other words, it doesn’t wait for the process. A good test is to apply a 1-sec sleep and then count the number of frames.

That part of my code is also something like this:

frame_count = 0
while True:
frame_count += 1
err = zed.grab(runtime_params)
zed.retrieve_image(image_left_tmp, sl.VIEW.LEFT)
image_net = image_left_tmp.get_data()

cudnn.benchmark = True

img = img_preprocess(image_net)
with torch.no_grad():
    pred = model(img)[0] 

Even if I move the prediction in a separate thread, this still happens.

I’ve tested it on both Linux and Windows. Tested with SDK versions of 3.7 and 3.8.

Is there any way that I can process all the frames in my video in this case?

Thank you

Hi @Thomas
this is correct if you are setting the True the initialization parameter svo_real_time_mode.
You can process the SVO frame by frame, without taking into account of the real frame rate by setting it to False.
Read more on the documentation:

1 Like

Hi @Myzhar,

Thank you so much for replying. Is there any way that I can get the original frame number of an image when setting the svo_real_time_mode to True? I actually need this information to sync the camera and GPS.

Thank you

Yes, you can use the get_svo_position function:

1 Like

Perfect! Thank you @Myzhar.

1 Like