OpenCV用于内存缓冲区或文件指针 [英] OpenCV to use in memory buffers or file pointers

查看:677
本文介绍了OpenCV用于内存缓冲区或文件指针的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

openCV中的两个函数cvLoadImage和cvSaveImage接受文件路径作为参数。



例如,当保存图像时,它会 cvSaveImage(/ tmp / output.jpg,dstIpl),并写入磁盘。



有没有办法提供这个已经在内存中的缓冲区?因此,代替磁盘写入,输出映像将在内存中。



我也想知道这个cvSaveImage和cvLoadImage(读写内存缓冲区)。非常感谢!






我的目标是存储Encoded(jpeg)在记忆中。同样的cvLoadImage,我想加载一个jpeg在内存中的IplImage格式。

解决方案

在SVN版本的库中有几个未记录的函数:

  CV_IMPL CvMat * cvEncodeImage(const char * ext,
const CvArr * arr,const int * _params)

CV_IMPL IplImage * cvDecodeImage (const CvMat * _buf,int iscolor)

最新签入消息声明他们是本地编码/或者,您可以使用标准图像编码库(例如libjpeg),并操作IplImage中的数据,以便对bmp,png,ppm和tiff(仅编码)进行解码。匹配编码库的输入结构。


The two functions in openCV cvLoadImage and cvSaveImage accept file path's as arguments.

For example, when saving a image it's cvSaveImage("/tmp/output.jpg", dstIpl) and it writes on the disk.

Is there any way to feed this a buffer already in memory? So instead of a disk write, the output image will be in memory.

I would also like to know this for both cvSaveImage and cvLoadImage (read and write to memory buffers). Thanks!


My goal is to store the Encoded (jpeg) version of the file in Memory. Same goes to cvLoadImage, I want to load a jpeg that's in memory in to the IplImage format.

解决方案

There are a couple of undocumented functions in the SVN version of the libary:

CV_IMPL CvMat* cvEncodeImage( const char* ext, 
                              const CvArr* arr, const int* _params )

CV_IMPL IplImage* cvDecodeImage( const CvMat* _buf, int iscolor )

Latest check in message states that they are for native encoding/decoding for bmp, png, ppm and tiff (encoding only).

Alternatively you could use a standard image encoding library (e.g. libjpeg) and manipulate the data in the IplImage to match the input structure of the encoding library.

这篇关于OpenCV用于内存缓冲区或文件指针的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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