/** * */ public Frame(RecordingReader reader) { this.gesture_id = reader.ReadInt(); this.cmd_id = reader.ReadInt(); time_remaining_s = reader.ReadFloat(); // remaining time text_pos_x = reader.ReadFloat(); // text position x text_pos_y = reader.ReadFloat(); // text position y this.pt = new Vector(63); this.bad_pt = false; for (int i = 0; i < 63; i++) { this.pt[i] = reader.ReadFloat(); if (double.IsNaN(this.pt[i]) == true) { this.bad_pt = true; } if (double.IsInfinity(this.pt[i]) == true) { this.bad_pt = true; } } }
/** * Read in all frames from a binary session file. */ public static void load_session( DeviceType device, int subject_id, List <Frame> frames) { // Build the subject's session path. string session_path = Global.GetRootDirectory() + string.Format("datasets/jk2017/{0}/sessions/U{1:D3}", device == DeviceType.KINECT ? "kinect" : "leap_motion", subject_id); RecordingReader r = new RecordingReader(session_path); //// Read position and extract file size. //// Size should be end position, but //// just in case, do this extract work. // convert to frame_cnt int frame_cnt = (int)r.FrameCount(); for (int ii = 0; ii < frame_cnt; ii++) { Frame frame = new Frame(r); // There is an issue where the main program ran at 60fps, // but the Kinect only samples at 30fps. Some a number of // readings are duplicates and need to be removed. if (ii > 0) { int idx = frames.Count - 1; double distance = frame.pt.L2Norm(frames[idx].pt); if (distance == 0.0) { continue; } } frames.Add(frame); } r.Close(); }