OpenCV indexing through Mat of unknown type

Viewed 2885

I would like to access the elements of a matrix of unknown type:

for(int ii = 0; ii < origCols; ii++)
{
  colIdx.at<img.type()>(0,ii) = ii+1; // make one based index
}

The expression defining the type (inside the <>) has to be a constant, so the above code will not work. Is there a way to do this other than just switching across the different image types?

2 Answers
Related