Ask Your Question

Revision history [back]

Undefined depth matrix

Hi there,

I'm trying to create an undefined number of layers, like this:

Mat img(rows, cols, CV_32SC(N));

It works fine until I need to access the values. I know I can't do anything like:

Vec<int, n> p =<Vec<int, n> >

I must have a predetermined number for the compiler, so the only alternative I see right now is to have a few predetermined values to choose, like below.

static void method(params..., int n)
    switch (n)
        case 8:   method_<Vec<int, 8> >(params..., int n); break;
        case 16:   method_<Vec<int, 8> >(params..., int n); break;
            string error_msg = format("Unsupported value of N. Choices: 8, 16 ...");
            CV_Error(CV_StsNotImplemented, error_msg);

Is there a way to make it more flexible? Thank you.