opencv 从内存加载图像
2015-12-08 14:46
447 查看
opencv 从内存加载图像
参考资料:http://stackoverflow.com/questions/13705578/convert-a-string-of-bytes-to-cvmat
http://blog.csdn.net/yang_xian521/article/details/7755101
一般 OpenCV 加载图像的方法是:
char path[1024] = "/home/yuzx/2.jpg"; cv::Mat img = cv::imread(path, CV_LOAD_IMAGE_COLOR);
从内存中加载的方法是:
// img_bin 的类型是 const std::string& img_bin vector<unsigned char> imgRawData(img_bin.begin(), img_bin.end()); cv::Mat dataMat(imgRawData, true); // You also need to decode the image (check documentation for which types are allowed, png, jpg, depending on the OpenCV version) cv::Mat img(cv::imdecode(dataMat, CV_LOAD_IMAGE_COLOR)); // put 0 if you want greyscale printf("raw : w=%d, h=%d, c=%d, d=%d %d s = %d\n", img.cols, img.rows, img.channels(), img.depth(), img.dims, (int )img.elemSize());
相关文章推荐
- Linux下安装Nginx详细图解教程
- jsp与tomcat相关知识整理
- didFinishLaunchingWithOptions参数launchOptions内容
- centos
- 【OpenCV】5种图像滤波辨析:方框、均值、高斯、中值、双边
- 《Android群英传》读书笔记 (2) 第三章 控件架构与自定义控件详解 + 第四章 ListView使用技巧 + 第五章 Scroll分析
- Android群英传》读书笔记 (1) 第一章 Android体系与系统架构 + 第二章 Android开发工具新接触
- CentOS6.5安装cuda
- centos7安装docker
- Linux性能分析的前60000毫秒
- java amr格式转mp3格式(完美解决Linux下转换0K问题)
- 怎么解决tomcat占用8080端口问题图文教程
- (五)关于Linux的历史习题整理
- linux实操常用命令总结
- 配置opencv环境
- 等待我们终将飞翔的那天—兄弟连IT教育
- NavigationBar 两种POP效果
- Linux进程间通信(IPC)编程实践(十一)System V信号量---实现一个先进先出的共享内存shmfifo
- eclipse下tomcat插件配置说明
- 终于可以慢慢地接近自己的梦想了—兄弟连IT教育