Ask Your Question

Revision history [back]

There don't seem to be any conversion options for ARGB. cvtColor raises an assertion if either the src or dst mat are 32S: "Assertion failed (depth == CV_8U || depth == CV_16U || depth == CV_32F)" Is your data in the Mat as floats or as signed ints? I'm guessing from your segfault that you've got CV_32S. You can use Mat convertTo() to turn your Mat into CV_32F depth and then you can successfully call cvtColor().

However, I've found that calling cvtColor() on an ARGB image with COLOR_RGBA2BGRA as the conversion type leads to wacky results like this. This leads me to believe that RGBA is not actually the same as ARGB and/or that signed/unsigned/float format conversions may be causing some truncation or other issues (I think the former is probably the real cause).

I noticed in your other thread that you mentioned the Android BitmapToMat conversion functions. I think something in the spirit of these are exactly what you need here (though in sounds like you're working in the C++ api so those won't be much help to you even with a bunch of hacking). I might try poking around the source for those function to see if there's some hints about what APIs they're calling that you could maybe use.

Other than that, there's always iterating through the Mat manually and reorganizing it.