This repository has been archived by the owner on Aug 14, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
countermainwindow.cpp
77 lines (66 loc) · 1.71 KB
/
countermainwindow.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
#include "countermainwindow.h"
#include "ui_countermainwindow.h"
using namespace std;
CounterMainWindow::CounterMainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::CounterMainWindow)
{
ui->setupUi(this);
track = false;
}
CounterMainWindow::~CounterMainWindow()
{
delete ui;
}
void CounterMainWindow::timerEvent(QTimerEvent *event)
{
Mat captureImg;
mCapture >> captureImg;
ui->imageViewer->showImage(captureImg);
if(track) {
motion_analyzer->processFrame(captureImg);
}
// ui->imageViewer->showImage(*motion_analyzer->tracker_img);
ui->lcdNumber->showCount(motion_analyzer->getCounter()->getTotalCount());
ui->lcdNumber_2->showCount(motion_analyzer->getCounter()->getCountIn());
ui->lcdNumber_3->showCount(motion_analyzer->getCounter()->getCountOut());
}
void CounterMainWindow::on_actionStartCamera_triggered()
{
if( !mCapture.isOpened() )
{
mCapture.set(CV_CAP_PROP_FPS, 30.0);
mCapture.set(CV_CAP_PROP_FRAME_HEIGHT, 480.0);
mCapture.set(CV_CAP_PROP_FRAME_WIDTH, 640.0);
motion_analyzer = new MotionAnalyzer();
if( !mCapture.open( 0 ) )
{
return;
}
else
{
timerId = startTimer(10);
}
}
if(ui->imageViewer->isHidden()){
ui->imageViewer->show();
}
}
void CounterMainWindow::on_actionStopCamera_triggered()
{
mCapture.release();
killTimer(timerId);
ui->imageViewer->hide();
}
void CounterMainWindow::on_actionStartTrack_triggered()
{
track = true;
}
void CounterMainWindow::on_actionStopTrack_triggered()
{
track = false;
}
void CounterMainWindow::on_actionReset_triggered()
{
motion_analyzer->resetBackground();
}