Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions dftarea.cpp

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 1089 emit updateFilterSize(Rad) is old code and overwrote the new code. So this file is not correct.

Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
}
if (poly.size()>0){
for (int n = 0; n < poly.size(); ++n){
cv::Point points[1][poly[n].size()];

Check warning on line 71 in dftarea.cpp

View workflow job for this annotation

GitHub Actions / build-macos (macos-15, arm64)

variable length arrays in C++ are a Clang extension [-Wvla-cxx-extension]

Check warning on line 71 in dftarea.cpp

View workflow job for this annotation

GitHub Actions / build-macos (macos-15, arm64)

variable length arrays in C++ are a Clang extension [-Wvla-cxx-extension]

Check warning on line 71 in dftarea.cpp

View workflow job for this annotation

GitHub Actions / build-macos (macos-15-intel, x86_64)

variable length arrays in C++ are a Clang extension [-Wvla-cxx-extension]

Check warning on line 71 in dftarea.cpp

View workflow job for this annotation

GitHub Actions / build-macos (macos-15-intel, x86_64)

variable length arrays in C++ are a Clang extension [-Wvla-cxx-extension]
for (std::size_t i = 0; i < poly[n].size(); ++i){

points[0][i] = cv::Point(poly[n][i].x, poly[n][i].y);
Expand Down Expand Up @@ -1086,8 +1086,7 @@

}
void DFTArea::mouseMovedExternal(int rad){
double frequencyBin = rad / (static_cast<double>(m_dftsize)/(m_outside.m_radius * 2 * m_scaleFactor));
emit updateFilterSize(rad);
emit updateFilterSize(rad);
}

void DFTArea::mousePressEvent(QMouseEvent *event)
Expand Down
4 changes: 2 additions & 2 deletions igramarea.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@
}
IgramArea::IgramArea(QWidget *parent, void *mw)
: QWidget(parent),m_mw(mw),m_hideOutlines(false),scale(1.),outterPcount(0), innerPcount(0),
zoomIndex(1),dragMode(false),cropTotalDx(0), cropTotalDy(0), hasBeenCropped(false),
m_zoomMode(NORMALZOOM),m_current_boundry(OutSideOutline)
zoomIndex(1),dragMode(false),hasBeenCropped(false), m_zoomMode(NORMALZOOM), m_current_boundry(OutSideOutline),
cropTotalDx(0),cropTotalDy(0)
{
leftMargin = 0;
searchOutlineScale = 1.;
Expand Down Expand Up @@ -977,7 +977,7 @@
}
}
}
bool IgramArea::openImage(QImage loadedImage, bool showBoundary, QString fileName){

Check warning on line 980 in igramarea.cpp

View workflow job for this annotation

GitHub Actions / build-linux-clazy (ubuntu-24.04)

Missing reference on large type (sizeof class QString is 24 bytes) [-Wclazy-function-args-by-ref]

if (Settings2::getInstance()->m_igram->m_removeDistortion){
cv::Mat raw = cv::imread(fileName.toStdString().c_str());
Expand Down Expand Up @@ -1013,7 +1013,7 @@

}
if (mirrorDlg::get_Instance()->shouldFlipH())
loadedImage = loadedImage.mirrored(true,false);

Check warning on line 1016 in igramarea.cpp

View workflow job for this annotation

GitHub Actions / build-macos (macos-15, arm64)

'mirrored' is deprecated: Use flipped(Qt::Orientations) instead [-Wdeprecated-declarations]

Check warning on line 1016 in igramarea.cpp

View workflow job for this annotation

GitHub Actions / build-macos (macos-15-intel, x86_64)

'mirrored' is deprecated: Use flipped(Qt::Orientations) instead [-Wdeprecated-declarations]
hasBeenCropped = false;
needToConvertBGR = true;
//m_demo->hide();
Expand Down Expand Up @@ -2443,7 +2443,7 @@
qWarning("Couldn't save .OLN (outline) file.");
return;
}
QFileInfo info(saveFile);

Check warning on line 2446 in igramarea.cpp

View workflow job for this annotation

GitHub Actions / build-linux-clazy (ubuntu-24.04)

unused QFileInfo [-Wclazy-unused-non-trivial-variable]
saveFile.write(jsondoc.toJson());
saveFile.close();

Expand Down
167 changes: 150 additions & 17 deletions liveviewdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include <QTextBrowser>
#include <QFile>
#include "zernikes.h"

#include <QInputDialog>


// ==========================================
Expand Down Expand Up @@ -76,6 +76,8 @@
connect(this, &LiveViewDialog::requestChangeSource, m_worker, &VideoStreamWorker::changeSource, Qt::QueuedConnection);
connect(this, &LiveViewDialog::requestSetResolution, m_worker, &VideoStreamWorker::setResolution, Qt::QueuedConnection);
connect(this, &LiveViewDialog::requestFrame, m_worker, &VideoStreamWorker::fetchNextFrame, Qt::QueuedConnection);
connect(this, &LiveViewDialog::requestCameraSetting, m_worker, &VideoStreamWorker::requestCameraSetting);


// Trigger the very first frame pull once the worker confirms the stream is open
connect(m_worker, &VideoStreamWorker::streamStarted, this, [this]() {
Expand All @@ -86,6 +88,49 @@
Q_ARG(int, selectedRes.height()));
statusLeft->setText("Stream Connected");

//
// brightness/gain slider
//

double gain;
bool bAvailable;
bAvailable = m_worker->getCameraGainRange(m_gain_mode, m_gainMinimum, m_gainMaximum, gain);
if (m_gainMaximum != m_gainMinimum)
m_gain_scale = 20/(m_gainMaximum - m_gainMinimum);

m_brightnessSlider->blockSignals(true);
m_brightnessSlider->setEnabled(bAvailable);
m_brightnessSlider->setRange(floor(m_gainMinimum * m_gain_scale), ceil(m_gainMaximum * m_gain_scale));
m_brightnessSlider->setValue(round(gain * m_gain_scale));
m_brightnessSlider->blockSignals(false);


//
// exposure slider
//

double exp;
bAvailable = m_worker->getCameraExposureRange(m_exposureMinimum, m_exposureMaximum,exp);
if (m_exposureMaximum != m_exposureMinimum)
m_exposure_scale = 20/(m_exposureMaximum - m_exposureMinimum);
m_exposureSlider->blockSignals(true);
m_exposureSlider->setEnabled(bAvailable);
m_exposureSlider->setRange(floor(m_exposureMinimum * m_exposure_scale), ceil(m_exposureMaximum * m_exposure_scale));
m_exposureSlider->setValue(round(exp * m_exposure_scale));
m_exposureSlider->blockSignals(false);

// auto exposure checkbox
bool bAuto;
m_worker->getAutoExpSetting(bAvailable, bAuto);
m_autoExposureCheck->blockSignals(true);
if (bAvailable == false) {
m_autoExposureCheck->setEnabled(false);
} else {
m_autoExposureCheck->setChecked(bAuto);
}
m_autoExposureCheck->blockSignals(false);


//emit requestFrame();
// Configure it once during initialization
m_throttle.setSingleShot(true);
Expand Down Expand Up @@ -172,6 +217,10 @@
event->ignore();
}

double clamp_within(double val, double _min, double _max) {
return fmin(fmax(val, _min), _max); // keep val between min and max
}

