How to find out which type to use for the OpenCV.at function in C ++?

Is there a simple reliable way to find out which equivalent type should I use for the .at function for Mat of a given CV type?

For example, how can I say that gaps should be filled ushort, floatand Vec3b?

Mat mat1(1, 2, CV_16UC1, 12345);
std::cout << mat1.at<___>(0, 1) << "\n";
Mat mat2(1, 2, CV_32FC1, 67.89);
std::cout << mat2.at<___>(0, 1) << "\n";
Mat mat3(1, 2, CV_8UC3, Scalar(65, 66, 67));
std::cout << mat3.at<___>(0, 1)[2] << "\n";
+4
source share
1 answer

Using data from

I built the following table:

        C1      C2     C3     C4     C6 (not sure whether C6 subtype exists as a macro)
CV_8U   uchar   Vec2b  Vec3b  Vec4b
CV_8S   char    -       
CV_16U  ushort  -
CV_16S  short   Vec2s  Vec3s  Vec4s
CV_32S  int     Vec2i  Vec3i  Vec4i
CV_32F  float   Vec2f  Vec3f  Vec4f  Vec6f
CV_64F  double  Vec2d  Vec3d  Vec4d  Vec6d

with uchar == unsigned charandushort == unsigned short

for missing types, you can create your own typedef if you want:

typedef Vec<ushort, 2> Vec2us;

am (Vec2s)

, , (32- 3- = 3 ), , ...

+4

All Articles