OpenCV Mat types

I'm currently working on reading in a depth image with OpenCV and converting it to a point cloud. After wrestling with data types for a while, I came upon a tremendously useful listing of the OpenCV Mat types and their corresponding numerical values, along with the data types corresponding to those map types. For example, a CV_16U OpenCV Mat outputs 2 with the type() member function, and stores the channel data as unsigned shorts. The mapping is posted on this blog here.

    cv::Mat depthImage;
    depthImage = cv::imread("banana_1_1_1_depth.png", CV_LOAD_IMAGE_ANYDEPTH | CV_LOAD_IMAGE_ANYCOLOR ); // Read the file

    if(! )                              // Check for invalid input
        std::cout <<  "Could not open or find the image" << std::endl ;
        return -1;

    std::cout << "Size of depthImage:\t" << depthImage.size() << std::endl;
    std::cout << "Type of depthImage:\t" << depthImage.type() << std::endl;
    std::cout << "Depth image at coord 0,0:\t" <<<ushort>(0,0) << std::endl;


Popular Posts