How to get pixel format of a Mat()?
I need to detect the pixel format of a cv::Mat() object, BGR or RGB or BGRA or RGBA or YUV or some else.
I know OpenCV use BGR/BGRA by default, but you can use cvtColor to change it, what I need is going to detect the pixel format for any cv::Mat() object.
Thanks a lot.
you can't. there's a lot of cases even, where a Mat does not hold 'pixels' but something completely different, like complex values, transformations, SIFT features, etc..
You can just see if the mat has 4 (RGBA, BGRA) or 3 (RGB, BGR, YUV) channels