问题描述
这里是我使用的代码转换* IplImage到jpg:
IplImage * fIplImageHeader;
fIplImageHeader = cvCreateImageHeader(cvSize(160,120),8,3);
fIplImageHeader-> imageData =(char *)memblock;
vector< int> p;
p.push_back(CV_IMWRITE_JPEG_QUALITY);
p.push_back(10);
矢量< unsigned char> f
cv :: imencode(JPEG,fIplImageHeader,buf,p);
cvReleaseImageHeader(& fIplImageHeader);
但我收到此错误:
OpenCV错误:未指定的错误(找不到指定的扩展名的编码器)在imencode,文件/build/buildd/opencv-2.1.0/src/highgui/loadsave.cpp,行409
终止在调用'cv :: Exception'的实例后调用
what /build/buildd/opencv-2.1.0/src/highgui/loadsave.cpp:409:错误:(-2)无法在函数imencode中找到指定扩展的编码器
为什么呢?我安装了OpenCV 2.1。这个工作很明显jpg编码器必须在那里:
cvSaveImage(/ home / richard / im.jpg,fIplImageHeader) ;
我想出了这一点。这个工程:
cv :: imencode(。jpg,fIplImageHeader,buf,p);
他们应该在文档中提到在扩展之前应该有一个句号。 >
Here is my code I am using to convert *IplImage to jpg:
IplImage* fIplImageHeader;
fIplImageHeader = cvCreateImageHeader(cvSize(160, 120), 8, 3);
fIplImageHeader->imageData = (char*) memblock;
vector<int> p;
p.push_back(CV_IMWRITE_JPEG_QUALITY);
p.push_back(10);
vector<unsigned char> buf;
cv::imencode("JPEG", fIplImageHeader, buf, p);
cvReleaseImageHeader(&fIplImageHeader);
But I am getting this error:
OpenCV Error: Unspecified error (could not find encoder for the specified extension) in imencode, file /build/buildd/opencv-2.1.0/src/highgui/loadsave.cpp, line 409
terminate called after throwing an instance of 'cv::Exception' what(): /build/buildd/opencv-2.1.0/src/highgui/loadsave.cpp:409: error: (-2) could not find encoder for the specified extension in function imencode
Why is that? I have OpenCV 2.1 installed. And this works so obviously jpg encoder must be there:
cvSaveImage("/home/richard/im.jpg", fIplImageHeader);
Ok. I've figured this out. This works:
cv::imencode(".jpg", fIplImageHeader, buf, p);
They should mention it somewhere in the documentation that there should be a full stop before extension.
这篇关于OpenCV - 找不到指定扩展名的编码器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!