|
Since, OpenCV’s documentation is more than lacking a few sentences I’ll post some important facts that can easily be missed.
To access the elements of a cv::Mat one can use the at<T>(int y, int x) method. Usually, the elements are stored as doubles (CV_64F). So to get for example elements (1,1) the call is
mat.at<double>(1,1);
but you’re not forbidden to call
mat.at<float>(1,1);
OpenCV won’t complain that you’re reading the wrong data type. OpenCV also doesn’t perform a type conversion. Hence, you’ll end up with the wrong data.
In summary, make sure you’re reading the correct data type. You might use the depth() method to figure out the internal type of the matrix
|