void MainWindow::getResultofScaleUp(std::string filename) { ImageStorage* imgstore = ImageStorage::getInstance(); if (imgstore->isEmpty()) { QMessageBox::warning(this, tr("Error"), tr("No image...")); return; } std::pair<const std::string, Ui::SrcAndRes>* pos = imgstore->find(filename); cv::Mat results = controller->getLastResult(); std::string s_name = pos->first; s_name.append("_label"); QString qname = QString::fromStdString(s_name); QString pageName = QString::fromStdString(filename); QWidget * t = ui->imageTab->findChild<QWidget*>(pageName); QString s = t->objectName(); QLabel * label = t->findChild<QLabel *>(qname); ASSERT(label != nullptr); displayImg(results, label); std::get<1>(pos->second) = results.clone(); std::get<2>(pos->second).push_back(results.clone()); ui->goBtn->setEnabled(true); //ui->processBtn->setEnabled(true); ui->showDiffBtn->setEnabled(true); ui->loadCfBtn->setEnabled(true); }
int main() { int img[M][N] = { {0,2,3,4,5,6,7,8,9,10}, {1,2,3,4,5,6,7,8,9,10}, {1,2,3,4,5,6,7,8,9,10}, {1,2,3,4,5,6,7,8,9,10}, {1,2,3,4,5,6,7,8,9,10}, {1,2,3,4,5,6,7,8,9,10}, {1,2,3,4,5,6,7,8,9,10}, {1,2,3,4,5,6,7,8,9,0} }; displayImg(img, M); setZero(img, M); displayImg(img, M); return 0; }
void MainWindow::on_hNextBtn_clicked() { ui->hPrevBtn->setEnabled(true); Vernier * vnr = Vernier::getInstance(); //vnr->decrease(); vnr->increase(); /* get a copy of history */ ImageStorage* imgstore = ImageStorage::getInstance(); std::pair<const std::string, Ui::SrcAndRes>* current = imgstore->getCurrent(); Ui::Images* histories = &(std::get<2>(current->second)); int index = vnr->getCurrentIdx(); displayImg((*histories)[index], ui->labelHistory); //if (vnr->getCurrentIdx() == 0) if (vnr->getCurrentIdx() == vnr->getLength() - 1) { ui->hNextBtn->setEnabled(false); } QCoreApplication::processEvents(); }
void MainWindow::setUpHistoryTab() { ui->labelHistory->clear(); if (! ui->historyTab->isHidden()) { ui->hNextBtn->setEnabled(false); ui->hPrevBtn->setEnabled(false); ui->hSaveBtn->setEnabled(false); /* get a copy of history */ ImageStorage* imgstore = ImageStorage::getInstance(); std::pair<const std::string, Ui::SrcAndRes>* current = imgstore->getCurrent(); /* -- */ if (/*!imgstore->isEmpty() &&*/ current != nullptr) { Ui::Images* histories = &(std::get<2>(current->second)); Vernier * vnr = Vernier::getInstance(); if (vnr->init(histories->size())) { ui->hSaveBtn->setEnabled(true); // to be done... displayImg((*histories)[histories->size() - 1], ui->labelHistory); // if (vnr->getCurrentIdx() > 0/*< vnr->getLength() - 1*/) { ui->hPrevBtn->setEnabled(true); } } } } else { ASSERT(0); } }
void MainWindow::on_processBtn_clicked() { try { // set up input img ImageStorage* imgstore = ImageStorage::getInstance(); std::pair<const std::string, Ui::SrcAndRes>* current = imgstore->getCurrent(); if (current == nullptr) { return; } if (controller) { int stat = controller->setInputImage(current->first, std::get<1>(current->second)); //QMessageBox mbox; switch (stat) { case success: break; case not3Channels: QMessageBox::warning(this, tr("Error"), tr("Input Image has no 3 channels")); break; case notSingleChannel: QMessageBox::warning(this, tr("Error"), tr("Input Image is not single-channel")); break; default: break; } if (stat == success) { /* newly added 2013.8.10 */ std::string subClassName = typeid(*controller).name(); if (subClassName == "class CSisrController") { if (ui->goBtn->isEnabled()) { ui->goBtn->clicked(); } } else { // do ... controller->process(); cv::Mat results = controller->getLastResult(); //int c = results.channels(); std::string s_name = current->first; s_name.append("_label"); QString qname = QString::fromStdString(s_name); QWidget * t = ui->imageTab->currentWidget(); QString s = t->objectName(); QLabel * label = ui->imageTab->currentWidget()->findChild<QLabel *>(qname); ASSERT(label != nullptr); displayImg(results, label); std::get<1>(current->second) = results.clone(); std::get<2>(current->second).push_back(results.clone()); } } else { /* mbox.setText("Error! Input image is broken!"); mbox.exec();*/ } } else { QMessageBox::warning(this, tr("Error"), tr("Please select parameters first!")); } } catch(CSisr::SisrExcept& e) { QMessageBox::warning(this, tr("Exception"), "Currently there are no over-complete dics loaded...\nPlease load config file or train the dics"); } catch(cv::Exception& e) { QMessageBox::warning(this, tr("Exception"), tr(e.what())); } catch(...) { QMessageBox::warning(this, tr("Exception"), tr("Unknown exception occurs...")); } }