示例#1
0
        private void LocateTwoStarsWithStarRecognition(List <PotentialStarStruct> stars, IAstroImage astroImage, uint[,] pixels)
        {
            TrackedObject trackedObject1 = TrackedObjects.Cast <TrackedObject>().ToList().Find(o => o.TargetNo == m_LocateObjects[0]);
            TrackedObject trackedObject2 = TrackedObjects.Cast <TrackedObject>().ToList().Find(o => o.TargetNo == m_LocateObjects[1]);

            LocateTwoStarsWithStarRecognition(stars, astroImage, pixels, trackedObject1, trackedObject2);
        }
示例#2
0
        private void LocateStarsWithStarRecognition(IAstroImage astroImage)
        {
            EnsureComputedRefinedData();

            if (m_MinLocateDistance > 8)
            {
                if (!LightCurveReductionContext.Instance.WindOrShaking)
                {
                    //TODO: If the wind flag is not set, then use a 3 frame binned integration to locate the stars on
                }

                uint[,] pixels = astroImage.GetPixelsCopy();

                List <PotentialStarStruct> peakPixels = new List <PotentialStarStruct>();
                AutoDiscoveredStars.Clear();
                AutoDiscoveredStars = StarFinder.GetStarsInArea(
                    ref pixels, astroImage.BitPix, astroImage.MaxSignalValue, TangraConfig.PreProcessingFilter.NoFilter, peakPixels, null,
                    (uint)Math.Round(TangraConfig.Settings.Special.LostTrackingMinSignalCoeff * m_MinLocateSignal),
                    TangraConfig.Settings.Special.LostTrackingMinDistance, false,
                    LightCurveReductionContext.Instance.OSDFrame, ReducePeakPixels);

                Stopwatch sw = new Stopwatch();
                sw.Start();
                if (m_LocateObjects.Count == 1 &&
                    AutoDiscoveredStars.Count == 1)
                {
                    LocateSingleStarsWithStarRecognition(AutoDiscoveredStars, astroImage);
                }
                else if (
                    m_LocateObjects.Count == 2 &&
                    peakPixels.Count > 1)
                {
                    LocateTwoStarsWithStarRecognition(peakPixels, astroImage, pixels);
                }
                else if (
                    m_LocateObjects.Count > 2 &&
                    peakPixels.Count > 1)
                {
                    List <TrackedObject> goodTrackedObjects = TrackedObjects.Cast <TrackedObject>().ToList().FindAll(t => t.LastKnownGoodPosition != null);
                    if (goodTrackedObjects.Count < 2)
                    {
                        // We don't have at least one good pair. Fail.
                    }
                    else if (goodTrackedObjects.Count >= 2)
                    {
                        goodTrackedObjects.Sort((a, b) =>
                                                Math.Min(b.LastKnownGoodPosition.XDouble, b.LastKnownGoodPosition.YDouble).CompareTo(
                                                    Math.Min(a.LastKnownGoodPosition.XDouble, a.LastKnownGoodPosition.YDouble)));

                        Trace.WriteLine(string.Format("StarRecognitionDistanceBasedLocation: Using objects {0} and {1}", goodTrackedObjects[0].TargetNo, goodTrackedObjects[1].TargetNo));
                        // There is only 1 good pair so fallback to using 2 star recognition
                        LocateTwoStarsWithStarRecognition(peakPixels, astroImage, pixels, goodTrackedObjects[0], goodTrackedObjects[1]);
                    }
                }

                sw.Stop();
                Trace.WriteLine(string.Format("StarRecognitionDistanceBasedLocation: {0} sec", sw.Elapsed.TotalSeconds.ToString("0.00")));
            }
        }
