1.初始化矩阵:
方式一、逐点赋值式:
CvMat* mat = cvCreateMat( 2, 2, CV_64FC1 );
cvZero( mat );
cvmSet( mat, 0, 0, 1 );
cvmSet( mat, 0, 1, 2 );
cvmSet( mat, 1, 0, 3 );
cvmSet( mat, 2, 2, 4 );
cvReleaseMat( &mat );
方式二、连接现有数组式: double a[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 };
CvMat mat = cvMat( 3, 4, CV_64FC1, a ); // 64FC1 for double
// 不需要cvReleaseMat,因为数据内存分配是由double定义的数组进行的。
http://cache.baiducontent.com/c?m=9f65cb4a8c8507ed19fa950d100b92235c4380146d8b804b2281d25f93130a1c187bb6e760785255ce963c365bf40d0bf7f03471371e23b786ca8e57ddb190282c8d2723706bdc074d8d0dea960673ce71d405a8f85ff0ba816fd1f98e829b&p=8d60c54ad6c347f80dafcd2d0214a5&newp=8b2a971c81934eaf58ebd434494d98231610db2151d6d6106b82c825d7331b001c3bbfb423241a0fd8c37e6007aa4c5cecf335753c072ba3dda5c91d9fb4c57479d170&user=baidu&fm=sc&query=cvmSet+++opencv&qid=d6a4b49600007747&p1=5