我正在嘗試調整圖像大小,然後顯示它以檢查它是否已被調整大小。調整大小和顯示圖像
#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