#include<iostream> #include <opencv2/core/core.hpp>#include <opencv2/highgui/highgui.hpp> using namespace cv; int main( int argc, char** argv ){ float a[18] = { 30,60,45,56,70,78, 90,80,94,89,87,91, 78,76,56,43,21,10 }; CvMat mat; cvInitMatHeader(&mat,3, 3, CV_32FC2,a); //创建一个空矩阵 for(int y = 0; y <mat.rows; y++) { for(int x = 0; x <mat.cols; x++) { CvScalar value = cvGet2D(&mat, y, x); PRintf("(%f %f )",value.val[0],value.val[1]); } printf("/n");}return 0; }
得到的结果如下
新闻热点
疑难解答