如題。在程式中用pb呼叫攝像頭拍照并保存到資料庫,原攝像頭是成功的。但換了高清攝像頭后,攝像頭界面直接黑屏。代碼如下:
通過capCreateCaptureWindowA打開攝像頭。
string lpszName
ulong l1
l1=handle(p_1)
lpszName='攝像頭界面...'
lhand=capCreateCaptureWindowA(lpszName,262144+12582912+1073741824 + 268435456 ,-5,-30,320,240,l1,0)
if lhand <> 0 then
send(lhand, WM_CAP_SET_CALLBACK_VIDEOSTREAM, 0, 0)
send(lhand, WM_CAP_SET_CALLBACK_ERROR, 0, 0)
send(lhand, WM_CAP_SET_CALLBACK_STATUSA, 0, 0)
send(lhand, WM_CAP_DRIVER_CONNECT, 0, 0)
send(lhand, WM_CAP_SET_SCALE, 1, 0)
send(lhand, WM_CAP_SET_PREVIEWRATE, 66, 0)
send(lhand, WM_CAP_SET_OVERLAY, 1, 0)
send(lhand, WM_CAP_SET_PREVIEW, 1, 0)
end if
請教該如何解決此問題?謝謝
uj5u.com熱心網友回復:
lhand=capCreateCaptureWindowA(lpszName,262144+12582912+1073741824 + 268435456,UnitsToPixels(0, XUnitsToPixels!),UnitsToPixels(0, YUnitsToPixels!),UnitsToPixels(parent.width - 25, XUnitsToPixels!),UnitsToPixels(1890, YUnitsToPixels!),l1,0)uj5u.com熱心網友回復:
這個是要用到getbitmap.dll 檔案的,是不是檔案版本不一樣的uj5u.com熱心網友回復:
回復1樓,試過了不行。我的代碼如下:string lpszName
ulong l1
l1=handle(p_1)
lpszName='攝像頭界面...'
lhand=capCreateCaptureWindowA(lpszName,262144+12582912+1073741824 + 268435456 ,-5,-30,320,240,l1,0)
if lhand <> 0 then
send(lhand, WM_CAP_SET_CALLBACK_VIDEOSTREAM, 0, 0)
send(lhand, WM_CAP_SET_CALLBACK_ERROR, 0, 0)
send(lhand, WM_CAP_SET_CALLBACK_STATUSA, 0, 0)
send(lhand, WM_CAP_DRIVER_CONNECT, 0, 0)
send(lhand, WM_CAP_SET_SCALE, 1, 0)
send(lhand, WM_CAP_SET_PREVIEWRATE, 66, 0)
send(lhand, WM_CAP_SET_OVERLAY, 1, 0)
send(lhand, WM_CAP_SET_PREVIEW, 1, 0)
end if
uj5u.com熱心網友回復:
回復2樓,我重新從網上下載了你說的dll檔案,也沒有成功,我的參考外部檔案如下:function ulong getwindowdc (ulong hwnd) library "user32.dll" alias for "GetWindowDC"
function ulong capcreatecapturewindowa (string lpszwindowname,ulong dwstyle,long x,long y,long nwidth,long nheight,ulong parentwin,long nid) library "AVICAP32.DLL" alias for "capCreateCaptureWindowA;Ansi"
function integer out_num (integer irow) library "getbitmap.dll" alias for "out_num"
function integer getbitmapfromscreen (string filename) library "getbitmap.dll" alias for "GetBitmapFromScreen;Ansi"
function integer getbitmapfromwindow (string lpfilename,ulong hwdc,integer x,integer y,integer w,integer h,integer zoom) library "getbitmap.dll" alias for "GetBitmapFromWindow;Ansi"
function integer grabimage (ulong hwndc,string path) library "getbitmap.dll" alias for "GrabImage;Ansi"
function integer stopkinescope (ulong hwndc) library "getbitmap.dll" alias for "StopKinescope"
function integer kinescope (ulong hwndc,string filename) library "getbitmap.dll" alias for "Kinescope;Ansi"
uj5u.com熱心網友回復:
你最好安裝了高清的驅動和對應的攝像軟體,再搜索一下getbitmap.dll ,試試用下他們自帶的uj5u.com熱心網友回復:
啥需求,我有個呼叫攝像頭的ocx,OpenCV封裝。uj5u.com熱心網友回復:
需求是通過攝像頭拍照身份證保存到本機上,并顯示在ole控制元件中,確認無誤后保存到sqlserver里。我現在可以做到保存到本機上了,但ole控制元件上只顯示圖片名。如圖
uj5u.com熱心網友回復:
換個方法,瀏覽的時候,先從資料庫拿出來,放臨時位置,然后用圖片控制元件加載。uj5u.com熱心網友回復:
這個直接用影像控制元件就可以的了,不管是上傳上去的BLOB資料還是檔案直接setpicture方法就行uj5u.com熱心網友回復:
string ls_photofile,ls_name
string ls_named
integer li_value
long ll_pos,ll_filelen
//選擇照片檔案
li_value = GetFileOpenName("選擇圖片檔案", &
+ ls_photofile, ls_named, "圖片檔案", &
+ "BMP Files (*.BMP),*.BMP," &
+ "JPG Files (*.JPG),*.JPG")
if ls_photofile='' or isnull(ls_photofile) then return 0
ll_filelen = FileLength(ls_photofile)
IF ll_filelen > 327650 THEN
Messagebox('出錯','檔案超出最大限制320K,建議使用大小320K以下圖片!')
return 0
end if
sle_photo.text = ls_photofile
ls_name=ls_photofile
ll_pos=pos(ls_name,'\')
do while ll_pos>0
ls_name=right(ls_name,len(ls_name) - ll_pos)
ll_pos=pos(ls_name,'\')
loop
sle_name.text=ls_name
integer li_fnum,li_set
long ll_bytes
blob Emp_Id_Pic
li_fnum = FileOpen( ls_photofile , StreamMode!)
ll_bytes = FileReadEx(li_fnum, Emp_Id_Pic)
if isnull(ll_bytes) then ll_bytes=-1
il_picread=ll_bytes
if il_picread>0 then
ib_pic=Emp_Id_Pic
else
return 0
end if
li_set=p_1.setpicture(ib_pic)
if isnull(li_set) then li_set=-1
if li_set<=0 then
il_picread=0
return 0
end if
//資料庫中呼叫
selectblob erp_img into :lb_picture from erp_img_setup where img_id=:ll_no;
p_1.setpicture(lb_picture)
uj5u.com熱心網友回復:
不行用個佳能提供的免費控制元件,windows帶的不穩定uj5u.com熱心網友回復:
你用的那方法,你是呼叫后,關閉程式的時候沒有關閉連接吧;然后導致以后打開多是黑屏了;uj5u.com熱心網友回復:
https://download.csdn.net/download/ganzhenyu/11967280可以試試我這個
uj5u.com熱心網友回復:
我遇到同樣的問題,怎么辦? 像素低的攝像頭可以用,高清的攝像頭則打開黑屏!!uj5u.com熱心網友回復:
先試下保存的圖片是否可以用圖片查看工具打開?轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/6898.html
標籤:API 調用
上一篇:有關計算域問題,為什么數量*單價 用計算域保留兩位小數等于33.23 按理應該是33.235 = 33.24 求解
