调用videocapX.ocx控件遇到的问题
By
admin
at 2018-05-06 • 0人收藏 • 2641人看过
最近准备用到摄像头,根据以前论坛上的那个貌似有时候摄像头显示不了,下载这个控件的示例发现每次能完美解决, 所以想要封装下这个控件。
我声明了个库:videoX.aardio
import util.metaProperty; class videoX{ ctor(winform){ this = winform.createEmbed("{912FB007-DD9A-11D3-BD8D-DAAFCB8D9378}"); }; aboutBox = function(){ this._object.AboutBox(); }; @_metaProperty; } namespace videoX{ _metaProperty = ..util.metaProperty( connected = { _set = function( v ){ owner._object.Connected = v; } }; preview = { _set = function( v ){ owner._object.Preview = v; } }; ) }
调用的时候:
import win.ui; import win.ui.ctrl.afvideocapture; /*DSG{{*/ var winform = win.form(text="视频捕获控件";right=614;bottom=487;parent=...) winform.add( custom={cls="custom";text="custom";left=27;top=11;right=587;bottom=366;z=1} ) /*}}*/ winform.show() import console console.open() import videoX; var vdx = videoX(winform.custom); vdx.aboutBox() vdx.connected = true; vdx.preview = true; win.loopMessage();
那个aboutbox弹出信息框倒是对了,后面根据官方文档来写怎么弄都出不来摄像图像,唉
错误提示:
查看这个错误地方
这里是按照文档写的,为什么会有这个提示呢?
2 个回复 | 最后更新于 2018-05-19
import win.ui; /*DSG{{*/ mainForm = win.form(text="aardio form";right=650;bottom=499) mainForm.add( picturebox={cls="picturebox";left=0;top=0;right=475;bottom=375;z=1} ) /*}}*/ var dll = ..raw.loadDll("\res\VideoCaptureModule.dll",,"cdecl"); vInit = dll.api("VideoCaptureModule_Initialize","int()" ) vUnInit = dll.api("VideoCaptureModule_UnInitialize","int()" ) vGetCameraCount = dll.api("VideoCaptureModule_GetCameraCount","int(int& nCameraCount)" ) vGetCameraName = dll.api("VideoCaptureModule_GetCameraName","int(string& strSourceName)" ) vSetSelectedNumber = dll.api("VideoCaptureModule_SetSelectedCamera","int(int& nNumber)" ) vOpen = dll.api("VideoCaptureModule_Open","int()" ) vClose = dll.api("VideoCaptureModule_Close","int()" ) vPlay = dll.api("VideoCaptureModule_Play","int()" ) vStop = dll.api("VideoCaptureModule_Stop","int()" ) vSetFrameSize = dll.api("VideoCaptureModule_SetFrameSize","int(int nWidth, int nHeight)" ) vGetFrameSize = dll.api("VideoCaptureModule_GetFrameSize","int(int& nWidth, int& nHeight)" ) vGetFrame = dll.api("VideoCaptureModule_GetFrame","int(addr pFrame, int nWidth, int nHeight)" ) import console console.open() vInit(); var ret,count = vGetCameraCount(10); console.dump(count) var ret,cname = vGetCameraName(raw.buffer(1000)); console.dump(ret) console.dump(cname) var nn = 0; console.log( vSetSelectedNumber(nn )); vSetFrameSize(450,350); vOpen(); vPlay(); var ret,wdd,hdd = vGetFrameSize(0,0); console.log(wdd,hdd) //var xxx = raw.buffer(450*350*3); var ret,imagebyte = vGetFrame(0,450,350); //import gdip; //var bmp = gdip.bitmap(450,350,,xxx); //mainForm.picturebox.image = imagebyte; console.dump(imagebyte) /* pagef = { BYTE buff[]; }; vGetFrame(pagef.buff,450,350); console.dump(pagef) */ mainForm.enableDpiScaling(); mainForm.show(); return win.loopMessage();
登录后方可回帖
貌似这个是vb的标准控件,会在vs的控件栏里出现这个控件图标,这种的aar应该怎么调用
我今天给我们公司用vb.net的人说,他们说这个是标准控件,会在vs控件栏生成一个标准摄像头控件,然后拖上去就可以了,感觉和aar的自定义控件很像啊
这个com控件里面用的是dispinterface接口
网上搜了下,貌似说是利用事件驱动,接口有点区别