opencv——mat操作
来源:互联网 发布:全网络大区什么意思 编辑:程序博客网 时间:2024/05/17 22:38
- //function: the mat operation
- // data:12 /20
- #include <cv.h>
- #include <highgui.h>
- #include <iostream.h>
- void PrintMat(CvMat *mat)
- {
- int i;
- int j;
- for (i=0; i<mat->rows; i++)
- {
- // the type of mat_depth
- switch (CV_MAT_DEPTH(mat->type))
- {
- case CV_32F:
- case CV_64F:
- //printf("aa");
- for (j=0; j<mat->cols; j++)
- {
- printf("%5.2f", (float)cvGetReal2D(mat, i,j));
- //printf("%5.5f", (float)CV_MAT_ELEM(*mat, double, i,j));
- }
- break;
- case CV_8U:
- case CV_16U:
- for (j=0; j<mat->cols; j++)
- printf("%d", (int)cvGetReal2D(mat,i,j));
- break;
- }
- printf("/n");
- }
- }
- int main(int argc, char* argv[])
- {
- // create mat
- CvMat *myMat=cvCreateMat(2,2, CV_32FC1);
- float mata[] = {
- 1,2,3,
- 4,5,6,7,
- 8,9,10};
- float matb[] = {1,1,1,
- 1,1,1,
- 1,1,1};
- float matc[9];
- CvMat Mata;
- CvMat Matb;
- CvMat Matc;
- // initial mat header
- cvInitMatHeader(&Mata, 3,3, CV_32FC1, mata, CV_AUTOSTEP);
- cvInitMatHeader(&Matb, 3,3, CV_32FC1, matb, CV_AUTOSTEP);
- cvInitMatHeader( &Matc, 3, 3, CV_32FC1, matc, CV_AUTOSTEP );
- // print mat's element
- printf("print the mata:/n");
- PrintMat(&Mata);
- printf("print the matb:/n");
- PrintMat(&Matb);
- // Mat add function
- cvAdd(&Mata,&Matb, &Matc, NULL);
- //print the result
- printf("print the matc:/n");
- PrintMat(&Matc);
- int i;
- int j;
- // enter the numbers to the mat
- for ( i = 0; i<myMat->rows; i++ )
- for ( j = 0; j <myMat->cols; j++)
- {
- scanf("%f", &CV_MAT_ELEM(*myMat, float , i , j));
- //cin >> CV_MAT_ELEM(*myMat, float , i , j);
- }
- // print mat element
- PrintMat(myMat);
- printf("Hello World!/n");
- return 0;
- }
- opencv——mat操作
- Opencv学习——Mat矩阵操作
- 学习OpenCV——Mat数据操作之普通青年、文艺青年、暴力青年.& Mat注意事项
- opencv Mat 像素操作
- Opencv Mat操作大全
- opencv mat像素操作
- Opencv Mat元素操作
- 【opencv】Mat 数据操作
- Opencv Mat操作大全
- opencv MAT数据操作
- opencv Mat基本操作
- opencv Mat常用操作
- 【OpenCV】Mat基本操作
- opencv的mat操作
- OpenCV Mat常用操作
- Opencv图像Mat操作
- OpenCV学习——Mat
- OpenCV ——mat---ROI
- 福德宫
- 学了差不多一个学期的c语言了,期末写的五子棋。
- 学习C语言之前统一思想
- 贵还是
- stl
- opencv——mat操作
- VC获得文件所在目录路径的方法
- DirectShow在VS2005中PVOID64问题和配置问题
- 何为人生
- 体会
- SQL 多表连接统计查询
- 快乐的种子(转)
- 十个习惯让你精通新的开发技术
- Linux终端关闭按键报警声