调用网上的摄像头ocx来打开摄像头
By
admin
at 2018-05-27 • 0人收藏 • 1728人看过
import win.ui; /*DSG{{*/ mainForm = win.form(text="aardio form";right=619;bottom=474) mainForm.add( button={cls="button";text="打开摄像头";left=0;top=434;right=620;bottom=475;db=1;dl=1;dr=1;z=2}; ffWindow={cls="custom";text="custom";left=0;top=0;right=620;bottom=435;db=1;dl=1;dr=1;dt=1;z=1} ) /*}}*/ import Vcapocx; import console console.open() var fm = Vcapocx(mainForm.ffWindow); var cont = fm.getDevCnt(); console.log(cont) console.log(fm.getDevName()) mainForm.button.oncommand = function(id,event){ fm.openCapDev(); } mainForm.onClose = function(hwnd,message,wParam,lParam){ fm.closeCapDev(); } mainForm.enableDpiScaling(); mainForm.show(); return win.loopMessage();
里面用到的自定义库如下:
class Vcapocx{ ctor( winform ){ winform.createEmbed("{7EEAA4B5-DE19-493F-950C-4053B77195D2}",this); this.imgFmt = 1; this.nCfg = 0; this.preview = 1; this.event = 0; }; getDevCnt = function(){ return this._object.GetDevCnt(0); }; getDevName = function(index=1){ return this._object.GetDevNam(index); }; openCapDev = function(index=1){ if(!this.preview){ this.nCfg = this.nCfg + 128; } if(this.event){ this.nCfg = this.nCfg + this.imgFmt; } return this._object.OpenCapDev(index,this.nCfg); }; closeCapDev = function(index=0){ return this._object.CloseCapDev(index); }; @_meta; } import win.guid; import com.activeX; namespace Vcapocx{ try{ ..com.CreateObject("{7EEAA4B5-DE19-493F-950C-4053B77195D2}") } catch(e){ ..com.activeX.regsvr32("\res\TesoSeeu.ocx",true); } _meta = { preview = { _set = function(v){ owner[["preview"]] = v; } }; event = { _set = function(v){ owner[["event"]] = v; } }; imgFmt = { _set = function(v){ owner[["imgFmt"]] = v; } } } }
1 个回复 | 最后更新于 2018-05-27
登录后方可回帖
第二版:
库文件: