Search code examples
opencviplimage

How get the color format in Opencv?


In C++, how can I get the color format (RGB or BGR for example), from an object cv::Mat or cv::IplImage?


Solution

  • The image type is not part of the image specification in OpenCV.
    The user needs to know and track the actual color format.
    In most cases, this is not a problem since ultimately the format of the source of the image is known.
    As a rule of thumb, most RGB image sources (webcams, files etc.) are represented as BGR, but you should check your particular domain.