C# OpenCV学习笔记三之图像捕捉及其灰度转换方法
来源:互联网 发布:微观数据的弊端 编辑:程序博客网 时间:2024/06/06 18:06
透过摄像头捕捉图像,需要注意的是这里的captureImageBox是Emgu.CV.UI.ImageBox,而不是.NET的PictureBox
private Capture capture; private bool captureInProcess; private void captureButton_Click(object sender, EventArgs e) { if (capture != null)//摄像头不为空 { if (captureInProcess) { Application.Idle -= new EventHandler(processframe); captureButton.Text = "Stop!"; } else { Application.Idle += new EventHandler(processframe); captureButton.Text = "Start!"; } captureInProcess = !captureInProcess; } else//摄像头为空则通过Capture()方法调用 { try { capture = new Capture(); if (captureInProcess) { Application.Idle -= new EventHandler(processframe); captureButton.Text = "Stop!"; } else { Application.Idle += new EventHandler(processframe); captureButton.Text = "Start!"; } captureInProcess = !captureInProcess; } catch (NullReferenceException excpt) { MessageBox.Show(excpt.Message); } } } private void processframe(object sender, EventArgs arg) { Image<Bgr, Byte> frame = capture.QueryFrame(); captureImageBox.Image = frame; }
图像灰度转换方法
private void btnGray_Click(object sender, EventArgs e) { Rectangle cr = CvInvoke.cvGetImageROI(captureImageBox.Image.Ptr); int width = cr.Width; int height = cr.Height; IntPtr GrayImg1 = CvInvoke.cvCreateImage(cr.Size, Emgu.CV.CvEnum.IPL_DEPTH.IPL_DEPTH_8U, 1); CvInvoke.cvCvtColor(captureImageBox.Image.Ptr, GrayImg1, Emgu.CV.CvEnum.COLOR_CONVERSION.CV_BGR2GRAY); CvInvoke.cvSaveImage("c:\\gray.bmp", GrayImg1); }
- C# OpenCV学习笔记三之图像捕捉及其灰度转换方法
- opencv学习笔记之对灰度图像遍历的三种方法
- opencv学习笔记之对灰度图像遍历的三种方法
- OpenCV之摄像头捕捉图像
- openCV彩色图像转换为灰度图像
- C# OpenCV学习笔记二之图像读写的两种方法
- C# OpenCV学习笔记二之图像读写的两种方法
- OpenCV学习点滴(三)转换并保存灰度图
- opencv入门学习之四: 灰度图像的二值化
- C# OpenCV学习笔记四之图像二值化
- C# OpenCV学习笔记五之图像轮廓
- opencv学习(一)实现将彩色图像转换成灰度图像和二值图像
- OpenCV 读取文件并转换灰度图像
- opencv彩色图像(RGB)转灰度图像及其优化
- [图像增强]三. 灰度线性转换
- OpenCV学习笔记(一)之灰度级分层
- opencv学习之图像颜色空间转换
- OpenCV 原始RGB图像转换为灰度图像
- Android --- 图片处理的方法
- 求好心人一份java的fm收音机源码,最好是Android的
- 男人必知的五大为夫之道
- js当中mouseover和mouseout多次触发(非冒泡)
- 利用vbs同时调用多个批处理
- C# OpenCV学习笔记三之图像捕捉及其灰度转换方法
- C++ 对象的内存布局
- WM_DEVICECHANGE使用方式
- 游戏服务器结构探讨
- 中国有哪些开源社区?
- C++程序中获取不带文件路径和后缀的文件名
- 实例iPhone编程入门教程-第八天
- 2007年最受欢迎的资源top100
- Ascii Codes