Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not all frames run? #8704

Closed
ls880 opened this issue Mar 30, 2021 · 18 comments
Closed

Not all frames run? #8704

ls880 opened this issue Mar 30, 2021 · 18 comments
Labels

Comments

@ls880
Copy link

ls880 commented Mar 30, 2021

When running functions like pointcloud and rosbag_example on matlab, I'm unsure these run every frame. If I stop at the same point running two different times this gives a different output? How do I ensure every frame is chosen to run?

@MartyG-RealSense
Copy link
Collaborator

MartyG-RealSense commented Mar 30, 2021

Hi @ls880 A RealSense team member provides guidance in the link below about how to obtain the timestamp of each frame of a program in the RealSense MATLAB wrapper, such as rosbag_example.m. Is this helpful to you, please?

#3965 (comment)

As the MATLAB script that the advice refers to has been updated slightly since the comment in the above link was written, I believe that the line that the advice is likely referring to is this:

https://github.com/IntelRealSense/librealsense/blob/master/wrappers/matlab/frame.m#L28

@ls880
Copy link
Author

ls880 commented Apr 5, 2021

Sorry for the late reply, I have been having computer problems. I have tried this and I get an error stating that timestamp domain is the system time, not the frame time. This also come up on the RS viewer tool. How do I change this?

@ls880
Copy link
Author

ls880 commented Apr 5, 2021

It also states that per frame metadata isn't enable at OS level and to follow installation guide for details

@ls880
Copy link
Author

ls880 commented Apr 5, 2021

But essentially I still have the problem that the frames do not run in order? Even using this feature I can see that the frames seemingly come out randomly?

@MartyG-RealSense
Copy link
Collaborator

If you are using the RealSense MATLAB wrapper then you are likely using Windows 10 on your computer. Is that correct, please?

If you are using Windows, then you can enable metadata for your camera in the RealSense Viewer program. If a Frame Metadata Disabled box pops up in the corner of the Viewer when it is launched then left-click on the box's Enable button to enable per-frame metadata.

image

@ls880
Copy link
Author

ls880 commented Apr 6, 2021

Hi, I have tried this but when I run the code files the frames still do no run in order, they seem completely random

@MartyG-RealSense
Copy link
Collaborator

A bag file always runs in the forward direction when played and does not run backwards. So there is a certain amount of predictable linearity in the playback, and once the bag reaches the end then it will loop around to the start and play from start frame to end again unless playback looping is disabled.

Could you tell me please which method you use to stop the bag playback and check the frame number? If you were using a 'stop' button then it would be very hard to stop the playback on the same frame number each time due to te speed at which frames are played back.

@ls880
Copy link
Author

ls880 commented Apr 12, 2021

I am currently using the beginning of the pointcloud example to run through the frames and have put a break point at the end of the loop. Many frames seem to be missing when using this method. I have been advised that with .bag files, some frames are not able to be captured fast enough and the next one will be used instead. Is there a way I can ensure that all frames are captured?

function pointcloud_example(Cross)
% Make Config object to manage pipeline settings
% From rosbag_example
cfg = realsense.config();
validateattributes(Cross, {'char','string'}, {'scalartext', 'nonempty'}, '', 'Cross', 1);
% Tell pipeline to stream from the given rosbag file
cfg.enable_device_from_file(Cross)

% Make Pipeline object to manage streaming
pipe = realsense.pipeline();

pointcloud = realsense.pointcloud();

% Start streaming from file with default settings
profile = pipe.start(cfg);

figure('units','normalized','outerposition',[0 0 1 1])

% Main loop
for i = 1:600

    % Obtain frames from a streaming device
    fs = pipe.wait_for_frames();

@ls880
Copy link
Author

ls880 commented Apr 12, 2021

Is it possible o implement the playback.m rather than pipeline.m and alter the playback speed, line 49?

@MartyG-RealSense
Copy link
Collaborator

MartyG-RealSense commented Apr 13, 2021

Apologies for the delay in responding further. Looking through your code, I notice that it is not using a command called playback.set_real_time(false);

Setting set_real_time to False is commonly done to help ensure smooth playback when reading frames from a bag file instead of live camera data. A C++ example script that demonstrates this function is in the link below.

#2743

image

The official SDK documentation entry about set_real_time is here:

https://intelrealsense.github.io/librealsense/doxygen/classrs2_1_1playback.html#aca02f3a4b789b150d2b7699d27a94324

@ls880
Copy link
Author

ls880 commented Apr 13, 2021

I have tried adding this in but I only seem to get error messages that there are not enough inputs, or "Unable to resolve the name playback.set_real_time"? I tried to implement similar to this issue: #3126

cfg.enable_device_from_file(filename)

% Make Pipeline object to manage streaming
pipe = realsense.pipeline();

% Start streaming from the file with default settings
profile = pipe.start(cfg);
device = profile.get_device();
run = realsense.playback(device)
playback.set_real_time(false)

@MartyG-RealSense
Copy link
Collaborator

MartyG-RealSense commented Apr 13, 2021

Comparing your code to the linked-to script, it looks as though playback has not been defined in the line before it is called by playback.set_real_time

rs2::playback playback = device.as<rs2::playback>();

I also note that your quoted script above is missing some semicolons on the end of the lines, in these lines:

cfg.enable_device_from_file(filename)
run = realsense.playback(device)
playback.set_real_time(false)

@ls880
Copy link
Author

ls880 commented Apr 13, 2021

This is not valid code in matlab, so I wrote it as below but I still get the error. It seems to want a second input for the index?

Error:
Not enough input arguments.

Error in realsense.playback (line 6)
this = this@realsense.device(handle, index);

Code:
profile = pipe.start(cfg);
device = profile.get_device();
playback = realsense.playback(device);
playback.set_real_time(false)

@MartyG-RealSense
Copy link
Collaborator

I found an example of a RealSense user who wrote a set_real_time playback routine in the MATLAB wrapper and how it was debugged.

#4034

@ls880
Copy link
Author

ls880 commented Apr 15, 2021

This is great, these comments have helped me find the error thank you! One last question; is there any way to find the number of depth frames, other than using the realsense viewer?

@MartyG-RealSense
Copy link
Collaborator

MartyG-RealSense commented Apr 15, 2021

Great news that you were successful with get_real_time in the MATLAB wrapper!

If you are using a bag file, you could check the number of messages in the recorded depth topics with the SDK's rosbag inspector C++ tool.

https://github.com/IntelRealSense/librealsense/tree/master/tools/rosbag-inspector

@MartyG-RealSense
Copy link
Collaborator

Hi @ls880 Do you require further assistance with this case, please? Thanks!

@MartyG-RealSense
Copy link
Collaborator

Case closed due to no further comments received.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants