调整动态校正和畸变校正等问题
This commit is contained in:
parent
8ba035a321
commit
8662f0b9bb
|
@ -53,7 +53,7 @@ Dialog_InputSerialNum::Dialog_InputSerialNum(class MainWindow *mainWnd, const QS
|
|||
|
||||
ui->pbtn_enterTest->setEnabled(false);
|
||||
ui->label_scanner->setText(tr("Device name: %1").arg(m_devName));
|
||||
ui->lineEdit_sn->setValidator(new QRegExpValidator(QRegExp("[a-zA-Z0-9]+$")));
|
||||
//ui->lineEdit_sn->setValidator(new QRegExpValidator(QRegExp("[a-zA-Z0-9]+$")));
|
||||
ui->lineEdit_sn->setMaxLength(14);
|
||||
|
||||
if (handle != nullptr)
|
||||
|
|
|
@ -150,8 +150,10 @@ void Form_mainInterface::setDevDisconnect()
|
|||
m_disconnect = true;
|
||||
}
|
||||
|
||||
void Form_mainInterface::checkWrongCorrectItem(int correctType)
|
||||
void Form_mainInterface::checkDynamicCorrectItem(bool pass, int correctType)
|
||||
{
|
||||
bool allPass = false;
|
||||
int correctItemId = -1;
|
||||
for (int i = 0; i < ui->tableWidget->rowCount(); i++)
|
||||
{
|
||||
QTableWidgetItem *item = ui->tableWidget->item(i, 1);
|
||||
|
@ -160,41 +162,57 @@ void Form_mainInterface::checkWrongCorrectItem(int correctType)
|
|||
QString title = item->text();
|
||||
QString name = m_map_title_name.value(title).name;
|
||||
|
||||
if (HGPDTTOOLDB_NAME_IMAGE_CORRECTION == name)
|
||||
{
|
||||
correctItemId = i;
|
||||
}
|
||||
|
||||
if (1 == correctType && HGPDTTOOLDB_NAME_IMAGE_CORRECTION_RGB_200DPI == name)
|
||||
{
|
||||
ui->tableWidget->item(i, 2)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
ui->tableWidget->item(i, 2)->setBackgroundColor(QColor(255,0,0));
|
||||
ui->tableWidget->item(i, 2)->setText(tr("not pass"));
|
||||
ui->tableWidget->item(i, 2)->setBackgroundColor(pass ? QColor(0,255,0) : QColor(255,0,0));
|
||||
ui->tableWidget->item(i, 2)->setText(pass ? tr("pass") : tr("not pass"));
|
||||
}
|
||||
else if (2 == correctType && HGPDTTOOLDB_NAME_IMAGE_CORRECTION_GRAY_200DPI == name)
|
||||
{
|
||||
ui->tableWidget->item(i, 2)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
ui->tableWidget->item(i, 2)->setBackgroundColor(QColor(255,0,0));
|
||||
ui->tableWidget->item(i, 2)->setText(tr("not pass"));
|
||||
ui->tableWidget->item(i, 2)->setBackgroundColor(pass ? QColor(0,255,0) : QColor(255,0,0));
|
||||
ui->tableWidget->item(i, 2)->setText(pass ? tr("pass") : tr("not pass"));
|
||||
}
|
||||
else if (3 == correctType && HGPDTTOOLDB_NAME_IMAGE_CORRECTION_RGB_300DPI == name)
|
||||
{
|
||||
ui->tableWidget->item(i, 2)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
ui->tableWidget->item(i, 2)->setBackgroundColor(QColor(255,0,0));
|
||||
ui->tableWidget->item(i, 2)->setText(tr("not pass"));
|
||||
ui->tableWidget->item(i, 2)->setBackgroundColor(pass ? QColor(0,255,0) : QColor(255,0,0));
|
||||
ui->tableWidget->item(i, 2)->setText(pass ? tr("pass") : tr("not pass"));
|
||||
}
|
||||
else if (4 == correctType && HGPDTTOOLDB_NAME_IMAGE_CORRECTION_GRAY_300DPI == name)
|
||||
{
|
||||
ui->tableWidget->item(i, 2)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
ui->tableWidget->item(i, 2)->setBackgroundColor(QColor(255,0,0));
|
||||
ui->tableWidget->item(i, 2)->setText(tr("not pass"));
|
||||
ui->tableWidget->item(i, 2)->setBackgroundColor(pass ? QColor(0,255,0) : QColor(255,0,0));
|
||||
ui->tableWidget->item(i, 2)->setText(pass ? tr("pass") : tr("not pass"));
|
||||
}
|
||||
else if (5 == correctType && HGPDTTOOLDB_NAME_IMAGE_CORRECTION_RGB_600DPI == name)
|
||||
{
|
||||
ui->tableWidget->item(i, 2)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
ui->tableWidget->item(i, 2)->setBackgroundColor(QColor(255,0,0));
|
||||
ui->tableWidget->item(i, 2)->setText(tr("not pass"));
|
||||
ui->tableWidget->item(i, 2)->setBackgroundColor(pass ? QColor(0,255,0) : QColor(255,0,0));
|
||||
ui->tableWidget->item(i, 2)->setText(pass ? tr("pass") : tr("not pass"));
|
||||
}
|
||||
else if (6 == correctType && HGPDTTOOLDB_NAME_IMAGE_CORRECTION_GRAY_600DPI == name)
|
||||
{
|
||||
ui->tableWidget->item(i, 2)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
ui->tableWidget->item(i, 2)->setBackgroundColor(QColor(255,0,0));
|
||||
ui->tableWidget->item(i, 2)->setText(tr("not pass"));
|
||||
ui->tableWidget->item(i, 2)->setBackgroundColor(pass ? QColor(0,255,0) : QColor(255,0,0));
|
||||
ui->tableWidget->item(i, 2)->setText(pass ? tr("pass") : tr("not pass"));
|
||||
|
||||
allPass = true;
|
||||
int row = item->row();
|
||||
ui->tableWidget->selectRow(row + 1);
|
||||
|
||||
if (correctItemId >= 0)
|
||||
{
|
||||
ui->tableWidget->item(correctItemId, 2)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
ui->tableWidget->item(correctItemId, 2)->setBackgroundColor(QColor(0,255,0));
|
||||
ui->tableWidget->item(correctItemId, 2)->setText(tr("pass"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -210,7 +228,8 @@ void Form_mainInterface::resetCorrectItems()
|
|||
QString title = item->text();
|
||||
QString name = m_map_title_name.value(title).name;
|
||||
|
||||
if (HGPDTTOOLDB_NAME_IMAGE_CORRECTION_RGB_200DPI == name ||
|
||||
if (HGPDTTOOLDB_NAME_IMAGE_CORRECTION == name ||
|
||||
HGPDTTOOLDB_NAME_IMAGE_CORRECTION_RGB_200DPI == name ||
|
||||
HGPDTTOOLDB_NAME_IMAGE_CORRECTION_GRAY_200DPI == name ||
|
||||
HGPDTTOOLDB_NAME_IMAGE_CORRECTION_RGB_300DPI == name ||
|
||||
HGPDTTOOLDB_NAME_IMAGE_CORRECTION_GRAY_300DPI == name ||
|
||||
|
@ -225,6 +244,34 @@ void Form_mainInterface::resetCorrectItems()
|
|||
}
|
||||
}
|
||||
|
||||
void Form_mainInterface::updateDistortionItem(bool pass)
|
||||
{
|
||||
for (int i = 0; i < ui->tableWidget->rowCount(); i++)
|
||||
{
|
||||
QTableWidgetItem *item = ui->tableWidget->item(i, 1);
|
||||
if (item != nullptr)
|
||||
{
|
||||
QString name = m_map_title_name.value(m_curItemName).name;
|
||||
if (m_curItemName== item->text() && HGPDTTOOLDB_NAME_VERIFY_DISTORTION_VAL == name)
|
||||
{
|
||||
ui->tableWidget->item(i, 2)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
ui->tableWidget->item(i, 2)->setBackgroundColor(pass ? QColor(0,255,0) : QColor(255,0,0));
|
||||
ui->tableWidget->item(i, 2)->setText(pass ? tr("pass") : tr("not pass"));
|
||||
|
||||
if (pass)
|
||||
{
|
||||
item->setToolTip("");
|
||||
writeTestLog(tr("Tester: %1, Test item: %2, Test result: Pass!")
|
||||
.arg(m_accountName).arg(m_curItemName));
|
||||
|
||||
on_pbtn_nextStep_clicked();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Form_mainInterface::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
(void)event;
|
||||
|
@ -244,7 +291,7 @@ void Form_mainInterface::on_testResult(QString text)
|
|||
|
||||
updateUiEnabled(true);
|
||||
m_isTesting = false;
|
||||
m_mainwnd->releaseTesting();
|
||||
m_mainwnd->initTestingRef();
|
||||
|
||||
if (m_disconnect)
|
||||
{
|
||||
|
@ -276,44 +323,71 @@ void Form_mainInterface::on_testDistortion(float width, float height, float dist
|
|||
{
|
||||
ui->label_imgInfo->setVisible(true);
|
||||
|
||||
ui->label_destortionInfo_200dpi->setVisible(!verify);
|
||||
ui->label_destortionInfo_300dpi->setVisible(!verify);
|
||||
ui->label_destortionInfo_200dpi->setVisible(true);
|
||||
ui->label_destortionInfo_300dpi->setVisible(true);
|
||||
|
||||
ui->label_imgInfo->setText(tr("image pixel: ") + QString::number((width > 0 && width < 9999) ? width : 0.0, 'f', 4) +
|
||||
" * " + QString::number((height > 0 && height < 9999) ? height : 0.0, 'f', 4));
|
||||
|
||||
if (!verify)
|
||||
if (200 == m_curDpi)
|
||||
{
|
||||
m_distortion_200dpi = distortion > 0 ? distortion : 0;
|
||||
ui->label_destortionInfo_200dpi->setText(" 200dpi" + tr("destortion value: ") + QString::number(m_distortion_200dpi, 'f', 4));
|
||||
|
||||
if (m_hg != nullptr)
|
||||
{
|
||||
m_hg->setDistortValue(m_distortion_200dpi);
|
||||
}
|
||||
}
|
||||
else if (300 == m_curDpi)
|
||||
{
|
||||
m_distortion_300dpi = distortion > 0 ? distortion : 0;
|
||||
ui->label_destortionInfo_300dpi->setText(" 300dpi" + tr("destortion value: ") + QString::number(m_distortion_300dpi, 'f', 4));
|
||||
|
||||
if (m_hg != nullptr)
|
||||
{
|
||||
m_hg->setDistortValue(m_distortion_300dpi);
|
||||
}
|
||||
}
|
||||
else if (600 == m_curDpi)
|
||||
{
|
||||
m_distortion_600dpi = distortion > 0 ? distortion : 0;
|
||||
ui->label_destortionInfo_600dpi->setText(" 600dpi" + tr("destortion value: ") + QString::number(m_distortion_600dpi, 'f', 4));
|
||||
|
||||
if (m_hg != nullptr)
|
||||
{
|
||||
m_hg->setDistortValue(m_distortion_600dpi);
|
||||
}
|
||||
}
|
||||
|
||||
if (verify)
|
||||
{
|
||||
bool pass = false;
|
||||
float absPixcel = std::abs(width - height);
|
||||
float absDistortion = std::abs(1 - distortion);
|
||||
if (200 == m_curDpi)
|
||||
{
|
||||
m_distortion_200dpi = distortion > 0 ? distortion : 0;
|
||||
ui->label_destortionInfo_200dpi->setText(" 200dpi" + tr("destortion value: ") + QString::number(m_distortion_200dpi, 'f', 4));
|
||||
|
||||
if (m_hg != nullptr)
|
||||
if ((absPixcel > 0 && absPixcel < 6.0f) || (absDistortion > 0 && absDistortion < 0.002))
|
||||
{
|
||||
m_hg->setDistortValue(m_distortion_200dpi);
|
||||
pass = true;
|
||||
}
|
||||
}
|
||||
else if (300 == m_curDpi)
|
||||
{
|
||||
m_distortion_300dpi = distortion > 0 ? distortion : 0;
|
||||
ui->label_destortionInfo_300dpi->setText(" 300dpi" + tr("destortion value: ") + QString::number(m_distortion_300dpi, 'f', 4));
|
||||
|
||||
if (m_hg != nullptr)
|
||||
if ((absPixcel > 0 && absPixcel < 8.0f) || (absDistortion > 0 && absDistortion < 0.002))
|
||||
{
|
||||
m_hg->setDistortValue(m_distortion_300dpi);
|
||||
pass = true;
|
||||
}
|
||||
}
|
||||
else if (600 == m_curDpi)
|
||||
{
|
||||
m_distortion_600dpi = distortion > 0 ? distortion : 0;
|
||||
ui->label_destortionInfo_600dpi->setText(" 600dpi" + tr("destortion value: ") + QString::number(m_distortion_600dpi, 'f', 4));
|
||||
|
||||
if (m_hg != nullptr)
|
||||
if ((absPixcel > 0 && absPixcel < 15.0f) || (absDistortion > 0 && absDistortion < 0.002))
|
||||
{
|
||||
m_hg->setDistortValue(m_distortion_600dpi);
|
||||
pass = true;
|
||||
}
|
||||
}
|
||||
|
||||
updateDistortionItem(pass);
|
||||
}
|
||||
|
||||
updateUiEnabled(true);
|
||||
|
|
|
@ -32,8 +32,9 @@ public:
|
|||
SANE_Handle getDevHandle();
|
||||
hgscanner *getScanner();
|
||||
void setDevDisconnect();
|
||||
void checkWrongCorrectItem(int correctType); //1:200dpi-color; 2:200dpi-gray;3:300dpi-color; 4:300dpi-gray;5:600dpi-color; 6:600dpi-gray;
|
||||
void checkDynamicCorrectItem(bool pass, int correctType); //1:200dpi-color; 2:200dpi-gray;3:300dpi-color; 4:300dpi-gray;5:600dpi-color; 6:600dpi-gray;
|
||||
void resetCorrectItems();
|
||||
void updateDistortionItem(bool pass);
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *event) override;
|
||||
|
|
|
@ -310,6 +310,12 @@ void MainWindow::releaseTesting()
|
|||
}
|
||||
}
|
||||
|
||||
void MainWindow::initTestingRef()
|
||||
{
|
||||
m_testingRef = 0;
|
||||
updateActionStatus(true);
|
||||
}
|
||||
|
||||
bool MainWindow::isTesting()
|
||||
{
|
||||
return (m_testingRef != 0);
|
||||
|
@ -317,11 +323,11 @@ bool MainWindow::isTesting()
|
|||
|
||||
void MainWindow::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
if (isTesting())
|
||||
{
|
||||
QMessageBox::information(this, tr("tips"), tr("Is testing, do not close!"));
|
||||
event->ignore();
|
||||
}
|
||||
// if (isTesting())
|
||||
// {
|
||||
// QMessageBox::information(this, tr("tips"), tr("Is testing, do not close!"));
|
||||
// event->ignore();
|
||||
// }
|
||||
}
|
||||
|
||||
int MainWindow::sane_ex_callback(SANE_Handle hdev, int code, void *data, unsigned int *len, void *param)
|
||||
|
@ -362,7 +368,10 @@ int MainWindow::sane_ex_callback(SANE_Handle hdev, int code, void *data, unsigne
|
|||
saneParams->data = content;
|
||||
saneParams->len = *len;
|
||||
|
||||
emit p->sane_create_interface(saneParams);
|
||||
if (code == SANE_EVENT_SCAN_FINISHED)
|
||||
{
|
||||
emit p->sane_create_interface(saneParams);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -453,7 +462,7 @@ void MainWindow::on_sane_dev_remove(QString devName)
|
|||
if (mainInterface != nullptr)
|
||||
{
|
||||
mainInterface->setDevDisconnect();
|
||||
//if (!mainInterface->isTesting())
|
||||
if (!mainInterface->isTesting())
|
||||
{
|
||||
RemoveInterface(mainInterface);
|
||||
}
|
||||
|
@ -475,14 +484,18 @@ void MainWindow::on_sane_create_interface(SaneParams *saneParams)
|
|||
{
|
||||
int type = 0;
|
||||
func_test_correct(true, &type);
|
||||
if (type > 0)
|
||||
{
|
||||
mainInterface->checkDynamicCorrectItem(true, type);
|
||||
}
|
||||
}
|
||||
else if (info == QString(STATU_DESC_SCANNER_ERR_IMAGE_CORRECTION_FAIL))
|
||||
else //if (info == QString(STATU_DESC_SCANNER_ERR_IMAGE_CORRECTION_FAIL))
|
||||
{
|
||||
int type = 0;
|
||||
func_test_correct(false, &type);
|
||||
if (type > 0)
|
||||
{
|
||||
mainInterface->checkWrongCorrectItem(type);
|
||||
mainInterface->checkDynamicCorrectItem(false, type);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ public:
|
|||
void updateActionStatus(bool enable);
|
||||
void addTestingRef();
|
||||
void releaseTesting();
|
||||
void initTestingRef();
|
||||
bool isTesting();
|
||||
QString getDevSn(SANE_Handle handle);
|
||||
|
||||
|
|
|
@ -140,8 +140,6 @@ int get_json_config_file()
|
|||
std::cout << buf << std::endl;
|
||||
}
|
||||
static std::wstring set_test_name_ = L"";
|
||||
//bool is_distortion_get_image = false;
|
||||
//bool is_distortion_get_image_abnormal = false;
|
||||
std::atomic<bool> is_distortion_get_image_abnormal(false);
|
||||
std::atomic<bool> is_distortion_get_image(false);
|
||||
|
||||
|
@ -404,11 +402,11 @@ static int sane_ex_callback(SANE_Handle hdev, int code, void* data, unsigned int
|
|||
is_distortion_get_image = false;
|
||||
is_distortion_get_image_abnormal = true;
|
||||
wcscpy(buf, L"畸变修正值获取失败,原因--->");
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
is_distortion_get_image = true;
|
||||
is_distortion_get_image_abnormal = false;
|
||||
//type = true;
|
||||
//wcscpy(buf, L"畸变修正值获取完成:");
|
||||
break;
|
||||
|
@ -510,6 +508,7 @@ static int sane_ex_callback(SANE_Handle hdev, int code, void* data, unsigned int
|
|||
wcscat(buf, wstr.c_str());
|
||||
//ret = h->io_control(IO_CTRL_CODE_RESTORE_SETTINGS, NULL, NULL);//结束恢复默认
|
||||
|
||||
bool correctFail = false;
|
||||
if (wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_CORRECTION) == 0)
|
||||
{
|
||||
if (g_currentCorrectType == 7)
|
||||
|
@ -521,6 +520,7 @@ static int sane_ex_callback(SANE_Handle hdev, int code, void* data, unsigned int
|
|||
{
|
||||
type = false;
|
||||
h->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)buf, type);
|
||||
correctFail = true;
|
||||
break;
|
||||
}
|
||||
else if (g_dynamicCorrectStatus == SCANNER_ERR_IMAGE_CORRECTION_FINISHED)
|
||||
|
@ -537,6 +537,14 @@ static int sane_ex_callback(SANE_Handle hdev, int code, void* data, unsigned int
|
|||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
if ((strcmp((char*)data, STATU_DESC_SCANNER_ERR_IMAGE_CORRECTION_FINISHED) != 0 && strcmp((char*)data, STATU_DESC_SCAN_STOPPED) != 0) ||
|
||||
g_dynamicCorrectStatus == SCANNER_ERR_IMAGE_CORRECTION_FAIL)
|
||||
{
|
||||
g_dynamicCorrectStatus = SCANNER_ERR_IMAGE_CORRECTION_FAIL;
|
||||
if (!correctFail)
|
||||
h->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)buf, false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -739,13 +747,13 @@ void test::thread_dynamic_correct(std::string correctData)
|
|||
{
|
||||
std::unique_lock<std::mutex> lock(m_lock);
|
||||
while (g_currentCorrectType <= 6)
|
||||
{
|
||||
{
|
||||
if (g_currentCorrectType > 1)
|
||||
m_waitCorrect.wait(lock);
|
||||
|
||||
if (g_currentCorrectType == 0)
|
||||
if (g_currentCorrectType == 0 || g_dynamicCorrectStatus == SCANNER_ERR_IMAGE_CORRECTION_FAIL)
|
||||
{
|
||||
return;
|
||||
break;
|
||||
}
|
||||
|
||||
SANE_Bool type = true;
|
||||
|
@ -775,12 +783,24 @@ void test::thread_distortion()
|
|||
if (ret != SCANNER_ERR_OK)
|
||||
{
|
||||
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)L"自动计算畸变值获取失败", false);
|
||||
return;
|
||||
}
|
||||
|
||||
int cnt = 0;
|
||||
SANE_DISTORTION_VAL dis = { 0 };
|
||||
|
||||
if (is_distortion_get_image_abnormal)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_waitDistortion.wait(lock);
|
||||
|
||||
if (is_distortion_get_image_abnormal)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ret = helper_->io_control(IO_CTRL_CODE_GET_PC_DISTORTION_CHECK_VAL, &dis, &len);
|
||||
|
||||
if (dis.h > 0 && dis.scaleXY < 10)
|
||||
|
@ -1874,6 +1894,7 @@ int test::test_image_correct_all(void* data)
|
|||
}
|
||||
|
||||
g_currentCorrectType = 1;
|
||||
g_dynamicCorrectStatus = SCANNER_ERR_OK;
|
||||
if (thread_dynamic_correct_handle.get() && thread_dynamic_correct_handle->joinable())
|
||||
thread_dynamic_correct_handle->join();
|
||||
thread_dynamic_correct_handle.reset(new std::thread(&test::thread_dynamic_correct, this, str));
|
||||
|
@ -1946,17 +1967,18 @@ DECL_API(int) func_test_uninit(void* uninit)
|
|||
|
||||
DECL_API(int) func_test_correct(bool isSuccess, int *currentIndex)
|
||||
{
|
||||
*currentIndex = g_currentCorrectType - 1;
|
||||
|
||||
if (!isSuccess)
|
||||
{
|
||||
*currentIndex = g_currentCorrectType - 1;
|
||||
if (g_currentCorrectType == 7)
|
||||
//if (g_currentCorrectType == 7)
|
||||
{
|
||||
g_dynamicCorrectStatus = SCANNER_ERR_IMAGE_CORRECTION_FAIL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (g_currentCorrectType == 7)
|
||||
//if (g_currentCorrectType == 7)
|
||||
{
|
||||
g_dynamicCorrectStatus = SCANNER_ERR_IMAGE_CORRECTION_FINISHED;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue