コード例 #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);
        }
コード例 #2
0
        /// <summary>
        /// Sets the current video mode
        /// </summary>
        /// <param name="mode">
        /// Video mode to switch to.
        /// </param>
        protected void SetVideoMode(VideoFrameMode mode)
        {
            // Is this a different mode?
            if (this.Mode == mode)
            {
                return;
            }

            // Stop camera first if running
            bool running = this.IsRunning;

            if (running)
            {
                this.Stop();
            }

            // Check to make sure mode is valid by finding it again
            VideoFrameMode foundMode = VideoFrameMode.Find(mode.Format, mode.Resolution);

            if (foundMode == null)
            {
                throw new Exception("Invalid Video Mode: [" + mode.Format + ", " + mode.Resolution + "]");
            }

            // Save mode
            this.captureMode = mode;

            // All good, switch to new mode
            int result = KinectNative.freenect_set_video_mode(this.parentDevice.devicePointer, foundMode.nativeMode);

            if (result != 0)
            {
                throw new Exception("Mode switch failed. Error Code: " + result);
            }

            // Update image map
            this.UpdateNextFrameImageMap();

            // If we were running before, start up again
            if (running)
            {
                this.Start();
            }
        }
コード例 #3
0
        /// <summary>
        /// Updates list of video modes that this camera has.
        /// </summary>
        private void UpdateVideoModes()
        {
            List <VideoFrameMode> modes = new List <VideoFrameMode>();

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

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

            // All done
            this.Modes = modes.ToArray();
        }
コード例 #4
0
ファイル: FrameMode.cs プロジェクト: EduardMe/libfreenect
		/// <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;
		}
コード例 #5
0
ファイル: VideoCamera.cs プロジェクト: EduardMe/libfreenect
		/// <summary>
		/// Sets the current video mode
		/// </summary>
		/// <param name="mode">
		/// Video mode to switch to.
		/// </param>
		protected void SetVideoMode(VideoFrameMode mode)
		{
			// Is this a different mode?
			if(this.Mode == mode)
			{
				return;	
			}
			
			// Stop camera first if running
			bool running = this.IsRunning;
			if(running)
			{	
				this.Stop();
			}
			
			// Check to make sure mode is valid by finding it again
			VideoFrameMode foundMode = VideoFrameMode.Find(mode.Format, mode.Resolution);
			if(foundMode == null)
			{
				throw new Exception("Invalid Video Mode: [" + mode.Format + ", " + mode.Resolution + "]");
			}
			
			// Save mode
			this.captureMode = mode;
			
			// All good, switch to new mode
			int result = KinectNative.freenect_set_video_mode(this.parentDevice.devicePointer, foundMode.nativeMode);
			if(result != 0)
			{
				throw new Exception("Mode switch failed. Error Code: " + result);
			}
			
			// Update image map
			this.UpdateNextFrameImageMap();
			
			// If we were running before, start up again
			if(running)
			{
				this.Start();	
			}
		}