81 lines
2.6 KiB
C++
81 lines
2.6 KiB
C++
|
|
#include "dialogalgoarg.h"
|
||
|
|
#include "ui_dialogalgoarg.h"
|
||
|
|
|
||
|
|
#include <QDoubleValidator>
|
||
|
|
#include <QIntValidator>
|
||
|
|
|
||
|
|
DialogAlgoArg::DialogAlgoArg(QWidget* parent)
|
||
|
|
: QDialog(parent)
|
||
|
|
, ui(new Ui::DialogAlgoArg)
|
||
|
|
{
|
||
|
|
ui->setupUi(this);
|
||
|
|
setWindowTitle(QStringLiteral("检测参数配置"));
|
||
|
|
|
||
|
|
// 设置输入验证器(只限制输入格式,不做上下选择)
|
||
|
|
ui->edit_score->setValidator(new QDoubleValidator(0.0, 1.0, 2, this));
|
||
|
|
ui->edit_nms->setValidator(new QDoubleValidator(0.0, 1.0, 2, this));
|
||
|
|
ui->edit_width->setValidator(new QIntValidator(0, 8192, this));
|
||
|
|
ui->edit_height->setValidator(new QIntValidator(0, 8192, this));
|
||
|
|
ui->edit_modelType->setValidator(new QIntValidator(0, 10, this));
|
||
|
|
}
|
||
|
|
|
||
|
|
DialogAlgoArg::~DialogAlgoArg()
|
||
|
|
{
|
||
|
|
delete ui;
|
||
|
|
}
|
||
|
|
|
||
|
|
void DialogAlgoArg::SetParams(const DroneScrewAlgoUiParams& params)
|
||
|
|
{
|
||
|
|
m_params = params;
|
||
|
|
loadToUi(params);
|
||
|
|
}
|
||
|
|
|
||
|
|
DroneScrewAlgoUiParams DialogAlgoArg::GetParams() const
|
||
|
|
{
|
||
|
|
return m_params;
|
||
|
|
}
|
||
|
|
|
||
|
|
void DialogAlgoArg::loadToUi(const DroneScrewAlgoUiParams& p)
|
||
|
|
{
|
||
|
|
if (ui->edit_score) ui->edit_score->setText(QString::number(p.scoreThreshold, 'f', 2));
|
||
|
|
if (ui->edit_nms) ui->edit_nms->setText(QString::number(p.nmsThreshold, 'f', 2));
|
||
|
|
if (ui->edit_width) ui->edit_width->setText(QString::number(p.inputWidth));
|
||
|
|
if (ui->edit_height) ui->edit_height->setText(QString::number(p.inputHeight));
|
||
|
|
if (ui->edit_modelType) ui->edit_modelType->setText(QString::number(p.modelType));
|
||
|
|
if (ui->edit_model) ui->edit_model->setText(QString::fromStdString(p.modelPath));
|
||
|
|
}
|
||
|
|
|
||
|
|
DroneScrewAlgoUiParams DialogAlgoArg::collectFromUi() const
|
||
|
|
{
|
||
|
|
DroneScrewAlgoUiParams p;
|
||
|
|
if (ui->edit_score) { bool ok; float v = ui->edit_score->text().toFloat(&ok); if (ok) p.scoreThreshold = v; }
|
||
|
|
if (ui->edit_nms) { bool ok; float v = ui->edit_nms->text().toFloat(&ok); if (ok) p.nmsThreshold = v; }
|
||
|
|
if (ui->edit_width) { bool ok; int v = ui->edit_width->text().toInt(&ok); if (ok) p.inputWidth = v; }
|
||
|
|
if (ui->edit_height) { bool ok; int v = ui->edit_height->text().toInt(&ok); if (ok) p.inputHeight = v; }
|
||
|
|
if (ui->edit_modelType) { bool ok; int v = ui->edit_modelType->text().toInt(&ok); if (ok) p.modelType = v; }
|
||
|
|
if (ui->edit_model) p.modelPath = ui->edit_model->text().toStdString();
|
||
|
|
return p;
|
||
|
|
}
|
||
|
|
|
||
|
|
void DialogAlgoArg::on_btn_ok_clicked()
|
||
|
|
{
|
||
|
|
m_params = collectFromUi();
|
||
|
|
accept();
|
||
|
|
}
|
||
|
|
|
||
|
|
void DialogAlgoArg::on_btn_cancel_clicked()
|
||
|
|
{
|
||
|
|
reject();
|
||
|
|
}
|
||
|
|
|
||
|
|
void DialogAlgoArg::on_btn_apply_clicked()
|
||
|
|
{
|
||
|
|
m_params = collectFromUi();
|
||
|
|
}
|
||
|
|
|
||
|
|
void DialogAlgoArg::on_btn_reset_clicked()
|
||
|
|
{
|
||
|
|
DroneScrewAlgoUiParams p; // 默认值
|
||
|
|
loadToUi(p);
|
||
|
|
}
|