add support for chaning cvimage scaleing in ui
cahnge .desktop exec params
This commit is contained in:
@ -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
|
||||
|
10
src/main.cpp
10
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());
|
||||
|
@ -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;
|
||||
|
@ -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_;
|
||||
}
|
||||
double a = 255.0/(max - min);
|
||||
double b = 0-(min*a);
|
||||
qDebug()<<min<<max<<a<<b;
|
||||
@ -118,6 +133,9 @@ void CvImageViewer::convertImage(cv::Mat image)
|
||||
{
|
||||
double min, max;
|
||||
cv::minMaxIdx(image_, &min, &max);
|
||||
sigMax(max);
|
||||
if(max > clamp_)
|
||||
max = clamp_;
|
||||
double a = 255.0/(max - min);
|
||||
double b = 0-(min*a);
|
||||
qDebug()<<min<<max<<a<<b;
|
||||
|
@ -4,6 +4,8 @@
|
||||
#include <QWidget>
|
||||
#include <QPainter>
|
||||
#include <QMenu>
|
||||
#include <QSlider>
|
||||
#include <limits>
|
||||
#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<double>::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);
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
|
||||
|
@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>600</height>
|
||||
<width>1042</width>
|
||||
<height>635</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -42,8 +42,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>182</width>
|
||||
<height>483</height>
|
||||
<width>244</width>
|
||||
<height>518</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_7">
|
||||
@ -74,8 +74,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>563</width>
|
||||
<height>282</height>
|
||||
<width>743</width>
|
||||
<height>289</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_6">
|
||||
@ -135,6 +135,39 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Render scale</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSlider" name="horizontalSlider_max">
|
||||
<property name="maximum">
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="pageStep">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
@ -227,7 +260,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<width>1042</width>
|
||||
<height>32</height>
|
||||
</rect>
|
||||
</property>
|
||||
|
Reference in New Issue
Block a user