Exemplo n.º 1
0
 /// <summary>
 /// Creates a Tracklet from the given arguments. This constructor is internally called by the Tracklet factories.
 /// </summary>
 public Tracklet(ImageDetection[] Detections, TrackletVelocity Velocity, TrackletVelocityRegression Regression)
 {
     this.Detections    = Detections;
     this.Velocity      = Velocity;
     VelReg             = Regression;
     ExtendedProperties = new Dictionary <Type, IExtensionProperty>();
 }
Exemplo n.º 2
0
        /// <summary>
        /// Recovers the tracklet on a given set of images (typically pipeline input ones).
        /// </summary>
        /// <returns><c>true</c>, if tracklet was recovered, <c>false</c> otherwise.</returns>
        /// <param name="tvr"><see cref="TrackletVelocityRegression"/> from which the positions are computed.</param>
        /// <param name="InputImages">Images on which to perform the recovery.</param>
        /// <param name="Recovered">Recovered tracklet.</param>
        public bool RecoverTracklet(TrackletVelocityRegression tvr, IEnumerable <Image> InputImages, out Tracklet Recovered)
        {
            List <ImageDetection> Detections = new List <ImageDetection>();

            foreach (Image img in InputImages)
            {
                /* Compute location */
                ObservationTime obTime = img.GetProperty <ObservationTime>();
                double          Secs   = (obTime.Time - tvr.ZeroTime).TotalSeconds;
                EquatorialPoint eqp    = new EquatorialPoint()
                {
                    RA = tvr.P_TR.Slope * Secs + tvr.P_TR.Intercept, Dec = tvr.P_TD.Slope * Secs + tvr.P_TD.Intercept
                };
                Position p = new Position(eqp, img.Transform.GetPixelPoint(eqp));
                /* Perform recovery */
                if (RecoverDetection(p, img, RecoverRadius, InputImages, out ImageDetection RecD))
                {
                    Detections.Add(RecD);
                }
            }
            if (Detections.Count >= MinDetections)
            {
                Recovered = StandardTrackletFactory.CreateTracklet(Detections.ToArray());
                return(true);
            }
            else
            {
                Recovered = null;  return(false);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Creates a tracklet from a set of detections.
        /// </summary>
        /// <param name="Detections">Input detections; one per image.</param>
        /// <returns>A new Tracklet instance.</returns>
        public static Tracklet CreateTracklet(ImageDetection[] Detections)
        {
            long[] Ticks = Detections.Select((x) => x.Time.Time.Ticks).ToArray();
            Array.Sort(Ticks, Detections);

            EquatorialPoint[] ValidEP    = new EquatorialPoint[Detections.Length];
            double[]          ValidTimes = new double[Detections.Length];
            DateTime          ZeroTime   = Detections[0].Time.Time;

            WCS.IWCSProjection Projection = Detections[0].ParentImage.Transform;

            for (int i = 0; i < Detections.Length; i++)
            {
                ValidEP[i]    = Detections[i].Barycenter.EP;
                ValidTimes[i] = (Detections[i].Time.Time - ZeroTime).TotalSeconds;
            }

            var                XRA      = ValidEP.Select((x) => x.RA).ToArray();
            var                XDec     = ValidEP.Select((x) => x.Dec).ToArray();
            var                RAreg    = LinearRegression.ComputeLinearRegression(ValidTimes, XRA);
            var                Decreg   = LinearRegression.ComputeLinearRegression(ValidTimes, XDec);
            var                RADecreg = LinearRegression.ComputeLinearRegression(XRA, XDec);
            double             ResRA    = LineFit.ComputeResidualSqSum(RAreg, ValidTimes, XRA);
            double             ResDec   = LineFit.ComputeResidualSqSum(Decreg, ValidTimes, XDec);
            EquatorialVelocity ev       = new EquatorialVelocity()
            {
                RAvel = RAreg.Slope, Decvel = Decreg.Slope
            };
            TrackletVelocityRegression tvr = new TrackletVelocityRegression()
            {
                R_TR = RAreg.PearsonR, R_TD = Decreg.PearsonR, R_RD = RADecreg.PearsonR,
                S_TR = ResRA, S_TD = ResDec, ZeroTime = ZeroTime, P_TD = Decreg, P_TR = RAreg
            };
            TrackletVelocity tvel = new TrackletVelocity()
            {
                EquatorialVelocity = ev,
                PixelVelocity      = Projection.GetPixelVelocity(ev),
                SphericalVelocity  = Math.Sqrt(ev.Decvel * ev.Decvel + ev.RAvel * ev.RAvel * Math.Cos(XRA[0]) * Math.Cos(XRA[0]))
            };

            return(new Tracklet(Detections, tvel, tvr));
        }