private void RunLoopWithDSAPI() { _dsAPI.setDepthExposureAndGain(33f, 1.0f); _dsAPI.enableDepth(Frame.DEPTH_WIDTH, Frame.DEPTH_WIDTH, (int)Frame.DEPTH_RATE); _dsAPI.enableColor(Frame.COLOR_WIDTH, Frame.COLOR_HEIGHT, (int)Frame.COLOR_RATE); _dsAPI.startCapture(); while (!_stop) { _dsAPI.grabFrame(); MemoryFrame frame = _pool.ObjectFromPool(); byte[] depthBytes = _dsAPI.getDepthImage(); byte[] colorBytes = _dsAPI.getColorImage(); byte[] depthPreviewBytes = _dsAPI.getDepthImageAsRGB(); Buffer.BlockCopy(depthBytes, 0, frame.BufferDepth, 0, depthBytes.Length); Buffer.BlockCopy(depthPreviewBytes, 0, frame.BufferDepthPreview, 0, depthPreviewBytes.Length); Buffer.BlockCopy(colorBytes, 0, frame.BufferColor, 0, colorBytes.Length); using (Handle <MemoryFrame> frameHandle = new Handle <MemoryFrame>(frame, _pool)) { FrameArrivedEventArgs eventArgs = new FrameArrivedEventArgs() { FrameHandle = frameHandle }; if (this.FrameArrived != null) { this.FrameArrived(this, eventArgs); } } } }