编译命令 :g++ arry_cv.cpp `pkg-config opencv --cflags --libs`
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include <iostream>
#include <stdio.h>
using namespace std;
using namespace cv;
void InitMat(Mat& m,float(*p)[255])
{
for(int i=0;i<m.rows;i++)
for(int j=0;j<m.cols;j++)
m.at<float>(i,j)=*(*(p+i)+j);
}
int main()
{
float a[255][255] = {0};
for(int i = 0; i < 255; i++)
{
//0cout << "第 " << i << "行 " << endl;
for(int j = 0; j < 255; j++)
{
a[i][j] = j;
//cout << a[i][j];
}
//cout << endl;
}
//Mat temp(255, 255, CV_8UC1, a);
Mat temp(255,255,CV_32FC1);
InitMat(temp,a);
imshow("a", temp);
cout << "temp" << temp << endl;
waitKey();
return 0;
}