diff --git a/kstars/ekos/focus/focus.cpp b/kstars/ekos/focus/focus.cpp --- a/kstars/ekos/focus/focus.cpp +++ b/kstars/ekos/focus/focus.cpp @@ -1097,7 +1097,7 @@ } // Let's now report the current HFR - qCDebug(KSTARS_EKOS_FOCUS) << "Focus newFITS #" << HFRFrames.count() + 1 << ": Current HFR " << currentHFR; + qCDebug(KSTARS_EKOS_FOCUS) << "Focus newFITS #" << HFRFrames.count() + 1 << ": Current HFR " << currentHFR << " Num stars " << (starSelected ? 1 : image_data->getDetectedStars()); // Add it to existing frames in case we need to take an average HFRFrames.append(currentHFR); @@ -1169,6 +1169,7 @@ // Format the HFR value into a string QString HFRText = QString("%1").arg(currentHFR, 0, 'f', 2); HFROut->setText(HFRText); + starsOut->setText(QString("%1").arg(image_data->getDetectedStars())); // Display message in case _last_ HFR was negative if (lastHFR == -1) @@ -3389,6 +3390,7 @@ focusingWidget->setLayout(vlayout); connect(focusView, &FITSView::trackingStarSelected, this, &Ekos::Focus::focusStarSelected, Qt::UniqueConnection); focusView->setStarsEnabled(true); + focusView->setStarsHFREnabled(true); } } diff --git a/kstars/ekos/focus/focus.ui b/kstars/ekos/focus/focus.ui --- a/kstars/ekos/focus/focus.ui +++ b/kstars/ekos/focus/focus.ui @@ -6,8 +6,8 @@ 0 0 - 697 - 537 + 884 + 646 @@ -38,21 +38,27 @@ + + + 0 + 0 + + Focuser 3 - 3 + 6 3 - 3 + 6 3 @@ -62,7 +68,7 @@ 0 - 28 + 32 @@ -107,7 +113,7 @@ 0 - 28 + 32 @@ -132,7 +138,7 @@ 0 - 28 + 32 @@ -184,7 +190,7 @@ 0 - 28 + 32 @@ -242,7 +248,7 @@ 0 - 28 + 32 @@ -264,6 +270,12 @@ false + + + 29 + 29 + + 32 @@ -367,21 +379,27 @@ + + + 0 + 0 + + CCD && Filter Wheel 3 - 3 + 6 3 - 3 + 6 3 @@ -401,24 +419,34 @@ + + 1 + - + + + + 0 + 32 + + + false - 22 - 22 + 32 + 32 - 22 - 22 + 32 + 32 @@ -433,8 +461,8 @@ - 22 - 22 + 28 + 28 @@ -461,6 +489,12 @@ + + + 0 + 32 + + 3 @@ -482,44 +516,56 @@ - 22 - 22 + 32 + 32 - 22 - 22 + 32 + 32 Toggle Full Screen + + + 28 + 28 + + - 22 - 22 + 32 + 32 - 22 - 22 + 32 + 32 Show in FITS Viewer + + + 28 + 28 + + @@ -541,6 +587,12 @@ false + + + 0 + 32 + + @@ -554,7 +606,14 @@ - + + + + 0 + 32 + + + @@ -573,6 +632,12 @@ false + + + 0 + 32 + + @@ -596,6 +661,12 @@ false + + + 0 + 32 + + -- @@ -629,17 +700,29 @@ false + + + 0 + 32 + + false + + + 32 + 32 + + - 22 - 22 + 32 + 32 @@ -652,6 +735,12 @@ .. + + + 28 + 28 + + @@ -668,6 +757,12 @@ + + + 0 + 32 + + -- @@ -684,6 +779,12 @@ + + + 0 + 32 + + Reset focus subframe to full capture @@ -696,405 +797,453 @@ - - - Settings + + + QTabWidget::Rounded - - - 1 - - - 3 - - - 3 - - - 3 - - - 3 - - - - - 3 - - - - - Subframe around the focus star during the autofocus procedure - - - Sub Frame - - - true - - - - - - - Automatically select the best focus star from the image - - - Auto Select Star - - - - - - - <html><head/><body><p>Measure average HFR from all stars combined in a full frame. This method defaults to the Centroid detection, but can use SEP detection too. Its performance decreases as the number of stars increases.</p></body></html> - - - Full Field - - - - - - - <html><body><p>During full field focusing, stars which are inside this percentage of the frame are filtered out of HFR calculation (default 0%). Detection algorithms may also have an inherent filter.</p></body></html> - - - % - - - 1 - - - 10.000000000000000 - - - - - - - <html><body><p>During full field focusing, stars which are outside this percentage of the frame are filtered out of HFR calculation (default 100%). Detection algorithms may also have an inherent filter.</p></body></html> - - - % - - - 1 - - - 10.000000000000000 - - - 100.000000000000000 - - - - - - - - - - Dark Frame - - - - - - - Suspend Guiding while autofocus in progress - - - Suspend Guiding - - - - - - - Wait this many seconds before resuming guiding. - - - 60.000000000000000 - - - - - - - - - Qt::Horizontal - - - - - - - - - <html><head/><body><p>Maximum travel in steps before the autofocus process aborts</p></body></html> - - - Max Travel: - - - - - - - 0.010000000000000 - - - 20.000000000000000 - - - 0.100000000000000 - - - 1.000000000000000 - - - - - - - 10.000000000000000 - - - 100000.000000000000000 - - - 1000.000000000000000 - - - 10000.000000000000000 - - - - - - + + 0 + + + + Settings + + + + 0 + + + 0 + + + 6 + + + 0 + + + 6 + + + + + QLayout::SetDefaultConstraint + + + 3 + + + + + + 0 + 29 + + + + Subframe around the focus star during the autofocus procedure + - Iterative + Sub Frame + + + true + + + + + + + Automatically select the best focus star from the image - - - Polynomial + Auto Select Star - - - - - - - Number of frames to average - - - 1 - - - - - - - Increase to restrict the centroid to bright cores. Decrease to enclose fuzzy stars. - - - Threshold (%): - - - - - - - false - - - 90.000000000000000 - - - 500.000000000000000 - - - 10.000000000000000 - - - 150.000000000000000 - - - - - - - <b>Initial</b> step size in ticks to cause a noticeable change in HFR value. For timer based focuser, it is the initial time in milliseconds to move the focuser inward or outward - - - - - - Step size: - - - - - - - 16 - - - 256 - - - 16 - - - 32 - - - - - - - Delay between two consequent focus images - - - Box Size: - - - - - - - <html><head/><body><p>Select focus process algorithm:</p> + + + + + + <html><head/><body><p>Measure average HFR from all stars combined in a full frame. This method defaults to the Centroid detection, but can use SEP detection too. Its performance decreases as the number of stars increases.</p></body></html> + + + Full Field + + + + + + + <html><body><p>During full field focusing, stars which are inside this percentage of the frame are filtered out of HFR calculation (default 0%). Detection algorithms may also have an inherent filter.</p></body></html> + + + % + + + 1 + + + 10.000000000000000 + + + + + + + <html><body><p>During full field focusing, stars which are outside this percentage of the frame are filtered out of HFR calculation (default 100%). Detection algorithms may also have an inherent filter.</p></body></html> + + + % + + + 1 + + + 10.000000000000000 + + + 100.000000000000000 + + + + + + + + + + Dark Frame + + + + + + + Suspend Guiding while autofocus in progress + + + Suspend Guiding + + + + + + + Wait this many seconds before resuming guiding. + + + 60.000000000000000 + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + Advanced + + + + 0 + + + 0 + + + 7 + + + 0 + + + 6 + + + + + 3 + + + + + <html><head/><body><p>Maximum travel in steps before the autofocus process aborts</p></body></html> + + + Max Travel: + + + + + + + 0.010000000000000 + + + 20.000000000000000 + + + 0.100000000000000 + + + 1.000000000000000 + + + + + + + 10.000000000000000 + + + 100000.000000000000000 + + + 1000.000000000000000 + + + 10000.000000000000000 + + + + + + + + Iterative + + + + + Polynomial + + + + + + + + <html><body><p>Number of frames to capture in order to average the HFR value at the current focuser position.</p></body></html> + + + 1 + + + + + + + Increase to restrict the centroid to bright cores. Decrease to enclose fuzzy stars. + + + Threshold (%): + + + + + + + false + + + 90.000000000000000 + + + 500.000000000000000 + + + 10.000000000000000 + + + 150.000000000000000 + + + + + + + <b>Initial</b> step size in ticks to cause a noticeable change in HFR value. For timer based focuser, it is the initial time in milliseconds to move the focuser inward or outward + + + + + + Step size: + + + + + + + 16 + + + 256 + + + 16 + + + 32 + + + + + + + Delay between two consequent focus images + + + Box Size: + + + + + + + <html><head/><body><p>Select focus process algorithm:</p> <ul> <li><b>Iterative</b>: Moves focuser by discreet steps initially decided by the step size. Once a curve slope is calculated, further step sizes are calculated to reach optimal solution. The algorithm stops when the measured HFR is within percentage tolerance of the minimum HFR recorded in the procedure.</li> <li><b>Polynomial</b>: Starts with iterative method. Upon crossing to the other side of the V-Curve, polynomial fitting coefficients along with possible minimum solution are calculated. This algorithm can be faster than purely iterative approach given a good data set.</li> </ul> </body></html> - - - Algorithm: - - - - - - - 1 - - - 50000 - - - 10 - - - 250 - - - - - - - Number of frames to average - - - Frames: - - - - - - + - Gradient + Algorithm: + + + + + + + 1 + + + 50000 + + + 10 + + + 250 + + + + + + + Number of frames to average - - - Centroid + Frames: + + + + + + + + Gradient + + + + + Centroid + + + + + Threshold + + + + + SEP + + + + + + + + <html><head/><body><p>Select star detection algorithm</p></body></html> - - - Threshold + Detection: + + + + + + + Decrease value to narrow optimal focus point solution radius. Increase to expand solution radius - - - SEP + Tolerance (%): - - - - - - - <html><head/><body><p>Select star detection algorithm</p></body></html> - - - Detection: - - - - - - - Decrease value to narrow optimal focus point solution radius. Increase to expand solution radius - - - Tolerance (%): - - - - - - - Settle: - - - - - - - <html><head/><body><p>Wait for this many seconds after moving the focuser before capturing the next image during Auto Focus.</p></body></html> - - - 3 - - - 30.000000000000000 - - - - - - - Backlash: - - - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - + + + + + + Settle: + + + + + + + <html><head/><body><p>Wait for this many seconds after moving the focuser before capturing the next image during Auto Focus.</p></body></html> + + + 3 + + + 30.000000000000000 + + + + + + + Backlash: + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + @@ -1191,15 +1340,53 @@ + + + 0 + 0 + + + + <html><body><p>HFR value in pixels consolidated at the current focuser position.</p></body></html> + + + 32767 + + + true + true + + + + Qt::Horizontal + + + + 40 + 20 + + + + - pixels + Stars: + + + + + + + <html><body><p>Number of stars used for HFR computation at the current focuser position.</p></body></html> + + + true diff --git a/kstars/fitsviewer/fitsdata.cpp b/kstars/fitsviewer/fitsdata.cpp --- a/kstars/fitsviewer/fitsdata.cpp +++ b/kstars/fitsviewer/fitsdata.cpp @@ -1954,7 +1954,7 @@ HFRs << center->HFR; std::sort(HFRs.begin(), HFRs.end()); - double sum = std::accumulate(HFRs.begin(), HFRs.end(), 0); + double sum = std::accumulate(HFRs.begin(), HFRs.end(), 0.0); double m = sum / HFRs.size(); if (HFRs.size() > 3) @@ -1977,7 +1977,7 @@ }); // New mean - sum = std::accumulate(HFRs.begin(), HFRs.end(), 0); + sum = std::accumulate(HFRs.begin(), HFRs.end(), 0.0); m = sum / HFRs.size(); } diff --git a/kstars/fitsviewer/fitsview.h b/kstars/fitsviewer/fitsview.h --- a/kstars/fitsviewer/fitsview.h +++ b/kstars/fitsviewer/fitsview.h @@ -157,6 +157,7 @@ int findStars(StarAlgorithm algorithm = ALGORITHM_CENTROID, const QRect &searchBox = QRect()); void toggleStars(bool enable); void setStarsEnabled(bool enable); + void setStarsHFREnabled(bool enable); void setStarFilterRange(float const innerRadius, float const outerRadius); int filterStars(); @@ -288,6 +289,7 @@ bool showObjects { false }; bool showEQGrid { false }; bool showPixelGrid { false }; + bool showStarsHFR { false }; struct { diff --git a/kstars/fitsviewer/fitsview.cpp b/kstars/fitsviewer/fitsview.cpp --- a/kstars/fitsviewer/fitsview.cpp +++ b/kstars/fitsviewer/fitsview.cpp @@ -880,9 +880,6 @@ { painter->setRenderHint(QPainter::Antialiasing, Options::useAntialias()); - if (markStars) - drawStarCentroid(painter); - if (trackingBoxEnabled && getCursorMode() != FITSView::scopeCursor) drawTrackingBox(painter); @@ -900,6 +897,9 @@ if (showPixelGrid) drawPixelGrid(painter); + + if (markStars) + drawStarCentroid(painter); } void FITSView::updateMode(FITSMode fmode) @@ -938,19 +938,31 @@ void FITSView::drawStarCentroid(QPainter * painter) { - painter->setPen(QPen(Qt::red, 2)); + float const ratio = currentZoom / ZOOM_DEFAULT; - // image_data->getStarCenter(); + if (showStarsHFR) + { + QFont painterFont; + painterFont.setPointSizeF(painterFont.pointSizeF() * 3 * ratio); + painter->setFont(painterFont); + } - QList starCenters = imageData->getStarCenters(); + painter->setPen(QPen(Qt::red, 2)); - for (int i = 0; i < starCenters.count(); i++) + foreach (Edge *starCenter, imageData->getStarCenters()) { - int x1 = (starCenters[i]->x - starCenters[i]->width / 2) * (currentZoom / ZOOM_DEFAULT); - int y1 = (starCenters[i]->y - starCenters[i]->width / 2) * (currentZoom / ZOOM_DEFAULT); - int w = (starCenters[i]->width) * (currentZoom / ZOOM_DEFAULT); + int x1 = std::floor((starCenter->x - starCenter->width / 2.0f) * ratio); + int y1 = std::floor((starCenter->y - starCenter->width / 2.0f) * ratio); + int w = std::ceil(starCenter->width * ratio); painter->drawEllipse(x1, y1, w, w); + + if (showStarsHFR) + { + painter->setPen(QPen(Qt::red, 3)); + painter->drawText(x1+w+5, y1+w/2, QString("%1").arg(starCenter->HFR, 0, 'f', 2)); + painter->setPen(QPen(Qt::red, 2)); + } } } @@ -1928,3 +1940,8 @@ } } } + +void FITSView::setStarsHFREnabled(bool enable) +{ + showStarsHFR = enable; +}