none
How to have Kinect fire all frames ready event only at certain times RRS feed

  • Question

  • Hi,

    In my wpf application I'm recording data from the Kinect, but only during certain points of the application. The all frames ready event sensor_ready is where the data is collected and recorded to a file. But the Kinect records data always, and it's really slowing everything down. So I thought I could just turn off the event when I don't want data recorded, on turn it back on when I do.

    I'm using the KinectSensorChooser(variable named sensorChooser), and when I type this in my code:

    sensorChooser.Kinect.AllFramesReady += sensor_ready;

    I get the null reference error. I can subscribe to the event in the KinectStatusChanged event because I can type this:

    args.NewSensor.Kinect.AllFramesReady += sensor_ready;

    The args come from the event arguments. But I can't write it like this anywhere else in the code because the args arguments are a local variable to that event.

    So I don't know how to start and stop the event, so I also tried this: I have a boolean variable in my code that is set to true when I want data recorded from the Kinect. So the event is always run whenever a frame is received from the Kinect, but then I have a check inside the event handler code that checks if the variable is true. If it is the code is run, and otherwise nothing happens, the event just keeps getting fired and the code inside it is not run. But for some reason this doesn't work either. I think maybe it's that I'm setting the boolean wrong so it's always true and always recording but I've checked it over and over and I don't think that's the problem. Should this idea work? 

    Do you have any other ideas/suggestions you think I should try?

    What I was doing before that does work, but causes my program to go insanely slow and laggy is: start and stop the sensorchooser every time that I want to start and stop recording (using sensorChooser.start() and sensorChooser.Stop()). But like I said when I do this the application is not even usuable so I need a better solution.

    Any input is appreciated. Thank you

    Thursday, July 18, 2013 7:49 PM

All replies