通过Aforge的免费开源库可以方便的实现摄像头的操作功能 , 然后利用gdi对图片的各种格式化, 就可以灵活的实现摄像头的各种骚操作.

得益于aardio对C#功能的大力改进, 现在可以非常方便的对c#程序集进行各种调用, 这就意味着c#创建的各种dll都可以被aardio所用.

下面我对AForge进行了简单的封装, 让我们在aardio中非常简单的使用摄像头操作.

当然, 别的帖子里我也提供了很多种办法来实现对摄像头的采集和镜像功能 , 这篇文章, 主要是对C#程序集调用的学习.

本文首发:https://aardio.com.cn/t/21369https://aardio.com.cn/t/21369

欢迎大家来踩, 程序打包文件也在那里.

AForgeVideo.aardio 库代码:

//AForge摄像头库
import dotNet
import System.Drawing;
import System.Windows.Forms;class AForgeVideo{ctor( winform ){this.pictureBox = ..System.Windows.Forms.CreateEmbed("PictureBox",winform); this.pictureBox.BackColor = ..System.Drawing.Color.Black;this.pictureBox.SizeMode = ..System.Windows.Forms.PictureBoxSizeMode.StretchImage;this.carema = ..dotNet.load("\res\AForge.dll");this.AForgeCamera = this.carema.import("AForge.Video");this.flip = 0;this.videoDevice = null;..table.gc(this,"stop");};getNameList = function(){var videoDevices = this.AForgeCamera.DirectShow.FilterInfoCollection(this.AForgeCamera.DirectShow.FilterCategory.VideoInputDevice);var retTab = {};if(videoDevices.Count>0){for(i=0;videoDevices.Count-1;1){//压入摄像头设备号名称列表   ..table.push(retTab , videoDevices.Item[i].MonikerString);}return retTab; }return null;}getVideoCapabilitiesList = function(deviceName){if(deviceName!=null){var videoDevice = this.AForgeCamera.DirectShow.VideoCaptureDevice(deviceName);var videoCapabilitiesEx = videoDevice.VideoCapabilities;var retTab = {};if(videoCapabilitiesEx.LongLength>0){for(i=0;videoCapabilitiesEx.LongLength-1;1){..table.push(retTab,{["Width"] = videoCapabilitiesEx.Item[i].FrameSize.Width,["Height"] = videoCapabilitiesEx.Item[i].FrameSize.Height,["FrameRate"] = videoCapabilitiesEx.Item[i].FrameRate,});}return retTab;}return null; }return null;}start = function(DeviceIndex=1,index=1){if(this.videoDevice){this.videoDevice.Stop();}var namelist = this.getNameList();if(DeviceIndex <= #namelist){name = namelist[DeviceIndex];}else {//超出摄像头数量,不开启return false;}   //设定帧率和分辨率var VideoCapabilities = this.getVideoCapabilitiesList(name);this.videoDevice = this.AForgeCamera.DirectShow.VideoCaptureDevice(name);if(VideoCapabilities!=null){if(index>#VideoCapabilities){index = 1;}this.videoDevice.DesiredFrameRate = VideoCapabilities[index].FrameRate;this.videoDevice.DesiredFrameSize = ..System.Drawing.Size(VideoCapabilities[index].Width,VideoCapabilities[index].Height);this.videoDevice.DesiredSnapshotSize = ..System.Drawing.Size(VideoCapabilities[index].Width,VideoCapabilities[index].Height);}this.videoDevice.NewFrame = function(sender, NewFrameEventArgs){var temp = NewFrameEventArgs.Frame.Clone();select(this.flip) {case 0 {}case 1 {temp.RotateFlip(..System.Drawing.RotateFlipType.RotateNoneFlipX);}case 2 {temp.RotateFlip(..System.Drawing.RotateFlipType.RotateNoneFlipXY);}case 3 {temp.RotateFlip(..System.Drawing.RotateFlipType.RotateNoneFlipY);}else {}}if (this.pictureBox.Image != null){this.pictureBox.Image.Dispose();}this.pictureBox.Image = temp;}this.videoDevice.Start();return true;}stop = function(){if(this.videoDevice){this.videoDevice.Stop();this.videoDevice = null;}}flipLoop = function(){select(this.flip) {case 0 {this.flip=1;}case 1 {this.flip=2;}case 2 {this.flip=3;}case 3 {this.flip=0;}else {}}}
}//库代码由popdes发布/**intellisense()
AForgeVideo = AForge摄像头库
AForgeVideo(.(winform) = 创建 摄像头 界面
AForgeVideo() = !AVideo.
end intellisense**//**intellisense(!AVideo)
getNameList() = 获取摄像头设备硬件DeviceName名称列表
getVideoCapabilitiesList(.(DeviceName) = 获取指定设备的 分辨率和帧率 列表,如果不存在那么返回 null
start(.(DeviceIndex,CapabilitiesIndex) = 开启摄像头\n DeviceIndex:设备序号 , CapabilitiesIndex:分辨率和帧率表序号
stop() = 关闭摄像头
flipLoop() = 循环镜像图像,调用一次改变一次镜像方向
end intellisense**/

使用的时候非常简单, 如果你不需要设置其他的东西, 那么调用代码如下

下面是 打开两个摄像头并分别镜像的功能代码示例:

import win.ui;
/*DSG{{*/
mainForm = win.form(text="AForge 摄像头调用-aardio示例";right=1209;bottom=556)
mainForm.add(
button={cls="button";text="start";left=16;top=519;right=127;bottom=545;db=1;dl=1;z=2};
button2={cls="button";text="flip";left=142;top=519;right=254;bottom=545;db=1;dl=1;z=3};
button3={cls="button";text="stop";left=265;top=519;right=381;bottom=545;db=1;dl=1;z=4};
button4={cls="button";text="start";left=833;top=518;right=944;bottom=544;db=1;dr=1;z=6};
button5={cls="button";text="flip";left=959;top=518;right=1071;bottom=544;db=1;dr=1;z=7};
button6={cls="button";text="stop";left=1082;top=518;right=1198;bottom=544;db=1;dr=1;z=8};
custom={cls="custom";text="自定义控件";left=0;top=0;right=601;bottom=496;bgcolor=12639424;db=1;dl=1;dr=0.5;dt=1;z=1};
custom2={cls="custom";text="自定义控件";left=609;top=0;right=1210;bottom=496;bgcolor=12639424;db=1;dl=0.5;dr=1;dt=1;z=5}
)
/*}}*/import AForgeVideo;
var video = AForgeVideo(mainForm.custom);mainForm.button.oncommand = function(id,event){//默认开启序号1摄像头,分辨率为序号1的分辨率和帧率video.start();
}mainForm.button2.oncommand = function(id,event){//摄像头1镜像video.flipLoop();
}mainForm.button3.oncommand = function(id,event){//摄像头1停止video.stop();
}//定义2号摄像头
var video2 = AForgeVideo(mainForm.custom2);
mainForm.button4.oncommand = function(id,event){//开启序号2摄像头,分辨率为序号1的分辨率和帧率video2.start(2);
}mainForm.button5.oncommand = function(id,event){//摄像头2镜像video2.flipLoop();
}mainForm.button6.oncommand = function(id,event){//摄像头2停止video2.stop();
}mainForm.show();
return win.loopMessage();

aardio调用AForge操作摄像头并实现镜像旋转功能相关推荐

  1. vue调用电脑端摄像头实时拍照

    vue调用电脑端摄像头实时拍照 需求描述 功能实现 效果展示 需求描述 点击照相机拍照,弹出照相机拍照弹窗,点击拍照按钮,截取录像的帧,点击保存,提交数据给后台. 功能实现 1.html模块 //点击 ...

  2. C# 调用AForge类库操作摄像头

    如有雷同,不胜荣幸,若转载,请注明 最近做项目需要操作摄像头,在网上百度了很多资料,很多都是C#调用window API 发送SendMessage,实现操作摄像头,但是C#调用window API的 ...

  3. C# 利用Aforge调用本机摄像头完成拍照,录像

    用C#做了一个简单的摄像头录像项目,记录一下. 实现功能 打开.关闭摄像头并显示相应画面 实现拍照功能 实现录像功能 实现保存图片.录像的功能 运行界面效果 winForm控件 首先安装NuGet程序 ...

  4. yunyang tensorflow-yolov3 Intel Realsense D435 (并发)调用两个摄像头运行识别程序并画框

    只是一个测试,测试在并发运行下,同时开启两个摄像头获取视频流并调用识别函数的运行结果,以后在摄像头多的情况下,肯定不能这样,需要批量创建各种对象. 并发,指的是不在多线程的情况下,每个摄像头的视频流送 ...

  5. opencv镜像_DX200操作要领—PAM与镜像平移变换(三十八)

    6.4 PAM功能 6.4.1 PAM功能 再现中的位置修改功能 (PAM 功能:Position Adjustment Manual) ,可在查看机器人动作状况的同时,在不停止机器人的情况下,通过简 ...

  6. JAVA使用摄像头录制_JavaCV开发详解之1:调用本机摄像头视频(建议使用javaCV最新版本)...

    引入依赖 org.bytedeco javacv 1.5.3 org.bytedeco javacv-platform 1.5.3 代码实现 package com.java.mmzsblog; im ...

  7. vue实现PC端调用摄像头拍照人脸录入、移动端调用手机前置摄像头人脸录入、及图片旋转矫正、压缩上传base64格式/文件格式

    PC端调用摄像头拍照上传base64格式到后台,这个没什么花里胡哨的骚操作,直接看代码 (canvas + video) <template><div><!--开启摄像头 ...

  8. java录制视频_javacv开发详解之1:调用本机摄像头视频(建议使用javaCV最新版本)...

    javaCV系列文章: ' i# f% S' a# J9 X! w- g) wjavacv开发详解之1:调用本机摄像头视频 4 r' C, [4 ?' M7 Y; }javaCV开发详解之2:推流器实 ...

  9. Matlab 2020a 调用usb3.0摄像头实例

    ## Matlab 2020a 调用usb3.0摄像头实例 相机为大恒水星,型号为(MER-301-125U3C-L) 调用摄像头之前,先在命令行输入代码 imaqhwinfo 看电脑自身是否已下载该 ...

最新文章

  1. 实验室管理系统LIMS有没有好的企业推荐?
  2. MySQL触发器的使用
  3. 因HTTP的Header长度过长导致下载文件名出现乱码的问题
  4. 2017年度中国专利代理十强
  5. 网络恶意营销账号猖獗,国家网信办出手了
  6. TMS、物流系统、司机运输商、承运商、结算流程、运输流程、运输调度、结构图、在途跟踪、提货单、签收单、回单交接、车辆管理、运力资源、报价管理、发票管理、询价单管理、审批报价、KPI数据、适度配载
  7. 普联技术java工程师_【普联技术(TP-LINK)工资】java开发工程师待遇-看准网
  8. 机器人学 —— 机器人感知(Kalman Filter)
  9. HDU2040 亲和数【水题】
  10. nodeJS之TCP模块net
  11. web 前端性能优化汇总
  12. keil51免费版安装教程2032版本
  13. 双眼融合训练一个月_双眼视觉是什么?为什么要进行视功能训练?
  14. 桌面图标有蓝底怎么办
  15. Linux Cannot assign requested address
  16. 查看电脑是否能插内存条
  17. 一个正项级数收敛, 它的平方也收敛吗?
  18. android studio 图表,[期末系列]手把手教你在Android Studio中实现图表-Go语言中文社区...
  19. iOS开发之网络通信(1)—— 计算机网络
  20. lol的不只有英雄联盟,还有程序开发天团!

热门文章

  1. ChatGPT使用案例之操作Excel
  2. 递归删除带内容的目录
  3. 大学计算机必修课 编译原理,大学计算机必修课新讲-编译原理+操作系统+图形学2020...
  4. html模仿360度VR
  5. Resnet18/50网络架构图
  6. 【NodeJS】关于Node.js Web框架Koa的中间件编写以及如何理解洋葱模型
  7. 成就你一生的100个哲理21-30
  8. pandas写入字典,或者pandas以各种格式输出数据
  9. Python学习笔记——鸭子类型(duck typing)
  10. parameter_server架构