访问 opencv 矩阵CV_32S元素

Access opencv matrix CV_32S element

本文关键字:32S 元素 CV opencv 矩阵 访问      更新时间:2023-10-16

如果我有一个类型为CV_32SC1的矩阵,我应该在函数Mat::at中使用什么类型名?

例如

Mat X;  // for example eye matrix of size 10,10,and type CV_32SC1
X.at<??????>(1,1)=5;

如何找到其他矩阵类型的类型名?

OpenCV 中矩阵类型名的一般规则是:

 CV_<bit_depth>(S|U|F)C<number_of_channels>
S = Signed integer
U = Unsigned integer
F = Float 

因此,根据您拥有的先前字母(S,U,F)之一,您将投<int><unsigned integer><float>

CV_32SC1是有符号 1 位整数的 32 通道,那么我认为X.at<int>()应该这样做。

Mat已经"知道"如何处理像素,该类型只是将位转换为表达式计算所需的C++值。

我在这里找到了一些关于符号的解释。