Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Understanding cv::Mat

cv::Mat mat34(3,4, CV_32FC(3),cv::Scalar(20,30,40));

mat34.at<float>(3,3) = 1000;

std::cout << mat34.at<float>(3,3) << " and " << mat34.at<cv::Vec<float,3> >(3,3)[0] << std::endl;
std::cout << mat34 << std::endl;

Output

1000 and 0
[20, 30, 40, 20, 30, 40, 20, 30, 40, 20, 30, 40;
 20, 30, 40, 20, 30, 40, 20, 30, 40, 20, 30, 40;
 20, 30, 40, 20, 30, 40, 20, 30, 40, 20, 30, 40]

I dont understand the 3,3 part. Is the element 3,3 not direclty in the matrix?

Understanding cv::Mat

cv::Mat mat34(3,4, CV_32FC(3),cv::Scalar(20,30,40));

mat34.at<float>(3,3) = 1000;

std::cout << mat34.at<float>(3,3) << " and " << mat34.at<cv::Vec<float,3> >(3,3)[0] << std::endl;
std::cout << mat34 << std::endl;

Output

1000 and 0
[20, 30, 40, 20, 30, 40, 20, 30, 40, 20, 30, 40;
 20, 30, 40, 20, 30, 40, 20, 30, 40, 20, 30, 40;
 20, 30, 40, 20, 30, 40, 20, 30, 40, 20, 30, 40]

I dont understand the 3,3 part. Is the element 3,3 not direclty in the matrix?matrix? Was expecting to see 1000 somewhere in the entire matrix. Also, how can I access channels using cv::Vec? Since, I am learning I am not looking for alternative solutions, but just understanding how this works.