三维垫返回一个空矩阵
3 dimensional Mat returns a null Matrix
我正在尝试在OpenCV中初始化一个三维垫,如下所示:
3d_matrix = Mat(3, sizes, CV_64FC1, double(0));
其中sizes
是大小3
的int
。 sizes
的值为 341
、 441
和 170
。
但是,在去窃听时,我看到3d_matrix
rows
和cols
都设置为-1
。
当我尝试将此矩阵编写为图像时,它会创建一个空图像(即它没有大小(,正如预期的那样。
正如@Miki所说,对于多维矩阵,行和列设置为 -1。
如果您只有 3 个暗角,则可以使用以下内容:
cv::Mat threed_matrix = cv::Mat(341, 441, CV_64FC(170));
std::cout << "rows: " << threed_matrix.rows << std::endl
<< "cols: " << threed_matrix.cols << std::endl
<< "channels(): " << threed_matrix.channels() << std::endl;
这给了:
rows: 341
cols: 441
channels(): 170
请注意,通道大小不应超过 CV_CN_MAX
,这是当前在 OpenCV 中512
定义的
相关文章:
- C++,class,一个返回对象的函数
- C++ 这里有一个返回 (24) 的布尔返回类型函数
- 我有一个返回字符串向量的函数.它需要两个字符串,并且返回一个字符串中缺少的字符串
- 两个相同的重载运算符[]一个返回引用
- 给定一个整数 N>0,区间 [0, 2^N) 中有多少个整数正好有 N-1 个设置位?编写一个返回正确答案的简短函数
- 为什么要定义一个返回结构的 lambda 函数,而不是直接定义结构
- 有没有办法重写一个返回指向 istringstream 的指针的函数,而不是返回一个引用?
- 提升:创建一个返回变体的函数
- C++重载运算符两次,一个返回非常量引用,另一个返回常量引用,首选项是什么
- 我是否应该将最后一个“返回”语句封装为“else { return .. }',如果它在逻辑上是可选的
- 野牛解析器:创建一个返回令牌的函数
- 为什么 C++ 数组的大小不能有一个返回常量的函数调用
- 如何创建一个返回传递的参数名称的函数
- 如何在C++中创建一个返回字节数组的函数?Arduino项目
- 将返回的指针分配给另一个返回的指针
- 如何声明一个返回类型是推导出来的函数
- Constexpr语言 - 为什么只是一个返回语句
- 如何创建一个返回护士函数的函数
- 如何用C包装一个返回智能指针的C++函数
- 如何使用两个函数,一个返回迭代器,另一个返回const_iterator