此教程使用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实例

最新文章

  1. 浅谈Collection集合
  2. 亚马逊云架设WordPress博客
  3. Css3:选择器、字体和颜色样式
  4. SQLServer将表数据导出为Insert语句
  5. 关于Autoit上传文件的问题
  6. Android 学习笔记之AndBase框架学习(七) SlidingMenu滑动菜单的实现
  7. js键盘事件全面控制
  8. iOS 简单block的使用
  9. github 删除远程仓库项目中的任意文件夹
  10. quartz任务时间调度入门使用
  11. electron + vue 实践项目
  12. TCHAR和CHAR类型的互转,string 转lpcwstr
  13. Atitit 管理的模式扁平化管理 金字塔 直线型管理 垂直管理 水平管理 矩阵式管理 网状式样管理 多头管理 双头管理
  14. 测试思想-流程规范 SVN代码管理与版本控制
  15. select默认选择后台转过来的option选项
  16. 学习BOS物流项目第十天
  17. 830. Positions of Large Groups
  18. JSP中的指令概述和示例
  19. 在ASP.NET MVC中使用Castle Windsor
  20. java基础43 IO流技术(输入字节流/缓冲输入字节流)

热门文章

  1. Pytest插件pytest-rerunfailures失败重跑
  2. Error: EPERM: operation not permitted, mkdir ‘C:\Program Files\nodejs‘TypeError: Cannot read proper
  3. pandas连接msyql报(1115, "Unknown character set: 'utf8mb4'")错误
  4. ChatGPT调研分析与应用场域结合构想
  5. 【Gerald and Giant Chess】
  6. JZOJ 捕老鼠
  7. 分享手机上一款超多功能的APP(含428个功能):宇宙工具箱
  8. python爬取网页的多种方式以及保存方法
  9. JavaScript 中的一些奇怪问题
  10. RT-Thread Studio使用——创建工程并配置外部时钟(转)