Opening and Handling Devices: Open Device

Short source code snippet that illustrates how to open a device and display its live video stream, using the shipped dialog box.
Language:.NET C#/Visual Basic
Version:3.0.3
Released on:April 7, 2005
Author:IC Imaging Control Support Department
Requirements:IC Imaging Control >2.1
Camera, converter or grabber with WDM Stream Class drivers.

The window of the resulting application looks as follows:

The dialog window of the sample application.

First of all, the program lists the names of all available video capture devices available on the system in the list box listBox1. All video capture devices names are added to the listBox1, by setting the listBox1.DataSource attribute to IcImagingControl.Devices.

[C#]
private void Form1_Load(object sender, System.EventArgs e)
{
    listBox1.DataSource = icImagingControl1.Devices;
}

When the user clicks "Open Device", the program stops the live video stream (.LiveStop). It then proceeds to gets the selected video capture device, using (listBox1.SelectedItem). And finally, live image data stream of the device is displayed using .LiveStart:

[C#]
private void buttonOpen_Click(object sender, System.EventArgs e)
{
    TIS.Imaging.Device dev = listBox1.SelectedItem as TIS.Imaging.Device;

    if( dev != null )
    {
        icImagingControl1.LiveStop();
                icImagingControl1.Device = dev;
        icImagingControl1.LiveStart();
    }
}

private void buttonClose_Click(object sender, System.EventArgs e)
{
    Close();
}

Related Source Code Samples

Disclaimer
The source code that appears in the IC Imaging Control Source Code Library is indented for educational purposes only. The Imaging Source Europe GmbH, the manufacturer of IC Imaging Control, does not assume any kind of warranty expressed or implied, resulting from the use of the content of this page.

This site is part of The Imaging Source Network. Other sites include Company Portal, Image Processing, Astronomy Cameras, Astronomy Cameras Blog, Blog caméras d'astronomie, Astronomy Cameras Competition, TX Text Control, LiveDocx, phpLiveDocx and Forums.