void LiveViewDialog::setupUI(const QString &defaultStreamUrl) {
setWindowTitle("DFTFringe - Live View");

Expand All @@ -190,9 +239,9 @@

averageMode = new QCheckBox("Compute and show average when loop is running", this);
averageMode->setChecked(set.value("liveViewAverageMode", false).toBool());
connect(averageMode, &QCheckBox::stateChanged, this,[](int val){

Check warning on line 242 in liveviewdialog.cpp

View workflow job for this annotation

GitHub Actions / build-macos (macos-15, arm64)

'stateChanged' is deprecated: Use checkStateChanged() instead [-Wdeprecated-declarations]

Check warning on line 242 in liveviewdialog.cpp

View workflow job for this annotation

GitHub Actions / build-DFTFringe

'void QCheckBox::stateChanged(int)' is deprecated: Use checkStateChanged() instead [-Wdeprecated-declarations]

Check warning on line 242 in liveviewdialog.cpp

View workflow job for this annotation

GitHub Actions / build-macos (macos-15-intel, x86_64)

'stateChanged' is deprecated: Use checkStateChanged() instead [-Wdeprecated-declarations]
QSettings set;
set.setValue("liveViewAverageMode",val);
set.setValue("liveViewAverageMode", val);
});

maxRMS = new QDoubleSpinBox(this);
Expand Down Expand Up @@ -343,23 +392,89 @@
dftLayout->addWidget(vivid);
sidebarLayout->addWidget(DFTGroup);
// Camera Hardware Sliders (Brightness / Exposure)
sidebarLayout->addWidget(new QLabel("Brightness:", this));
brightnessSlider = new QSlider(Qt::Horizontal, this);
brightnessSlider->setRange(-64, 64);
brightnessSlider->setValue(0);
connect(brightnessSlider, &QSlider::valueChanged, this, [this](int val) {
emit requestCameraSetting(CameraProperty::Brightness, val);
sidebarLayout->addWidget(new QLabel("Gain:", this));

//
// brightness slider
//

m_brightnessSlider = new QSlider(Qt::Horizontal, this);
m_brightnessSlider->setRange(-64, 64);
m_brightnessSlider->setValue(0);
connect(m_brightnessSlider, &QSlider::valueChanged, this, [this](int val) {
// this was too slow: emit requestCameraSetting("Gain", clamp_within(val / m_gain_scale, m_gainMinimum, m_gainMaximum));
m_worker->requestCameraSetting("Gain", clamp_within(val / m_gain_scale, m_gainMinimum, m_gainMaximum));
});
m_brightnessSlider->installEventFilter(this);
connect(this, &LiveViewDialog::gainSliderRightClicked, this, [this]() {
// User right clicked slider
bool ok;
QString currentVal="";
struct VideoStreamWorker::CameraConfiguration config;
if (m_worker != nullptr && m_worker->getCameraConfiguration(config))
currentVal = QString("%1").arg(config.gain);
QString text = QInputDialog::getText(this, "Gain",
QString("Gain (%1 to %2)").arg(m_gainMinimum).arg(m_gainMaximum),
QLineEdit::Normal,
currentVal, &ok);
if (ok && !text.isEmpty()) {
// User clicked OK and entered a value, use 'text' here
bool ok;
double val = text.toDouble(&ok);
if (ok)
emit requestCameraSetting("Gain", val);
}
});
sidebarLayout->addWidget(brightnessSlider);


sidebarLayout->addWidget(m_brightnessSlider);

QHBoxLayout *exposureGroupLayout = new QHBoxLayout();

//
// exposure slider
//

sidebarLayout->addWidget(new QLabel("Exposure / Shutter:", this));
QSlider *exposureSlider = new QSlider(Qt::Horizontal, this);
exposureSlider->setRange(-13, 0);
exposureSlider->setValue(-6);
connect(exposureSlider, &QSlider::valueChanged, this, [this](int val) {
emit requestCameraSetting(CameraProperty::Exposure, val);
m_exposureSlider = new QSlider(Qt::Horizontal, this);
m_exposureSlider->setRange(-16, 0);
m_exposureSlider->setValue(-6);
connect(m_exposureSlider, &QSlider::valueChanged, this, [this](int val) {
// this was too slow: emit requestCameraSetting("Exposure", clamp_within(val / m_exposure_scale, m_exposureMinimum, m_exposureMaximum));
m_worker->requestCameraSetting("Exposure", clamp_within(val / m_exposure_scale, m_exposureMinimum, m_exposureMaximum));
});
sidebarLayout->addWidget(exposureSlider);
m_exposureSlider->installEventFilter(this);
connect(this, &LiveViewDialog::expSliderRightClicked, this, [this]() {
// User right clicked slider
bool ok;
QString currentVal="";
struct VideoStreamWorker::CameraConfiguration config;
if (m_worker != nullptr && m_worker->getCameraConfiguration(config))
currentVal = QString("%1").arg(config.exposure);
QString text = QInputDialog::getText(this, "Exposure",
QString("Exposure (%1 to %2)").arg(m_exposureMinimum).arg(m_exposureMaximum),
QLineEdit::Normal,
currentVal, &ok);
if (ok && !text.isEmpty()) {
// User clicked OK and entered a value, use 'text' here
bool ok;
double val = text.toDouble(&ok);
if (ok)
emit requestCameraSetting("Exposure", val);
}
});
exposureGroupLayout->addWidget(m_exposureSlider, 1);

// auto exposure checkbox
m_autoExposureCheck = new QCheckBox("Auto", this);
connect(m_autoExposureCheck, &QCheckBox::stateChanged, this, [this]() {

Check warning on line 470 in liveviewdialog.cpp

View workflow job for this annotation

GitHub Actions / build-DFTFringe

'void QCheckBox::stateChanged(int)' is deprecated: Use checkStateChanged() instead [-Wdeprecated-declarations]
m_worker->setAutoExpSetting(m_autoExposureCheck->isChecked());
});

exposureGroupLayout->addWidget(m_autoExposureCheck,0);

sidebarLayout->addLayout(exposureGroupLayout);


sidebarLayout->addStretch(1);

Expand Down Expand Up @@ -529,7 +644,7 @@
}
});
QHBoxLayout *connectTimeoutLayout = new QHBoxLayout();
connectTimeoutLayout->addWidget(new QLabel("number of blank frames before connect failes:"));
connectTimeoutLayout->addWidget(new QLabel("number of blank frames before connect fails:"));
QSpinBox *frameTimeout = new QSpinBox(connectGroup);
frameTimeout->setValue(settings.value("liveViewConnectFrames",15).toInt());
connectTimeoutLayout->addWidget(frameTimeout);
Expand Down Expand Up @@ -661,7 +776,6 @@
// Tell the worker thread to switch sources safely

if (m_worker) {

qDebug() << "apply emitting requestChangeSource:" << newUrl;
emit requestChangeSource(newUrl);
}
Expand Down Expand Up @@ -1100,3 +1214,22 @@
setFitToWindowZoom();
}

bool LiveViewDialog::eventFilter(QObject *obj, QEvent *event) {
// Check if the event comes from an object we care about
if (event->type() == QEvent::MouseButtonPress) {
QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);

// Check if it was a right-click
if (mouseEvent->button() == Qt::RightButton) {
if (obj == m_exposureSlider)
emit expSliderRightClicked();
if (obj == m_brightnessSlider)
emit gainSliderRightClicked();

return true; // Handled the event, don't pass it further
}
}

// Pass unhandled events to the base class
return QWidget::eventFilter(obj, event);
}
24 changes: 15 additions & 9 deletions liveviewdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,7 @@
#include "liveviewhistory.h"
#include <QSplitter>
class FrameProcessorWorker;
enum class CameraProperty {
Brightness,
Contrast,
Exposure, // Shutter speed
Gain
};
Q_DECLARE_METATYPE(CameraProperty)

