-
Notifications
You must be signed in to change notification settings - Fork 0
/
mainwindow.cpp
61 lines (46 loc) · 1.89 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
53
54
55
56
57
58
59
60
61
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <opencv/cv.h>
#include <opencv/highgui.h>
#define DEFAULT_CAMERA_TIMER_MS 100 // 0.1-second timer
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
// Initializing the default camera
camera = cvCreateCameraCapture(0);
assert(camera);
IplImage *image=cvQueryFrame(camera);
assert(image);
printf("Image depth=%i\n", image->depth);
printf("Image nChannels=%i\n", image->nChannels);
ui->cameraWidget->setCascadeName(ui->cascadesCB->currentText());
ui->cameraWidget->setSubObjsCascadeName(ui->subObjsCascadesCB->currentText());
ui->cameraWidget->setHsvHueInterval(ui->hsvHueSB->value());
ui->cameraWidget->setHsvBrightnessThreshold(ui->hsvBrightnessThresholdSB->value());
ui->cameraWidget->setHsvSaturationThreshold(ui->hsvSaturationThresholdSB->value());
cameraTimerId=startTimer(DEFAULT_CAMERA_TIMER_MS);
}
MainWindow::~MainWindow()
{
cvReleaseCapture(&camera);
delete ui;
}
void MainWindow::timerEvent(QTimerEvent*) {
IplImage *image=cvQueryFrame(camera);
ui->cameraWidget->putImage(image);
ui->objsFoundLabel->setText(QString::number(ui->cameraWidget->getObjsFound()));
ui->calcTimeLabel->setText(QString::number(ui->cameraWidget->getODCalcTime()).append(" ms"));
ui->subObjsFoundLabel->setText(QString::number(ui->cameraWidget->getSubObjsFound()));
ui->calcTimeSubLabel->setText(QString::number(ui->cameraWidget->getSubODCalcTime()).append(" ms"));
ui->imageSizeInfoLabel->setText(QString("Image size: ").append(QString::number(image->width)).append("x").append(QString::number(image->height)));
}
void MainWindow::on_faceDetectionEnabled_clicked(bool checked)
{
}
void MainWindow::on_pushButton_clicked()
{
killTimer(cameraTimerId);
cameraTimerId=startTimer(ui->timeOutCamera->value());
}