-
Notifications
You must be signed in to change notification settings - Fork 2
/
cvtoqt.cpp
35 lines (31 loc) · 874 Bytes
/
cvtoqt.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include "cvtoqt.h"
CvToQt::CvToQt(QObject *parent) : QObject(parent)
{
}
QImage CvToQt::MatToQImage(const cv::Mat &mat, bool isGray)
{
if(!mat.empty()){
// GrayScale Image
if(isGray){
return QImage(
mat.data,
mat.cols,
mat.rows,
mat.step,
QImage::Format_Grayscale8);
}
// Colored Image
return QImage(
mat.data,
mat.cols,
mat.rows,
mat.step,
QImage::Format_RGB888).rgbSwapped(); //Swapped : BGR(cv) to RGB(Qt)
}
return QImage();
}
// 18-06/2018 01:35
QPixmap CvToQt::MatToQPixmap(const cv::Mat &mat, bool isGray)
{
return QPixmap::fromImage(CvToQt::MatToQImage(mat,isGray));
}