Changeset View
Changeset View
Standalone View
Standalone View
kstars/ekos/focus/focus.cpp
Show First 20 Lines • Show All 1043 Lines • ▼ Show 20 Line(s) | 1020 | { | |||
---|---|---|---|---|---|
1044 | } | 1044 | } | ||
1045 | 1045 | | |||
1046 | return; | 1046 | return; | ||
1047 | } | 1047 | } | ||
1048 | 1048 | | |||
1049 | setCaptureComplete(); | 1049 | setCaptureComplete(); | ||
1050 | } | 1050 | } | ||
1051 | 1051 | | |||
1052 | void Focus::setCaptureComplete() | 1052 | double Focus::searchForStars(FITSData *image_data) | ||
1053 | { | | |||
1054 | DarkLibrary::Instance()->disconnect(this); | | |||
1055 | | ||||
1056 | // Get Binning | | |||
1057 | ISD::CCDChip *targetChip = currentCCD->getChip(ISD::CCDChip::PRIMARY_CCD); | | |||
1058 | int subBinX = 1, subBinY = 1; | | |||
1059 | targetChip->getBinning(&subBinX, &subBinY); | | |||
1060 | | ||||
1061 | // If we have a box, sync the bounding box to its position. | | |||
1062 | syncTrackingBoxPosition(); | | |||
1063 | | ||||
1064 | // Notify user if we're not looping | | |||
1065 | if (inFocusLoop == false) | | |||
1066 | appendLogText(i18n("Image received.")); | | |||
1067 | | ||||
1068 | // If we're not looping and not in autofocus, enable user to capture again. | | |||
1069 | if (captureInProgress && inFocusLoop == false && inAutoFocus == false) | | |||
1070 | { | | |||
1071 | captureB->setEnabled(true); | | |||
1072 | stopFocusB->setEnabled(false); | | |||
1073 | currentCCD->setUploadMode(rememberUploadMode); | | |||
1074 | } | | |||
1075 | | ||||
1076 | if (rememberCCDExposureLooping) | | |||
1077 | currentCCD->setExposureLoopingEnabled(true); | | |||
1078 | | ||||
1079 | captureInProgress = false; | | |||
1080 | | ||||
1081 | // Get handle to the image data | | |||
1082 | FITSData *image_data = focusView->getImageData(); | | |||
1083 | | ||||
1084 | // Emit the tracking (bounding) box view | | |||
1085 | emit newStarPixmap(focusView->getTrackingBoxPixmap(10)); | | |||
1086 | | ||||
1087 | // If we are not looping; OR | | |||
1088 | // If we are looping but we already have tracking box enabled; OR | | |||
1089 | // If we are asked to analyze _all_ the stars within the field | | |||
1090 | // THEN let's find stars in the image and get current HFR | | |||
1091 | if (inFocusLoop == false || (inFocusLoop && (focusView->isTrackingBoxEnabled() || Options::focusUseFullField()))) | | |||
1092 | { | | |||
1093 | // First check that we haven't already search for stars | | |||
1094 | // Since star-searching algorithm are time-consuming, we should only search when necessary | | |||
1095 | if (image_data->areStarsSearched() == false) | | |||
1096 | { | 1053 | { | ||
1097 | // Reset current HFR | | |||
1098 | currentHFR = -1; | | |||
1099 | | ||||
1100 | // When we're using FULL field view, we always use either CENTROID algorithm which is the default | 1054 | // When we're using FULL field view, we always use either CENTROID algorithm which is the default | ||
1101 | // standard algorithm in KStars, or SEP. The other algorithms are too inefficient to run on full frames and require | 1055 | // standard algorithm in KStars, or SEP. The other algorithms are too inefficient to run on full frames and require | ||
1102 | // a bounding box for them to be effective in near real-time application. | 1056 | // a bounding box for them to be effective in near real-time application. | ||
1103 | if (Options::focusUseFullField()) | 1057 | if (Options::focusUseFullField()) | ||
1104 | { | 1058 | { | ||
1059 | Q_ASSERT_X(focusView->getTrackingBox().isNull(), __FUNCTION__, "Tracking box is disabled when detecting in full-field"); | ||||
1060 | | ||||
1105 | if (focusDetection != ALGORITHM_CENTROID && focusDetection != ALGORITHM_SEP) | 1061 | if (focusDetection != ALGORITHM_CENTROID && focusDetection != ALGORITHM_SEP) | ||
1106 | focusView->findStars(ALGORITHM_CENTROID); | 1062 | focusView->findStars(ALGORITHM_CENTROID); | ||
1107 | else | 1063 | else | ||
1108 | focusView->findStars(focusDetection); | 1064 | focusView->findStars(focusDetection); | ||
1065 | | ||||
1109 | focusView->setStarFilterRange(static_cast <float> (fullFieldInnerRing->value() / 100.0), | 1066 | focusView->setStarFilterRange(static_cast <float> (fullFieldInnerRing->value() / 100.0), | ||
1110 | static_cast <float> (fullFieldOuterRing->value() / 100.0)); | 1067 | static_cast <float> (fullFieldOuterRing->value() / 100.0)); | ||
1111 | focusView->filterStars(); | 1068 | focusView->filterStars(); | ||
1112 | focusView->updateFrame(); | 1069 | focusView->updateFrame(); | ||
1113 | 1070 | | |||
1114 | // Get the average HFR of the whole frame | 1071 | // Get the average HFR of the whole frame | ||
1115 | currentHFR = image_data->getHFR(HFR_AVERAGE); | 1072 | return image_data->getHFR(HFR_AVERAGE); | ||
1116 | } | 1073 | } | ||
1117 | else | 1074 | else | ||
1118 | { | 1075 | { | ||
1119 | // If star is already selected then use whatever algorithm currently selected. | 1076 | // If star is already selected then use whatever algorithm currently selected. | ||
1120 | if (starSelected) | 1077 | if (starSelected) | ||
1121 | { | 1078 | { | ||
1122 | focusView->findStars(focusDetection); | 1079 | focusView->findStars(focusDetection); | ||
1123 | focusView->updateFrame(); | 1080 | focusView->updateFrame(); | ||
1124 | currentHFR = image_data->getHFR(HFR_MAX); | 1081 | return image_data->getHFR(HFR_MAX); | ||
1125 | } | 1082 | } | ||
1126 | else | 1083 | else | ||
1127 | { | 1084 | { | ||
1128 | // Disable tracking box | 1085 | // Disable tracking box | ||
1129 | focusView->setTrackingBoxEnabled(false); | 1086 | focusView->setTrackingBoxEnabled(false); | ||
1130 | 1087 | | |||
1131 | // If algorithm is set something other than Centeroid or SEP, then force Centroid | 1088 | // If algorithm is set something other than Centeroid or SEP, then force Centroid | ||
1132 | // Since it is the most reliable detector when nothing was selected before. | 1089 | // Since it is the most reliable detector when nothing was selected before. | ||
1133 | if (focusDetection != ALGORITHM_CENTROID && focusDetection != ALGORITHM_SEP) | 1090 | if (focusDetection != ALGORITHM_CENTROID && focusDetection != ALGORITHM_SEP) | ||
1134 | focusView->findStars(ALGORITHM_CENTROID); | 1091 | focusView->findStars(ALGORITHM_CENTROID); | ||
1135 | else | 1092 | else | ||
1136 | // Otherwise, continue to find use using the selected algorithm | 1093 | // Otherwise, continue to find use using the selected algorithm | ||
1137 | focusView->findStars(focusDetection); | 1094 | focusView->findStars(focusDetection); | ||
1138 | 1095 | | |||
1139 | // Reenable tracking box | 1096 | // Reenable tracking box | ||
1140 | focusView->setTrackingBoxEnabled(true); | 1097 | focusView->setTrackingBoxEnabled(true); | ||
1141 | 1098 | | |||
1142 | focusView->updateFrame(); | 1099 | focusView->updateFrame(); | ||
1143 | 1100 | | |||
1144 | // Get maximum HFR in the frame | 1101 | // Get maximum HFR in the frame | ||
1145 | currentHFR = image_data->getHFR(HFR_MAX); | 1102 | return image_data->getHFR(HFR_MAX); | ||
1146 | } | 1103 | } | ||
1147 | } | 1104 | } | ||
1148 | } | 1105 | } | ||
1149 | 1106 | | |||
1107 | void Focus::setCaptureComplete() | ||||
1108 | { | ||||
1109 | DarkLibrary::Instance()->disconnect(this); | ||||
1110 | | ||||
1111 | // Get Binning | ||||
1112 | ISD::CCDChip *targetChip = currentCCD->getChip(ISD::CCDChip::PRIMARY_CCD); | ||||
1113 | int subBinX = 1, subBinY = 1; | ||||
1114 | targetChip->getBinning(&subBinX, &subBinY); | ||||
1115 | | ||||
1116 | // If we have a box, sync the bounding box to its position. | ||||
1117 | syncTrackingBoxPosition(); | ||||
1118 | | ||||
1119 | // Notify user if we're not looping | ||||
1120 | if (inFocusLoop == false) | ||||
1121 | appendLogText(i18n("Image received.")); | ||||
1122 | | ||||
1123 | // If we're not looping and not in autofocus, enable user to capture again. | ||||
1124 | if (captureInProgress && inFocusLoop == false && inAutoFocus == false) | ||||
1125 | { | ||||
1126 | captureB->setEnabled(true); | ||||
1127 | stopFocusB->setEnabled(false); | ||||
1128 | currentCCD->setUploadMode(rememberUploadMode); | ||||
1129 | } | ||||
1130 | | ||||
1131 | if (rememberCCDExposureLooping) | ||||
1132 | currentCCD->setExposureLoopingEnabled(true); | ||||
1133 | | ||||
1134 | captureInProgress = false; | ||||
1135 | | ||||
1136 | // Get handle to the image data | ||||
1137 | FITSData *image_data = focusView->getImageData(); | ||||
1138 | | ||||
1139 | // Emit the tracking (bounding) box view | ||||
1140 | emit newStarPixmap(focusView->getTrackingBoxPixmap(10)); | ||||
1141 | | ||||
1142 | // If we are not looping; OR | ||||
1143 | // If we are looping but we already have tracking box enabled; OR | ||||
1144 | // If we are asked to analyze _all_ the stars within the field | ||||
1145 | // THEN let's find stars in the image and get current HFR | ||||
1146 | if (inFocusLoop == false || (inFocusLoop && (focusView->isTrackingBoxEnabled() || Options::focusUseFullField()))) | ||||
1147 | { | ||||
1148 | // First check that we haven't already search for stars | ||||
1149 | // Since star-searching algorithm are time-consuming, we should only search when necessary | ||||
1150 | if (image_data->areStarsSearched() == false) | ||||
1151 | currentHFR = searchForStars(image_data); | ||||
1152 | | ||||
1150 | // Let's now report the current HFR | 1153 | // Let's now report the current HFR | ||
1151 | qCDebug(KSTARS_EKOS_FOCUS) << "Focus newFITS #" << HFRFrames.count() + 1 << ": Current HFR " << currentHFR << " Num stars " << (starSelected ? 1 : image_data->getDetectedStars()); | 1154 | qCDebug(KSTARS_EKOS_FOCUS) << "Focus newFITS #" << HFRFrames.count() + 1 << ": Current HFR " << currentHFR << " Num stars " << (starSelected ? 1 : image_data->getDetectedStars()); | ||
1155 | | ||||
1152 | // Add it to existing frames in case we need to take an average | 1156 | // Add it to existing frames in case we need to take an average | ||
1153 | HFRFrames.append(currentHFR); | 1157 | HFRFrames.append(currentHFR); | ||
1154 | 1158 | | |||
1155 | // Check if we need to average more than a single frame | 1159 | // Check if we need to average more than a single frame | ||
1156 | if (HFRFrames.count() >= focusFramesSpin->value()) | 1160 | if (HFRFrames.count() >= focusFramesSpin->value()) | ||
1157 | { | 1161 | { | ||
1158 | currentHFR = 0; | 1162 | currentHFR = 0; | ||
1159 | 1163 | | |||
▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Line(s) | |||||
1205 | } | 1209 | } | ||
1206 | else | 1210 | else | ||
1207 | { | 1211 | { | ||
1208 | // If we need to capture more frames to average the HFR, let's do that now. | 1212 | // If we need to capture more frames to average the HFR, let's do that now. | ||
1209 | capture(); | 1213 | capture(); | ||
1210 | return; | 1214 | return; | ||
1211 | } | 1215 | } | ||
1212 | 1216 | | |||
1213 | | ||||
1214 | // Let signal the current HFR now depending on whether the focuser is absolute or relative | 1217 | // Let signal the current HFR now depending on whether the focuser is absolute or relative | ||
1215 | if (canAbsMove) | 1218 | if (canAbsMove) | ||
1216 | emit newHFR(currentHFR, static_cast<int>(currentPosition)); | 1219 | emit newHFR(currentHFR, static_cast<int>(currentPosition)); | ||
1217 | else | 1220 | else | ||
1218 | emit newHFR(currentHFR, -1); | 1221 | emit newHFR(currentHFR, -1); | ||
1219 | 1222 | | |||
1220 | // Format the HFR value into a string | 1223 | // Format the HFR value into a string | ||
1221 | QString HFRText = QString("%1").arg(currentHFR, 0, 'f', 2); | 1224 | QString HFRText = QString("%1").arg(currentHFR, 0, 'f', 2); | ||
▲ Show 20 Lines • Show All 2467 Lines • Show Last 20 Lines |