I want to write a short function to display OpenCV Mat matrix type. I\'m closed to finish it. This is my code:
template
int MATmtxdisp(con
What about this?
cv::Mat myMat(2,3, CV_8UC3, cv::Scalar(1, 2, 3));
std::cout << myMat << std::endl;
Anyway, your code is much easier if you use cout:
template <class T>
int MATmtxdisp(const Mat& mtx)
{
uchar chan = mtx.channels();
int step = mtx.step();
T* ptr = (T*)mtx.data;
for(int i = 0; i < mtx.rows; i++)
for(int k = 0; k < chan; k++)
{
for(int l = 0; l < mtx.cols; l++)
{
cout << ptr[ /* calculate here the index */];
}
cout << endl;
}
}