Items with no label
3335 Discussions

D435 C# Record and Playback depth and color streams

MCC001
Novice
1,643 Views

Is there any sample available demonstrating recording and playback code using C# ? In the sdk I see there is a Playback and RecordingDevice classes available.. but couldnt find any example using them.

 

cheers

Max

7 Replies
MartyG
Honored Contributor III
1,206 Views

The link below has a long discussion of recording with C#.

https://github.com/IntelRealSense/librealsense/issues/3142

​Within that discussion, a RealSense community member posts the script of their solution here:

 

https://github.com/IntelRealSense/librealsense/issues/3142#issuecomment-465494716

0 Kudos
MCC001
Novice
1,206 Views

I used the above links to further my work and can successfully record images in *.bag file.

however playback using c# still doesnt seem to work.

 

Below is my code. For some reasons my playback.Status value is always "Stopped". Any suggestions would be greatly appreciated. Thank you.

 

 

var ctx = new Context();

        var dev = ctx.AddDevice(@"C:\temp\20190522_133223.bag");

        cfg = new Config();

        pipeline = new Pipeline(ctx);   

                                     

        var token = tokenSource.Token;

 

        using (pipeline.Start())

        using (var playback = PlaybackDevice.FromDevice(dev))

        {

          Debug.WriteLine(playback.FileName);

          playback.Realtime = false;

          playback.Resume();

          var t = Task.Run(async () =>

          {

            var start = DateTime.Now;

            while (playback.Status == PlaybackStatus.Playing)

            {

              if (pipeline.PollForFrames(out FrameSet frames))

                using (frames)

                {

                  var releaser = new FramesReleaser();

......

0 Kudos
MCC001
Novice
1,206 Views

Ok i found out what was happening here.

 

The following command adds another device in the list of your devices.

 var ctx = new Context(); 

var dev = ctx.AddDevice(@"C:\temp\My_test100.bag");

 

Which means if you still have your physical sensor connected then by default when you do:

 

var  pipeline = new Pipeline(ctx);

 var pp = pipeline.Start();

 

This will pick up your physical sensor as the default and attempt to start that pipeline. Which is why I kept getting playback.Status as Stopped.

When I disconnected the sensor from my computer then this code rightly sets up the saved file as a device which you can then start and access frames from.

I can post the whole code if someone wants !

 

cheers

Max

 

0 Kudos
MCC001
Novice
1,206 Views

Thank you, much appreciated.

0 Kudos
Eliza_D_Intel
Employee
1,206 Views
Hello MCC001, Thank you for your interest in the Intel RealSense D435 camera. Could you please provide us the full source code so we can reproduce? Thank you, Eliza
Eliza_D_Intel
Employee
1,206 Views

Hello MCC001,

 

We would like to know if you are still requiring assistance on this matter.

 

Thank you,

Eliza

0 Kudos
MCC001
Novice
1,206 Views

Apologies Eliza - I had been away for a while.

But thanks on this particular issue i dont require any support. There is another issue which I'll post soon regarding Playback.

 

Thanks

Max

0 Kudos
Reply