添加了倒计时和同时喷气阀数量控制

This commit is contained in:
XinJiang1 2025-01-05 19:05:45 +08:00
parent 9394384cd8
commit 1ba0432ad2
15 changed files with 4839 additions and 2114 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -41,13 +41,9 @@ int SaveImg_Flag;
ONNXRunner runner;
int dual_cam_offset_y = 0; // 双相机之间的上下偏移值
int widthBlocks = 20; // 输出的喷阀通道数
int heightBlocks = 512; // 输出的Mask高度
int sizeThreshold = 4; // 转化为喷阀的每块要求像素个数
int expansionRaidus = 1; // 获取mask后进行左右位置的扩展
int padLeft = 1; // 左侧在结果Mask上补0
int padRight = 1; // 右侧在结果Mask上补0
int rowRange = 1; // 结果维持行数至少为1
@ -64,13 +60,18 @@ static std::vector<std::vector<uint8_t>> tail_1(0);
uint8_t temp_buf[512 * 64] = {0};
extern int file_delay;
// 总体参数
extern int lowmac_sm; //吹气量
extern int file_encoder;
extern int file_valve;
//下位机参数
// 颜色模块参数
extern int sizeThreshold; // 转化为喷阀的每块要求像素个数
extern int expansionRaidus; // 获取mask后进行左右位置的扩展
extern int file_delay;
// 偏振模块参数
extern int lowmac_dp; //偏振延迟时间
extern int lowmac_sm; //吹气量
extern int lowmac_ts; //模板匹配阈值
extern int lowmac_sg; //偏振绿色通道大小阈值
extern int lowmac_td; //偏振红色通道差值
@ -549,22 +550,8 @@ MIL_INT ProcessingFunction1(MIL_INT HookType, MIL_ID HookId, void *HookDataPtr)
// 将结果的左右补充上0让物体大小符合要求
PadColumns(mask_expaned, padLeft, padRight, 0);
// ======= 新增:统计 mask_expaned 里的 1 的总个数,并累加到全局变量 =======
{
long long count_ones_this_time = 0;
for(const auto & row : mask_expaned)
{
for(uint8_t val : row)
{
count_ones_this_time += (val == 1);
}
}
g_valveActionCount += count_ones_this_time;
// 如果你想调试打印,可以
// qDebug() << "This callback1 new triggered bits =" << count_ones_this_time
// << ", total=" << g_valveActionCount;
}
// ======= 新增结束 =======
max_valves_together_limit(mask_expaned, params["max_valves_together"]);
//将mask扩展到合适发送的大小
std::vector<std::vector<uint8_t>> mask_Total = expandArray(mask_expaned,64);
@ -779,6 +766,42 @@ std::vector<std::vector<uint8_t>> generateMaskFromMatImage(const cv::Mat& image,
return mask;
}
void max_valves_together_limit(std::vector<std::vector<uint8_t>> &mask_expaned, const int row_threshold)
{
// 初始化当前回调的1的计数
long long count_ones_this_time = 0;
// 遍历每一行
for(auto & row : mask_expaned)
{
// 计算当前行中1的数量
long long row_count = 0;
for(uint8_t val : row)
{
row_count += (val == 1);
}
// 检查是否超过阈值
if(row_count > row_threshold)
{
// 如果超过阈值将整行置为0
std::fill(row.begin(), row.end(), 0);
g_camera_error.store(true); // 原子赋值为 true
}
else
{
count_ones_this_time += row_count;
g_camera_error.store(false); // 原子赋值为 true
}
}
// 更新全局的1的计数
g_valveActionCount += count_ones_this_time;
// 如果需要调试打印,可以取消注释以下代码
// qDebug() << "This callback1 new triggered bits =" << count_ones_this_time
// << ", total=" << g_valveActionCount;
}
bool iniColor()
{
@ -839,14 +862,15 @@ bool iniLowMac()
cout << "Error: Lower machine is not available or writable." << endl;
return 0 ;
}
return setLowMacParam();
}
bool setLowMacParam(){
// 计算 Y = 100000000 / X
int divide_camera = (file_encoder != 0) ? 100000000 / file_encoder : 0; // 防止除以零的情况
int divide_valve = (file_valve != 0) ? 100000000 / file_valve : 0; // 防止除以零的情况
// 将参数转换为长度为8的字符串前面补0
QString delay_time = QString("%1").arg(file_delay, 8, 10, QChar('0'));
QString divide_parameter = QString("%1").arg(divide_camera, 8, 10, QChar('0'));
@ -874,6 +898,7 @@ bool iniLowMac()
if (lower_machine->isWritable()) {
lower_machine->write((const char*)delay_buf, len_delay + 8);
qDebug() << "彩色相机延迟时间:" << delay_byte.data();
} else {
cout << "Error: Unable to write to lower machine for delay parameter." << endl;
}
@ -893,6 +918,7 @@ bool iniLowMac()
if (lower_machine->isWritable()) {
lower_machine->write((const char*)divide_buf, len_divide + 8);
qDebug() << "彩色相机分频系数:" << divide_byte.data();
} else {
cout << "Error: Unable to write to lower machine for encoder parameter." << endl;
}
@ -910,24 +936,14 @@ bool iniLowMac()
valve_divide_buf[len_sv + 6] = 0xFF;
valve_divide_buf[len_sv + 7] = 0xBB;
qDebug()<<"相机参数"<<divide_byte.data();
qDebug()<<"阀门参数"<<sv_byte.data();
if (lower_machine->isWritable()) {
lower_machine->write((const char*)valve_divide_buf, len_sv + 8);
qDebug() << "阀门分频系数:" << sv_byte.data();
} else {
cout << "Error: Unable to write to lower machine for valve parameter." << endl;
}
delete[] valve_divide_buf;
// //下位机参数
// int lowmac_dp = 400; //偏振延迟时间
// int lowmac_sm = 5; //吹气量
// int lowmac_ts = 15; //模板匹配阈值
// int lowmac_sg = 80; //偏振绿色通道大小阈值
// int lowmac_td = 10; //偏振红色通道差值
//新增下位机协议
// 将参数转换为长度为8的字符串前面补0
QString dp = QString("%1").arg(lowmac_dp, 8, 10, QChar('0'));
QString sm = QString("%1").arg(lowmac_sm, 8, 10, QChar('0'));
@ -947,6 +963,7 @@ bool iniLowMac()
QByteArray sg_byte = sg.toLatin1();
QByteArray td_byte = td.toLatin1();
//偏振延迟时间
uint8_t* dp_buf = new uint8_t[len_dp + 8];
dp_buf[0] = 0xAA;
dp_buf[1] = 0x00;
@ -960,11 +977,13 @@ bool iniLowMac()
if (lower_machine->isWritable()) {
lower_machine->write((const char*)dp_buf, len_dp + 8);
qDebug() << "偏振延迟时间: " << dp_byte.data();
} else {
cout << "Error: Unable to write to lower machine for dp parameter." << endl;
}
delete[] dp_buf;
// 吹气量
uint8_t* sm_buf = new uint8_t[len_sm + 8];
sm_buf[0] = 0xAA;
sm_buf[1] = 0x00;
@ -978,11 +997,13 @@ bool iniLowMac()
if (lower_machine->isWritable()) {
lower_machine->write((const char*)sm_buf, len_sm + 8);
qDebug() << "吹气量: " << sm_byte.data();
} else {
cout << "Error: Unable to write to lower machine for sm parameter." << endl;
}
delete[] sm_buf;
// 模板匹配阈值
uint8_t* ts_buf = new uint8_t[len_ts + 8];
ts_buf[0] = 0xAA;
ts_buf[1] = 0x00;
@ -996,11 +1017,13 @@ bool iniLowMac()
if (lower_machine->isWritable()) {
lower_machine->write((const char*)ts_buf, len_ts + 8);
qDebug() << "模板匹配阈值: " << ts_byte.data();
} else {
cout << "Error: Unable to write to lower machine for ts parameter." << endl;
}
delete[] ts_buf;
// 偏振绿色通道大小阈值
uint8_t* sg_buf = new uint8_t[len_sg + 8];
sg_buf[0] = 0xAA;
sg_buf[1] = 0x00;
@ -1014,11 +1037,13 @@ bool iniLowMac()
if (lower_machine->isWritable()) {
lower_machine->write((const char*)sg_buf, len_sg + 8);
qDebug() << "偏振绿色通道大小阈值: " << sg_byte.data();
} else {
cout << "Error: Unable to write to lower machine for sg parameter." << endl;
}
delete[] sg_buf;
// 偏振红色通道差值
uint8_t* td_buf = new uint8_t[len_td + 8];
td_buf[0] = 0xAA;
td_buf[1] = 0x00;
@ -1032,12 +1057,13 @@ bool iniLowMac()
if (lower_machine->isWritable()) {
lower_machine->write((const char*)td_buf, len_td + 8);
qDebug() << "偏振红色通道差值: " << td_byte.data();
} else {
cout << "Error: Unable to write to lower machine for td parameter." << endl;
}
delete[] td_buf;
return 1;
return true;
}
bool DestoryLowMac()
@ -1156,7 +1182,7 @@ void Start_camera()
if (lower_machine != nullptr && lower_machine->isWritable())
{
lower_machine->write((const char*)start_command, 9);
qDebug()<<"发送相机参数成功";
qDebug()<<"发送相机启动成功";
}
else
{

View File

@ -69,6 +69,8 @@ bool iniOnnx();
void Start_camera();
bool setLowMacParam();
bool DestoryCamera();
bool DestoryLowMac();
@ -120,4 +122,6 @@ extern bool volatile is_running;
bool get_valve_data(std::vector<std::vector<uint8_t>> mask );
void max_valves_together_limit(std::vector<std::vector<uint8_t>> &mask_expaned, const int row_threshold);
#endif // CAMERA_H

View File

@ -12,6 +12,7 @@ CONFIG += console
SOURCES += \
camera.cpp \
color_range.cpp \
countdowndialog.cpp \
detectionworker.cpp \
globals.cpp \
img_utils.cpp \
@ -23,6 +24,7 @@ SOURCES += \
HEADERS += \
camera.h \
color_range.h \
countdowndialog.h \
detectionworker.h \
globals.h \
img_utils.h \

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 15.0.0, 2025-01-02T20:20:23. -->
<!-- Written by QtCreator 15.0.0, 2025-01-04T20:22:11. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>

View File

@ -1,4 +1,3 @@
# Green color parameters
green_L_min = 16
green_L_max = 56
green_a_min = -33
@ -6,7 +5,6 @@ green_a_max = -11
green_b_min = -7
green_b_max = 24
# Blue color parameters
blue_L_min = 20
blue_L_max = 43
blue_a_min = -13
@ -14,15 +12,13 @@ blue_a_max = 22
blue_b_min = -48
blue_b_max = -8
# Orange color parameters
orange_L_min = 60
orange_L_max = 60
orange_a_min = 6
orange_a_max = 6
orange_b_min = 20
orange_b_max = 46
orange_L_min = 63
orange_L_max = 78
orange_a_min = 7
orange_a_max = 14
orange_b_min = 23
orange_b_max = 47
# Black color parameters
black_L_min = 0
black_L_max = 8
black_a_min = -4
@ -30,7 +26,6 @@ black_a_max = 2
black_b_min = -3
black_b_max = 4
# Red color parameters
red_L_min = 23
red_L_max = 48
red_a_min = 12
@ -38,7 +33,6 @@ red_a_max = 55
red_b_min = -80
red_b_max = 37
# Purple color parameters
purple_L_min = 38
purple_L_max = 54
purple_a_min = 10
@ -46,7 +40,20 @@ purple_a_max = 20
purple_b_min = -45
purple_b_max = 1
# Other parameters
yellow_L_min = 45
yellow_L_max = 56
yellow_a_min = -4
yellow_a_max = 7
yellow_b_min = 20
yellow_b_max = 21
expansionRaidus = 1
file_delay = 1180
lab_denoising = 1
saturation_threshold = 165
lowmac_dp = 350
lowmac_sg = 70
lowmac_td = 7
lowmac_ts = 10
saturation_denoising = 1
saturation_threshold = 165
sizeThreshold = 4

2
dist/license.txt vendored
View File

@ -61,7 +61,7 @@
1. **Software Provided “As Is”**
The Software and any related services are provided on an “as is” basis. The Licensor makes no express or implied warranties regarding the performance, quality, compatibility, or suitability of the Software.
2. **Assumption of Risk**
The User understands and agrees that any risks or losses arising from the use of or inability to use the Software are borne by the User. The Licensor shall not be liable for any direct or indirect losses arising therefrom.
The User understands and agrees that any risks or losses arising from the use of or inability to use the Software are borne by the User. The Licensor shall not be liable for any direct or indirect losses arising therefrom. And the Licensor shall agree that NC is NC.
---

View File

@ -3,6 +3,7 @@
// camera.cpp 顶部或 globals.cpp 中
long long g_valveActionCount = 0;
std::atomic<bool> g_camera_error(false);
// 初始化图片显示互斥锁和MIL_ID
QMutex gDispPicMutex0;
@ -43,6 +44,8 @@ std::atomic<bool>* g_recognitionRunning[2] = { nullptr, nullptr };
bool g_dl_enable[2] = { true, true };
bool g_traditional_enable[2] = { true, true };
int sizeThreshold = 4; // 转化为喷阀的每块要求像素个数
int expansionRaidus = 1; // 获取mask后进行左右位置的扩展
// 初始化全局ONNXRunner实例数组
ONNXRunner* g_runner_array[2] = { nullptr, nullptr };

View File

@ -16,7 +16,9 @@
#include <atomic>
#include "onnxrunner.h"
// 计数喷阀次数
extern long long g_valveActionCount;
extern std::atomic<bool> g_camera_error;
// 图片显示0
extern QMutex gDispPicMutex0;
@ -39,6 +41,9 @@ extern QSemaphore detection_ready;
extern bool g_dl_enable[2];
extern bool g_traditional_enable[2];
extern int sizeThreshold; // 转化为喷阀的每块要求像素个数
extern int expansionRaidus;
// 获取保存目录和配置目录函数
QString getSaveDirectory();
QString getConfigDirectory();

View File

@ -47,6 +47,16 @@ yellow_a_max = 7
yellow_b_min = 20
yellow_b_max = 21
expansionRaidus = 1
file_delay = 1180
lab_denoising = 1
lowmac_dp = 350
lowmac_sg = 70
lowmac_sm = 1200
lowmac_td = 7
lowmac_ts = 10
machine_num = 0
max_valves_together = 20
saturation_denoising = 1
saturation_threshold = 165
sizeThreshold = 4

File diff suppressed because it is too large Load Diff

View File

@ -38,6 +38,7 @@ int lowmac_sm = 1200; //吹气量 valve/12 = 吹气时间ms
int lowmac_ts = 10; //模板匹配阈值
int lowmac_sg = 65; //偏振绿色通道大小阈值
int lowmac_td = 7; //偏振红色通道差值
Widget::Widget(QWidget *parent)
: QWidget(parent)
, ui(new Ui::Widget)
@ -63,10 +64,12 @@ Widget::Widget(QWidget *parent)
iniOnnx();
// iniColor();
loadConfig(getConfigDirectory()+"/color_range_config.txt");
loadConfig(getConfigDirectory()+"/color_range_config.txt"); // 读取配置文件
iniLowMac();
iniCamera();
update_colorlist();
update_machine_num();
update_colorlist(); // 更新色彩列表
update_polar(); // 更新偏振相机界面
// 初始化存储工作者和线程
storageWorker = new StorageWorker();
storageWorker->moveToThread(&storageThread);
@ -80,9 +83,41 @@ Widget::Widget(QWidget *parent)
// 启动显示定时器,每秒检查一次
QTimer* timer = new QTimer(this);
connect(timer, &QTimer::timeout, this, &Widget::refreshImage);
timer->start(40); // 每50毫秒秒刷新一次界面
timer->start(40); // 每40毫秒秒刷新一次界面
ui->tabWidget->setCurrentIndex(1);
// on_btn_start_clicked();
// 显示启动倒计时
showStartupCountdown();
}
void Widget::showStartupCountdown()
{
CountdownDialog* countdown = new CountdownDialog(10, this);
countdown->setAttribute(Qt::WA_DeleteOnClose); // 对话框关闭后自动删除
// 连接倒计时完成信号
connect(countdown, &CountdownDialog::countdownFinished, this, &Widget::onCountdownFinished);
// 连接对话框的关闭事件,以处理用户提前关闭
connect(countdown, &QDialog::rejected, this, &Widget::onCountdownCancelled);
countdown->show(); // 非模态显示,允许用户在倒计时期间与主窗口交互
}
void Widget::onCountdownCancelled()
{
qDebug() << "用户取消了启动倒计时。";
// 根据需求处理取消后的操作,例如不启动识别任务
// 可以选择什么都不做,或者提供提示
}
void Widget::onCountdownFinished()
{
qDebug() << "启动倒计时结束,继续执行开机操作。";
on_btn_start_clicked();
}
Widget::~Widget()
@ -115,6 +150,17 @@ void Widget::refreshImage()
this->ui->tra_enable_0->setEnabled(!this->isCamRunning);
this->ui->tra_enable_1->setEnabled(!this->isCamRunning);
this->ui->btn_quit->setEnabled(!this->isCamRunning);
// refresh settings buttons
this->ui->btn_setColor->setEnabled(!this->isCamRunning);
this->ui->btn_reset_color->setEnabled(!this->isCamRunning);
this->ui->btn_del_color->setEnabled(!this->isCamRunning);
this->ui->btn_add_color->setEnabled(!this->isCamRunning);
this->ui->btn_reset_polar->setEnabled(!this->isCamRunning);
this->ui->btn_save_polar->setEnabled(!this->isCamRunning);
this->ui->btn_set_lower->setEnabled(!this->isCamRunning);
//
QDateTime now = QDateTime::currentDateTime();
ui->label_currentDateTime->setText(now.toString("yyyy-MM-dd hh:mm:ss"));
@ -158,7 +204,11 @@ void Widget::refreshImage()
}
else
{
info = "运行";
if(g_camera_error.load()){
info = "图像问题!!!";
} else {
info = "运行";
}
};
}else {
info = "停止";
@ -338,6 +388,8 @@ void Widget::on_btn_stop_clicked()
void Widget::on_btn_start_clicked()
{
// 设置相机参数
setLowMacParam();
g_dl_enable[0] = !this->ui->dl_enable_0->isChecked();
g_dl_enable[1] = !this->ui->dl_enable_0->isChecked();
g_traditional_enable[0] = !this->ui->tra_enable_0->isChecked();
@ -359,17 +411,12 @@ void Widget::on_btn_start_clicked()
HANDLE hThread = static_cast<HANDLE>(g_recognitionThread[i]->native_handle());
// 设置线程优先级为最高
if(SetThreadPriority(hThread, THREAD_PRIORITY_HIGHEST))
{
std::cout << "DL Thread " << i << " set highest thread priority。" << std::endl;
}
else
if(!SetThreadPriority(hThread, THREAD_PRIORITY_HIGHEST))
{
std::cerr << "SET thread " << i << " failed, error code" << GetLastError() << std::endl;
}
}
Start_camera();
}
@ -422,11 +469,23 @@ void Widget::on_btn_quit_clicked()
void Widget::on_btn_set_lower_clicked()
{
// 硬编码参数值
file_delay = ui->spinbox_delaytime->text().toInt(); // 延迟时间(毫秒)
lowmac_sm = ui->spinbox_maintime->value();
params["lowmac_sm"]=lowmac_sm;
params["machine_num"] = ui->spinbox_machine_code->value();
params["max_valves_together"] = ui->spinbox_max_valves_together->value();
saveConfig(getConfigDirectory()+"/color_range_config.txt", params, colors);
// 两个过去的参量不支持读取配置文件
file_encoder = ui->spinbox_encoder->text().toInt(); // 编码器值++
file_valve = ui->spinbox_valve->text().toInt(); // 阀门通道
}
void Widget::update_machine_num()
{
ui->lab_machine_num->setText(QString("%1号机").arg(params["machine_num"]));
ui->spinbox_machine_code->setValue(params["machine_num"]);
ui->spinbox_maintime->setValue(params["lowmac_sm"]);
}
void Widget::on_btn_set_valve_clicked()
{
@ -448,7 +507,7 @@ void Widget::on_btn_live_clicked()
void Widget::on_btn_tab3_backtab2_2_clicked()
{
ui->tabWidget->setCurrentIndex(3);
ui->tabWidget->setCurrentIndex(5);
}
@ -585,7 +644,13 @@ bool Widget::loadConfig(const QString &filePath)
}
file.close();
lowmac_dp = params["lowmac_dp"]; //偏振延迟时间
lowmac_ts = params["lowmac_ts"]; //模板匹配阈值
lowmac_sg = params["lowmac_sg"]; //偏振绿色通道大小阈值
lowmac_td = params["lowmac_td"]; //偏振红色通道差值
file_delay = params["file_delay"]; // 延迟时间
expansionRaidus = params["expansionRaidus"]; // 扩展半径
sizeThreshold = params["sizeThreshold"]; // 大小过滤
qDebug() << "配置已成功从" << filePath << "加载";
// qDebug()<<colors;
return true;
@ -637,7 +702,20 @@ void Widget::initDefaultConfig()
// Other parameters
{"lab_denoising", 1},
{"saturation_threshold", 165},
{"saturation_denoising", 1}
{"saturation_denoising", 1},
{"lowmac_sg",lowmac_sg},
{"lowmac_td",lowmac_td},
{"lowmac_ts",lowmac_ts},
{"lowmac_dp",lowmac_dp},
{"lowmac_sm", lowmac_sm},
{"machine_num", params["machine_num"]},
{"max_valves_together", params["max_valves_together"]},
{"sizeThreshold",4},
{"file_delay",1180},
{"expansionRaidus",1}
};
}
@ -646,14 +724,24 @@ void Widget::on_btn_setColor_clicked()
std::string current_color=ui->comboBox_colorlist->currentText().toLocal8Bit().constData();
if (!(std::find(colors.begin(), colors.end(), current_color) != colors.end()))
return;
// 设置当前色彩
params[current_color+"_L_min"]=ui->spinBox_L_min->value();
params[current_color+"_L_max"]=ui->spinBox_L_max->value();
params[current_color+"_a_min"]=ui->spinBox_A_min->value();
params[current_color+"_a_max"]=ui->spinBox_A_max->value();
params[current_color+"_b_min"]=ui->spinBox_B_min->value();
params[current_color+"_b_max"]=ui->spinBox_B_max->value();
// 准备写入本地
params["file_delay"]=ui->spinbox_delaytime->value();
params["saturation_threshold"]=ui->spb_saturation->value(); // 这个参数会通过params直接被调用无需赋值给其他全局变量
params["sizeThreshold"]=ui->spinbox_msize_color->value();
params["expansionRaidus"]=ui->spb_expandsize->value();
// 写入内存进行使用
file_delay = params["file_delay"];
sizeThreshold = params["sizeThreshold"];
expansionRaidus = params["expansionRaidus"];
// 存入本地
saveConfig(getConfigDirectory()+"/color_range_config.txt",params,colors);
}
void Widget::update_colorlist()
@ -690,12 +778,23 @@ void Widget::on_comboBox_colorlist_currentIndexChanged(int index)
void Widget::on_btn_add_color_clicked()
{
std::string current_color=ui->lineEdit_color->text().toLocal8Bit().constData();
// 空不添加
if(current_color== "")
{
QMessageBox::warning(this, "什么颜色?", "这名字起的不雅");
return;
}
// 必须跟之前所有颜色都不一致
if (!(std::find(colors.begin(), colors.end(), current_color) != colors.end()))
{
colors.push_back(current_color);
}
else
{
QMessageBox::warning(this, "已有名字", "这名字跟别的色撞了");
return;
}
// 存盘刷界面
params[current_color+"_L_min"]=ui->spinBox_L_min->value();
params[current_color+"_L_max"]=ui->spinBox_L_max->value();
params[current_color+"_a_min"]=ui->spinBox_A_min->value();
@ -825,3 +924,122 @@ void Widget::on_btn_reset_color_clicked()
}
void Widget::on_btn_tab_color_clicked()
{
ui->tabWidget->setCurrentIndex(3);
}
void Widget::on_btn_tab3_backtab2_3_clicked()
{
ui->tabWidget->setCurrentIndex(5);
}
void Widget::on_btn_tab3_backtab2_5_clicked()
{
ui->tabWidget->setCurrentIndex(1);
}
void Widget::on_btn_tab_color_2_clicked()
{
ui->tabWidget->setCurrentIndex(3);
}
void Widget::on_btn_tab3_backtab2_6_clicked()
{
ui->tabWidget->setCurrentIndex(4);
}
void Widget::on_btn_tab3_backtab2_7_clicked()
{
ui->tabWidget->setCurrentIndex(5);
}
void Widget::on_btn_tab3_backtab2_8_clicked()
{
ui->tabWidget->setCurrentIndex(1);
}
void Widget::on_btn_tab_color_3_clicked()
{
ui->tabWidget->setCurrentIndex(3);
}
void Widget::on_btn_tab3_backtab2_9_clicked()
{
ui->tabWidget->setCurrentIndex(4);
}
void Widget::on_btn_tab3_backtab2_4_clicked()
{
ui->tabWidget->setCurrentIndex(4);
}
void Widget::on_btn_save_polar_clicked()
{
QMessageBox::StandardButton reply;
reply = QMessageBox::question(this, "确定保存", "确定要将偏振配置保存吗?",
QMessageBox::Yes | QMessageBox::No);
if (reply != QMessageBox::Yes)
return;
params["lowmac_td"]=ui->spb_diff->value();
params["lowmac_sg"]=ui->spb_green->value();
params["lowmac_dp"]=ui->spb_delay_polar->value();
params["lowmac_ts"]=ui->spb_msize_polar->value();
lowmac_dp = params["lowmac_dp"]; //偏振延迟时间
lowmac_ts = params["lowmac_ts"]; //模板匹配阈值
lowmac_sg = params["lowmac_sg"]; //偏振绿色通道大小阈值
lowmac_td = params["lowmac_td"]; //偏振红色通道差值
saveConfig(getConfigDirectory()+"/color_range_config.txt",params,colors);
}
void Widget::on_btn_reset_polar_clicked()
{
QMessageBox::StandardButton reply;
reply = QMessageBox::question(this, "确定重置", "确定要将偏振部分配置重置吗?",
QMessageBox::Yes | QMessageBox::No);
if (reply != QMessageBox::Yes)
return;
params["lowmac_td"]= 7;
params["lowmac_sg"]= 65;
params["lowmac_dp"]= 350;
params["lowmac_ts"]= 10;
lowmac_dp = params["lowmac_dp"]; //偏振延迟时间
lowmac_ts = params["lowmac_ts"]; //模板匹配阈值
lowmac_sg = params["lowmac_sg"]; //偏振绿色通道大小阈值
lowmac_td = params["lowmac_td"]; //偏振红色通道差值
saveConfig(getConfigDirectory()+"/color_range_config.txt",params,colors);
update_polar();
}
void Widget::update_polar()
{
ui->spb_green->setValue(lowmac_sg);
ui->spb_diff->setValue(lowmac_td);
ui->spb_delay_polar->setValue(lowmac_dp);
ui->spb_msize_polar->setValue(lowmac_ts);
}
void Widget::on_tabWidget_currentChanged(int index)
{
update_machine_num();
update_colorlist(); // 更新色彩列表
update_polar(); // 更新偏振相机界面
}

