forked from berndporr/opencv-camera-callback
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwindow.cpp
More file actions
38 lines (31 loc) · 816 Bytes
/
window.cpp
File metadata and controls
38 lines (31 loc) · 816 Bytes
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
#include "window.h"
Window::Window()
{
myCallback.window = this;
camera.registerSceneCallback(&myCallback);
// set up the thermometer
thermo = new QwtThermo;
thermo->setFillBrush( QBrush(Qt::red) );
thermo->setScale(0, 255);
thermo->show();
image = new QLabel;
// plot to the left of button and thermometer
hLayout = new QHBoxLayout();
hLayout->addWidget(thermo);
hLayout->addWidget(image);
setLayout(hLayout);
camera.start();
}
Window::~Window()
{
camera.stop();
}
void Window::updateImage(const cv::Mat &mat) {
const QImage frame(mat.data, mat.cols, mat.rows, mat.step,
QImage::Format_RGB888);
image->setPixmap(QPixmap::fromImage(frame));
const int h = frame.height();
const int w = frame.width();
const QColor c = frame.pixelColor(w/2, h/2);
thermo->setValue(c.lightness());
}