aar调用sv4000E视频采集卡dll库实现视频显示和镜像处理
By
admin
at 2018-08-03 • 0人收藏 • 1665人看过
前面写过调用win系统自带的函数利用directshow方式来显示摄像头和对图像进行上下左右翻转,还写过调用网上的ocx控件来操作摄像头,但是当这些方式应用与sv4000这个采集卡的时候就出现了问题...(采集卡的通道有时候有某些通道出现打不开。。。。而且这个现象很频繁)
于是找供货商询问,并索取了它的SDK,发现它自带的实例是调用的一个dll
把这个dll封装到aar之后,再次测试,所有的通道均没有问题了,晕
下面是操作代码:
import win.ui; /*DSG{{*/ mainForm = win.form(text="调用SDK";right=1081;bottom=655) mainForm.add( button={cls="button";text="button";left=881;top=145;right=1031;bottom=199;z=5}; button2={cls="button";text="button";left=881;top=216;right=1031;bottom=270;z=6}; picturebox={cls="picturebox";left=0;top=0;right=393;bottom=323;dl=1;dt=1;z=1}; picturebox2={cls="picturebox";left=406;top=0;right=799;bottom=323;dr=1;dt=1;z=2}; picturebox3={cls="picturebox";left=0;top=333;right=393;bottom=656;db=1;dl=1;z=3}; picturebox4={cls="picturebox";left=406;top=333;right=799;bottom=656;db=1;dr=1;z=4} ) /*}}*/ var dll = ..raw.loadDll("\res\DXMediaCap.dll"); dxInitialize = dll.api("DXInitialize","int()"); dxUninitialize = dll.api("DXUninitialize","int()"); dxopenDevice = dll.api("DXOpenDevice","INT(int idx, int& err)"); dxCloseDevice = dll.api("DXCloseDevice","int(INT Device)"); dxSetVideoPara = dll.api("DXSetVideoPara","INT(INT Device,int standard, int colorspace, int width, int height, int framerate)"); dxDeviceRun = dll.api("DXDeviceRun","int(INT idx)"); dxDeviceStop = dll.api("DXDeviceStop","int(INT idx)"); dxStartPreview = dll.api("DXStartPreview","int(INT Device, INT hWnd, struct rect, int vmrtype)"); dxStopPreview = dll.api("DXStopPreview","int(INT Device)"); dxFlipVideo = dll.api("DXFlipVideo","int(INT Device, bool flip )"); dxMirrorVideo = dll.api("DXMirrorVideo","int(INT Device, bool mirror )"); dxEnableDenoise = dll.api("DXEnableDenoise","int(INT Device, int denoise )"); dxEnableSharpen = dll.api("DXEnableSharpen","int(INT Device, int deSharpness )"); dxEnableDeinterlace = dll.api("DXEnableDeinterlace","int(INT Device, int deinterlace )"); if(!dxInitialize()){ CardHandle,ret = dxopenDevice(0,0); dxSetVideoPara(CardHandle, 32, 2, mainForm.picturebox.width, mainForm.picturebox.height, 25) dxDeviceRun(CardHandle) dxStartPreview(CardHandle, mainForm.picturebox.hwnd, mainForm.picturebox.clientRect, 1) dxEnableDenoise(CardHandle,65); dxEnableSharpen(CardHandle,25); dxEnableDeinterlace(CardHandle,0); CardHandle1,ret = dxopenDevice(1,0); dxSetVideoPara(CardHandle1, 32, 2, mainForm.picturebox2.width, mainForm.picturebox2.height, 25) dxDeviceRun(CardHandle1) dxStartPreview(CardHandle1, mainForm.picturebox2.hwnd, mainForm.picturebox2.clientRect, 1) dxEnableDenoise(CardHandle1,65); dxEnableSharpen(CardHandle1,25); dxEnableDeinterlace(CardHandle1,0); CardHandle2,ret = dxopenDevice(2,0); dxSetVideoPara(CardHandle2, 32, 2, mainForm.picturebox3.width, mainForm.picturebox3.height, 25) dxDeviceRun(CardHandle2) dxStartPreview(CardHandle2, mainForm.picturebox3.hwnd, mainForm.picturebox3.clientRect, 1) dxEnableDenoise(CardHandle2,65); dxEnableSharpen(CardHandle2,25); dxEnableDeinterlace(CardHandle2,0); CardHandle3,ret = dxopenDevice(3,0); dxSetVideoPara(CardHandle3, 32, 2, mainForm.picturebox4.width, mainForm.picturebox4.height, 25) dxDeviceRun(CardHandle3) dxStartPreview(CardHandle3, mainForm.picturebox4.hwnd, mainForm.picturebox4.clientRect, 1) dxEnableDenoise(CardHandle3,65); dxEnableSharpen(CardHandle3,25); dxEnableDeinterlace(CardHandle3,0); } mainForm.onClose = function(hwnd,message,wParam,lParam){ dxStopPreview(CardHandle); dxDeviceStop(CardHandle); dxCloseDevice(CardHandle); dxStopPreview(CardHandle1); dxDeviceStop(CardHandle1); dxCloseDevice(CardHandle1); dxStopPreview(CardHandle2); dxDeviceStop(CardHandle2); dxCloseDevice(CardHandle2); dxStopPreview(CardHandle3); dxDeviceStop(CardHandle3); dxCloseDevice(CardHandle3); dxUninitialize(); } var Flipflag,Mirrorflag = false,false; mainForm.button.oncommand = function(id,event){ Flipflag = !Flipflag dxFlipVideo(CardHandle1,Flipflag); } mainForm.button2.oncommand = function(id,event){ Mirrorflag = !Mirrorflag dxMirrorVideo(CardHandle1,Mirrorflag); } mainForm.show(); return win.loopMessage();
这个代码只能运行在有sv4000采集卡的硬件上。。。。。
1 个回复 | 最后更新于 2018-08-06
登录后方可回帖
必须按照这样的顺序关闭通道才可以,要不然就会报错。