OpenCV to use in memory buffers or file pointers(在内存缓冲区或文件指针中使用的 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在内存缓冲区或文件指针中使用的 OpenCV


基础教程推荐
- 为什么派生模板类不能访问基模板类的标识符? 2021-01-01
- 初始化列表*参数*评估顺序 2021-01-01
- 非静态 const 成员,不能使用默认赋值运算符 2022-10-09
- CString 到 char* 2021-01-01
- 我应该对 C++ 中的成员变量和函数参数使用相同的名称吗? 2021-01-01
- 为什么 typeid.name() 使用 GCC 返回奇怪的字符以及如 2022-09-16
- 为什么 RegOpenKeyEx() 在 Vista 64 位上返回错误代码 2021-01-01
- 如果我为无符号变量分配负值会发生什么? 2022-01-01
- 通过引用传递 C++ 迭代器有什么问题? 2022-01-01
- GDB 显示调用堆栈上函数地址的当前编译二进制文 2022-09-05