-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfacedatabasewidget.cpp
124 lines (94 loc) · 3.45 KB
/
facedatabasewidget.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#include "facedatabasewidget.h"
FaceDatabaseWidget::FaceDatabaseWidget(QWidget *parent) : QWidget(parent)
{
}
void FaceDatabaseWidget::loadPrevious()
{
if(!m_imageList.size() || !m_currentFrame)
return;
m_currentFrame--;
QString dbPath = "../Database/"+m_name+"/";
QString imgToLoadPath = dbPath + m_imageList.at(m_currentFrame);
emit imageChanged(imgToLoadPath);
}
void FaceDatabaseWidget::loadNext()
{
if(!m_imageList.size() || m_currentFrame==m_imageList.size()-1)
return;
m_currentFrame++;
QString dbPath = "../Database/"+m_name+"/";
QString imgToLoadPath = dbPath + m_imageList.at(m_currentFrame);
emit imageChanged(imgToLoadPath);
}
void FaceDatabaseWidget::loadDatabase(int dbNumber)
{
// no data for yaleB14, yaleB16
if(dbNumber == 14 || dbNumber == 16)
return;
m_imageList.clear();
m_lightDirections.clear();
QString dbName = "yaleB"+QString::number(dbNumber);
QString dbPath = "../Database/"+dbName+"/";
QString imglistPath = dbPath+dbName+"_P00";
QString lightlistPath = dbPath+ "lightDirections";
QVecOperator::load(m_imageList,imglistPath);
QVecOperator::load(m_lightDirections,lightlistPath);
m_name = dbName;
m_currentFrame = 0;
QString imgToLoadPath = dbPath + m_imageList.at(m_currentFrame);
emit imageChanged(imgToLoadPath);
}
void FaceDatabaseWidget::loadArtificial(int dbNumber)
{
m_imageList.clear();
m_lightDirections.clear();
QString dbName = "artificialB"+QString::number(dbNumber);
QString dbPath = "../Database/"+dbName+"/";
QString imglistPath = dbPath+dbName+"_P00";
QString lightlistPath = dbPath + "lightDirections";
QVecOperator::load(m_imageList,imglistPath);
QVecOperator::load(m_lightDirections,lightlistPath);
m_name = dbName;
m_currentFrame = 0;
QString imgToLoadPath = dbPath + m_imageList.at(m_currentFrame);
emit imageChanged(imgToLoadPath);
}
QGroupBox *FaceDatabaseWidget::menu()
{
QGroupBox *m_menu = new QGroupBox("Database");
QPushButton *nextBtm = new QPushButton("next");
connect(nextBtm, SIGNAL(pressed()),this,SLOT(loadNext()));
QPushButton *prevBtm = new QPushButton("prev");
connect(prevBtm, SIGNAL(pressed()),this,SLOT(loadPrevious()));
QHBoxLayout *btmLayout = new QHBoxLayout;
btmLayout->addWidget(prevBtm);
btmLayout->addWidget(nextBtm);
QSpinBox *yaleSpin = new QSpinBox;
yaleSpin->setMinimum(11);
yaleSpin->setMaximum(39);
yaleSpin->setValue(31);
connect(yaleSpin, SIGNAL(valueChanged(int)),this,SLOT(loadDatabase(int)));
QLabel *yaleLabel = new QLabel;
yaleLabel->setText("yaleB");
QHBoxLayout *yaleForm= new QHBoxLayout;
yaleForm->addWidget(yaleLabel);
yaleForm->addWidget(yaleSpin);
QSpinBox *artSpin = new QSpinBox;
artSpin->setMinimum(1);
artSpin->setMaximum(8);
artSpin->setValue(1);
connect(artSpin, SIGNAL(valueChanged(int)),this,SLOT(loadArtificial(int)));
QLabel *artLabel = new QLabel;
artLabel->setText("artificial");
QHBoxLayout *artForm= new QHBoxLayout;
artForm->addWidget(artLabel);
artForm->addWidget(artSpin);
QGridLayout *menuLayout = new QGridLayout;
menuLayout->addWidget(prevBtm,0,0);
menuLayout->addWidget(nextBtm,0,1);
menuLayout->addItem(yaleForm,1,0);
menuLayout->addItem(artForm,2,0);
m_menu->setLayout(menuLayout);
m_menu->setSizePolicy(QSizePolicy( QSizePolicy::Fixed,QSizePolicy::Preferred));
return m_menu;
}