user3441653
user3441653

Reputation:

Accessing elements of OpenCV Mat CV_16UC1

i tried with the following line code:

image.at<char>(row, column);
image.at<uchar>(row, column);
image.at<unsigned char>(row, column);
image.at<double>(row, column);

what is wrong?

after that, i need to convert this value to a float. A casting is enough?

Upvotes: 5

Views: 13800

Answers (1)

Nathan Monteleone
Nathan Monteleone

Reputation: 5470

CV_16UC1 has unsigned short as an underlying type, so you probably need

unsigned short val = image.at<unsigned short>(row, column);

And yes, you can simply static cast that to a float afterwards:

float fval = static_cast<float>(val);

Upvotes: 9

Related Questions