a. 靜態影像擷取
( capGrabFrame, capGrabFrameNoStop )
b. 視訊畫面複製到剪貼簿( capEditCopy )
c. 視訊畫面存成 BMP 檔案( capFileSaveDIB )
d. 取得與設定錄影參數
( capCaptureGetSetup, capCaptureGetSetup )
e. CAPTUREPARMS structure
2. 範例程式 Webcam Programming (3)
範例程式 Webcam Programming (3) 所設定的學習目標主要是靜態影像擷取與動態視訊錄影之實作。分成 3 個部分:
part A - 靜態影像擷取
part B - 錄影參數之取得與設定
part C - 錄影控制
part A - 靜態影像擷取
關於靜態影像擷取, 我們針對 VFW 所提供的 4 個函式, 分別使用 4 個 TButton 元件, 如圖 3-A-1 。當使用者按下 Button 時, 就會啟動相關的事件處理程序執行函式。程式內容詳見範例程式 Webcam Programming (3)。

圖 3-A-1
當使用者按下 Grab Frame 的 Button 時, 視訊擷取視窗的畫面會暫時靜止, 以便讓使用者觀看所擷取的畫面內容, 如圖 3-A-2。

圖 3-A-2
當使用者按下 Edit Copy 的 Button 時, 視訊擷取視窗的畫面會被複製到剪貼簿之中, 使用者可以從其他的應用程式中, 使用 Ctrl-V "貼上", 就可將剪貼簿中的畫面內容貼到影用程式之中。圖 3-A-3 是使用Windows所提供的小畫家, 貼上剪貼簿內容所呈現的結果。

圖 3-A-3
當使用者按下 File Save DIB 的 Button 時, 視訊擷取視窗的畫面會被存成所設定的 bmp 檔案, 圖 3-A-4 所顯示的是使用 File Save DIB 按鈕所儲存的 bmp 檔案內容。

圖 3-A-4
part B - 錄影參數之取得與設定
要將視訊擷取視窗的畫面錄影成視訊檔案之前, 必須先設定各個相關的錄影參數, 由於所需設定的參數太多, 因此, 在 vfw.h 之中, 將各個錄影參數集合起來, 定義了一個結構資料型態 CAPTUREPARMS structure, 方便程式設計師宣告使用。在範例程式 Webcam Programming (3) 之中, 宣告 cpCaptureParms 為 CAPTUREPARMS 資料型態。
CAPTUREPARMS cpCaptureParms;
關於錄影參數的取得與設定, 我們提供了 3 個版本的範例程式:
版本 1 : 所有的錄影參數都用 TLabel 元件顯示在 pcWebcam TPageControl 元件的 tsCaptureParameter 分頁之中, 如圖 3-B-1。

圖 3-B-1
版本 2 : 將錄影參數中, 屬於布林資料型態的參數改成使用 TCheckBox 元件顯示, 使用者可以直接點選更改設定, 如圖 3-B-2。

圖 3-B-2
版本 3 : 將錄影參數中, 屬於整數資料型態的參數改成使用 TEdit 元件顯示, 使用者可以直接輸入更改設定, 如圖 3-B-3。

圖 3-B-3
參考資料:




沒有留言:
張貼留言