Mat Datatypes in OpenCV

I spend most of my OpenCV debugging time on falsy datatypes causing all kinds of different errors, from segmentation faults to very strange image outputs. I searched the internet for a complete list of OpenCV datatypes that works as a quick reference. The documentation I found was poor, so I decided to write a short overview myself.

The datatypes are named by the following structure:

OpenCV Mat datatype reference

Initialize a Mat object

// Mat myMat(rows, cols, Datatype);
Mat myMat(2, 2, CV_32FC3);

Access a pixel in a Mat

// myMat.at(row, col);
myMat.at<int>(y, x);
myMat.at<float>(y, x);
myMat.at<double>(y, x);

More information