tags:

views:

909

answers:

2

Does anyone have any idea how to access elements by row, col in OpenCV 2.0's new "Mat" class? The documentation is linked below, but I have not been able to make any sense of it. http://opencv.willowgarage.com/documentation/cpp/basic%5Fstructures.html#mat

+1  A: 

On the documentation:

http://opencv.willowgarage.com/documentation/cpp/basic%5Fstructures.html#mat

It says:

(...) if you know the matrix element type, e.g. it is float, then you can use at<>() method

That is, you can use:

Mat M(100, 100, CV_8U);
cout << M.at<double>(0,0);

Maybe it is easier to use the Mat* class. It is a template wrapper for Mat. _*Mat* has the operator() overloaded in order to access the elements.

J. Calleja
+1  A: 

The same discussion about accessing element of Mat in detail.

OwnWaterloo
ah, thanks very much!
sheldon