Example #1
0
        /// <summary>
        /// Gets a nice C# library version of the Frame Mode class
        /// </summary>
        /// <param name="mode">
        /// A <see cref="FreenectFrameMode"/>
        /// </param>
        /// <returns>
        /// A <see cref="FrameMode"/>
        /// </returns>
        internal static FrameMode FromInterop(FreenectFrameMode nativeMode, FrameModeType type)
        {
            FrameMode mode = null;

            // Make sure mode is valid
            if (nativeMode.IsValid == 0)
            {
                return(null);
            }

            // Figure out what type of mode it is
            if (type == FrameMode.FrameModeType.VideoFormat)
            {
                mode = new VideoFrameMode();
            }
            else if (type == FrameMode.FrameModeType.DepthFormat)
            {
                mode = new DepthFrameMode();
            }

            // Copy over rest of data
            mode.nativeMode          = nativeMode;
            mode.Size                = nativeMode.Bytes;
            mode.Width               = nativeMode.Width;
            mode.Height              = nativeMode.Height;
            mode.Resolution          = nativeMode.Resolution;
            mode.DataBitsPerPixel    = nativeMode.DataBitsPerPixel;
            mode.PaddingBitsPerPixel = nativeMode.PaddingBitsPerPixel;
            mode.FrameRate           = nativeMode.Framerate;
            mode.videoFormat         = nativeMode.VideoFormat;
            mode.depthFormat         = nativeMode.DepthFormat;

            return(mode);
        }
 /// <summary>
 /// Constructor with only mode and data pointer specified. No allocation is made.
 /// </summary>
 /// <param name="mode">
 /// A <see cref="VideoFrameMode"/>
 /// </param>
 internal BaseDataMap(FrameMode mode, IntPtr bufferPointer)
 {
     this.Width       = mode.Width;
     this.Height      = mode.Height;
     this.CaptureMode = mode;
     this.Data        = null;
     this.dataHandle  = default(GCHandle);
     this.DataPointer = bufferPointer;
 }
 /// <summary>
 /// Constructor with only mode speicifed. Data is allocated inside.
 /// </summary>
 /// <param name="mode">
 /// A <see cref="VideoFrameMode"/>
 /// </param>
 internal BaseDataMap(FrameMode mode)
 {
     // Save format and resolution
     this.Width       = mode.Width;
     this.Height      = mode.Height;
     this.CaptureMode = mode;
     this.Data        = new byte[mode.Size];
     this.dataHandle  = GCHandle.Alloc(this.Data, GCHandleType.Pinned);
     this.DataPointer = this.dataHandle.AddrOfPinnedObject();
 }
        /// <summary>
        /// Updates list of depth modes that this camera has.
        /// </summary>
        private void UpdateDepthModes()
        {
            List <DepthFrameMode> modes = new List <DepthFrameMode>();

            // Get number of modes
            int numModes = KinectNative.freenect_get_depth_mode_count(this.parentDevice.devicePointer);

            // Go through modes
            for (int i = 0; i < numModes; i++)
            {
                DepthFrameMode mode = (DepthFrameMode)FrameMode.FromInterop(KinectNative.freenect_get_depth_mode(i), FrameMode.FrameModeType.DepthFormat);
                if (mode != null)
                {
                    modes.Add(mode);
                }
            }

            // All done
            this.Modes = modes.ToArray();
        }
 /// <summary>
 /// Constructor #2
 /// </summary>
 /// <param name="mode">
 /// A <see cref="FrameMode"/>
 /// </param>
 /// <param name="buffer">
 /// A <see cref="IntPtr"/>
 /// </param>
 public DepthMap(FrameMode mode, IntPtr buffer) : base(mode, buffer)
 {
 }
 /// <summary>
 /// Constructor #1
 /// </summary>
 /// <param name="mode">
 /// A <see cref="FrameMode"/>
 /// </param>
 public DepthMap(FrameMode mode) : base(mode)
 {
 }
 /// <summary>
 /// Finds a mode, given a format and resolution.
 /// </summary>
 /// <param name="format">
 /// Depth format for the mode
 /// </param>
 /// <param name="resolution">
 /// Resolution for the mode
 /// </param>
 /// <returns>
 /// Mode with the format/resolution combo. Null if the combination is invalid.
 /// </returns>
 public static DepthFrameMode Find(DepthFormat format, Resolution resolution)
 {
     return((DepthFrameMode)FrameMode.FromInterop(KinectNative.freenect_find_depth_mode(resolution, format), FrameMode.FrameModeType.DepthFormat));
 }
