So, I've created a program with Kinect as its input. As you know, Kinect will send the data 30 frame per second.
I have a model that will mimic Kinect's input motion, so on Update() I read the motion from Kinect.
The problem is, on Update(), I've done a heavy computational algorithm. It makes the system lag and freezing. I've tried to do the calculation every 60 frames instead of each frame, but the system still got lag.
void Update(){
...
//GET DATA FROM KINECT
frame = new SkeletonRecorded();
frame.root.rotation = skeletons[kinect2SensorID, playerID].root.rotation;
...
frame.rightShoulder.position = skeletons[kinect2SensorID, playerID].rightShoulder.position;
frames.Add(frame);
if (frames.Count >= 60) {
//CALLING THE CALCULATION METHOD (Here is the heavy part begin)
comparatorClass.GetSkeletonData(frames);
frames.Clear();
}
}
The above code is just small parts of the Update() method (I cut it short for convenience). So, how should I call the GetSkeletonData() method without making the interface lag?