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 + 702 + 468 @@ -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,6 +379,12 @@ + + + 0 + 0 + + CCD && Filter Wheel @@ -386,71 +404,16 @@ 3 - - - - - - - - - - CCD: - - - - - - - - - - - - false - - - - 22 - 22 - - - - - 22 - 22 - - - - Live Video - - - - - - - .. - - - - 22 - 22 - - - - true - - - - - - - - - Exposure time in seconds + + + + false - - Exp: + + + 0 + 32 + @@ -461,6 +424,12 @@ + + + 0 + 32 + + 3 @@ -482,140 +451,207 @@ - 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 - - - - - - - - Bin: - - - - - - - 1 - - - - - false - - - - - - - Exposure time in seconds - - - Gain: + + + 28 + 28 + - - - - - + + false + + Filter Wheel + + + + - ISO: + FW: - - - - false + + + + Bin: - - + + false - Filter Wheel + Number of images to capture - FW: + Filter: false + + + 0 + 32 + + -- - - - - false + + + + Exposure time in seconds + + + Exp: + + + + + + + + 0 + 32 + - Number of images to capture + Reset focus subframe to full capture + + + Reset + + + + .. + + + + + + + - Filter: + CCD: + + + + + + + 1 + + + + + false + + + + 0 + 32 + + + + + + + + Exposure time in seconds + + + Gain: + + + + + + + + 0 + 32 + + + + + + + + + + false + + + ISO: @@ -629,17 +665,29 @@ false + + + 0 + 32 + + false + + + 32 + 32 + + - 22 - 22 + 32 + 32 @@ -652,449 +700,763 @@ .. + + + 28 + 28 + + - - - - Apply filter to image after capture to enhance it - - - Effect: - - - - - - - - -- - - - - - - - - Frame: - - - - - - - Reset focus subframe to full capture - - - Reset - - - - - - - - - - Settings - - - - 1 - - - 3 - - - 3 - - - 3 - - - 3 - - - + + - 3 + 1 - - - - 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 + + + + + 0 + 32 + - - - - <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 + + + + false - - 10.000000000000000 + + + 32 + 32 + - - 100.000000000000000 + + + 32 + 32 + - - - - - + Live Video - Dark Frame - - - - - - - Suspend Guiding while autofocus in progress + - - Suspend Guiding + + + .. - - - - - - Wait this many seconds before resuming guiding. + + + 28 + 28 + - - 60.000000000000000 + + true - - - - 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 - - - - - - + + + + + + + QTabWidget::Rounded + + + 0 + + + + Settings + + + + 0 + + + 3 + + + 3 + + + 3 + + + 3 + + + + + QLayout::SetDefaultConstraint + + + 6 + + + 3 + + + - Iterative + Box: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + 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> + + + + + + + 0 + 0 + + + + <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 + + + + + + + + 0 + 0 + + + + <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 + + + + + + + + 0 + 0 + + + + Suspend Guiding while autofocus in progress + + + Suspend Guiding + + + + + + + + 0 + 0 + + + + Use dark frames from the library. + + + Dark Frame + + + + + + + Settle: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Annulus: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + Wait this many seconds before resuming guiding. + + + s + + + 60.000000000000000 + + + + + + + + 0 + 0 + + + + <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 + + + + + + + + 0 + 0 + + + + Subframe around the focus star during the autofocus procedure + + + Sub Frame + + + true + + + + + + + + 0 + 0 + + + + <html><body><p>Size of the subframe to constrain capture to, in pixels.</p></body></html> + + + px + + + 16 + + + 256 + + + 16 + + + 32 + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + Process + + + + 3 + + + 3 + + + 3 + + + 3 + + + 3 + + + + + 3 + + + + + + + + Tolerance: + + + + + + + + 0 + 0 + + + + Decrease value to narrow optimal focus point solution radius. Increase to expand solution radius + + + % + + + 0.010000000000000 + + + 20.000000000000000 + + + 0.100000000000000 + + + 1.000000000000000 + + + + + + + + + + Effect: + + + + + + + + 0 + 0 + + + + <html><head/><body><p>Select star detection algorithm</p></body></html> + + + + Gradient + + + + + Centroid + + + + + Threshold + + + + + SEP + + + + + + + + + + + Threshold: + + + + + + + false + + + + 0 + 0 + + + + <html><body><p>Increase to restrict the centroid to bright cores. Decrease to enclose fuzzy stars.</p></body></html> + + + % + + + 90.000000000000000 + + + 500.000000000000000 + + + 10.000000000000000 + + + 150.000000000000000 + + + + + + + + 0 + 0 + + + + <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: - - - - - - + + + + Iterative + + + + + Polynomial + + + + + + + + + + + Algorithm: + + + + + + + + + + Detection: + + + + + + + + 0 + 0 + + + + Apply filter to image after capture to enhance it + + + + -- + + + + + + + + + + + Average over: + + + + + + + + 0 + 0 + + + + <html><body><p>Number of frames to capture in order to average the HFR value at the current focuser position.</p></body></html> + + + frames + + + 1 + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + Mechanics + + + + 3 + + + 3 + + + 3 + + + 3 + + + 3 + + + + + 3 + + + + + + - Gradient + Max Travel: + + + + + + + + 0 + 0 + + + + <html><head/><body><p>Wait for this many seconds after moving the focuser before capturing the next image during Auto Focus.</p></body></html> + + + s + + + 3 + + + 30.000000000000000 + + + + + + + + 0 + 0 + + + + <html><head/><body><p>Maximum travel in steps before the autofocus process aborts</p></body></html> + + + 0 + + + 10.000000000000000 + + + 100000.000000000000000 + + + 1000.000000000000000 + + + 10000.000000000000000 + + + + + + + + 0 + 0 + + + + <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 + + + 1 + + + 50000 + + + 10 - - + + 250 + + + + + - Centroid + Backlash: + + + + + + + + 0 + 0 + - - + + <html><body><p>For backlash-aware focuser, the amount of backlash to apply when reversing movement direction.</p></body></html> + + + + + - Threshold + Settle: + + + + + + + + + + - - - SEP + Step size: - - - - - - - <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 - - - - - + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + @@ -1191,15 +1553,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 @@ -1273,24 +1673,13 @@ FilterDevicesCombo FilterPosCombo filterManagerB - filterCombo resetFrameB useAutoStar - useSubFrame - darkFrameCheck useFullField fullFieldInnerRing - fullFieldOuterRing suspendGuideCheck GuideSettleTime - focusBoxSize maxTravelIN - stepIN - toleranceIN - thresholdSpin - focusAlgorithmCombo - focusFramesSpin - focusDetectionCombo HFROut relativeProfileB clearDataB 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,49 @@ void FITSView::drawStarCentroid(QPainter * painter) { - painter->setPen(QPen(Qt::red, 2)); + float const ratio = currentZoom / ZOOM_DEFAULT; + + if (showStarsHFR) + { + QFont painterFont; + + // If we need to print the HFR out, give an arbitrarily sized font to the painter + painterFont.setPointSizeF(painterFont.pointSizeF() * 3 * ratio); + painter->setFont(painterFont); + } - // image_data->getStarCenter(); + painter->setPen(QPen(Qt::red, 2)); - QList starCenters = imageData->getStarCenters(); + QFontMetrics const fontMetrics = painter->fontMetrics(); + QRect const boundingRect(0, 0, painter->device()->width(), painter->device()->height()); - for (int i = 0; i < starCenters.count(); i++) + foreach (auto const &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 const x1 = std::round((starCenter->x - starCenter->width / 2.0f) * ratio); + int const y1 = std::round((starCenter->y - starCenter->width / 2.0f) * ratio); + int const w = std::round(starCenter->width * ratio); + // Draw a circle around the detected star painter->drawEllipse(x1, y1, w, w); + + if (showStarsHFR) + { + // Ask the painter how large will the HFR text be + QString const hfr = QString("%1").arg(starCenter->HFR, 0, 'f', 2); + QSize const hfrSize = fontMetrics.size(Qt::TextSingleLine, hfr); + + // Store the HFR text in a rect + QPoint const hfrBottomLeft(x1+w+5, y1+w/2); + QRect const hfrRect(hfrBottomLeft.x(), hfrBottomLeft.y() - hfrSize.height(), hfrSize.width(), hfrSize.height()); + + // Render the HFR text only if it can be displayed entirely + if (boundingRect.contains(hfrRect)) + { + painter->setPen(QPen(Qt::red, 3)); + painter->drawText(hfrBottomLeft, hfr); + painter->setPen(QPen(Qt::red, 2)); + } + } } } @@ -1928,3 +1958,8 @@ } } } + +void FITSView::setStarsHFREnabled(bool enable) +{ + showStarsHFR = enable; +}