示例#3
0
        private void EnsureComputedRefinedData()
        {
            if (!float.IsNaN(m_MinLocateSignal))
            {
                m_LocateObjects.Clear();
                for (int i = 0; i < TrackedObjects.Count; i++)
                {
                    if (
                        (!(TrackedObjects[i] as TrackedObject).IsOccultedStar || !LightCurveReductionContext.Instance.FullDisappearance) &&
                        !TrackedObjects[i].IsOffScreen &&
                        !float.IsNaN((TrackedObjects[i] as TrackedObject).LastFrameX)
                        )
                    {
                        // Don't include targets offscreen, or targets that were not found during the last tracking (could have been off screen)
                        m_LocateObjects.Add((TrackedObjects[i] as TrackedObject).TargetNo);
                    }
                }
                return;
            }

            m_MinLocateSignal = TrackedObjects.Cast <TrackedObject>().Min(o => o.RefinedOrLastSignalLevel == 0 ? 255f : o.RefinedOrLastSignalLevel);

            // Locate all peak pixels with signal higher than (minSignal + medianNoise) / 2
            m_MinLocateSignal = (m_MedianValue + m_MinLocateSignal) / 2f;

            double minDistance = double.MaxValue;

            for (int i = 0; i < TrackedObjects.Count; i++)
            {
                if ((!(TrackedObjects[i] as TrackedObject).IsOccultedStar && !TrackedObjects[i].IsOffScreen) ||
                    !LightCurveReductionContext.Instance.FullDisappearance)
                {
                    m_LocateObjects.Add((TrackedObjects[i] as TrackedObject).TargetNo);
                }

                for (int j = 0; j < TrackedObjects.Count; j++)
                {
                    if (i == j)
                    {
                        continue;
                    }

                    double dist = ImagePixel.ComputeDistance(
                        TrackedObjects[i].OriginalObject.ApertureStartingX,
                        TrackedObjects[j].OriginalObject.ApertureStartingX,
                        TrackedObjects[i].OriginalObject.ApertureStartingY,
                        TrackedObjects[j].OriginalObject.ApertureStartingY);

                    if (minDistance > dist)
                    {
                        minDistance = dist;
                    }
                }
            }

            m_MinLocateDistance = minDistance / 2.0;
        }
示例#4
0
        private void LocateSingleStarsWithStarRecognition(List <PSFFit> stars, IAstroImage astroImage)
        {
            TrackedObject trackedObject = TrackedObjects.Cast <TrackedObject>().ToList().Find(o => o.TargetNo == m_LocateObjects[0]);

            trackedObject.ThisFrameX         = (float)stars[0].XCenter;
            trackedObject.ThisFrameY         = (float)stars[0].YCenter;
            trackedObject.PSFFit             = stars[0];
            trackedObject.ThisFrameCertainty = (float)stars[0].Certainty;
            trackedObject.SetIsLocated(true, NotMeasuredReasons.TrackedSuccessfullyAfterStarRecognition);
            AutoDiscoveredStars.Clear();

            if (TrackedObjects.Count > 1 &&
                LocateFirstObjects.Contains(trackedObject))
            {
                // If guiding star then run the locate second objects again
                ReLocateNonGuidingObjects(astroImage);
            }
        }
示例#5
0
        private void ReducePeakPixels2Targets(List <PotentialStarStruct> potentialStars)
        {
            const double TOLERANCE = 9;

            List <int> possibleStarIndexes = new List <int>();

            TrackedObject trackedObject1 = TrackedObjects.Cast <TrackedObject>().ToList().Find(o => o.TargetNo == m_LocateObjects[0]) as TrackedObject;
            TrackedObject trackedObject2 = TrackedObjects.Cast <TrackedObject>().ToList().Find(o => o.TargetNo == m_LocateObjects[1]) as TrackedObject;

            if (trackedObject1.TargetNo != trackedObject2.TargetNo &&
                trackedObject1.LastKnownGoodPosition != null &&
                trackedObject2.LastKnownGoodPosition != null)
            {
                double deltaX = Math.Abs(trackedObject1.LastKnownGoodPosition.X - trackedObject2.LastKnownGoodPosition.X);
                double deltaY = Math.Abs(trackedObject1.LastKnownGoodPosition.Y - trackedObject2.LastKnownGoodPosition.Y);

                for (int i = 0; i < potentialStars.Count; i++)
                {
                    for (int j = i + 1; j < potentialStars.Count; j++)
                    {
                        PotentialStarStruct px1 = potentialStars[i];
                        PotentialStarStruct px2 = potentialStars[j];

                        double distX = Math.Abs(px1.X - px2.X);
                        double distY = Math.Abs(px1.Y - px2.Y);

                        if (Math.Abs(distX - deltaX) < TOLERANCE &&
                            Math.Abs(distY - deltaY) < TOLERANCE)
                        {
                            possibleStarIndexes.Add(i);
                            possibleStarIndexes.Add(j);
                        }
                    }
                }
            }

            for (int i = potentialStars.Count - 1; i >= 0; i--)
            {
                if (possibleStarIndexes.IndexOf(i) == -1)
                {
                    potentialStars.RemoveAt(i);
                }
            }
        }