-
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
Using python to access sensor_timestamp from metadata #12058
Comments
Hi @XupengZhu-SW Did you apply a patch script to the kernel before building the librealsense SDK, please? Doing so is necessary when building from source code in order to enable support for hardware timestamps. If you are using a kernel older than 5.13 then the ./scripts/patch-realsense-ubuntu-lts.sh patch script should be used. If the kernel is 5.13 or 5.15 then use ./scripts/patch-realsense-ubuntu-lts-hwe.sh |
Hi Marty, Thanks for the quick response! I find my linux kernel version is 5.19.0-50-generic. The script ./scripts/patch-realsense-ubuntu-lts-hwe.sh does not support my kernel. Do you know which patch script should I use? Moreover, I didn't notice the readme for building from source. Thanks, |
Kernel 5.19 is not yet supported in the RealSense SDK as of the current version 2.54.1. If you require hardware metadata then you can bypass the kernel and not need to use a patch script by building the SDK from source code with CMake with the build flag -DFORCE_RSUSB_BACKEND=TRUE included in the CMake build instruction. An RSUSB build of the SDK includes hardware metadata support. |
Hi Marty, Thank you for your quick reply! I tried building with the flag -DFORCE_RSUSB_BACKEND=TRUE, but there is a bug. I can access the sensor_timestamp now, but the reading is weird:
I got prints:
These readings are in unit of seconds and should have similar values, i.e., around 1690911559.39. FYI, I copy-past the built pyrealsense2 (pybackend2.cpython-38-x86_64-linux-gnu.so Best, |
A RealSense user at #9891 took the approach of dividing the sensor timestamp by 1000./1000. instead of 1e3. An example of a timestamp that this instruction returned was 888.8259390000001
|
Unfortunately dividing the sensor timestamp by "1000./1000." get unreasonable results as well. Build from source in a 5.19 kernel may be problematic. |
What is the result like if you simply remove the division factor?
|
I print out all the time stamps as follows:
I got:
Ideally, all the time stamps should be close to the current time, i.e., "1690995514" in second, but only ".time_of_arrival" and ".get_timestamp()" are reasonable. |
Different timestamps have different characteristics. At #2188 (comment) a RealSense team member provides a list of timestamp types and descriptions for them, and further information about how the timestamps work at #4525 |
Hi there, I am trying to access accurate time stamp when the image is captured by the sensor. For previous post I know that there are 4 stamps availabe:
frames.get_frame_metadata(rs.frame_metadata_value.backend_timestamp)
frames.get_frame_metadata(rs.frame_metadata_value.frame_timestamp)
frames.get_frame_metadata(rs.frame_metadata_value.sensor_timestamp)
frames.get_frame_metadata(rs.frame_metadata_value.time_of_arrival)
From the explanations, the sensor_timestamp is what I need. However, I cannot access this attribute using pyrealsense2 package. I got error "RuntimeError: metadata not available".
I also tried build from source with "cmake . -DENFORCE_METADATA=true -DBUILD_PYTHON_BINDINGS:bool=true -DPYTHON_EXECUTABLE=/home/...", but the build do not build a python binding.
Any idea to access time_stamp using python? Thanks in advance for the help!
Best,
XP
The text was updated successfully, but these errors were encountered: