diff --git a/MAClient.desktop b/MAClient.desktop index 0df78d2..1fc181f 100644 --- a/MAClient.desktop +++ b/MAClient.desktop @@ -6,7 +6,7 @@ Version=1.0 # The name of the application Name=Lubricant Thickness Detector # A comment which can/will be used as a tooltip -Comment=MAClient +Comment=MAClient -sd 0 -t 30 # The executable of the application, possibly with arguments. Exec=MAClient # The name of the icon that will be used to display this entry diff --git a/src/main.cpp b/src/main.cpp index 8cfa4e1..e0b4b78 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -84,6 +84,8 @@ int main(int argc, char *argv[]) parser.addOption(quirkDurationOption); QCommandLineOption cameraBootDurationOption(QStringList() << "t" << "boot-duration", QCoreApplication::translate("main", "Camera boot time"), QCoreApplication::translate("main", "time")); parser.addOption(cameraBootDurationOption); + QCommandLineOption viewerOption(QStringList() << "c" << "viewer", QCoreApplication::translate("main", "Open app as viewer")); + parser.addOption(viewerOption); parser.process(a); QSplashScreen splash(QPixmap(":/images/splash.png")); @@ -99,7 +101,7 @@ int main(int argc, char *argv[]) QSettings settings(QSettings::IniFormat, QSettings::UserScope, QCoreApplication::organizationName(), QCoreApplication::applicationName()); - if(uvosledRet >= 0) + if(uvosledRet >= 0 && !parser.isSet(viewerOption)) { qDebug()<<"uvosled_poweron"; uvosled_poweron(&led); @@ -118,7 +120,7 @@ int main(int argc, char *argv[]) if(parser.isSet(quirkDurationOption)) cameras.quirkTime = parser.value(quirkDurationOption).toDouble(); - MainWindow w; + MainWindow w(parser.isSet(viewerOption)); QObject::connect(&cameras, &Cameras::cameraAdded, &w, &MainWindow::addCamera); QObject::connect(&cameras, &Cameras::cameraRemoved, &w, &MainWindow::removeCamera); @@ -159,10 +161,10 @@ int main(int argc, char *argv[]) splash.hide(); w.show(); - if(uvosledRet < 0) + if(uvosledRet < 0 && !parser.isSet(viewerOption)) QMessageBox::warning(&w, "UVOS LED", "Can not connect to the UVOS LED device"); - if(cameras.getCameras().empty()) + if(!parser.isSet(viewerOption) && cameras.getCameras().empty()) { QMessageBox::information(&w, "Cameras", "No cameras configured, please choose at least one camera."); cameras.setCameras(showCameraSelectionDialog()); diff --git a/src/ui/configurecameradialog.cpp b/src/ui/configurecameradialog.cpp index 902ac68..eee19f4 100644 --- a/src/ui/configurecameradialog.cpp +++ b/src/ui/configurecameradialog.cpp @@ -95,10 +95,10 @@ void ConfigureCameraDialog::bayerIndexChanged(int index) setup_.bayerMode = cam::Camera::BAYER_BLUE; break; case 1: - setup_.bayerMode = cam::Camera::BAYER_RED; + setup_.bayerMode = cam::Camera::BAYER_GREEN; break; case 2: - setup_.bayerMode = cam::Camera::BAYER_GREEN; + setup_.bayerMode = cam::Camera::BAYER_RED; break; case 3: setup_.bayerMode = cam::Camera::BAYER_PASSTHOUGH; diff --git a/src/ui/cvimageviewer.cpp b/src/ui/cvimageviewer.cpp index fab68d6..f677b24 100644 --- a/src/ui/cvimageviewer.cpp +++ b/src/ui/cvimageviewer.cpp @@ -90,6 +90,14 @@ void CvImageViewer::showSatDiag() diag.exec(); } +void CvImageViewer::setClamp(double max) +{ + clamp_ = max; + convertImage(origImage_); + update(); + roi_ = cv::Rect(0, 0, image_.size().width, image_.size().height); +} + void CvImageViewer::convertImage(cv::Mat image) { image_ = image; @@ -107,6 +115,13 @@ void CvImageViewer::convertImage(cv::Mat image) { double min, max; cv::minMaxIdx(image_, &min, &max); + sigMax(max); + if(max > clamp_) + { + max = clamp_; + + qDebug()<<"clamped to"< clamp_) + max = clamp_; double a = 255.0/(max - min); double b = 0-(min*a); qDebug()< #include #include +#include +#include #include "../cameras.h" class CvImageViewer : public QWidget @@ -25,6 +27,7 @@ private: cv::Rect roi_; QRect selectionRect_; bool selectionStarted_ = false; + double clamp_ = std::numeric_limits::max(); void transfromToSourceCoordinates(int inX, int inY, int& outX, int& outY); void convertImage(cv::Mat image); @@ -44,9 +47,11 @@ protected: signals: void sigValue(size_t x, size_t y, double value); + void sigMax(double max); public slots: void setImage(Camera::Image img); + void setClamp(double max); public: explicit CvImageViewer(QWidget *parent = nullptr, size_t lastId = 0); diff --git a/src/ui/mainwindow.cpp b/src/ui/mainwindow.cpp index bb30fa3..454878f 100644 --- a/src/ui/mainwindow.cpp +++ b/src/ui/mainwindow.cpp @@ -7,7 +7,7 @@ #include "../profile.h" -MainWindow::MainWindow(QWidget *parent) +MainWindow::MainWindow(bool viewer, QWidget *parent) : QMainWindow(parent) , about_(this) , ui(new Ui::MainWindow) @@ -24,8 +24,17 @@ MainWindow::MainWindow(QWidget *parent) connect(ui->actionOpen, &QAction::triggered, [this](bool checked){(void)checked; openImage();}); connect(ui->actionSave_2, &QAction::triggered, [this](bool checked){(void)checked; saveImage();}); connect(ui->actionAbout, &QAction::triggered, [this](bool checked){(void)checked; about_.show();}); + connect(ui->horizontalSlider_max, &QSlider::sliderMoved, [this](double value){ui->mainViewer->setClamp(value/10.0);}); + connect(ui->mainViewer, &CvImageViewer::sigMax, [this](double max){ui->horizontalSlider_max->setMaximum(max*10.0);}); refreshProfiles(); + + if(viewer) + { + ui->groupBoxCameras->setVisible(false); + ui->groupBox_3->setVisible(false); + } } + void MainWindow::setImageValue(size_t x, size_t y, double value) { ui->lcdNumber_3->display((double)x); diff --git a/src/ui/mainwindow.h b/src/ui/mainwindow.h index effa831..21bf98d 100644 --- a/src/ui/mainwindow.h +++ b/src/ui/mainwindow.h @@ -42,7 +42,7 @@ public slots: void setTemperature(double temp); public: - MainWindow(QWidget *parent = nullptr); + MainWindow(bool viewer = false, QWidget *parent = nullptr); ~MainWindow(); CvImageViewer* mainImageViewer(); diff --git a/src/ui/mainwindow.ui b/src/ui/mainwindow.ui index a662687..0cd5df6 100644 --- a/src/ui/mainwindow.ui +++ b/src/ui/mainwindow.ui @@ -6,8 +6,8 @@ 0 0 - 800 - 600 + 1042 + 635 @@ -42,8 +42,8 @@ 0 0 - 182 - 483 + 244 + 518 @@ -74,8 +74,8 @@ 0 0 - 563 - 282 + 743 + 289 @@ -135,6 +135,39 @@ + + + + 0 + + + 0 + + + + + Render scale + + + + + + + 100 + + + 1 + + + 100 + + + Qt::Horizontal + + + + + @@ -227,7 +260,7 @@ 0 0 - 800 + 1042 32