Knowing the value of an Mat element Opencv

99封情书 提交于 2019-12-02 02:07:44

You print the character not the integer representation. See:

cv::Mat img(3,3,CV_8U,cvScalar(123));
cout<<"Number "<<(int)img.at<uchar>(1,1)<<" represents ASCII character \""<<img.at<uchar>(1,1)<<"\"";

Output:

Number 123 represents ASCII character "{"

You can validate this fact here.

William already touched on this, but you want the numeric representation of the value in your matrix. Instead of casting it as suggested by William (which works!), you can simply request the data as an unsigned integer.

cout << abs_dst_gray.at<unsigned int>(10,10) << endl;
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!