opencv mat
mat基础教程:
http://blog.csdn.net/sinat_31802439/article/details/50083291
mat 初始化:
Mat M(,,CV_32FC1);
Mat shftMat=(Mat_<double>(,)<<1.0,,leftImg.cols, ,1.0,, ,,1.0);
mat 读取:
topleft2 = presentToLastCorners.col();
topleft2<float>(,);
Keep in mind that the size identifier used in the at operator cannot be chosen at random. It depends
on the image from which you are trying to retrieve the data. The table below gives a better insight in this:
- If matrix is of type `CV_8U` then use `Mat.at<uchar>(y,x)`.
- If matrix is of type `CV_8S` then use `Mat.at<schar>(y,x)`.
- If matrix is of type `CV_16U` then use `Mat.at<ushort>(y,x)`.
- If matrix is of type `CV_16S` then use `Mat.at<short>(y,x)`.
- If matrix is of type `CV_32S` then use `Mat.at<int>(y,x)`.
- If matrix is of type `CV_32F` then use `Mat.at<float>(y,x)`.
- If matrix is of type `CV_64F` then use `Mat.at<double>(y,x)`.
在Mat.at中看到
mat 转变数据类型: 转载自http://blog.csdn.net/xiaxiazls/article/details/51204265
cv::Mat matTemp = cv::Mat::zeros(,,CV_32F); //得到一个浮点型的100*100的矩阵
cv::Mat MatTemp2;
matTemp.convertTo(MatTemp2, CV_8U); //把矩阵matTemp转为unsing char类型的矩阵,注在转换过程中有可能数值上会出现一些变化,这个要注意
如何初始化一个任意大小mat
使用构造函数
Mat formedMat(,,CV_8UC3);
图片彩色转黑白
http://blog.csdn.net/qq5132834/article/details/37736693
cvtColor(OpencvimageColor,OpencvimageGray,COLOR_RGB2GRAY);
将两幅图像链接成一幅图片
http://blog.csdn.net/quincuntial/article/details/49947791
计算图片像素平均值和方差
void meanStdDev_test()
{
const char* imagename = "E:/1.jpg";
//产生灰度图
Mat img = imread(imagename);
Mat gray,color;
cvtColor(img, gray, CV_RGB2GRAY);
cout << "Channel: " << gray.channels() << endl; Mat tmp_m, tmp_sd;
double m = , sd = ; m = mean(gray)[];
cout << "Mean: " << m << endl; meanStdDev(gray, tmp_m, tmp_sd);
m = tmp_m.at<double>(,);
sd = tmp_sd.at<double>(,);
cout << "Mean: " << m << " , StdDev: " << sd << endl;
}
Mat type()返回值对应类型:
http://ninghang.blogspot.com/2012/11/list-of-mat-type-in-opencv.html
使用mat出现corrupted unsorted chunks corrupted double-linked list错误,原因在于原来按Mat(col,row) 访问mat,应该是按照Mat(row,col)访问mat才对
逐点访问Mat
http://blog.csdn.net/xiaowei_cqu/article/details/7771760
Mat& ScanImageAndReduceIterator(Mat& I, const uchar* const table)
{
// accept only char type matrices
CV_Assert(I.depth() != sizeof(uchar));
const int channels = I.channels();
switch(channels)
{
case :
{
MatIterator_<uchar> it, end;
for( it = I.begin<uchar>(), end = I.end<uchar>(); it != end; ++it)
*it = table[*it];
break;
}
case :
{
MatIterator_<Vec3b> it, end;
for( it = I.begin<Vec3b>(), end = I.end<Vec3b>(); it != end; ++it)
{
(*it)[] = table[(*it)[]];
(*it)[] = table[(*it)[]];
(*it)[] = table[(*it)[]];
}
}
}
return I;
}
opencv mat的更多相关文章
- Matlab to OpenCV Mat
convert Matlab matrix to OpenCV Mat. Support CV_32FC3 only currently. The Code int matlab2opencv(cv: ...
- OpenCV Mat数据类型及位数总结(转载)
OpenCV Mat数据类型及位数总结(转载) 前言 opencv中很多数据结构为了达到內存使用的最优化,通常都会用它最小上限的空间来分配变量,有的数据结构也会因为图像文件格式的关系而给予适当的变量, ...
- OpenCV Mat数据类型指针ptr的使用
OpenCV Mat数据类型指针ptr的使用 cv::Mat image = cv::Mat(400, 600, CV_8UC1); //宽400,长600 uchar * data00 = imag ...
- Qt QImage与OpenCV Mat转换
本系列文章由 @yhl_leo 出品,转载请注明出处. 文章链接: http://blog.csdn.net/yhl_leo/article/details/51029382 应一个朋友的要求,整理总 ...
- 快速遍历OpenCV Mat图像数据的多种方法和性能分析 | opencv mat for loop
本文首发于个人博客https://kezunlin.me/post/61d55ab4/,欢迎阅读! opencv mat for loop Series Part 1: compile opencv ...
- 海康网络摄像机YV12转换为BGR,由opencv Mat显示 (转)
我使用的是海康DS-2CD852MF-E, 200万,网络摄像机,已经比较老了,不过SDK在海康官网下载的,开发流程都差不多. 海康摄像机回调解码后的视频数据格式为YV12,顺便说一下YV12的数据格 ...
- Live YUV420 和 OpenCV Mat 的互相转换
1. YUV420 -> Mat 可用于转换接受到的YUV视频源到OpenCV可以识别的数据 Mat myuv( Frame_Height + Frame_Height / 2, Frame_W ...
- OpenCv Mat操作总结
Author:: Maddock Date: 2015-03-23 16:33:49 转载请注明出处:http://blog.csdn.net/adong76/article/details/4053 ...
- OpenCV MAT基本图像容器
参考博客: OpenCv中cv::Mat和IplImage,CvMat之间的转换 Mat - 基本图像容器 Mat类型较CvMat和IplImage有更强的矩阵运算能力,支持常见的矩阵运算(参照Mat ...
- Opencv Mat的操作
cout << mat 有错误的原因 You are using OpenCV built with VS10. The ostream operator << in the ...
随机推荐
- PAT 1089 狼人杀-简单版
https://pintia.cn/problem-sets/994805260223102976/problems/1038429385296453632 以下文字摘自<灵机一动·好玩的数学& ...
- Delphi中动态创建窗体有四种方式
Delphi中动态创建窗体有四种方式,最好的方式如下: 比如在第一个窗体中调用每二个,主为第一个,第二个设为动态创建 Uses Unit2; //引用单元文件 procedure TForm1.But ...
- NS产品演进
NS产品演进 Citrix产品体系================ Citrix产品类别================ NS产品演进================ 产品联系方式========== ...
- [洛谷P2626]斐波那契数列(升级版)
题目大意:请你求出第$n$个斐波那契数列的数$mod 2^{31}$之后的值.并把它分解质因数. 题解:乱搞 卡点:1.忘记取模 C++ Code: #include<cstdio> #i ...
- Winpcap网络开发库入门
原文链接地址:http://www.cnblogs.com/phinecos/archive/2008/10/20/1315176.html Winpcap是一个强大的网络开发库,可以实现许多功能:获 ...
- Hello to the cruel world
- Vue获取DOM元素样式 && 样式更改
在 vue 中用 document 获取 dom 节点进行节点样式更改的时候有可能会出现 'style' is not definde的错误, 这时候可以在 mounted 里用 $refs 来获取样 ...
- 用JavaScript实现一个简单的树结构
数据源用数组混json结构,实现了基本的功能.效率一般,跟 dhtree 梅花雪树对比了下,都差不多. (ps感觉比dhtree快点,跟梅花雪树差不多,个人测试) 这个实现树的原理是根据json,不断 ...
- Reasons to use innodb_file_per_table
When working with InnoDB, you have two ways for managing the tablespace storage: Throw everything in ...
- Educational Codeforces Round 55 (Rated for Div. 2):D. Maximum Diameter Graph
D. Maximum Diameter Graph 题目链接:https://codeforces.com/contest/1082/problem/D 题意: 给出n个点的最大入度数,要求添加边构成 ...