internal override void ReleaseXNAResources() { if (VideoTextureBuffer != null) { VideoTextureBuffer.Dispose(); } if (DepthTextureBuffer != null) { DepthTextureBuffer.Dispose(); } }
void UploadTextures() { if (ColorData != null && DepthData != null && !BufferUsageDisabled && XNAReady) { VideoTextureBuffer.SetData(ColorData); DepthTextureBuffer.SetData(DepthData); VideoTextureBuffer.SetData(ColorData); DepthTextureBuffer.SetData(DepthData); FileLoaded = true; } }
internal override void ReleaseXNAResources() { XNAReady = false; if (VideoTextureBuffer != null) { VideoTextureBuffer.Dispose(); VideoTextureBuffer = null; } if (DepthTextureBuffer != null) { DepthTextureBuffer.Dispose(); DepthTextureBuffer = null; } FileLoaded = false; }
void ProcessingWorker() { XKinect.LED.Color = LEDColor.Red; ThreadsOn = true; while (ThreadsOn) { Kinect.ProcessEvents(); XKinect.UpdateStatus(); Thread.Sleep(1); } switch (Mode) { case Modes.RGB1024: case Modes.RGB480: XKinect.VideoCamera.Stop(); VideoTextureBuffer.Dispose(); break; case Modes.IR1024: case Modes.IR480: XKinect.VideoCamera.Stop(); VideoTextureBuffer.Dispose(); break; case Modes.Depth480: XKinect.DepthCamera.Stop(); DepthTextureBuffer.Dispose(); XKinect.VideoCamera.Stop(); VideoTextureBuffer.Dispose(); break; } Prebuffer = null; XKinect.LED.Color = LEDColor.Yellow; StopARE.Set(); }
void DepthDataReceived(object sender, BaseCamera.DataReceivedEventArgs e) { if (!BufferUsageDisabled) { DepthBufferInUse = true; switch (Mode) { case Modes.Depth480: if (DepthMeasurementWindow != null) { int x1 = DepthMeasurementWindow.Value.X, y1 = DepthMeasurementWindow.Value.Y; int x2 = DepthMeasurementWindow.Value.Width + x1, y2 = DepthMeasurementWindow.Value.Height + y1; int n, dmax = 10000, w = x2 - x1 + 1, h = y2 - y1 + 1, pos, x; byte[] data = e.Data.Data; for (int i = x1; i <= x2; i++) { n = 0; for (int j = y1; j <= y2; j++) { pos = (j * DepthWidth + i) * 2; x = data[pos + 1] << 8; x += data[pos]; n += x; } n /= h; if (n < dmax) { dmax = n; } } Depth = dmax; DepthCount++; DepthSum += Depth; DepthAverage = (double)DepthSum / DepthCount; } FrameCounter++; DepthTextureBuffer.SetData(e.Data.Data); break; } DepthBufferInUse = false; } else { BufferReleaseARE.Set(); } OnRawFrameIn(e.Data.Data, FrameTypes.Depth); if (RawSaveDepthNext) { string path = RawSavePath + ".rwd"; try { File.WriteAllBytes(path, e.Data.Data); SendIOEvent(new IOEventArgs(path, true, null)); } catch (Exception t) { SendIOEvent(new IOEventArgs(path, false, t.Message)); } RawSaveDepthNext = false; } }