-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimagedialog.cpp
52 lines (36 loc) · 1.05 KB
/
imagedialog.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
#include "imagedialog.hpp"
#include "imageutils.hpp"
#include <QVBoxLayout>
#include <QPixmap>
using namespace cv;
ImageDialog::ImageDialog(QWidget * parent, char * title, Size size, Point pointXY):
QDialog(parent), lastFrame(NULL){
QVBoxLayout * layout = new QVBoxLayout(this);
frameDisplayer = new QLabel(this);
layout->addWidget(frameDisplayer);
setLayout(layout);
setWindowTitle(title);
move(pointXY.x, pointXY.y);
setFixedSize(size.width, size.height);
show();
}
ImageDialog::~ImageDialog(){
}
void ImageDialog::showImage(IplImage * frame){
IplImage * toDisplay = cvCreateImage(cvGetSize(frame), 8, 4);
frameDisplayer->setPixmap
(QPixmap::fromImage(ImageUtils::iplImageToQImage(frame, toDisplay), 0));
update();
cvReleaseImage(&frame);
if(lastFrame != NULL){
cvReleaseImage(&lastFrame);
}
lastFrame = toDisplay;
}
void ImageDialog::showImage(Mat & image){
IplImage * ipl = new IplImage(image);
showImage(ipl);
}
void ImageDialog::closeEvent (QCloseEvent * e){
e->ignore();
}