public override void MouseClick(ObjectClickEventArgs e) { if (m_State == FittingsState.Configuring) { m_OSDExcluderTool.MouseClick(e); } if (m_State == FittingsState.Solved) { IStarMap starMap = AstrometryContext.Current.StarMap; if (starMap != null) { int x, y; StarMapFeature feature = starMap.GetFeatureInRadius(e.Pixel.X, e.Pixel.Y, 5); if (feature != null) { x = feature.GetCenter().X; y = feature.GetCenter().Y; } else { x = e.Pixel.X; y = e.Pixel.Y; } int searchArea = Control.ModifierKeys == Keys.Shift ? 5 : 10; PSFFit psfFit; ImagePixel pixelCent = starMap.GetPSFFit(x, y, searchArea, out psfFit); if (pixelCent != null && pixelCent != ImagePixel.Unspecified) { PlateConstStarPair selectedPair = null; LeastSquareFittedAstrometry astrometry = FittedAstrometryFromUserSelectedFitGrade(); if (astrometry != null) { foreach (PlateConstStarPair pair in astrometry.FitInfo.AllStarPairs) { if (Math.Abs(pair.x - pixelCent.X) < 2 && Math.Abs(pair.y - pixelCent.Y) < 2) { selectedPair = pair; break; } } } DrawHighResFeature(pixelCent, selectedPair, astrometry); } else { ClearZoomImage(); } } } }
public void SetManuallyIdentifiedHints(Dictionary <PSFFit, IStar> manuallyIdentifiedStars) { m_ManualStarMatch = new Dictionary <StarMapFeature, IStar>(); foreach (PSFFit fit in manuallyIdentifiedStars.Keys) { StarMapFeature feature = m_StarMap.GetFeatureInRadius((int)fit.XCenter, (int)fit.YCenter, 2); if (feature != null && !m_ManualStarMatch.ContainsKey(feature)) { m_ManualStarMatch.Add(feature, manuallyIdentifiedStars[fit]); } } }
public void NextFrame(int frameNo, IAstroImage astroImage, IStarMap starMap, LeastSquareFittedAstrometry astrometricFit) { IsTrackedSuccessfully = false; PSFFit psfFit = null; if (m_RepeatedIntergationPositions * 4 < m_PastFrameNos.Count) { var expectedPos = GetExpectedPosition(frameNo); if (expectedPos != null) AstrometryContext.Current.StarMap.GetPSFFit(expectedPos.X, expectedPos.Y, PSFFittingMethod.NonLinearFit, out psfFit); } if (psfFit == null) { var brightestFeature = starMap.GetFeatureInRadius((int)TrackedObject.LastKnownX, (int)TrackedObject.LastKnownY, CoreAstrometrySettings.Default.PreMeasureSearchCentroidRadius); if (brightestFeature != null) { var center = brightestFeature.GetCenter(); var referenceStarFeatures = astrometricFit.FitInfo.AllStarPairs.Where(x => x.FitInfo.UsedInSolution).ToList(); var refStar = referenceStarFeatures.FirstOrDefault(s => Math.Sqrt((s.x - center.X) * (s.x - center.X) + (s.y - center.Y) * (s.y - center.Y)) < 2); if (refStar == null) // The brightest feature is not a reference star, so we assume it is our object AstrometryContext.Current.StarMap.GetPSFFit(center.X, center.Y, PSFFittingMethod.NonLinearFit, out psfFit); } } if (psfFit == null) { ImagePixel centroid = AstrometryContext.Current.StarMap.GetCentroid( (int)TrackedObject.LastKnownX, (int)TrackedObject.LastKnownY, CoreAstrometrySettings.Default.PreMeasureSearchCentroidRadius); if (centroid != null) AstrometryContext.Current.StarMap.GetPSFFit(centroid.X, centroid.Y, PSFFittingMethod.NonLinearFit, out psfFit); } if (psfFit != null) { double ra, de; astrometricFit.GetRADEFromImageCoords(psfFit.XCenter, psfFit.YCenter, out ra, out de); double maxPosDiffArcSec = astrometricFit.GetDistanceInArcSec(astrometricFit.Image.CenterXImage, astrometricFit.Image.CenterYImage, astrometricFit.Image.CenterXImage + CoreAstrometrySettings.Default.PreMeasureSearchCentroidRadius, astrometricFit.Image.CenterYImage); if (!double.IsNaN(TrackedObject.RAHours)) { double posDif = 3600 * AngleUtility.Elongation(15 * TrackedObject.RAHours, TrackedObject.DEDeg, ra, de); if (posDif > maxPosDiffArcSec) { // NOTE: Not a valid measurement Trace.WriteLine(string.Format("The target position is too far from the last measured position", posDif)); return; } } TrackedObject.RAHours = ra / 15.0; TrackedObject.DEDeg = de; TrackedObject.LastKnownX = psfFit.XCenter; TrackedObject.LastKnownY = psfFit.YCenter; TrackedObject.PSFFit = psfFit; IsTrackedSuccessfully = true; } if (psfFit != null && psfFit.XCenter > 0 && psfFit.YCenter > 0) { m_PastFramePosX.Add(psfFit.XCenter); m_PastFramePosY.Add(psfFit.YCenter); m_PastFrameNos.Add(frameNo); } }
public override void MouseMove(Point location) { IStarMap map = AstrometryContext.Current.StarMap; if (map == null) { return; } bool nearbyStarFound = false; AstrometricState state = AstrometryContext.Current.AstrometricState; if (state != null) { if (state.AstrometricFit != null) { for (int radius = 1; radius < 8; radius++) { ImagePixel centroid = map.GetCentroid(location.X, location.Y, radius); if (centroid == null) { continue; } foreach (PlateConstStarPair star in state.AstrometricFit.FitInfo.AllStarPairs) { if (Math.Abs(star.x - centroid.XDouble) < radius && Math.Abs(star.y - centroid.YDouble) < radius) { m_Object = star; nearbyStarFound = true; break; } } if (nearbyStarFound) { break; } } if (!nearbyStarFound) { m_State = SelectObjectState.NoObject; } else { m_State = SelectObjectState.ObjectLocked; } if (m_AstrometricState.MeasuringState == AstrometryInFramesState.Ready) { double ra, de; state.AstrometricFit.GetRADEFromImageCoords(location.X, location.Y, out ra, out de); string moreInfo = string.Format("RA={0} DE={1}", AstroConvert.ToStringValue(ra / 15, "HHhMMmSS.Ts"), AstroConvert.ToStringValue(de, "+DD°MM'SS\"")); m_VideoController.DisplayCursorPositionDetails(location, moreInfo); } } else { StarMapFeature nearbyFeature = map.GetFeatureInRadius(location.X, location.Y, 8); nearbyStarFound = nearbyFeature != null && nearbyFeature.PixelCount > 4; } m_VideoController.SetPictureBoxCursor(nearbyStarFound ? Cursors.Hand : (state.ManualStarIdentificationMode ? Cursors.Cross : Cursors.Default)); } }
private bool TryMatchingPairsFromManualPairs(IStarMap starMap) { ThreeStarFit.StarPair[] pairs = new ThreeStarFit.StarPair[3]; Dictionary<ImagePixel, IStar> matchedPairs = new Dictionary<ImagePixel, IStar>(); Dictionary<int, ulong> matchedFeatureIdToStarIdIndexes = new Dictionary<int, ulong>(); int idx = 0; foreach (StarMapFeature feature in m_ManualPairs.Keys) { IStar star = m_ManualPairs[feature]; ImagePixel center = feature.GetCenter(); StarMapFeature ftr = starMap.GetFeatureInRadius((int)center.X, (int)center.Y, (int)CoreAstrometrySettings.Default.SearchArea); if (ftr != null) { if (!matchedFeatureIdToStarIdIndexes.ContainsKey(ftr.FeatureId)) { if (idx < 3) { pairs[idx] = new ThreeStarFit.StarPair(center.X, center.Y); pairs[idx].RADeg = star.RADeg; pairs[idx].DEDeg = star.DEDeg; pairs[idx].Star = star; idx++; } matchedPairs.Add(center, star); matchedFeatureIdToStarIdIndexes.Add(ftr.FeatureId, star.StarNo); } } } if (matchedPairs.Count >= m_Settings.MinimumNumberOfStars) { // When there was a previous fit and we have sufficient stars from the current star map // then don't require % of the bright features to approve the solution. Do it as a calibration fit (not too precise) LeastSquareFittedAstrometry fit = SolveStarPairs( starMap, matchedPairs, matchedFeatureIdToStarIdIndexes, pairs[0], pairs[1], pairs[2], m_PlateConfig.EffectiveFocalLength, null, TangraConfig.Settings.Astrometry.MinimumNumberOfStars); if (fit != null) { m_Solution = fit; m_MatchedPairs = matchedPairs; m_MatchedFeatureIdToStarIdIndexes = matchedFeatureIdToStarIdIndexes; return true; } } return false; }
private bool TryMatchingPairsFromPreviousFit(IStarMap starMap) { ThreeStarFit.StarPair[] pairs = new ThreeStarFit.StarPair[3]; Dictionary<ImagePixel, IStar> matchedPairs = new Dictionary<ImagePixel, IStar>(); Dictionary<int, ulong> matchedFeatureIdToStarIdIndexes = new Dictionary<int, ulong>(); int idx = 0; foreach (PlateConstStarPair pair in m_PreviousFit.AllStarPairs) { if (pair.FitInfo.ExcludedForHighResidual) continue; StarMapFeature ftr = starMap.GetFeatureInRadius((int)pair.x, (int)pair.y, (int)CoreAstrometrySettings.Default.SearchArea); if (ftr != null) { ImagePixel center = starMap.GetCentroid( (int)pair.x, (int)pair.y, (int)CoreAstrometrySettings.Default.SearchArea); IStar star = null; foreach (IStar s in m_CelestialPyramidStars) { if (s.StarNo == pair.StarNo) { star = s; break; } } if (star != null && center != null && !matchedFeatureIdToStarIdIndexes.ContainsKey(ftr.FeatureId)) { if (idx < 3) { pairs[idx] = new ThreeStarFit.StarPair(center.X, center.Y); pairs[idx].RADeg = star.RADeg; pairs[idx].DEDeg = star.DEDeg; pairs[idx].Star = star; idx++; } matchedPairs.Add(center, star); matchedFeatureIdToStarIdIndexes.Add(ftr.FeatureId, star.StarNo); } } } // Shortcurcuit to FeautreId - StarNo detection if (matchedPairs.Count >= m_Settings.MinimumNumberOfStars) { // When there was a previous fit and we have sufficient stars from the current star map // then don't require % of the bright features to approve the solution. Do it as a calibration fit (not too precise) LeastSquareFittedAstrometry fit = SolveStarPairs( starMap, matchedPairs, matchedFeatureIdToStarIdIndexes, pairs[0], pairs[1], pairs[2], m_PreviousFit.FittedFocalLength, null, TangraConfig.Settings.Astrometry.MinimumNumberOfStars); if (fit != null) { m_Solution = fit; m_MatchedPairs = matchedPairs; m_MatchedFeatureIdToStarIdIndexes = matchedFeatureIdToStarIdIndexes; return true; } } return false; }