New to Telerik UI for WinForms? Download free 30-day trial

Connect to a Camera Device

If you have more than one camera devices, you can specify which device to use. The code snippet below demonstrates how to get the video and audio devices and initialize the camera with them.

The RadWebCam.AutoStart property should be set to false if you want to initialize it with a specific camera device.

To connect to a web cam manually, execute the following steps:

  1. Get the camera device. To do this, use the RadWebCam.GetVideoCaptureDevices static method.
  2. Get a video format from the camera. To do this, use the RadWebCam.GetVideoFormats static method.
  3. Initialize the camera device in the control. To do this, use the Initialize method of the RadWebCam control.
  4. Start the web cam control. To do this, use the Start method of the control.

The manual initialization of RadWebCam should be executed after the control gets loaded. For example, you can use the form's Load event.

            ReadOnlyCollection<MediaFoundationDeviceInfo> videoDevices = RadWebCam.GetVideoCaptureDevices();
            ReadOnlyCollection<MediaFoundationVideoFormatInfo> videoFormats = RadWebCam.GetVideoFormats(videoDevices[1], true);
            ReadOnlyCollection<MediaFoundationDeviceInfo> audioDevices = RadWebCam.GetAudioCaptureDevices();
            radWebCam1.Initialize(videoDevices[1], videoFormats[9], audioDevices[1]);

        Dim videoDevices As ReadOnlyCollection(Of MediaFoundationDeviceInfo) = RadWebCam.GetVideoCaptureDevices()
        Dim videoFormats As ReadOnlyCollection(Of MediaFoundationVideoFormatInfo) = RadWebCam.GetVideoFormats(videoDevices(1), True)
        Dim audioDevices As ReadOnlyCollection(Of MediaFoundationDeviceInfo) = RadWebCam.GetAudioCaptureDevices()
        radWebCam1.Initialize(videoDevices(1), videoFormats(9), audioDevices(1))

See Also

In this article