当前位置:网站首页>《opencv学习笔记》-- CV::Mat类
《opencv学习笔记》-- CV::Mat类
2022-06-24 10:00:00 【cc_rong】
目录
Mat初始化函数
//默认构造函数 cv::Mat //拷贝构造 cv::Mat(const Mat& mat) // 指定行和列的拷贝构造 cv::Mat(const Mat& mat, const cv::Range& rows, const cv::Range& cols); // 指定ROI(感兴趣的区域)的拷贝构造 cv::Mat(const Mat& mat, const cv::Rect& roi); // 使用n维数组中指定范围内的数据的拷贝构造 cv::Mat(const Mat& mat, const cv::Range* ranges); // 指定类型的二维数组 cv::Mat(int rows, int cols, int type); // 指定类型的二维数据,并指定初始化值 cv::Mat(int rows, int cols, int type, const Scalar& s); // 使用预先存在的数据,并指定类型的二维数组 cv::Mat(int rows, int cols, int type, void *data, size_t step = AUTO_STEP); // 指定大小和类型的二维数组 cv::Mat(cv::Size sz, int type) // 指定大小和类型的二维数组,并指定初始值 cv::Mat(cv::Size sz, int type, const Scalar& s); // 使用预先存在的数据,指定类型的二维数组 cv::Mat(cv::Size sz, int type, void *data, size_t step = AUTO_STEP); // 指定类型的多维数据 cv::Mat(int ndims, const int *sizes, int type); // 指定类型的多维数据,并初始值 cv::Mat(int ndims, const int *sizes, int type, const Scalar& s); // 使用预先存在的数据,指定类型的多维数组 cv::Mat(int ndims, const int* sizes, int type, void* data, size_t step = AUTO_STEP); //mat的模板构造函数 // 构造如同cv::Vec所指定的数据类型、大小为n的一维数组 cv::Mat(const cv::Vec<T, n>& vec, bool copyData = true); // 构造如同cv::Matx所指定的数据类型、大小为mXn的二维数组 cv::Mat(const cv::Matx<T, m, n>& vec, bool copyData = true); // 构造STL的vector所指定的数据类型的一维数组 cv::Mat mat(const std::vector<T>& vec, bool copyData = true); //构造mat的静态方法 // 使用zeros()函数定义指定大小(rows X cols)和类型(type)的cv::Mat(全为0)的矩阵 cv::Mat::zeros(int rows, int cols, int type); // 使用ones()函数定义指定大小(rows X cols)和类型(type)的cv::Mat(全为1)的矩阵 cv::Mat::ones(int rows, int cols, int type); // 使用eye()函数定义指定大小(rows X cols)和类型(type)的单位矩阵 cv::Mat::eye(int rows, int cols, int type);
访问像素
方法一:使用at函数
//直接访问 at函数 cv::Mat mat = cv::Mat::eye(10, 10, 32FC1); m.at<float>(3, 3) //多通道数组操作 cv::Mat mat = cv::Mat::eye(10, 10, 32FC2); m.at<cv::Vec2f>(3, 3)[0]; m.at<cv::Vec2f>(3, 3)[1];
方法二:使用迭代器
int sz[3] = {4, 4, 4}; Mat m(3, sz, CV_32FC3); cv::MatIterator<cv::Vec3b> it = m.begin(); while(it != m.end()) { cout << (*)it[0]; it++; }
边栏推荐
- Why are some old SEO methods still effective?
- [Flink source code practice (I)] add a rest API to Flink
- Centripetalnet: more reasonable corner matching, improved cornernet | CVPR 2020 in many aspects
- PHP SMS notification + voice broadcast automatic double call
- 2008R2 precautions for configuring L2TP pre shared key VPN
- Mongodb index operation
- Cloud vendor secondary virtualization restrictions
- Self cleaning Manual of mining Trojan horse
- Google Earth Engine(GEE)—如何新增一个图例在Map面板
- Tencent wetest platform will bring new benefits in 2021 with 618 special offers!
猜你喜欢

How to develop hospital information system (his) with SMS notification and voice function

math_等比数列求和推导&等幂和差推导/两个n次方数之差/

Shell脚本(.sh文件)如何执行完毕之后不自动关闭、闪退?

使用Process Monitor工具监测进程对注册表和文件的操作

脚本之美│VBS 入门交互实战

Shape change loader loads jsjs special effect code

服乔布斯不服库克,苹果传奇设计团队解散内幕曝光

Simple pricelist style code

工具及方法 - 在Source Insight中使用代码格式化工具

Visual presentation of pictures effectively enhances the attraction of large screen
随机推荐
Attribute observer didset and willset in swift of swiftui swift internal skill
Google ranging for PHP wechat development
Any 与 TypeVar,让 IDE 的自动补全更好用
如何开发短信通知和语音功能医院信息系统(HIS系统)
【本周六活动】.NET Day in China
Cause analysis of frequent crash and restart of easynvr-arm cloud terminal
MYSQL_ Elaborate on database data types
TP-LINK 1208路由器教程(2)
H5 video conference, camera monitoring, web streaming and live broadcast integration scheme
Why are some old SEO methods still effective?
图片的可视化呈现有效增强大屏吸引力
【毕业季·进击的技术er】绕树三匝,何枝可依?
What is the knowledge map? What does it do
Give you a server. Can you deploy your code online?
Beauty of script │ VBS introduction interactive practice
≥ 2012r2 configure IIS FTP
How to develop hospital information system (his) with SMS notification and voice function
Libuv的安装及运行使用
[latest in the whole network] how to start the opentsdb source code in the local ide run
Plant growth H5 animation JS special effect