-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmainwindow.cpp
More file actions
86 lines (66 loc) · 1.78 KB
/
mainwindow.cpp
File metadata and controls
86 lines (66 loc) · 1.78 KB
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
82
83
84
85
86
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <iostream>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
cam=new Image();
cam->setCameraNum(0);
cam->takePicture();
cam2=new Image();
cam2->copy(cam);
old = new Image();
history = new Image();
history->copy(cam);
history->clearHistory();
hsvHist=new Image();
int numBuckets=50;
hsvHist->createHist(numBuckets);
hsvOut=new Image();
Mat histReadIn;
FileStorage fsHistIn("histogram.xml", FileStorage::READ);
if(fsHistIn.isOpened() == false){
std::cout << "Error reading in histogram." << std::endl;
//cry
}
fsHistIn["histogram"] >> histReadIn;
fsHistIn.release();
hsvHist->addHSVfromFile(histReadIn);
hsvHist->histToSrc();
histExist = true;
QTimer *qTimer= new QTimer(this);
connect(qTimer, SIGNAL(timeout()),this,SLOT(displayFrame()));
qTimer->start(5);
ui->imDisplay5->setScaledContents(true);
ui->imDisplay6->setScaledContents(true);
//histExist=false;
capPause=false;
hsvThreshold=235;
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::displayFrame(){
cam->takePicture();
if(histExist){
old->copy(cam);
//old->colorHistHSV(hsvHist,hsvThreshold, history);
old->paintScreen(hsvHist,hsvThreshold, history);
old->showPath(history);
old->rectList();
history->displayImage(*ui->imDisplay5);
old->displayImage(*ui->imDisplay6);
}
}
void MainWindow::on_hsvSlider_valueChanged(int value)
{
hsvThreshold=255-value;
ui->hsvThresh->setText(QString("Threshold Value: %1").arg(value));
}
void MainWindow::on_sHisto_clicked()
{
hsvHist->saveHist();
}