public void nui_SkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e) { if (!IsRecording) { return; } lock (RecordStream) { SkeletonFrame skeletonFrame = e.SkeletonFrame; int iSkeleton = 0; foreach (SkeletonData data in skeletonFrame.Skeletons) { if (SkeletonTrackingState.Tracked == data.TrackingState) { //Recording for longer than a day will cause the timer to roll over. Who would record 24+ hours of Kinect data anyways? TimeSpan elapsedTime = DateTime.Now - StartTime; RecordStream.Write(elapsedTime.Hours.ToString() + ":" + elapsedTime.Minutes.ToString() + ":" + elapsedTime.Seconds.ToString() + ":" + elapsedTime.Milliseconds.ToString() + ","); foreach (Joint joint in data.Joints) { RecordStream.Write(joint.ID.ToString() + "," + (joint.Position.X * 1000).ToString() + "," + (joint.Position.Y * 1000) + "," + (joint.Position.Z * 1000) + ","); } RecordStream.WriteLine(""); } iSkeleton++; } // for each skeleton } }
public override int Read(byte[] buffer, int offset, int count) { int bytesRead = InputStream.Read(buffer, offset, count); if (RecordStream != null) { RecordStream.Write(buffer, offset, bytesRead); RecordStream.Flush(); } return(bytesRead); }
/// <summary> /// Add the record item to the record table. /// </summary> /// <param name="item"></param> /// <returns></returns> private long AddRecord(RepeatItem <TValue> item) { byte[] bytes = this.ToRecordBytes(item); int bytelen = bytes.Length; lock (_object) { Int64 insertposition = GetRecordInsertPosition(); RecordStream.Position = insertposition; RecordStream.Write(bytes, 0, bytelen); item.id = insertposition; return(insertposition); } }
public int AddOrGet(string tag) { int key; lock (_lock) if (!_tags.TryGetValue(tag, out key)) { var id = NextTagId(); _tags.Add(tag, key = id); _strings.Add(id, tag); _file.Write(new TagStorageClass { Tag = tag }); _file.Flush(); } return(key); }
public int AddOrGet(IEnumerable <int> tagsIn) { var tags = tagsIn.ToArray(); lock (_lock) { int id; var item = _paths.FirstOrDefault(p => StructuralComparisons.StructuralEqualityComparer.Equals(p.Key, tags)); if (item.Key == null) { id = GetNextPathId(); _paths[tags] = id; _pathLookup[id] = tags; _file.Write(new PathStorageClass { Tags = tags }); _file.Flush(); return(id); } return(item.Value); } }