Robert Kirchhoff
Robert Kirchhoff

Reputation: 517

Access opencv matrix CV_32S element

If I have a matrix of type CV_32SC1, what typename should I use in function Mat::at?

e.g.

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

How can I find the typename for other matrix types?

Upvotes: 16

Views: 25487

Answers (2)

CapelliC
CapelliC

Reputation: 60034

CV_32SC1 is a 1 Channel of Signed 32 bit integer, then I think that X.at<int>() should do.

Mat already 'knows' how to address a pixel, the type just cast the bits to the C++ value you require for the expression evaluation.

I found here some explanation about the notation.

Upvotes: 4

Jav_Rock
Jav_Rock

Reputation: 22245

The general rule for Matrices typenames in OpenCV is:

 CV_<bit_depth>(S|U|F)C<number_of_channels>

S = Signed integer
U = Unsigned integer
F = Float 

So depending on which one of the previous letters (S,U,F) you have, you will be casting <int>, <unsigned integer> or <float>.

Upvotes: 25

Related Questions