-
Notifications
You must be signed in to change notification settings - Fork 0
/
videoplayer.cpp
81 lines (63 loc) · 2.21 KB
/
videoplayer.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#include <QFileDialog>
#include <QCheckBox>
#include "videoplayer.h"
VideoPlayer::VideoPlayer(QWidget *parent)
: QMainWindow(parent)
//, ui(new Ui::VideoPlayer)
, videoThread(new VideoEngine)
, colorKeyerHSV(new ColorKeyerHSV())
{
ui->setupUi(this);
videoThread->setProcessor(colorKeyerHSV);
connect(videoThread, SIGNAL(sendInputImage(const QImage&)), ui->inputFrame, SLOT(setImage(const QImage&)));
connect(videoThread, SIGNAL(sendProcessedImage(const QImage&)), ui->processedFrame , SLOT(setImage(const QImage&)));
updateParameters();
}
VideoPlayer::~VideoPlayer()
{
delete videoThread;
delete colorKeyerHSV;
delete ui;
}
void VideoPlayer::on_playButton_clicked()
{
videoThread->start();
}
void VideoPlayer::on_openVideoFileButton_clicked()
{
QString fileName = QFileDialog::getOpenFileName(this, tr("Open Movie"),QDir::homePath());
if (!fileName.isEmpty()) {
videoThread->openCamera
}
}
void VideoPlayer::updateParameters(){
// hue thresholds
int hueValue = ui->hueSlider->value();
int hueTolerance = ui->hueTolerance->value();
int hueLowerThreshold = hueValue - hueTolerance;
if (hueLowerThreshold < 0){
hueLowerThreshold += 360;
}
int hueUpperThreshold = hueValue + hueTolerance;
if (hueUpperThreshold > 360){
hueUpperThreshold -= 360;
}
colorKeyerHSV->setHueLowerThreshold(hueLowerThreshold);
colorKeyerHSV->setHueUpperThreshold(hueUpperThreshold);
ui->labelHue->setNum(hueValue);
ui->labelHueTolerance->setNum(hueTolerance);
// saturation thresholds
int saturationThreshold = ui->saturationSlider->value();
colorKeyerHSV->setSaturationThreshold(saturationThreshold);
ui->labelSaturation->setNum(saturationThreshold);
// alpha
float alpha = ui->lowpassAlpha->value();
colorKeyerHSV->setAlpha(alpha/100.f);
ui->labelAlpha->setNum(alpha);
// median
colorKeyerHSV->setMedianEnable(ui->checkBoxMedian->checkState() == Qt::Checked);
// opening
colorKeyerHSV->setOpeningEnable(ui->checkBoxOpening->checkState() == Qt::Checked);
// small regions masking
colorKeyerHSV->setMaskSmallRegions(ui->checkBoSxSmallRegions->checkState() == Qt::Checked);
}