/// <summary> /// Constructor where a buffer allocation isn't needed /// </summary> /// <param name="dataFormat"> /// A <see cref="VideoCamera.DataFormatOption"/> /// </param> /// <param name="bufferPointer"> /// A <see cref="IntPtr"/> /// </param> internal ImageMap(VideoCamera.DataFormatOption dataFormat, IntPtr bufferPointer) { this.Width = VideoCamera.DataFormatDimensions[dataFormat].X; this.Height = VideoCamera.DataFormatDimensions[dataFormat].Y; this.DataFormat = dataFormat; this.Data = null; this.dataHandle = default(GCHandle); this.DataPointer = bufferPointer; }
/// <summary> /// Constructor that allocates a pinned buffer /// </summary> /// <param name="dataFormat"> /// A <see cref="VideoCamera.DataFormatOption"/> /// </param> /// <param name="allocateBuffer"> /// /// </param> internal ImageMap(VideoCamera.DataFormatOption dataFormat) { this.Width = VideoCamera.DataFormatDimensions[dataFormat].X; this.Height = VideoCamera.DataFormatDimensions[dataFormat].Y; this.DataFormat = dataFormat; this.Data = new byte[VideoCamera.DataFormatSizes[dataFormat]]; this.dataHandle = GCHandle.Alloc(this.Data, GCHandleType.Pinned); this.DataPointer = this.dataHandle.AddrOfPinnedObject(); }
/// <summary> /// Sets the VideoCamera's data format. Support function for VideoCamera.DataFormat property. /// </summary> /// <param name="format"> /// Format to change the video camera to /// </param> protected void SetDataFormat(VideoCamera.DataFormatOption format) { // change imagemap that's waiting cause format has changed this.UpdateNextFrameImageMap(); // change format int result = KinectNative.freenect_set_video_format(this.parentDevice.devicePointer, format); if (result != 0) { throw new Exception("Could not switch to video format " + format + ". Error Code: " + result); } this.dataFormat = format; }
public static extern int freenect_set_video_format(IntPtr device, VideoCamera.DataFormatOption rgbFormat);