Ask Your Question

Revision history [back]

Mat different channels

Hello everyone, newbie here.

I am trying to put the pixel values of one Mat into another via mat.put(x,y,values)

That does work, but only for Mats of the same type. When they are not, I get an error.

Provided data element number (4) should be multiple of the Mat channels count (3)

The solution to that problem would be to have the Mats share the same type by converting one of them (right?).

The problem with THAT is, that I need to explicitly state in the cvtColor - Method, which channel to convert (and how). But I do not know the exact channel on runtime, channels count should either be 3 or 4...

So, how do I convert one mat to the type of another mat dynamically? Any ideas?

Thank you very much.

With kind regards, David.