When iterating through a cv::Mat to output all of its values, you could do the following:
for (int r = 0; r < t.rows; r++)
{
for (int c = 0; c < t.cols; c++)
{
std::cout << t.at<float>(r,c) << ", ";
}
std::cout << std::endl << std::endl;
}
However, if the information stored in that array is not of type float, this will crash. How do you enforce the type of this matrix?
for 2 Mats
nonFloatMatandfloatMatwhen the first is the source matrix and the last is the destination matrix doconvertTo‘s reference can be found here.
Edit:
and by the way, the code will work if you’ll change the float to the correct concrete type of the matrix ie if the mat is a
CV_8Uyou can dot.at<char>(r,c)etc.