Skip to content

Instantly share code, notes, and snippets.

@nylocx
Created January 7, 2016 11:09
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 nylocx/660d48d6c5fca6d8fd8c to your computer and use it in GitHub Desktop.
Save nylocx/660d48d6c5fca6d8fd8c to your computer and use it in GitHub Desktop.
Convert OpenCV image type to a QString
QString cvImageTypeToQString(int type) {
QString result;
uchar depth = type & CV_MAT_DEPTH_MASK;
uchar chans = 1 + (type >> CV_CN_SHIFT);
switch ( depth ) {
case CV_8U: result = "8U"; break;
case CV_8S: result = "8S"; break;
case CV_16U: result = "16U"; break;
case CV_16S: result = "16S"; break;
case CV_32S: result = "32S"; break;
case CV_32F: result = "32F"; break;
case CV_64F: result = "64F"; break;
default: result = "User"; break;
}
result += "C";
result += QString::number(chans);
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment