OpenCV实现PCA算法出错!!help~!!!

#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <cv.h>
#include <highgui.h>
#include <iostream>
void main()
{
	srand((unsigned int)time(NULL));
	double a[30*1200]={0.0};
	int k=0;
	for(int i=0; i<36000; ++i)
	{
		a[i]=rand()%5000;
	}
	CvMat *pData = cvCreateMat(30,1200,CV_32FC1);
	cvSetData(pData,a,pData->step);//向矩阵中添加数据,a:是一个数组

	CvMat *pMean = cvCreateMat(1,1200,CV_32FC1);
	CvMat *pEigVals = cvCreateMat(1,min(30,1200),CV_32FC1);
	CvMat *pEigVecs = cvCreateMat(min(30,1200),1200,CV_32FC1);

	cvCalcPCA(pData,pMean,pEigVals,pEigVecs,CV_PCA_DATA_AS_ROW);//??????????????????????????????????????????????????????

	CvMat *pResult = cvCreateMat(15,120,CV_32FC1);

	cvProjectPCA(pData,pMean,pEigVecs,pResult); //??????????????????????????????????????

	for(int i=0; i<30; ++i)
	{
		for(int j=0; j<100; ++j)
		{
			std::cout<<","<<cvGet2D(pResult,i,j).val[0];
		}
		std::cout<<std::endl;
	}
}
出错位置:
cvProjectPCA(pData,pMean,pEigVecs,pResult); 
控制台 错误提示:opencv error : assertion failed (dst0.data == dst.data) in unkown function~~


   

你可能感兴趣的:(算法,function,null,include,DST)