Advertisement
Guest User

Untitled

a guest
Jan 7th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. cv::Mat Widget::qImageToMat(QImage img)
  2. {
  3.     cv::Mat mat;
  4.    
  5.     if (img.format() == QImage::Format_Indexed8)
  6.         mat = cv::Mat(img.height(), img.width(), CV_8U, img.bits(), img.bytesPerLine()).clone();
  7.     else if (img.format() == QImage::Format_RGB888)
  8.     {
  9.         mat = cv::Mat(img.height(), img.width(), CV_8UC3, img.bits(), img.bytesPerLine()).clone();
  10.         cv::cvtColor(mat, mat, CV_RGB2BGR);
  11.     }
  12.    
  13.     return mat;
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement