问题描述
- 关于在VS2008中的错误:error C2660: “cvCreateImage”: 函数不接受 1 个参数
- 代码如下,很急,谢各位
#include ""stdafx.h""
#include ""stdio.h""#include ""cv.h""
#include ""cxcore.h""
#include ""highgui.h""IplImage* DrawHistogram(CvHistogram* hist float scaleX = 1 float scaleY = 1)
{float histMax = 0;
cvGetMinMaxHistValue(hist 0 &histMax 0 0);
IplImage* imgHist = cvCreateImage(cvSize(256*scaleX 64*scaleY));
cvZero(imgHist);for(int i=0;i<255;i++){ float histValue = cvQueryHistValue_1D( hist i); float nextValue = cvQueryHistValue_1D( hist i+1); CvPoint pt1 = cvPoint(i*scaleX 64*scaleY); CvPoint pt2 = cvPoint((i+1)*scaleX 64*scaleY); CvPoint pt3 = cvPoint((i+1)*scaleX 64*scaleY - (nextValue/histMax)*64*scaleY); CvPoint pt4 = cvPoint( i*scaleX 64*scaleY - (nextValue/histMax)*64*scaleY); int numPts = 5; CvPoint pts[5]; pts[0] = pt1; pts[1] = pt2; pts[2] = pt3; pts[3] = pt4; pts[4] = pt1; cvFillConvexPoly(imgHist pts numPts cvScalar(255));}return imgHist;
}
int main(int argc _TCHAR* argv[])
{
IplImage* src = cvLoadImage(""E:lena.jpg"");
cvNamedWindow(""src"");
cvShowImage(""src"" src);int dims = 1;int size = 256;float range[] = {0255};float* ranges[] = {range};CvHistogram* hist;hist = cvCreateHist(dims &size CV_HIST_ARRAY ranges 1);cvClearHist(hist);IplImage* imgRed = cvCreateImage(cvGetSize(src) 8 1);IplImage* imgGreen = cvCreateImage(cvGetSize(src) 8 1);IplImage* imgBlue = cvCreateImage(cvGetSize(src) 8 1);cvSplit(src imgBlue imgGreen imgRed NULL);cvCalcHist(&imgBlue hist 0 0 );IplImage* histBlue = DrawHistogram(hist);cvClearHist(hist);cvCalcHist(&imgGreen hist 0 0 );IplImage* histGreen = DrawHistogram(hist);cvClearHist(hist);cvCalcHist(&imgRed hist 0 0 );IplImage* histRed = DrawHistogram(hist);cvClearHist(hist);cvNamedWindow(""B"");cvNamedWindow(""G"");cvNamedWindow(""R"");cvShowImage(""B"" histBlue);cvShowImage(""G"" histGreen);cvShowImage(""R"" histRed);cvWaitKey(0);return 0;
}
解决方案
IplImage* imgHist = cvCreateImage(cvSize(256*scaleX 64*scaleY));
这里的问题
IplImage* cvCreateImage( CvSize size int depth int channels );
这个函数需要3个参数
时间: 2025-01-21 19:36:46