-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Incoherent frameset: frame number mismatch frames #7807
Comments
Same thing with depth and color: #include <librealsense2/rs.hpp> // Include RealSense Cross Platform API
#include <iostream>
#include <unistd.h>
int main(int argc, char * argv[])
{
try
{
const int N = 100;
rs2::config config;
config.enable_stream(RS2_STREAM_DEPTH, 848, 480, RS2_FORMAT_Z16, 30);
config.enable_stream(RS2_STREAM_COLOR, 848, 480, RS2_FORMAT_RGB8, 30);
rs2::pipeline pipe;
{
auto selection = pipe.start(config);
rs2::device selected_device = selection.get_device();
auto depth_sensor = selected_device.first<rs2::depth_sensor>();
depth_sensor.set_option(RS2_OPTION_VISUAL_PRESET,RS2_RS400_VISUAL_PRESET_DEFAULT);
}
double preTimestampDepth = 0;
double preTimestampColor = 0;
for (int i = 0; i < N; i++)
{
auto fs = pipe.wait_for_frames();
auto depth_frame = fs.get_depth_frame();
auto color_frame = fs.get_color_frame();
double timestampDepth = depth_frame.get_timestamp();
double timestampColor = color_frame.get_timestamp();
if (i == 0)
{
printf("frame [%02d]. depth : frame# %lld, timestamp diff [%7.3f]. color : frame# %lld, timestamp diff[%7.3f].\n", i,
depth_frame.get_frame_number(), 0.0f,
color_frame.get_frame_number(), 0.0f);
}
else
{
printf("frame [%02d]. depth : frame# %lld, timestamp diff [%7.3f]. color : frame# %lld, timestamp diff[%7.3f].\n", i,
depth_frame.get_frame_number(), timestampDepth - preTimestampDepth,
color_frame.get_frame_number(), timestampColor - preTimestampColor );
}
preTimestampDepth = timestampDepth;
preTimestampColor = timestampColor;
}
return EXIT_SUCCESS;
}
catch (const rs2::error & e)
{
std::cerr << "RealSense error calling " << e.get_failed_function() << "(" << e.get_failed_args() << "):\n " << e.what() << std::endl;
return EXIT_FAILURE;
}
catch (const std::exception& e)
{
std::cerr << e.what() << std::endl;
return EXIT_FAILURE;
}
} Output:
|
Hi @randomstuff If you are not using a point cloud and do not need the reduced point cloud spraying that the Default visual preset provides, then it should be fine to leave the visual preset instruction out and let the default configuration settings be used. The majority of people use a preset to achieve a biased weighting of settings that favor certain characteristics but have a trade-off in other characteristics (e.g the High Accuracy preset for higher accuracy at the cost of reduced fill rate). If you want a balanced spread of characteristics then the camera default settings should be sufficient. |
I'm not sure I'm following you. The settings (such as Note: I checked with a visual inspection of the frames and I think the frames are actually synchronized even if the frame numbers are not consistent. |
Thanks very much for the update @randomstuff - given your visual inspection of the frames, do you believe that there is still a problem that needs resolving, please? Thanks! |
The frames seems in sync but the frames have a different frame number. Is this expected (especially for depth/infrared) or are we expected to be able to use the frame numbers for frames synchronization? |
I reviewed your case again from the beginning again to look for new insights. Basically, the situation as I understand it is:
depth_sensor.set_option(RS2_OPTION_VISUAL_PRESET,RS2_RS400_VISUAL_PRESET_DEFAULT); I researched similar cases of setting a built-in visual preset with C++ using this method, and observed that the line above seems to be missing some code compared to the cases I researched. Could you therefore try adjusting your visual preset line to use the code below, please?
|
To summarize, when using the following lines after depth_sensor.set_option(RS2_OPTION_VISUAL_PRESET,RS2_RS400_VISUAL_PRESET_DEFAULT); The frames in a
However, the timestamp is the same inside the same frame [00]. depth : frame# 33, timestamp [1606311696103.691]. infrared : frame# 35, timestamp [1606311696103.691].
frame [01]. depth : frame# 34, timestamp [1606311696137.537]. infrared : frame# 36, timestamp [1606311696137.537].
frame [02]. depth : frame# 35, timestamp [1606311696171.317]. infrared : frame# 37, timestamp [1606311696171.317].
frame [03]. depth : frame# 36, timestamp [1606311696205.030]. infrared : frame# 38, timestamp [1606311696205.030].
frame [04]. depth : frame# 37, timestamp [1606311696238.677]. infrared : frame# 39, timestamp [1606311696238.677].
frame [05]. depth : frame# 38, timestamp [1606311696272.641]. infrared : frame# 40, timestamp [1606311696272.641]. As per bug 2224, I thought this difference of frame number was a sign that the frames were not synchronized correctly by librealsense inside the However, visual inspection of the frames did not allow me to conclude there was a mismatch within a In this use-case, for a single
How should I ensure that two frames actually map to the same moment in the real world?
|
You suggest I should try using the following line: depth_sensor.set_option(rs2_option::RS2_OPTION_VISUAL_PRESET,
rs2_rs400_visual_preset::RS2_RS400_VISUAL_PRESET_DEFAULT); This line is however equivalent to the one I'm using: depth_sensor.set_option(RS2_OPTION_VISUAL_PRESET,RS2_RS400_VISUAL_PRESET_DEFAULT); as: typedef enum rs2_option
{
// ....
RS2_OPTION_VISUAL_PRESET,
// ...
};
// ...
typedef enum rs2_rs400_visual_preset
{
// ...
RS2_RS400_VISUAL_PRESET_DEFAULT,
// ...
} rs2_rs400_visual_preset; |
I reviewed your case again from the start and noted that you list in the specification box at the top of the case that you are using kernel 5.9. SDK 2.39.0 is known to be able to work unofficially with kernel 5.4-generic (official kernel 5.4 support was added in SDK 2.40.0). There is no previous case I know of where a newer Linux Kernel than 5.4 has been used with librealsense though. It may therefore be worth trying to build librealsense from source code with the RSUSB method that bypasses the kernel. RSUSB - activated by including the term -DFORCE_RSUSB_BACKEND=true in a CMake buid instruction - requires an internet connection but is not dependent on Linux versions or kernel versions and does not require patching. I akso note that the camera firmware version listed - 05.11.01.100 - is very old, and the recommended firmware version for SDK 2.39.0 is 5.12.8.200. |
Hi @randomstuff Do you require further assistance with this case, please? Thanks! |
Sorry for the delay. Compiling the same code with Note: I need to run as I'll try to update the firmware as well. |
Thanks very much for the update @randomstuff |
I guess this was expected but updating the firmware does not change that. |
For reference, the RUSB backend requires access to |
Hi @randomstuff Do you need further advice from me about anything please? Thanks! |
I assume the bug will be fixed because this kernel version is not supported. The current state is fine for me: AFAIU, the bug is more about the metadata which is incorrectly reported than an actual desync of the frames. |
If you are referring to #2224, it looks as though timestamp differences are regarded as a consequence of the rules of depth-RGB sync rather than a bug. |
Hi @randomstuff Do you require further assistance with this case, please? Thanks! |
No, it should be OK for me. |
Thanks very much for the update @randomstuff - I will close this case now if you are satisified. Thanks again! |
Issue Description
When enabling
RS2_RS400_VISUAL_PRESET_DEFAULT
, the frames are not coherent within a singlers2::frameset
: the frame numbers (infrared and depth frames) do not match.Minimal example (derived from issue 2224):
Output:
This is fixed by removing line (1).
The text was updated successfully, but these errors were encountered: