-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmainwindow.cpp
52 lines (38 loc) · 1.15 KB
/
mainwindow.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 "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
Grabber_pt = new CCGrabber("/dev/video2", "NTSC");
Timer = new QTimer(this);
connect(Timer, SIGNAL(timeout()), this, SLOT(trigger_frame_capture()));
}
MainWindow::~MainWindow()
{
delete Grabber_pt;
delete Timer;
delete ui;
}
void MainWindow::trigger_frame_capture()
{
qDebug() << "Before Grabber_pt->read_frame()";
// Read a frame from the grabber
Grabber_pt->read_frame();
qDebug() << "After Grabber_pt->read_frame()";
//QImage::Format_RGB32
// Use QImage::Format_RGB888 for a 3 channels image
QImage qimage(Grabber_pt->image_pt(), Grabber_pt->width(), Grabber_pt->height(), Grabber_pt->bpl(), QImage::Format_RGB888);
ui->lbl_image->setPixmap(QPixmap::fromImage(qimage));
}
void MainWindow::on_btn_open_video_clicked()
{
// Try to initialise video
bool initialised = Grabber_pt->initialise_video();
// Only start timer if video was correctly initialised
if (initialised)
{
Timer->start(TIMER_TIMEOUT);
}
}