Search code examples
c++copencvmat

Mat_<unsigned char> in opencv - Mat datatypes


In the below code if I read image using imread the image is displaying differently and if the source is camera it is showing normal colored image. And below is the code.

Can some one explain bit in detail with some good link if possible?

int main () {

    cv :: Mat_<unsigned char> src;
    cv :: VideoCapture cap(0);

    while ( 1 ) {
        cap >> src;
//      src = cv :: imread ( "C:\\Users\\hubuser10\\Desktop\\1.jpg" );

        imshow ( "test image", src );
        cv :: waitKey(1);
    }

}

Result from imread:enter image description here

Camera image:

enter image description here


Solution

  • Both VideoCapture and imread without additional parameter returns 3-channels BGR frames. Use cv::Mat_<cv::Vec3b> type.