使用EmguCV3.0.0调用摄像头并设置帧率
2024-10-21 09:32:28
此教程使用emgu3.0.0,其他版本兼容性未知。
转载请注明出处: http://www.cnblogs.com/zaiyuzhong/p/open-camera-with-emgu3_0_0.html
先说设置帧率,是通过调用Capture实例的SetCaptureProperty方法:
capture.SetCaptureProperty(CapProp.Fps, 帧率数);
该方法可以设置绝大多数摄像头参数。相应的,可以通过GetCaptureProperty获得这些参数。
该示例只需引用 Emgu.CV.dll 和 Emgu.Util.dll
1 var capture = new Capture(0); //这里打开第一个, 多个摄像头先获取名字数组, 再根据名字获得对应下标
2 capture.SetCaptureProperty(CapProp.Fps, 1);
3 var ts = new ThreadStart(() =>
4 {
5 while(!shouldStop)
6 {
7 var image = capture.QueryFrame(); // image是Emgu.CV.Mat类型
8 }
9 });
10 shouldStop = false;
11 new Thread(ts){ IsBackground = true }.Start();
打开摄像头
1 public Bitmap ConvertMat2Bitmap(Mat cvImg)
2 {
3 Bitmap bmpImg;
4 if (cvImg.Depth != DepthType.Cv8U)
5 {
6 bmpImg = new Bitmap(1, 1, PixelFormat.Format8bppIndexed);
7 return bmpImg;
8 }
9 var pixelFormat = PixelFormat.Format8bppIndexed;
10 if (cvImg.NumberOfChannels == 3)
11 pixelFormat = PixelFormat.Format24bppRgb;
12 else if (cvImg.NumberOfChannels == 4)
13 pixelFormat = PixelFormat.Format32bppArgb;
14 bmpImg = new Bitmap(cvImg.Cols, cvImg.Rows, cvImg.Step, pixelFormat, Marshal.UnsafeAddrOfPinnedArrayElement(cvImg.Data, 0));
15 return bmpImg;
16 }
Mat转Bitmap
最近家里没电脑, 等等我实验一下3.1
最后别忘了释放Capture实例
最新文章
- 浅谈Collection集合
- 亚马逊云架设WordPress博客
- Css3:选择器、字体和颜色样式
- SQLServer将表数据导出为Insert语句
- 关于Autoit上传文件的问题
- Android 学习笔记之AndBase框架学习(七) SlidingMenu滑动菜单的实现
- js键盘事件全面控制
- iOS 简单block的使用
- github 删除远程仓库项目中的任意文件夹
- quartz任务时间调度入门使用
- electron + vue 实践项目
- TCHAR和CHAR类型的互转,string 转lpcwstr
- Atitit 管理的模式扁平化管理 金字塔 直线型管理 垂直管理 水平管理 矩阵式管理 网状式样管理 多头管理 双头管理
- 测试思想-流程规范 SVN代码管理与版本控制
- select默认选择后台转过来的option选项
- 学习BOS物流项目第十天
- 830. Positions of Large Groups
- JSP中的指令概述和示例
- 在ASP.NET MVC中使用Castle Windsor
- java基础43 IO流技术(输入字节流/缓冲输入字节流)
热门文章
- Pytest插件pytest-rerunfailures失败重跑
- Error: EPERM: operation not permitted, mkdir ‘C:\Program Files\nodejs‘TypeError: Cannot read proper
- pandas连接msyql报(1115, ";Unknown character set: 'utf8mb4'";)错误
- ChatGPT调研分析与应用场域结合构想
- 【Gerald and Giant Chess】
- JZOJ 捕老鼠
- 分享手机上一款超多功能的APP(含428个功能):宇宙工具箱
- python爬取网页的多种方式以及保存方法
- JavaScript 中的一些奇怪问题
- RT-Thread Studio使用——创建工程并配置外部时钟(转)