Opencv C++ 声明一个类型为 uint8 的矩阵
Opencv C++ Declaring a matrix of type uint8
相当简单的问题:我想知道如何在opencv中指定矩阵的类型。 我 https://docs.opencv.org/trunk/dc/d84/group__core__basic.html 查看此页面,它为 cv::Mat1f 等的浮点矩阵指定了 typedef。 我不熟悉C++;我可以使用他们在 typedefs 中做的类似事情来制作我自己的 uint8 矩阵吗?
Mat_< uint8 > mymatrix;
或类似的东西? 我可以制作自己的类型定义吗?
C++中的标准类型是 uint8_t
,即 Mat_< uint8_t > mymatrix;
.你需要#include <cstdint>
.
你也可以制作自己的类型定义
typedef Mat_< uint8_t > uint8_matrix_type;
或类似的东西。
您应该使用内置的:
cv::Mat1b
在mat.hpp
中定义为:
typedef Mat_<uchar> Mat1b;
其中uchar
在interface.h
中定义:
//! - uchar - unsigned 1 byte integer
typedef unsigned char uchar;
您也可以typedef
具有首选类型的矩阵,但您可能会遇到奇怪的错误,因为它的DataType
(traits.hpp
(不会被指定,因此它可能与某些OpenCV函数不兼容。
相关文章:
- ArduinoJson 6.15.2:JsonObject没有命名类型
- 防止主数据类型C++的隐式转换
- 大量序列中核苷酸类型的快速计数
- 如何从C++中的依赖类型中获得它所依赖的类型
- 有关插入适配器的错误。[错误]请求从 'back_insert_iterator<vector<>>' 类型转换为非标量类型
- 是否可以初始化不可复制类型的成员变量(或基类)
- 如何获取std::result_of函数的返回类型
- 从父命名空间重载类型
- 如果C++类在类方法中具有动态分配,但没有构造函数/析构函数或任何非静态成员,那么它仍然是POD类型吗
- 我想将一个对T类型的非常量左值引用绑定到一个T类型的临时值
- Openssl 1.1.1d无效使用不完整的类型"struct dsa_st"
- 访问者访问变体并返回不同类型时出错
- 在VS2010-VS2015下编译时,如何使用decltype作为较大类型表达式的LHS
- 处理小于cpu数据总线的数据类型.(c++转换为机器代码)
- C++ 雷神库 - 使用资源加载器类时出现问题(不命名类型)
- uint32, int16, uint8 .为什么这些常用的数据类型没有进入标准
- Opencv C++ 声明一个类型为 uint8 的矩阵
- Uint8 - 缺少类型说明符
- 将uint8 vector类型的元素转换为stringstream类型
- 将std::string转换为uint8 *类型