-
Notifications
You must be signed in to change notification settings - Fork 1
/
threeparams.cpp
147 lines (114 loc) · 4.6 KB
/
threeparams.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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#include "threeparams.h"
#include "ui_threeparams.h"
threeParams::threeParams(QWidget *parent) :
QDialog(parent),
ui(new Ui::threeParams)
{
ui->setupUi(this);
this -> setWindowFlags(Qt::WindowCloseButtonHint); //隐藏标题栏问号
wd_AP = new AdjustParameters(this);
connect(this, &threeParams::paramMinChanged, wd_AP, &AdjustParameters::setParamMin);
connect(this, &threeParams::paramMaxChanged, wd_AP, &AdjustParameters::setParamMax);
connect(this, &threeParams::paramDefaultChanged, wd_AP, &AdjustParameters::setParamDefault);
connect(this, &threeParams::paramWinTitleChanged, wd_AP, &AdjustParameters::setWinTitle);
connect(this, &threeParams::sendCvMat, wd_AP, &AdjustParameters::setInDisplay);
}
threeParams::~threeParams()
{
delete ui;
}
void threeParams::on_pb_Yellow_clicked()
{
QString winTitle = QString::fromLocal8Bit("黄色通道参数调整");
emit paramWinTitleChanged(winTitle);
std::vector<int> paramMin(10, 0); //创10个0
std::vector<int> paramMax = {180, 180, 255, 255, 255, 255, 255, 255, 255, 255};//创建列表
// === 从ini文件中,读取参数 === //
std::vector<int> paramDefault = {120, 40, 0, 255, 25, 255, 0, 255, 0, 100};
QString channelStr;
channelStr.sprintf("Yellow");
fileReader.readIni(channelStr, paramDefault);
//传参(图片变)
emit paramMinChanged(paramMin);
emit paramMaxChanged(paramMax);
emit paramDefaultChanged(paramDefault);
//QPixmap inputImg2 = QPixmap::fromImage(QImage(inFrame.data, inFrame.cols,
// inFrame.rows, inFrame.step, QImage::Format_RGB888).rgbSwapped());
wd_AP->updataOutDisplay = false;
if(hasInputImg){
emit sendCvMat(this->inputImg);
}
wd_AP->exec();
}
void threeParams::on_pb_Green_clicked()
{
QString winTitle = QString::fromLocal8Bit("绿色通道参数调整");
emit paramWinTitleChanged(winTitle);
// qDebug() << "hello" << endl;
std::vector<int> paramMin(10, 0);
std::vector<int> paramMax = {180, 180, 255, 255, 255, 255, 255, 255, 255, 255};
std::vector<int> paramDefault = {45, 100, 70, 255, 25, 255, 0, 255, 0, 255};
fileReader.readIni(QString("Green"), paramDefault);
emit paramMinChanged(paramMin);
emit paramMaxChanged(paramMax);
emit paramDefaultChanged(paramDefault);
wd_AP->updataOutDisplay = false;
if(hasInputImg){
emit sendCvMat(this->inputImg);
}
wd_AP->exec();
}
void threeParams::on_pb_Blue_clicked()
{
QString winTitle = QString::fromLocal8Bit("蓝色通道参数调整");
emit paramWinTitleChanged(winTitle);
std::vector<int> paramMin(10, 0);
std::vector<int> paramMax = {180, 180, 255, 255, 255, 255, 255, 255, 255, 255};
std::vector<int> paramDefault = {100, 120, 30, 255, 25, 255, 0, 255, 0, 255};
fileReader.readIni(QString("Blue"), paramDefault);
emit paramMinChanged(paramMin);
emit paramMaxChanged(paramMax);
emit paramDefaultChanged(paramDefault);
wd_AP->updataOutDisplay = false;
if(hasInputImg){
emit sendCvMat(this->inputImg);
}
wd_AP->exec();
}
void threeParams::on_pb_Brown_clicked()
{
QString winTitle = QString::fromLocal8Bit("棕色通道参数调整");
emit paramWinTitleChanged(winTitle);
std::vector<int> paramMin(10, 0);
std::vector<int> paramMax = {180, 180, 255, 255, 255, 255, 255, 255, 255, 255};
std::vector<int> paramDefault = {120, 40, 0, 255, 25, 255, 0, 255, 100, 255};
fileReader.readIni(QString("Brown"), paramDefault);
emit paramMinChanged(paramMin);
emit paramMaxChanged(paramMax);
emit paramDefaultChanged(paramDefault);
wd_AP->updataOutDisplay = false;
if(hasInputImg){
emit sendCvMat(this->inputImg);
}
wd_AP->exec();
}
void threeParams::write_params(std::vector<std::vector<int>> ¶ms1)
{
std::vector<int> blueThreshold{ 100, 120, 30, 255, 25, 255, 0, 255, 0, 255 };
std::vector<int> greenThreshold{ 45, 100, 70, 255, 50, 255, 0, 255, 0, 255 };
std::vector<int> yellowThreshold{ 120, 40, 0, 255, 50, 255, 0, 255, 0, 100 };
std::vector<int> brownThreshold{ 120, 40, 0, 255, 40, 255, 0, 255, 101, 255 };
QString channelStr;
channelStr.sprintf("Blue");
fileReader.readIni(channelStr, blueThreshold);
channelStr.sprintf("Green");
fileReader.readIni(channelStr, greenThreshold);
channelStr.sprintf("Yellow");
fileReader.readIni(channelStr, yellowThreshold);
channelStr.sprintf("Brown");
fileReader.readIni(channelStr, brownThreshold);
params1.push_back(blueThreshold);
params1.push_back(greenThreshold);
params1.push_back(yellowThreshold);
params1.push_back(brownThreshold);
}