Mat转QImage
生活随笔
收集整理的這篇文章主要介紹了
Mat转QImage
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
由于常常使用qt和opencv開發一些功能,在此記錄一個使用頻率很高的轉換。
cv::Mat類型的圖像轉換為QImage
QImage Mat2QImage(const cv::Mat& InputMat) { cv::Mat TmpMat; QImage Result; if (InputMat.channels() == 1){cv::cvtColor(InputMat, TmpMat, CV_GRAY2RGB);Result = QImage((const uchar*)(TmpMat.data), TmpMat.cols, TmpMat.rows, TmpMat.cols*TmpMat.channels(), QImage::Format_Indexed8);}else { cv::cvtColor(InputMat, TmpMat, CV_BGR2RGB); Result = QImage((const uchar*)(TmpMat.data), TmpMat.cols, TmpMat.rows, TmpMat.cols*TmpMat.channels(), QImage::Format_RGB888); } Result.bits(); return Result;}總結
以上是生活随笔為你收集整理的Mat转QImage的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: var与dynamic区别
- 下一篇: Linux中使用GDB调试NS2