Пример #1
0
        private void ComputeRefinedDistances()
        {
            for (int i = 0; i < TrackedObjects.Count; i++)
            {
                TrackedObject obj1 = TrackedObjects[i] as TrackedObject;
                obj1.OtherGuidingStarsLocationVectors = new Dictionary<int, LocationVector>();

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

                    TrackedObject obj2 = TrackedObjects[j] as TrackedObject;

                    double xVector, yVector;
                    double refinedDistance = obj1.ComputeRefinedDistances(obj2, out xVector, out yVector);

                    long pairId = (((long)obj1.TargetNo) << 32) + (long)obj2.TargetNo;
                    m_RefinedDistances.Add(pairId, refinedDistance);

                    LocationVector vector = new LocationVector();
                    vector.DeltaXToAdd = xVector;
                    vector.DeltaYToAdd = yVector;
                    obj1.OtherGuidingStarsLocationVectors.Add(obj2.TargetNo, vector);
                }
            }
        }
Пример #2
0
        public override void NextFrame(int frameNo, IAstroImage astroImage)
        {
            base.NextFrame(frameNo, astroImage);

            #region run the full star recognition recovery if enabled
            if (TangraConfig.Settings.Tracking.RecoverFromLostTracking &&
                m_RefiningFramesLeft <= 0)
            {
                bool notAllStarsLocated            = TrackedObjects.Exists(o => !o.IsLocated);
                bool notAllLocateFirstStarsLocated = LocateFirstObjects.Exists(o => !o.IsLocated);
                if (notAllLocateFirstStarsLocated && LocateFirstObjects.Count > 1)
                {
                    LocateStarsWithStarRecognition(astroImage);
                }

                // TODO: Use the notAllStarsLocated to troubleshoot the pattern recognition alignment
            }
            #endregion

            bool allGuidingStarsLocated = true;
            foreach (TrackedObject trackedObject in LocateFirstObjects)
            {
                if (!trackedObject.IsLocated && !trackedObject.IsOffScreen)
                {
                    allGuidingStarsLocated = false;
                }
            }

            if (m_RefiningFramesLeft > 0)
            {
                if (allGuidingStarsLocated)
                {
                    m_RefiningFramesLeft--;
                }
            }
            else
            {
                m_IsTrackedSuccessfully =
                    LocateFirstObjects.Count > 0
                            ? allGuidingStarsLocated
                            : OccultedStar.IsLocated;
            }

            if (!m_Refining &&
                (LocateFirstObjects.Count > 0 && allGuidingStarsLocated) &&
                (LightCurveReductionContext.Instance.FieldRotation || LightCurveReductionContext.Instance.LightCurveReductionType == LightCurveReductionType.MutualEvent))
            {
                for (int i = 0; i < TrackedObjects.Count; i++)
                {
                    TrackedObject obj1 = TrackedObjects[i] as TrackedObject;

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

                        TrackedObject obj2 = TrackedObjects[j] as TrackedObject;

                        long pairId = (((long)obj1.TargetNo) << 32) + (long)obj2.TargetNo;

                        double oldDistance = m_RefinedDistances[pairId];
                        double newDistance = ImagePixel.ComputeDistance(
                            obj1.Center.XDouble, obj2.Center.XDouble,
                            obj1.Center.YDouble, obj2.Center.YDouble);

                        m_RefinedDistances[pairId] = (oldDistance + newDistance) / 2.0;

                        LocationVector vector = obj1.OtherGuidingStarsLocationVectors[obj2.TargetNo];
                        vector.DeltaXToAdd = (vector.DeltaXToAdd + obj2.Center.XDouble - obj1.Center.XDouble) / 2;
                        vector.DeltaYToAdd = (vector.DeltaYToAdd + obj2.Center.YDouble - obj1.Center.YDouble) / 2;
                    }
                }
            }


            if (!m_IsTrackedSuccessfully)
            {
                // If the tracking has failed, then some objects may be offscreen and have NaN position
                // So inherit the IsOffScreen flag from the previous position
                foreach (TrackedObject obj in TrackedObjects)
                {
                    if (m_IsOffScreenPrev[obj.TargetNo] && double.IsNaN(obj.Center.XDouble))
                    {
                        obj.SetIsLocated(false, NotMeasuredReasons.ObjectExpectedPositionIsOffScreen);
                    }
                }
            }
            else
            {
                foreach (TrackedObject obj in TrackedObjects)
                {
                    m_IsOffScreenPrev[obj.TargetNo] = obj.IsOffScreen;
                }
            }
        }