AForge.Video.Kinect.Kinect.GetVideoCamera C# (CSharp) Method

GetVideoCamera() public method

Get Kinect's video camera.

The method simply creates instance of the KinectVideoCamera class by calling its appropriate constructor. Use KinectVideoCamera.Start method to start the video then.

public GetVideoCamera ( ) : KinectVideoCamera
return KinectVideoCamera
        public KinectVideoCamera GetVideoCamera( )
        {
            return new KinectVideoCamera( deviceID );
        }

Usage Example

Beispiel #1
0
        // Connect to Kinect cameras
        private bool Connect()
        {
            bool ret = false;

            Cursor = Cursors.WaitCursor;

            if (Kinect.DeviceCount != 0)
            {
                int deviceID = devicesCombo.SelectedIndex;

                try
                {
                    kinectDevice = Kinect.GetDevice(deviceID);

                    if (videoCamera == null)
                    {
                        videoCamera = kinectDevice.GetVideoCamera();
                        videoCamera.CameraMode = (videoModeCombo.SelectedIndex == 0) ? VideoCameraMode.Color :
                            ((videoModeCombo.SelectedIndex == 1) ? VideoCameraMode.Bayer : VideoCameraMode.InfraRed);
                        videoCameraPlayer.VideoSource = videoCamera;
                        videoCameraPlayer.Start();
                    }

                    if (depthCamera == null)
                    {
                        depthCamera = kinectDevice.GetDepthCamera();
                        depthCameraPlayer.VideoSource = depthCamera;
                        depthCameraPlayer.Start();
                    }

                    ledColorCombo.SelectedIndex = 0;

                    if (tiltUpDown.Value != 0)
                    {
                        tiltUpDown.Value = 0;
                    }
                    else
                    {
                        kinectDevice.SetMotorTilt((int)tiltUpDown.Value);
                    }

                    timer.Start();

                    ret = true;
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Failed connecting to Kinect device.\n" + ex.Message,
                        "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

                    Disconnect();
                }
            }

            Cursor = Cursors.Default;

            return ret;
        }
All Usage Examples Of AForge.Video.Kinect.Kinect::GetVideoCamera