private void PollData() { Debug.Log("KinectProxy polling"); // Declare the hashtable reference. RawFrameData frame = new RawFrameData(); try { // receive bytes IPEndPoint anyIP = new IPEndPoint(IPAddress.Any, 0); byte[] data = client.Receive(ref anyIP); using (var ms = new MemoryStream(data)) { // deserialize. frame.bodies = (List <BodyData>)formatter.Deserialize(ms); OnFrameArrived(frame); } } catch (SocketException e) { if (e.SocketErrorCode != SocketError.WouldBlock) { throw; } } catch (SerializationException e) { Debug.LogError("Failed to deserialize. Reason: " + e.Message); } catch (Exception err) { Debug.LogError(err.ToString()); } }
public void OnFrameArrived(RawFrameData data) { //InternalLog("Raw frame data arrived"); if (LimitQueueSize > 0 && frameQueue.Count >= LimitQueueSize) { InternalLog("raw frame data queue exceded max length, dropping earliest frame data!!"); while (frameQueue.Count >= LimitQueueSize) { frameQueue.Dequeue(); } } frameQueue.Enqueue(data); }
public static uint NuiSkeletonGetNextFrame(uint dwMillisecondsToWait, ref NuiSkeletonFrame pSkeletonFrame) { //TODO: NuiSkeletonGetNextFrame if (dwMillisecondsToWait != 0) { Debug.LogWarning("non-zero wdMillisecondsToWait is not implemented, will be ignored."); } RawFrameData rawFrame = KinectProxy.Instance.GetLatestFrame(); if (rawFrame != null) { int count = 0; foreach (var body in rawFrame.bodies) { PopulateSkeletonData(body, ref pSkeletonFrame.SkeletonData[count++]); } for (; count < Constants.SkeletonCount; count++) { pSkeletonFrame.SkeletonData[count].eTrackingState = NuiSkeletonTrackingState.NotTracked; } return(0); } return((uint)NuiErrorCodes.SkeletalEngineBusy); }