[education/kstars] kstars/ekos/focus: fix: Focus::autoFocusLinear and scanStartPos passing measure as weight
Jasem Mutlaq <[email protected]>
| Newsgroups | gmane.comp.kde.cvs |
|---|---|
| Message-ID | <[email protected]> |
Git commit 031d945d3911bf8281c86a5eb4f6687f8acce07d by Jasem Mutlaq, on behalf of Thomas Nemer.
Committed on 18/07/2026 at 18:46.
Pushed by mutlaqja into branch 'master'.
fix: Focus::autoFocusLinear and scanStartPos passing measure as weight
Two callsites passed getLastMeasure() into a weight slot instead of
getLastWeight():
* autoFocusLinear() called
linearFocuser->newMeasurement(position, value, starWeight, stars)
with getLastMeasure() in both the value and starWeight slots. The
Linear / Linear1Pass curve fitter therefore weighted every point by
its own HFR instead of by getLastWeight(), corrupting the V-curve fit
and the weights exposed via Focus Advisor's getPass1Measurements
consumer.
* scanStartPos() emitted newHFRPlotPosition with pow(getLastMeasure(),
-0.5) where every other emit site uses pow(weight, -0.5). The V-curve
scan markers therefore had wrong sizes/transparencies.
Both regressed in 796e6da58482 ("Draft: Focus history navigation"),
which introduced getLastWeight() in the same change but did not switch
these two callsites over.
M +5 -2 kstars/ekos/focus/focus.cpp
https://invent.kde.org/education/kstars/-/commit/031d945d3911bf8281c86a5eb4f6687f8acce07d
diff --git a/kstars/ekos/focus/focus.cpp b/kstars/ekos/focus/focus.cpp
index 88bcee7ba7..795e933600 100644
--- a/kstars/ekos/focus/focus.cpp
+++ b/kstars/ekos/focus/focus.cpp
@@ -1603,12 +1603,14 @@ CaptureHistory::FrameData Focus::calculateCurrentMeasureAndWeight()
getFWHM(m_ImageData->getStarCenters(), &newFWHM, &newWeight);
frameData.fwhm = newFWHM;
frameData.measure = newFWHM;
+ frameData.weight = newWeight;
}
else if (m_StarMeasure == FOCUS_STAR_FOURIER_POWER)
{
getFourierPower(&newFourierPower, &newWeight);
frameData.measure = newFourierPower;
+ frameData.weight = newWeight;
}
else if (m_StarMeasure == FOCUS_STAR_STDDEV || m_StarMeasure == FOCUS_STAR_SOBEL ||
m_StarMeasure == FOCUS_STAR_LAPLASSIAN || m_StarMeasure == FOCUS_STAR_CANNY)
@@ -1618,6 +1620,7 @@ CaptureHistory::FrameData Focus::calculateCurrentMeasureAndWeight()
roi = m_FocusView->isTrackingBoxEnabled() ? m_FocusView->getTrackingBox() : QRect();
getBlurriness(m_StarMeasure, m_OpsFocusProcess->focusDenoise->isChecked(), &newBlurriness, &newWeight, roi);
frameData.measure = newBlurriness;
+ frameData.weight = newWeight;
}
else
{
@@ -3874,7 +3877,7 @@ void Focus::scanStartPos()
const int step = m_scanPosition.size();
const int maxSteps = m_OpsFocusProcess->focusScanDatapoints->value();
const int stepSize = m_OpsFocusMechanics->focusTicks->value() * m_OpsFocusProcess->focusScanStepSizeFactor->value();
- Q_EMIT newHFRPlotPosition(static_cast<double>(currentPosition), getLastMeasure(), pow(getLastMeasure(), -0.5), false,
+ Q_EMIT newHFRPlotPosition(static_cast<double>(currentPosition), getLastMeasure(), pow(getLastWeight(), -0.5), false,
stepSize,
true);
if (step < maxSteps)
@@ -3938,7 +3941,7 @@ void Focus::autoFocusLinear()
&& m_OpsFocusProcess->focusFramesCount->value() == 1;
auto focusStars = useFocusStarsHFR || (m_FocusAlgorithm == FOCUS_LINEAR1PASS) ? &(m_ImageData->getStarCenters()) : nullptr;
- linearRequestedPosition = linearFocuser->newMeasurement(currentPosition, getLastMeasure(), getLastMeasure(), focusStars);
+ linearRequestedPosition = linearFocuser->newMeasurement(currentPosition, getLastMeasure(), getLastWeight(), focusStars);
if (m_FocusAlgorithm == FOCUS_LINEAR1PASS && linearFocuser->isDone() && linearFocuser->solution() != -1)
{
// Linear 1 Pass is done, graph is drawn, so just move to the focus position, and update the graph.