我正在尝试调整图像大小,然后显示它以检查它是否已被调整大小。调整大小和显示图像
#include"cv.h"
#include"highgui.h"
#include<iostream>
using namespace cv;
int main()
{
IplImage* ipl = cvLoadImage("test1.jpg");
cvShowImage("original:",ipl);
CvSize size = cvSize(128,128);
IplImage* tmpsize=cvCreateImage(size,8,0);
cvResize(ipl,tmpsize,CV_INTER_LINEAR);
cvShowImage("new",tmpsize);
waitKey(0);
return 0;
}
但它会产生一个错误 OpenCV的错误:断言未知功能 文件c ==失败dst.type < >>:\从\ winInstallerMegaPack的\ src \ OpenCV的\模块\ imgproc的\ src \ imgwarp。 cpp line. 请指出我做错了什么,并提出一些解决方法。另一方面,其他代码工作正常。
IplImage *source = cvLoadImage("test1.jpg");
// Here we retrieve a percentage value to a integer
int percent =50;
// declare a destination IplImage object with correct size, depth and channels
IplImage *destination = cvCreateImage
(cvSize((int)((source->width*percent)/100) , (int)((source->height*percent)/100)),
source->depth, source->nChannels);
//use cvResize to resize source to a destination image
cvResize(source, destination);
// save image with a name supplied with a second argument
cvShowImage("new:",destination);
waitKey(0);
return 0;
请说明。
问题是,您试图将操作的结果存储在与原始图像不兼容的图像中:两张图像必须具有相同类型(n通道和深度)。 – karlphillip 2012-02-05 03:25:53
@ karlphillip-我了解这两个图像有一些区别,但我无法弄清楚区别。谢谢。 – 2012-02-05 07:35:41