class ResizableScrollArea : public QScrollArea {
Q_OBJECT
public:
Expand All @@ -51,8 +45,8 @@ class LiveViewDialog : public QDialog {
protected:
void closeEvent(QCloseEvent *event) override;
void resizeEvent(QResizeEvent *event) override;
bool eventFilter(QObject *obj, QEvent *event) override;
private slots:

void onResolutionChanged(int index);
void onZoomChanged(int index);
void setFitToWindowZoom();
Expand All @@ -66,13 +60,15 @@ public slots:
void onGrabClicked();
void setCenterFilter(double freqBin) ;
signals:
void gainSliderRightClicked();
void expSliderRightClicked();
void igramCaptured();
void streamDisconnected();
void requestChangeSource(QString newSource);
void requestSetResolution(int width, int height);
void stopLiveLoopRequested();
void requestFrame();
void requestCameraSetting(CameraProperty prop , int val);
void requestCameraSetting(QString prop , double val);
void outline(QPointF center, double rad);
void blueCircle(double rad);
void autoOutLine();
Expand Down Expand Up @@ -159,4 +155,14 @@ public slots:
QTimer m_throttle;
double m_binToBinScale = 1.;
QRect m_normalGeometry;
double m_exposureMinimum=-16;
double m_exposureMaximum=3;
double m_gainMinimum=0;
double m_gainMaximum=255;
bool m_gain_mode;
double m_gain_scale=1;
double m_exposure_scale=1;
QSlider * m_exposureSlider = nullptr;
QSlider * m_brightnessSlider = nullptr;
QCheckBox * m_autoExposureCheck = nullptr;
};
3 changes: 1 addition & 2 deletions mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2109,7 +2109,6 @@ void MainWindow::on_autoOutlineHelp_clicked()
QString link = qApp->applicationDirPath() + "/res/Help/outlineing.html";
QDesktopServices::openUrl(QUrl(link));
}
#include "transformwavefrontdlg.h"
void MainWindow::on_actionwave_front_transforms_triggered()
{
m_surfaceManager->transform();
Expand Down Expand Up @@ -2372,7 +2371,7 @@ void MainWindow::on_actionLive_view_triggered()
m_viewDlg->m_tmpShowLive = false;

});
connect(m_igramArea, &IgramArea::boundary, this, [this](CircleOutline outside, bool cropped, QPointF offset, CircleOutline inside) {
connect(m_igramArea, &IgramArea::boundary, this, [this](CircleOutline outside, bool cropped, QPointF offset) {

if (cropped){
outside.translate(offset);
Expand Down
Loading
Loading