Example #8
0
		/// <summary>
		/// Constructor #2
		/// </summary>
		/// <param name="mode">
		/// A <see cref="FrameMode"/>
		/// </param>
		/// <param name="buffer">
		/// A <see cref="IntPtr"/>
		/// </param>
		public DepthMap(FrameMode mode, IntPtr buffer) : base(mode, buffer)
		{
			
		}
Example #9
0
		/// <summary>
		/// Constructor #1
		/// </summary>
		/// <param name="mode">
		/// A <see cref="FrameMode"/>
		/// </param>
		public DepthMap(FrameMode mode) : base(mode)
		{
			
		}
Example #10
0
 /// <summary>
 /// Constructor #2
 /// </summary>
 /// <param name="mode">
 /// A <see cref="FrameMode"/>
 /// </param>
 /// <param name="buffer">
 /// A <see cref="IntPtr"/>
 /// </param>
 public ImageMap(FrameMode mode, IntPtr buffer) : base(mode, buffer)
 {
 }
Example #11
0
 /// <summary>
 /// Constructor #1
 /// </summary>
 /// <param name="mode">
 /// A <see cref="FrameMode"/>
 /// </param>
 public ImageMap(FrameMode mode) : base(mode)
 {
 }
Example #12
0
 /// <summary>
 /// Finds a mode, given a format and resolution.
 /// </summary>
 /// <param name="format">
 /// Video format for the mode
 /// </param>
 /// <param name="resolution">
 /// Resolution for the mode
 /// </param>
 /// <returns>
 /// Mode with the format/resolution combo. Null if the combination is invalid.
 /// </returns>
 public static VideoFrameMode Find(VideoFormat format, Resolution resolution)
 {
     return((VideoFrameMode)FrameMode.FromInterop(KinectNative.freenect_find_video_mode(resolution, format), FrameMode.FrameModeType.VideoFormat));
 }
Example #13
0
		/// <summary>
		/// Constructor with only mode speicifed. Data is allocated inside.
		/// </summary>
		/// <param name="mode">
		/// A <see cref="VideoFrameMode"/>
		/// </param>
		internal BaseDataMap(FrameMode mode)
		{
			// Save format and resolution
			this.Width = mode.Width;
			this.Height = mode.Height;
			this.CaptureMode = mode;
			this.Data = new byte[mode.Size];
			this.dataHandle = GCHandle.Alloc(this.Data, GCHandleType.Pinned);
			this.DataPointer = this.dataHandle.AddrOfPinnedObject();
		}
Example #14
0
		/// <summary>
		/// Constructor with only mode and data pointer specified. No allocation is made.
		/// </summary>
		/// <param name="mode">
		/// A <see cref="VideoFrameMode"/>
		/// </param>
		internal BaseDataMap(FrameMode mode, IntPtr bufferPointer)
		{
			this.Width = mode.Width;
			this.Height = mode.Height;
			this.CaptureMode = mode;
			this.Data = null;
			this.dataHandle = default(GCHandle);
			this.DataPointer = bufferPointer;
		}
Example #15
0
		/// <summary>
		/// Constructor #2
		/// </summary>
		/// <param name="mode">
		/// A <see cref="FrameMode"/>
		/// </param>
		/// <param name="buffer">
		/// A <see cref="IntPtr"/>
		/// </param>
		public ImageMap(FrameMode mode, IntPtr buffer) : base(mode, buffer)
		{
			
		}
Example #16
0
		/// <summary>
		/// Constructor #1
		/// </summary>
		/// <param name="mode">
		/// A <see cref="FrameMode"/>
		/// </param>
		public ImageMap(FrameMode mode) : base(mode)
		{
			
		}