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

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

问题描述

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

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

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

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.

我也想知道 cvSaveImage 和 cvLoadImage(读取和写入内存缓冲区)的这一点.谢谢!

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

我的目标是将文件的编码 (jpeg) 版本存储在内存中.cvLoadImage 也是如此,我想将内存中的 jpeg 加载为 IplImage 格式.

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.

推荐答案

在库的 SVN 版本中有几个未公开的函数:

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 )

最新签入消息指出它们用于 bmp、png、ppm 和 tiff(仅编码)的本机编码/解码.

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

或者,您可以使用标准图像编码库(例如 libjpeg)并操作 IplImage 中的数据以匹配编码库的输入结构.

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天全站免登陆