摄像头拍的照片怎么样用软件获取到? 摄像头拍的照片怎么样用软件获取到?我想做一个人事档案记录软件,员工照片用摄像头采集,然后通过软件取过来存到制定目录。问题是不知道照的照片默认存在那里。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 unit uvfw;interfaceuses Windows, Messages;const WM_CAP_START = WM_USER; WM_CAP_SET_CALLBACK_VIDEOSTREAM = WM_CAP_START + 6; WM_CAP_SET_CALLBACK_ERROR = WM_CAP_START + 2; WM_CAP_SET_CALLBACK_STATUSA = WM_CAP_START + 3; WM_CAP_SET_OVERLAY = WM_CAP_START + 51 ; WM_CAP_SET_PREVIEW = WM_CAP_START + 50 ; WM_CAP_SET_SCALE = WM_CAP_START + 53 ; WM_CAP_SET_PREVIEWRATE = WM_CAP_START + 52 ; WM_CAP_DRIVER_CONNECT = WM_CAP_START + 10; WM_CAP_DRIVER_DISCONNECT = WM_CAP_START + 11; WM_CAP_SAVEDIB = WM_CAP_START + 25; WM_CAP_DLG_VIDEOSOURCE = WM_CAP_START + 42;function OpenVideoDevice(_ParentHandle: HWND; _capWinRect: TRect; _wIndex: Integer): BOOL; stdcall; export;procedure CloseVideoDevice(); stdcall; export;function GetBitmapToFile(_filename: PChar): BOOL; stdcall; export;procedure SetVideoSource(); stdcall; export;implementationfunction capCreateCaptureWindowA(lpszWindowName: PChar; dwStyle: Longint; x: Integer; y: Integer; nWidth: Integer; nHeight: Integer; ParentWin: HWND; nID: Integer): HWND; stdcall external 'AVICAP32.DLL';var capWindowHandle: HWND; VideoFlag: Boolean;function OpenVideoDevice(_ParentHandle: HWND; _capWinRect: TRect; _wIndex: Integer): BOOL; stdcall; export;begin _wIndex := 0; capWindowHandle := capCreateCaptureWindowA('通软视频接口窗体', WS_CHILD or WS_VISIBLE, _capWinRect.Left, _capWinRect.Top, _capWinRect.Right, _capWinRect.Bottom, _ParentHandle, 0); result := false; if capWindowHandle <> 0 then begin SendMessage(capWindowHandle, WM_CAP_SET_CALLBACK_VIDEOSTREAM, 0, 0); SendMessage(capWindowHandle, WM_CAP_SET_CALLBACK_ERROR, 0, 0); SendMessage(capWindowHandle, WM_CAP_SET_CALLBACK_STATUSA, 0, 0); SendMessage(capWindowHandle, WM_CAP_DRIVER_CONNECT, _wIndex, 0); SendMessage(capWindowHandle, WM_CAP_SET_SCALE, 1, 0); SendMessage(capWindowHandle, WM_CAP_SET_PREVIEWRATE, 50, 0); SendMessage(capWindowHandle, WM_CAP_SET_OVERLAY, 1, 0); VideoFlag := SendMessage(capWindowHandle, WM_CAP_SET_PREVIEW, 1, 0) = 1; result := VideoFlag; end;end;procedure CloseVideoDevice(); stdcall; export;begin if VideoFlag then SendMessage(capWindowHandle, WM_CAP_DRIVER_DISCONNECT, 0, 0); VideoFlag := false;end;function GetBitmapToFile(_filename: PChar): BOOL; stdcall; export;begin result := false; if VideoFlag then result := SendMessage(capWindowHandle, WM_CAP_SAVEDIB, 0, Integer(_filename)) = 1;end;procedure SetVideoSource(); stdcall; export;begin if VideoFlag then SendMessage(capWindowHandle, WM_CAP_DLG_VIDEOSOURCE, 0, 0);end;end.給你幾個過程。OpenVideoDevice 打開攝像頭,參數分別是在哪顯示動態圖像、RECT是多少,最後一個忽略先。CloseVideoDevice() 關閉攝像頭GetBitmapToFile 拍照到指定參數的位置保存SetVideoSource 設置攝像頭參數。 你首先要知道GetBitmapToFile(圖片存在位置),再用程序去讀取這個目錄即可拋個磚: procedure TForm1.Button1Click(Sender: TObject);var v, vImg, vFile: Variant; sUrl: string; aStream: TMemoryStream;begin sUrl:='http://www.zzz.com\aaa.jpg'; v := CreateOleObject('MSXML2.XMLHTTP'); v.Open('GET', sUrl, False); v.Send(); if v.ReadyState <> 4 then ShowMessage('Error.'); vImg := v.ResponseBody; vFile := CreateOleObject('ADODB.Stream'); vFile.Type := 1; vFile.Open; vFile.Write(vImg); //將vImg內容寫入到vFile物件 vFile.SaveToFile('C:\Documents and Settings\db2admin\Local Settings\Temp\1.jpg',2); vFile.Close; Image1.Picture.LoadFromFile('C:\Documents and Settings\db2admin\Local Settings\Temp\1.jpg');end; 请教CS架构和BS架构的数据同步技术选型 请教如何判断TADBQuery是否已经打开? socket 错误 寻找一个函数…… 想将JPG图片保存到BLOB字段中?请问我的代码哪里错了? ==大家元旦快乐==我也来散散分=== 大家为什么在网上回答提问?- 送分,敬请关注! 有感Delphi新人基础太差,特开个站写写基础教程 如何去掉调用Dll在任务栏产生的图标 好傻的问题哟 delphi Idhttp小程序的请教。 TeeChart中Numeric Gauge怎么设置字体颜色
Windows, Messages;const
WM_CAP_START = WM_USER;
WM_CAP_SET_CALLBACK_VIDEOSTREAM = WM_CAP_START + 6;
WM_CAP_SET_CALLBACK_ERROR = WM_CAP_START + 2;
WM_CAP_SET_CALLBACK_STATUSA = WM_CAP_START + 3;
WM_CAP_SET_OVERLAY = WM_CAP_START + 51 ;
WM_CAP_SET_PREVIEW = WM_CAP_START + 50 ;
WM_CAP_SET_SCALE = WM_CAP_START + 53 ;
WM_CAP_SET_PREVIEWRATE = WM_CAP_START + 52 ;
WM_CAP_DRIVER_CONNECT = WM_CAP_START + 10;
WM_CAP_DRIVER_DISCONNECT = WM_CAP_START + 11;
WM_CAP_SAVEDIB = WM_CAP_START + 25;
WM_CAP_DLG_VIDEOSOURCE = WM_CAP_START + 42;function OpenVideoDevice(_ParentHandle: HWND; _capWinRect: TRect; _wIndex: Integer): BOOL; stdcall; export;
procedure CloseVideoDevice(); stdcall; export;
function GetBitmapToFile(_filename: PChar): BOOL; stdcall; export;
procedure SetVideoSource(); stdcall; export;implementationfunction capCreateCaptureWindowA(lpszWindowName: PChar; dwStyle: Longint; x: Integer; y: Integer;
nWidth: Integer; nHeight: Integer; ParentWin: HWND; nID: Integer): HWND; stdcall external 'AVICAP32.DLL';var
capWindowHandle: HWND;
VideoFlag: Boolean;function OpenVideoDevice(_ParentHandle: HWND; _capWinRect: TRect; _wIndex: Integer): BOOL; stdcall; export;
begin
_wIndex := 0;
capWindowHandle := capCreateCaptureWindowA('通软视频接口窗体', WS_CHILD or WS_VISIBLE,
_capWinRect.Left, _capWinRect.Top, _capWinRect.Right, _capWinRect.Bottom,
_ParentHandle, 0);
result := false;
if capWindowHandle <> 0 then
begin
SendMessage(capWindowHandle, WM_CAP_SET_CALLBACK_VIDEOSTREAM, 0, 0);
SendMessage(capWindowHandle, WM_CAP_SET_CALLBACK_ERROR, 0, 0);
SendMessage(capWindowHandle, WM_CAP_SET_CALLBACK_STATUSA, 0, 0);
SendMessage(capWindowHandle, WM_CAP_DRIVER_CONNECT, _wIndex, 0);
SendMessage(capWindowHandle, WM_CAP_SET_SCALE, 1, 0);
SendMessage(capWindowHandle, WM_CAP_SET_PREVIEWRATE, 50, 0);
SendMessage(capWindowHandle, WM_CAP_SET_OVERLAY, 1, 0);
VideoFlag := SendMessage(capWindowHandle, WM_CAP_SET_PREVIEW, 1, 0) = 1;
result := VideoFlag;
end;
end;procedure CloseVideoDevice(); stdcall; export;
begin
if VideoFlag then
SendMessage(capWindowHandle, WM_CAP_DRIVER_DISCONNECT, 0, 0);
VideoFlag := false;
end;function GetBitmapToFile(_filename: PChar): BOOL; stdcall; export;
begin
result := false;
if VideoFlag then
result := SendMessage(capWindowHandle, WM_CAP_SAVEDIB, 0, Integer(_filename)) = 1;
end;procedure SetVideoSource(); stdcall; export;
begin
if VideoFlag then
SendMessage(capWindowHandle, WM_CAP_DLG_VIDEOSOURCE, 0, 0);
end;end.
給你幾個過程。
OpenVideoDevice 打開攝像頭,參數分別是在哪顯示動態圖像、RECT是多少,最後一個忽略先。
CloseVideoDevice() 關閉攝像頭
GetBitmapToFile 拍照到指定參數的位置保存
SetVideoSource 設置攝像頭參數。
var
v, vImg, vFile: Variant;
sUrl: string;
aStream: TMemoryStream;
begin
sUrl:='http://www.zzz.com\aaa.jpg';
v := CreateOleObject('MSXML2.XMLHTTP');
v.Open('GET', sUrl, False);
v.Send();
if v.ReadyState <> 4 then
ShowMessage('Error.');
vImg := v.ResponseBody;
vFile := CreateOleObject('ADODB.Stream');
vFile.Type := 1;
vFile.Open;
vFile.Write(vImg); //將vImg內容寫入到vFile物件
vFile.SaveToFile('C:\Documents and Settings\db2admin\Local Settings\Temp\1.jpg',2);
vFile.Close;
Image1.Picture.LoadFromFile('C:\Documents and Settings\db2admin\Local Settings\Temp\1.jpg');
end;