summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJasem Mutlaq <mutlaqja@ikarustech.com>2016-08-21 09:49:26 (GMT)
committerJasem Mutlaq <mutlaqja@ikarustech.com>2016-08-21 09:49:26 (GMT)
commite9fc373200beabc5c9e9c15001b41174c66e91ec (patch)
tree32c547a69042c475f0d060522f6bcc69332f632a
parenta29536ce3a2e40ef08794915c203bf0dfc4c9d07 (diff)
Add threshold and average frame options to improve focusing verstality
-rw-r--r--kstars/ekos/focus.cpp46
-rw-r--r--kstars/ekos/focus.h10
-rw-r--r--kstars/ekos/focus.ui173
-rw-r--r--kstars/kstars.kcfg8
4 files changed, 179 insertions, 58 deletions
diff --git a/kstars/ekos/focus.cpp b/kstars/ekos/focus.cpp
index 43b1ae3..1456c61 100644
--- a/kstars/ekos/focus.cpp
+++ b/kstars/ekos/focus.cpp
@@ -94,6 +94,7 @@ Focus::Focus()
currentFilterIndex=-1;
minPos=1e6;
maxPos=0;
+ frameNum=0;
connect(startFocusB, SIGNAL(clicked()), this, SLOT(start()));
connect(stopFocusB, SIGNAL(clicked()), this, SLOT(checkStopFocus()));
@@ -215,6 +216,11 @@ Focus::Focus()
suspendGuideCheck->setChecked(Options::suspendGuiding());
lockFilterCheck->setChecked(Options::lockFocusFilter());
focusDarkFrameCheck->setChecked(Options::focusDarkFrame());
+ thresholdSpin->setValue(Options::focusThreshold());
+ focusFramesSpin->setValue(Options::focusFrames());
+
+ connect(thresholdSpin, SIGNAL(valueChanged(double)), this, SLOT(setThreshold(double)));
+ connect(focusFramesSpin, SIGNAL(valueChanged(int)), this, SLOT(setFrames(int)));
}
Focus::~Focus()
@@ -638,6 +644,7 @@ void Focus::start()
inAutoFocus = true;
m_autoFocusSuccesful = false;
+ frameNum=0;
resetButtons();
@@ -666,7 +673,7 @@ void Focus::start()
Options::setAutoSelectStar(kcfg_autoSelectStar->isChecked());
Options::setSuspendGuiding(suspendGuideCheck->isChecked());
Options::setLockFocusFilter(lockFilterCheck->isChecked());
- Options::setFocusDarkFrame(focusDarkFrameCheck->isChecked());
+ Options::setFocusDarkFrame(focusDarkFrameCheck->isChecked());
if (Options::focusLogging())
qDebug() << "Focus: Starting focus with pulseDuration " << pulseDuration;
@@ -720,6 +727,7 @@ void Focus::abort()
//starSelected= false;
minimumRequiredHFR = -1;
noStarCount = 0;
+ frameNum=0;
//maxHFR=1;
disconnect(currentCCD, SIGNAL(BLOBUpdated(IBLOB*)), this, SLOT(newFITS(IBLOB*)));
@@ -1020,7 +1028,24 @@ void Focus::newFITS(IBLOB *bp)
}*/
if (Options::focusLogging())
- qDebug() << "Focus newFITS: Current HFR " << currentHFR;
+ qDebug() << "Focus newFITS #" << frameNum+1 << ": Current HFR " << currentHFR;
+
+ HFRFrames[frameNum++] = currentHFR;
+
+ if (frameNum >= focusFramesSpin->value())
+ {
+ currentHFR=0;
+ for (int i=0; i < frameNum; i++)
+ currentHFR+= HFRFrames[i];
+
+ currentHFR /= frameNum;
+ frameNum =0;
+ }
+ else
+ {
+ capture();
+ return;
+ }
HFRText = QString("%1").arg(currentHFR, 0,'g', 3);
@@ -1519,14 +1544,14 @@ void Focus::autoFocusAbs()
HFRDec=0;
// Reality Check: If it's first time, let's capture again and see if it changes.
- if (HFRInc <= 1 && reverseDir == false)
+ /*if (HFRInc <= 1 && reverseDir == false)
{
capture();
return;
}
// Looks like we're going away from optimal HFR
else
- {
+ {*/
reverseDir = true;
lastHFR = currentHFR;
lastHFRPos = currentPosition;
@@ -1562,7 +1587,7 @@ void Focus::autoFocusAbs()
if (Options::focusLogging())
qDebug() << "Focus: new targetPosition " << targetPosition;
- }
+ // }
}
// Limit target Pulse to algorithm limits
@@ -1891,6 +1916,7 @@ void Focus::startFraming()
}
inFocusLoop = true;
+ frameNum=0;
//emit statusUpdated(true);
state = Ekos::FOCUS_FRAMING;
@@ -2201,6 +2227,16 @@ void Focus::setActiveBinning(int bin)
activeBin = bin + 1;
}
+void Focus::setThreshold(double value)
+{
+ Options::setFocusThreshold(value);
+}
+
+void Focus::setFrames(int value)
+{
+ Options::setFocusFrames(value);
+}
+
}
diff --git a/kstars/ekos/focus.h b/kstars/ekos/focus.h
index e52eb59..b14357b 100644
--- a/kstars/ekos/focus.h
+++ b/kstars/ekos/focus.h
@@ -34,7 +34,7 @@ struct HFRPoint
*@class Focus
*@short Supports manual focusing and auto focusing using relative and absolute INDI focusers.
*@author Jasem Mutlaq
- *@version 1.0
+ *@version 1.1
*/
class Focus : public QWidget, public Ui::Focus
{
@@ -318,6 +318,10 @@ private slots:
void updateBoxSize(int value);
+ void setThreshold(double value);
+
+ void setFrames(int value);
+
signals:
void newLog();
void autoFocusFinished(bool status, double finalHFR);
@@ -374,6 +378,8 @@ private:
int HFRInc;
// If HFR decreasing? Well, good job. Once HFR start decreasing, we can start calculating HFR slope and estimating our next move.
int HFRDec;
+ // How many frames have we captured thus far? Do we need to average them?
+ uint8_t frameNum;
/****************************
* Absolute position focusers
@@ -424,6 +430,8 @@ private:
ISD::CCD::UploadMode rememberUploadMode;
// Previous binning setting
int activeBin;
+ // HFR values for captured frames before averages
+ double HFRFrames[5];
QStringList logText;
ITextVectorProperty *filterName;
diff --git a/kstars/ekos/focus.ui b/kstars/ekos/focus.ui
index c6d5978..16da8e0 100644
--- a/kstars/ekos/focus.ui
+++ b/kstars/ekos/focus.ui
@@ -580,20 +580,26 @@ Otherwise, the autofocus process will utilize whatever filter currently set by t
</item>
<item>
<layout class="QGridLayout" name="gridLayout">
- <item row="0" column="0">
- <widget class="QLabel" name="label_10">
- <property name="whatsThis">
- <string>Delay between two consequent focus images</string>
- </property>
- <property name="text">
- <string>Box Size:</string>
+ <item row="0" column="3">
+ <widget class="Line" name="line_2">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
</property>
</widget>
</item>
- <item row="2" column="2">
- <widget class="QLabel" name="label_9">
- <property name="text">
- <string>ticks</string>
+ <item row="2" column="5">
+ <widget class="QDoubleSpinBox" name="toleranceIN">
+ <property name="minimum">
+ <double>0.010000000000000</double>
+ </property>
+ <property name="maximum">
+ <double>20.000000000000000</double>
+ </property>
+ <property name="singleStep">
+ <double>0.100000000000000</double>
+ </property>
+ <property name="value">
+ <double>1.000000000000000</double>
</property>
</widget>
</item>
@@ -613,6 +619,13 @@ Otherwise, the autofocus process will utilize whatever filter currently set by t
</property>
</widget>
</item>
+ <item row="0" column="6">
+ <widget class="QLabel" name="label_3">
+ <property name="text">
+ <string>ticks</string>
+ </property>
+ </widget>
+ </item>
<item row="0" column="2">
<widget class="QLabel" name="label_11">
<property name="text">
@@ -620,103 +633,159 @@ Otherwise, the autofocus process will utilize whatever filter currently set by t
</property>
</widget>
</item>
- <item row="2" column="1">
- <widget class="QDoubleSpinBox" name="maxTravelIN">
+ <item row="0" column="5">
+ <widget class="QSpinBox" name="stepIN">
<property name="minimum">
- <double>10.000000000000000</double>
+ <number>1</number>
</property>
<property name="maximum">
- <double>50000.000000000000000</double>
+ <number>10000</number>
</property>
<property name="singleStep">
- <double>100.000000000000000</double>
+ <number>10</number>
</property>
<property name="value">
- <double>10000.000000000000000</double>
+ <number>250</number>
</property>
</widget>
</item>
- <item row="2" column="0">
- <widget class="QLabel" name="label_12">
+ <item row="2" column="4">
+ <widget class="QLabel" name="label_4">
+ <property name="toolTip">
+ <string>Decrease value to narrow optimal focus point solution radius. Increase to expand solution radius</string>
+ </property>
<property name="text">
- <string>Max Travel:</string>
+ <string>Tolerance:</string>
</property>
</widget>
</item>
- <item row="0" column="6">
- <widget class="QLabel" name="label_3">
+ <item row="2" column="6">
+ <widget class="QLabel" name="label_5">
+ <property name="text">
+ <string>%</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="0">
+ <widget class="QLabel" name="label_10">
+ <property name="whatsThis">
+ <string>Delay between two consequent focus images</string>
+ </property>
+ <property name="text">
+ <string>Box Size:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="2">
+ <widget class="QLabel" name="label_9">
<property name="text">
<string>ticks</string>
</property>
</widget>
</item>
- <item row="2" column="4">
- <widget class="QLabel" name="label_4">
+ <item row="2" column="0">
+ <widget class="QLabel" name="label_12">
+ <property name="toolTip">
+ <string>Maximum travel in ticks before the autofocus process aborts</string>
+ </property>
<property name="text">
- <string>Tolerance:</string>
+ <string>Max Travel:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QDoubleSpinBox" name="maxTravelIN">
+ <property name="minimum">
+ <double>10.000000000000000</double>
+ </property>
+ <property name="maximum">
+ <double>50000.000000000000000</double>
+ </property>
+ <property name="singleStep">
+ <double>100.000000000000000</double>
+ </property>
+ <property name="value">
+ <double>10000.000000000000000</double>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QLabel" name="label">
+ <property name="toolTip">
+ <string>&lt;b&gt;Initial&lt;/b&gt; step size in ticks to cause a noticable change in HFR value. For timer based focuser, it is the initial time in milliseconds to move the focuser inward or outward</string>
+ </property>
<property name="whatsThis">
- <string>Delay between two consequent focus images</string>
+ <string/>
</property>
<property name="text">
<string>Step:</string>
</property>
</widget>
</item>
- <item row="2" column="6">
- <widget class="QLabel" name="label_5">
+ <item row="2" column="3">
+ <widget class="Line" name="line_3">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0">
+ <widget class="QLabel" name="label_19">
+ <property name="toolTip">
+ <string>Increase to restrict the centroid to bright cores. Decrease to enclose fuzzy stars.</string>
+ </property>
<property name="text">
- <string>%</string>
+ <string>Threshold:</string>
</property>
</widget>
</item>
- <item row="2" column="5">
- <widget class="QDoubleSpinBox" name="toleranceIN">
+ <item row="3" column="1">
+ <widget class="QDoubleSpinBox" name="thresholdSpin">
<property name="minimum">
- <double>0.010000000000000</double>
+ <double>90.000000000000000</double>
</property>
<property name="maximum">
- <double>20.000000000000000</double>
+ <double>500.000000000000000</double>
</property>
<property name="singleStep">
- <double>0.100000000000000</double>
+ <double>10.000000000000000</double>
</property>
<property name="value">
- <double>1.000000000000000</double>
+ <double>150.000000000000000</double>
</property>
</widget>
</item>
- <item row="0" column="5">
- <widget class="QSpinBox" name="stepIN">
- <property name="minimum">
- <number>1</number>
- </property>
- <property name="maximum">
- <number>10000</number>
+ <item row="3" column="2">
+ <widget class="QLabel" name="label_20">
+ <property name="text">
+ <string>%</string>
</property>
- <property name="singleStep">
- <number>10</number>
+ </widget>
+ </item>
+ <item row="3" column="4">
+ <widget class="QLabel" name="label_21">
+ <property name="toolTip">
+ <string>Number of frames to average</string>
</property>
- <property name="value">
- <number>250</number>
+ <property name="text">
+ <string>Frames:</string>
</property>
</widget>
</item>
- <item row="0" column="3">
- <widget class="Line" name="line_2">
+ <item row="3" column="3">
+ <widget class="Line" name="line_4">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
- <item row="2" column="3">
- <widget class="Line" name="line_3">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
+ <item row="3" column="5">
+ <widget class="QSpinBox" name="focusFramesSpin">
+ <property name="minimum">
+ <number>1</number>
+ </property>
+ <property name="maximum">
+ <number>5</number>
</property>
</widget>
</item>
diff --git a/kstars/kstars.kcfg b/kstars/kstars.kcfg
index 41ca183..b8cbde4 100644
--- a/kstars/kstars.kcfg
+++ b/kstars/kstars.kcfg
@@ -1469,6 +1469,14 @@
<label>Image filter to be applied to focus image upon loading.</label>
<default>0</default>
</entry>
+ <entry name="FocusThreshold" type="Double">
+ <label>Relative percentage strength of centroid edge pixel strength to average pixel value.</label>
+ <default>150</default>
+ </entry>
+ <entry name="FocusFrames" type="UInt">
+ <label>Number of frames to average</label>
+ <default>1</default>
+ </entry>
</group>
<group name="Align">
<entry name="DefaultAlignCCD" type="String">