圖像獲取: 獲取一幀圖像

講解如何使用 IC Imaging Control 獲取並顯示單張圖像。
語言:.NET C#/Visual Basic
版本:3.0.3
发布于:2005年4月7日
作者:IC Imaging Control 技術支持部
需求:IC Imaging Control >2.1
由WDM數據流類驅動程序驅動的相機、視頻轉換器或圖像采集卡

示例程序窗體如下圖所示:

The Testdialog of IC Imaging Control,

首先向窗體中加入一個 IC Imaging Control 窗口和一個圖片框。 圖片框用於顯示抓取的單幀圖像。

程序首先調用內置對話框 .ShowDeviceSettingsDialog,選擇設備。 在選擇一個有效設備後,使用 .LiveStart 顯示現場視頻。

[C#]
private void Form1_Load(object sender, System.EventArgs e)
{
    icImagingControl1.ShowDeviceSettingsDialog();

    if( icImagingControl1.DeviceValid )
    {
        icImagingControl1.LiveStart();
    }
    else
    {
        Close();
    }
}

用戶點擊"Capture"按鈕,.MemorySnapImage 將從視頻流中抓取一幀圖像並將其拷貝至內部環形緩存中。

此時,就可以通過調用 .ImageActiveBuffer 來訪問這幀圖像了。 該屬性含有最近一幀被抓取的圖像。 而後程序將 .ImageActiveBuffer.Bitmap 賦值給 pictureBox1.Image。 這樣一來,抓取的圖像就被顯示在程序中了。

[C#]
private void button1_Click(object sender, System.EventArgs e)
{
    icImagingControl1.MemorySnapImage();
    pictureBox1.Image = icImagingControl1.ImageActiveBuffer.Bitmap;
}

相關源代碼示例

責任聲明
IC Imaging Control源代碼庫中的所有代碼均只用於教學目的,The Imaging Source Europe GmbH作為IC Imaging Control的開發製造商,不對任何由於使用本文或其中源代碼所產生的後果承擔責任。

该网站为The Imaging Source网络的一部分。其它的站点包括 公司, Imaging, 天文相機, Astronomy Cameras Blog, Blog caméras d'astronomie, 天文相機有獎競答, TX Text Control, LiveDocx, phpLiveDocxForum.