How to detect the end of replay in Kinect Toolbox

242 views Asked by At

I am using Kinect.Toolbox in my project, i need to show a message after the replay ends. Is there a way to get this moment?

actualy my code do the following

Stream recordStream = File.OpenRead(@"D:\recorded.FisioKinect");
this.Replay = new KinectReplay(recordStream);
this.Replay.ColorImageFrameReady += replay_ColorImageFrameReady;
this.Replay.Start();

and the replay_ColorImageFrameReady is here

void replay_ColorImageFrameReady(object sender, ReplayColorImageFrameReadyEventArgs e)
{
    if (this.Replay.IsFinished)
    {
        MessageBox.Show("End");
    }
    byte[] pixelData = new byte[e.ColorImageFrame.PixelDataLength];
    e.ColorImageFrame.CopyPixelDataTo(pixelData);
    // Other awesome stuff :)
}

Note that the Replay object have a property called IsFinished, but the replay_ColorImageFrameReady will not be raised if the Replay IsFinished, so, the message never will be shown.

The code of Kinect.Toolbox uses TPL and i dont know so much about TPL, i want to change the code of the Kinect.Toolbox to fire an event like OnReplayEnd

1

There are 1 answers

1
bseh On BEST ANSWER

You can build a structure like this:

In your KinectReplay.cs

add

public event EventHandler Closing;

protected virtual void OnClosing()
{
    EventHandler Closing = this.Closing;
    if (Closing != null)
        Closing(this, EventArgs.Empty);
}  

and trigger it wherever you want to use it.

replay.Closing += new EventHandler(replayMediaEnded);