作者:
出处:
/* * ===================================================================================== * * Filename: array1.c * * Description: To show how to set and get a Array * * Version: 1.0 * Created: 01/08/2009 09:17:17 PM * Revision: none * Compiler: gcc * * Author: Futuredaemon (BUPT), gnuhpc@gmail.com * Company: BUPT_UNITED * * ===================================================================================== */#pragma comment( lib, "cxcore.lib" )#include "cv.h"#includeint main(){ CvMat* mat = cvCreateMat(3,3,CV_32FC1); cvZero(mat);//将矩阵置0//为矩阵元素赋值 CV_MAT_ELEM( *mat, float, 0, 0 ) = 1.f; CV_MAT_ELEM( *mat, float, 0, 1 ) = 2.f; CV_MAT_ELEM( *mat, float, 0, 2 ) = 3.f; CV_MAT_ELEM( *mat, float, 1, 0 ) = 4.f; CV_MAT_ELEM( *mat, float, 1, 1 ) = 5.f; CV_MAT_ELEM( *mat, float, 1, 2 ) = 6.f; CV_MAT_ELEM( *mat, float, 2, 0 ) = 7.f; CV_MAT_ELEM( *mat, float, 2, 1 ) = 8.f; CV_MAT_ELEM( *mat, float, 2, 2 ) = 9.f;//获得矩阵元素(0,2)的值 float *p = (float*)cvPtr2D(mat, 0, 2); printf("%f/n",*p); return 0;}
作者:
出处: