Wielokanałowa funkcja wyświetlania mat

Chcę napisać krótką funkcję, aby wyświetlić typ macierzy OpenCV Mat. Jestem zamknięty, żeby to zakończyć. To jest mój kod:

template <class eleType>
int MATmtxdisp(const Mat mtx, eleType fk)   
// create function template to avoid type dependent programming i.e. Mat element can be float, Vec2f, Vec3f, Vec4f
// cannot get rid of fk ('fake') variable to identify Mat element type
{   
    uchar chan = mtx.channels();

    for(int i = 0; i < mtx.rows; i++)
        for(int k = 0; k < chan; k++)
        {
            for(int l = 0; l < mtx.cols; l++)
            {
                eleType ele = mtx.at<eleType>(i,l);  
// I even split 2 cases for 1 channel and multi-channel element
// but this is unacceptable by the compiler when element is float type (1 channel)
// i.e. C2109: subscript requires array or pointer type
                if (chan > 1)
                    printf("%8.2f",ele[k]);   
                else 
                    printf("%8.2f",ele);
            }
            printf("\n");
        }

        return 0;
}

czy jest jakiś sposób, żeby to obejść, aby mieć kompaktową i kanałową funkcję wyświetlania wolnej liczby ???

questionAnswers(1)

yourAnswerToTheQuestion