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

Hi,
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)
print(frame_number)
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:
https://www.stereolabs.com/docs/api/python/classpyzed_1_1sl_1_1InitParameters.html#a3bbfffa102044cfdea15b52d0ab14bcb

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:
https://www.stereolabs.com/docs/api/python/classpyzed_1_1sl_1_1Camera.html#a62497cb9d331f804f2592b6088023ddc

1 Like

Perfect! Thank you @Myzhar.

1 Like