yuv420p转为emgucv的图像格式Emgu.CV.Image<Bgr, Byte>
2016-04-26 09:56
661 查看
GCHandle handle = GCHandle.Alloc(yuvs, GCHandleType.Pinned); Emgu.CV.Image<Bgr, Byte> image = new Image<Bgr, Byte>(640, 480); using (Image<Bgr, Byte> yuv420p = new Image<Bgr, byte>(640, (480 >> 1) * 3, 640, handle.AddrOfPinnedObject())) { CvInvoke.CvtColor(yuv420p, image, Emgu.CV.CvEnum.ColorConversion.Yuv420P2Bgr); //image now contains the same yuv image in bgr color space // this.imgboxVideo.Image = image; } if (handle.IsAllocated) handle.Free();
说明:
1、yuvs为yuv的byte[]数组,
假设ys,vs,us为一帧图像的y,u,v对应的数组,可以这样获取
byte[] yuvs = new byte[ys.Length + vs.Length + us.Length]; ys.CopyTo(yuvs, 0); vs.CopyTo(yuvs, ys.Length); us.CopyTo(yuvs, ys.Length + vs.Length);
2. 640为yuv图像的宽,480为高,根据实际需要修改
3.效率上创建Image比较慢
Emgu.CV.Image<Bgr, Byte> image = new Image<Bgr, Byte>(640, 480);,
可以作为程序的全局变量一开始创建,其他转换很快的
Emgu.CV.CvEnum.ColorConversion有很多枚举值,注意根据yuv格式进行选择。比如yv12有Yuv2BgrYv12
阅读(0)| 评论(0) | 编辑 |删除 |推送 |置顶
相关文章推荐
- 数组实现队列 C++实现(2)
- wps 调整列最合适宽度
- 获取线程pid和ps、top显示的pid相同的做法
- 日积月累,聚沙成塔……
- Android 程序中实现Tab类型界面
- postgresql空和null的区别
- 也谈底部导航和抽屉导航
- 未能加载文件或程序集“Newtonsoft.Json”或它的某一个依赖项。找到的程序集清单定义与程序集引用不匹配。 (异常来自 HRESULT:0x80131040)
- 配置获得权限
- 依赖注入&控制反转
- Emgu.CV/opencv 绘图 线面文字包括中文
- 06-图3 六度空间 (30分)
- 【HR必知】员工离职中的法律风险防范
- 支持树莓派3的 Chromium OS 发布0.5版本
- SQL Server 2008 R2数据挖掘即学即用
- 全局ajax事件
- SQLServer两张表筛选相同数据和不同数据
- 枚举
- Java异常
- 使用Python进行多进程编程