delphi dxCameraControl控件(拍照)
拍照演示
DevExpressVCL 組件之一
TdxCameraControl Object
Hierarchy Properties Methods Events
一個攝像頭控件
Unit dxCameraControl
Syntax
TdxCameraControl = class(TdxCustomCameraControl)
Descrition
該控件允許您捕捉視頻或圖像從內置/連接的網絡攝像頭或設備、前后攝像頭。也可以訪問指定的攝像頭,并可以預覽;
該控件實現與攝像機相關聯的基本功能。它使用允許您執行以下操作:
可以指定圖像/視頻捕獲的攝像機,并獲取其名稱:(DeviceIndex和DeviceName)。
可以控制攝像機的視頻:活動、暫停、播放和停止 (Active, Pause, Play, Stop).
會列出來支持的攝像機分辨率,用戶可以選擇一個分辨率或者分辨率索引用于輸出:(Resolutions 和ResolutionIndex).
可以縮放渲染圖像(FitMode)。
捕獲截屏當前渲染的圖像并訪問它:(Capture 和 CapturedBitmap).
獲取控件的當前狀態,以及狀態更改事件(state和OnStateChanged)。
啟用設置按鈕,提供用戶對彈出菜單的訪問,您也可以以編程方式調用該菜單(ShowSettingsButton和ShowSettingsToolbar)。
TdxCameraControl Properties(屬性)
TdxCameraControl Legend
Derived from TdxCustomCameraControl
Active 激活控件
BorderStyle 控件的邊框風格
CapturedBitmap 捕捉的圖像
DeviceIndex 攝像頭設備索引
DeviceName 當前攝像頭的名字
FitMode 填充模式
ResolutionCount 返回當前訪問的攝像機支持的分辨率數目
ResolutionIndex 返回當前分辨率的索引
Resolutions 分辨率
State 控件當前的狀態
ShowSettingsButton 是否顯示設置按鈕
TdxCameraControl Methods(方法)
TdxCameraControl Legend
Derived from TdxCustomCameraControl
Capture 從當前攝像頭捕獲一張圖片
Pause 使當前攝像頭處于暫停狀態
Play 使當前攝像頭處于預覽輸出狀態
ShowSettingsToolbar 調用設置彈出菜單。
Stop 停止渲染從攝像頭獲得的輸出幀,使攝像頭處于不激活的狀態。
TdxCustomCameraControl Events(事件)
TdxCustomCameraControl Legend
In TdxCustomCameraControl
OnStateChanged 控件狀態發生變化時
TdxCustomCameraControl.DeviceIndex
TdxCustomCameraControl
通過索引指定當前控件的攝像頭處于激活;
Syntax
property DeviceIndex: Integer;
Description
控件是通過在設備管理器中注冊的攝像機列表(也稱為網絡攝像機或成像設備)中的索引來識別的。默認情況下,控件被設置為訪問列表中的第一個相機。如果注冊了多個攝像機,可以使用DeviceIndex屬性選擇所需的攝像機。
終端用戶可以使用控件的設置彈出菜單中的設備子菜單在相機之間切換。
TdxCustomCameraControl.State
TdxCustomCameraControl
Indicates the camera control‘s current state.Syntax
type TdxCameraControlState = (ccsInactive, ccsInitializing, ccsRunning, ccsPaused, ccsNoDevice, ccsDeviceIsBusy);property State: TdxCameraControlState;
Description
Values include:
ValueDescription
ccsInactive攝像機控制處于非活動狀態。該狀態對應sdxCameraInactive。除此之外,所有其他狀態都與攝像機控制有關。
ccsInitializing攝像機控件正在初始化以捕獲或呈現攝像機輸出。此狀態對應于sdxCameraInitializing。
ccsRunning控件在其表面呈現攝像機的輸出。(預覽)
ccsPaused攝像頭處于暫停狀態
ccsNoDevice相機控件無法找到所選相機或當前已關閉。此狀態對應sdxcameranotdetection。
ccsDeviceIsBusy設備處于鎖定狀態。
這是個只讀屬性。
Active:True
DeviceIndex:設備號,默認為0
其他方法
procedure Capture; //捕獲
procedure Pause; //暫停
procedure Play; //播放
procedure Stop; //停止
property State: TdxCameraControlState read FState; //設備狀態
設計界面
代碼
復制代碼
//拍照并在cxImage中顯示
procedure TForm1.Button1Click(Sender: TObject);
begin
dxCameraControl1.Capture;
cxImage1.Picture.Assign(dxCameraControl1.CapturedBitmap);
end;
//保存圖片
procedure TForm1.Button3Click(Sender: TObject);
begin
if SavePictureDialog1.Execute then
begin
cxImage1.Picture.SaveToFile(SavePictureDialog1.FileName);
end;
end;
復制代碼
拍照演示

浙公網安備 33010602011771號