Skip to content

Instantly share code, notes, and snippets.

@udaya1223
Created September 7, 2015 03:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save udaya1223/a7dc2c6fc3ebd2ff78f3 to your computer and use it in GitHub Desktop.
Save udaya1223/a7dc2c6fc3ebd2ff78f3 to your computer and use it in GitHub Desktop.
string openCVType2str(int type) {
string r;
uchar depth = type & CV_MAT_DEPTH_MASK;
uchar chans = 1 + (type >> CV_CN_SHIFT);
switch ( depth ) {
case CV_8U: r = "8U"; break;
case CV_8S: r = "8S"; break;
case CV_16U: r = "16U"; break;
case CV_16S: r = "16S"; break;
case CV_32S: r = "32S"; break;
case CV_32F: r = "32F"; break;
case CV_64F: r = "64F"; break;
default: r = "User"; break;
}
r += "C";
r += (chans+'0');
return r;
}
int main(){
//Your matrix here
Mat M;
string ty = openCVType2str( M.type() );
printf("Matrix: %s %dx%d \n", ty.c_str(), M.cols, M.rows );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment