-
Notifications
You must be signed in to change notification settings - Fork 0
/
showimage.cpp
55 lines (44 loc) · 1.28 KB
/
showimage.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include "showimage.h"
QImage ShowImage::MattoQImage(Mat cvImg)
{
QImage qImg;
if(cvImg.channels()==3)
{
cvtColor(cvImg,cvImg,CV_BGR2RGB);
qImg =QImage((const unsigned char*)(cvImg.data),
cvImg.cols, cvImg.rows,
cvImg.cols*cvImg.channels(),
QImage::Format_RGB888);
}
else if(cvImg.channels()==1) {
qImg =QImage((const unsigned char*)(cvImg.data),
cvImg.cols,cvImg.rows,
cvImg.cols*cvImg.channels(),
QImage::Format_Indexed8);
}
else
{
qImg =QImage((const unsigned char*)(cvImg.data),
cvImg.cols,cvImg.rows,
cvImg.cols*cvImg.channels(),
QImage::Format_RGB888);
}
return qImg;
}
ShowImage::ShowImage(QObject *parent) :
QObject(parent)
{
m_pImgProvider = new ImageProvider();
}
void ShowImage::setImage(QImage Image1)
{
m_pImgProvider->img = Image1.copy();
emit callQmlRefeshImg();
}
void ShowImage::connectWithThread(IThread* t)
{
connect(t, SIGNAL(signalQImage(QImage)),this,SLOT(setImage(QImage)));
}
void ShowImage::closewithThread(IThread* t){
disconnect(t, SIGNAL(signalQImage(QImage)),this,SLOT(setImage(QImage)));
}