Access to OpenCV Mat Elements CV_16UC1

I tried using 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's wrong?

after that I need to convert this value to float. Is casting enough?

+4
source share
1 answer

CV_16UC1 has unsigned short as the base type, so you probably need to

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

And yes, you can simply static cast into the float afterwards:

float fval = static_cast<float>(val);
+6
source

Source: https://habr.com/ru/post/1533582/


All Articles