转换一个字节ARRY到OpenCV的图像在C ++中 [英] Convert a byte arry to OpenCV image in C++

查看:134
本文介绍了转换一个字节ARRY到OpenCV的图像在C ++中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个字节数组重新presents,我想直接转换为OpenCV的垫目标.jpg文件。

我有这样的事情

 字节*数据; //重新presents,我不希望到磁盘,然后读取JPG。
//善有善报这里与下面一行结束了?
CV ::垫* image_re presenting_the_data;


解决方案

pviously提到的方法将正常工作,如果它的像素数据$ P $。

如果不是,你有记忆,头,COM pression,所有整体的jpg文件,它不会工作。

在这种情况下你想要的:

  IMG垫= imde code(数据);

这将做同样的 imread(),只从内存中,而不是从一个文件名

I have a byte array that represents a .jpg file that I want to convert directly to an OpenCV Mat object.

I have something like

byte* data; // Represents a JPG that I don't want to disk and then read.
// What goes here to end up with the following line?
cv::Mat* image_representing_the_data;

解决方案

the previously mentioned method will work fine, if it's PIXEL data.

if instead, you have a whole jpg FILE in memory, headers, compression, and all, it won't work.

in that case you want:

Mat img = imdecode(data);

which will do the same as imread(), only from memory, not from a filename

这篇关于转换一个字节ARRY到OpenCV的图像在C ++中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