分享一个摄像头dll , 支持上下左右镜像功能
By
admin
at 2022-01-26 • 0人收藏 • 494人看过
此摄像头控件 , 官方提供了两种调用方式, 可以使用ocx也可以直接调用dll, 支持上下左右镜像.
经过简单的测试, 很不错, 功能很强大, 也可以和之前那些摄像头控件一样 , 支持录屏保存....
这些功能我不需要, 所以将不需要用的dll都删除了, 只保留了必须的摄像头dll
测试发现这个控件有一个问题: dll不能内存隔离, 这样每次打开摄像头就只能打开一个, 不能实现同时打开多个摄像头 , 无论是dll调用还是ocx调用 , 这两种方式最终还是调用的那三个dll , 所以还是共享了一个内存.
因为上面的重大缺点 , 所以要用摄像头控件的话,
推荐用 https://www.chengxu.xyz/t/547 这个.
本控件官方网站: http://www.pmlxj.com/screen-recorder-sdk.html
压缩包里有官方原版SDK , ScnLib.exe
要用ocx方式, 就去里面注册那个 ScnLibX.ocx
如果用dll方式, 只需要3个dll即可, avutil-55.dll / ScnLib.dll / swscale-4.dll
dll方式:
import win.ui; /*DSG{{*/ var winform = win.form(text="aardio form";right=709;bottom=516) winform.add( button={cls="button";text="左右镜像";left=21;top=475;right=150;bottom=506;z=2}; button2={cls="button";text="上下镜像";left=164;top=475;right=293;bottom=506;z=3}; button3={cls="button";text="上下左右";left=307;top=475;right=436;bottom=506;z=4}; button4={cls="button";text="还原";left=452;top=475;right=581;bottom=506;z=5}; picturebox={cls="picturebox";left=0;top=0;right=710;bottom=469;bgcolor=12639424;db=1;dl=1;dr=1;dt=1;z=1} ) /*}}*/ import console console.open() var dll = raw.loadDll("\ScnLib.dll"); ScnLib_Initialize = dll.api("ScnLib_Initialize","bool()" ) ScnLib_SelectWebcamDevice = dll.api("ScnLib_SelectWebcamDevice","bool(int)" ) ScnLib_SetWebcamResolution = dll.api("ScnLib_SetWebcamResolution","void(int,int)" ) ScnLib_SetWebcamViewMode = dll.api("ScnLib_SetWebcamViewMode","void(int)" ) ScnLib_SetWebcamViewSize = dll.api("ScnLib_SetWebcamViewSize","void(int,int)" ) ScnLib_PreviewWebcam = dll.api("ScnLib_PreviewWebcam","bool(bool,ADDR,bool,INT)" ) ScnLib_SetWebcamDirection = dll.api("ScnLib_SetWebcamDirection","void(bool,bool)" ) ScnLib_Uninitialize = dll.api("ScnLib_Uninitialize","void()" ) console.log("1",ScnLib_Initialize()) console.log("2",ScnLib_SelectWebcamDevice(0)); console.log("3",ScnLib_SetWebcamResolution(0,0)); console.log("4",ScnLib_SetWebcamViewMode(2)); console.log("5",ScnLib_SetWebcamViewSize(winform.picturebox.width,winform.picturebox.height)); console.log("6",ScnLib_PreviewWebcam(true,winform.picturebox.hwnd,true,0x00ff00)); winform.onOk = function(){ ScnLib_Uninitialize(); } winform.button.oncommand = function(id,event){ ScnLib_SetWebcamDirection(true,false); } winform.button2.oncommand = function(id,event){ ScnLib_SetWebcamDirection(false,true); } winform.button3.oncommand = function(id,event){ ScnLib_SetWebcamDirection(true,true); } winform.button4.oncommand = function(id,event){ ScnLib_SetWebcamDirection(false,false); } winform.show(); win.loopMessage();
OCX方式:
import win.ui; /*DSG{{*/ var winform = win.form(text="aardio form";right=759;bottom=469) winform.add( button={cls="button";text="Button";left=49;top=422;right=180;bottom=462;db=1;dl=1;z=2}; button2={cls="button";text="Button";left=210;top=421;right=341;bottom=461;db=1;dl=1;z=3}; picturebox={cls="picturebox";left=0;top=0;right=760;bottom=415;bgcolor=15780518;db=1;dl=1;dr=1;dt=1;z=1} ) /*}}*/ /* import console console.open() */ var video = com.CreateObject("SCNLIBX.ScnLibXCtrl.1") video.Initialize() video.SelectWebcamDevice(0); video.SetWebcamResolution(0,0); video.SetWebcamViewMode(2); video.SetWebcamViewSize(winform.picturebox.width,winform.picturebox.height); video.PreviewWebcam(true,winform.picturebox.hwnd,true,0x00ff00); winform.onOk = function(){ video.Uninitialize(); } winform.button.oncommand = function(id,event){ video.SetWebcamViewSize(winform.picturebox.width,winform.picturebox.height); } winform.button2.oncommand = function(id,event){ video.SetWebcamDirection(true,false); } winform.show(); win.loopMessage();
登录后方可回帖