View File

@ -8,6 +8,7 @@
#include <QPushButton>
#include "globals.h"
#include "storageworker.h"
#include "countdowndialog.h"
QT_BEGIN_NAMESPACE
namespace Ui {
@ -28,6 +29,10 @@ public slots:
private slots:
void onCountdownFinished();
void onCountdownCancelled();
void refreshSingleImage(int camera_id, bool overlay_traditional_result = false, bool overlay_dl_result = false, bool mirror = false);
void on_pushButton_2_clicked();
@ -72,6 +77,36 @@ private slots:
void on_btn_reset_color_clicked();
void on_btn_tab_color_clicked();
void on_btn_tab3_backtab2_3_clicked();
void on_btn_tab3_backtab2_5_clicked();
void on_btn_tab_color_2_clicked();
void on_btn_tab3_backtab2_6_clicked();
void on_btn_tab3_backtab2_7_clicked();
void on_btn_tab3_backtab2_8_clicked();
void on_btn_tab_color_3_clicked();
void on_btn_tab3_backtab2_9_clicked();
void on_btn_tab3_backtab2_4_clicked();
void on_btn_save_polar_clicked();
void on_btn_reset_polar_clicked();
void update_polar();
void update_machine_num();
void on_tabWidget_currentChanged(int index);
private:
Ui::Widget *ui;
@ -82,5 +117,7 @@ private:
QThread storageThread; // 存储线程
StorageWorker* storageWorker; // 存储工作者
void showStartupCountdown();
};
#endif // WIDGET_H

4520
widget.ui

File diff suppressed because it is too large Load Diff