librealsense icon indicating copy to clipboard operation
librealsense copied to clipboard

loop break condition for data from recorded file?

Open vams08 opened this issue 6 years ago • 3 comments

Hello all, I am using recorded data and when I run hello-realsense example it is looping infinite times instead I want it to run upto last recorded frame only so can any one suggest how to handle this?


Required Info
Camera Model { R200 / F200 / SR300 / ZR300 / D400 }
Firmware Version (Open RealSense Viewer --> Click info)
Operating System & Version {Win (8.1/10) / Linux (Ubuntu 14/16/17) / MacOS
Kernel Version (Linux Only) (e.g. 4.14.13)
Platform PC/Raspberry Pi/ NVIDIA Jetson / etc..
SDK Version { legacy / 2.. }
Language {C/C#/labview/nodejs/opencv/pcl/python/unity }
Segment {Robot/Smartphone/VR/AR/others }

Issue Description

vams08 avatar Jun 13 '20 14:06 vams08

Hi @vams08 In Python, you can stop bag playback from looping by using repeat_playback=false

https://github.com/IntelRealSense/librealsense/issues/4344#issuecomment-507387892

If you are using C++ then the solution is not so obvious. A RealSense user did write a bag playback script though that included "stop condition management" code.

https://github.com/IntelRealSense/librealsense/issues/1579#issuecomment-430163908

MartyG-RealSense avatar Jun 13 '20 16:06 MartyG-RealSense

Thank you @MartyG-RealSense , just now i got another way to do in c++. rs2::frameset frames = p.wait_for_frames(); long long int a = frames.get_frame_number(); using these frame number as stamps we can close the loop.

vams08 avatar Jun 13 '20 16:06 vams08

Great! Thanks for posting the code for the benefit of C++ users. :)

MartyG-RealSense avatar Jun 13 '20 16:06 MartyG-RealSense