Exemple #1
0
        public bool InitializeOperation(IVideoController videoContoller, Panel controlPanel, IFramePlayer framePlayer, Form topForm)
        {
            m_VideoController = (VideoController)videoContoller;
            m_FramePlayer     = framePlayer;

            if (m_ControlPanel == null)
            {
                lock (m_SyncRoot)
                {
                    if (m_ControlPanel == null)
                    {
                        m_ControlPanel = new ucSpectroscopy(this, (VideoController)videoContoller, m_SpectroscopyController, framePlayer);
                    }
                }
            }

            controlPanel.Controls.Clear();
            controlPanel.Controls.Add(m_ControlPanel);
            m_ControlPanel.Dock = DockStyle.Fill;

            m_OperationState   = SpectroscopyState.ChoosingStar;
            SelectedStar       = null;
            SelectedAnglePoint = Point.Empty;

            m_OriginalWidth      = framePlayer.Video.Width;
            m_OriginalHeight     = framePlayer.Video.Height;
            m_OriginalVideoFrame = new Rectangle(0, 0, m_OriginalWidth, m_OriginalHeight);

            return(true);
        }
Exemple #2
0
        internal void StartMeasurements()
        {
            MeasurementAreaWing   = m_SpectroscopyController.SpectraReductionContext.MeasurementAreaWing;
            BackgroundAreaWing    = m_SpectroscopyController.SpectraReductionContext.BackgroundAreaWing;
            BackgroundAreaGap     = m_SpectroscopyController.SpectraReductionContext.BackgroundAreaGap;
            PixelValueCoefficient = m_SpectroscopyController.SpectraReductionContext.PixelValueCoefficient;

            var starToTrack = new TrackedObjectConfig()
            {
                ApertureInPixels  = (float)(SelectedStarFWHM * 2),
                MeasureThisObject = false,
                ApertureDX        = 0,
                ApertureDY        = 0,

                Gaussian           = m_SelectedStarGaussian,
                ApertureStartingX  = (float)m_SelectedStarGaussian.XCenter,
                ApertureStartingY  = (float)m_SelectedStarGaussian.YCenter,
                TrackingType       = TrackingType.OccultedStar,
                IsWeakSignalObject = false
            };

            m_Tracker = new SpectroscopyStarTracker(starToTrack);

            m_OperationState = SpectroscopyState.RunningMeasurements;
            m_AllFramesSpectra.Clear();

            m_ControlPanel.MeasurementsStarted();

            m_FirstMeasuredFrame          = null;
            m_CancelMeasurementsRequested = false;
            m_FramePlayer.Start(FramePlaySpeed.Fastest, null, 1);
        }
Exemple #3
0
        public override void MouseClick(ObjectClickEventArgs e)
        {
            if (m_OperationState == SpectroscopyState.ChoosingStar && e.Gausian != null && e.Gausian.IsSolved && e.Gausian.Certainty > 0.2)
            {
                float bestAngle = m_SpectroscopyController.LocateSpectraAngle(e.Gausian);

                if (float.IsNaN(bestAngle))
                {
                    SelectedStar           = new ImagePixel(e.Gausian.XCenter, e.Gausian.YCenter);
                    SelectedStarFWHM       = e.Gausian.FWHM;
                    m_SelectedStarGaussian = e.Gausian;
                    MeasurementAreaWing    = (int)(2 * Math.Ceiling(SelectedStarFWHM));
                    BackgroundAreaWing     = MeasurementAreaWing;
                    BackgroundAreaGap      = 5;

                    SelectedAnglePoint = Point.Empty;
                    m_ControlPanel.ClearSpectra();

                    m_OperationState = SpectroscopyState.ChoosingAngleManually;
                }
                else
                {
                    SelectedStar           = new ImagePixel(e.Gausian.XCenter, e.Gausian.YCenter);
                    SelectedStarFWHM       = e.Gausian.FWHM;
                    m_SelectedStarGaussian = e.Gausian;
                    MeasurementAreaWing    = (int)(2 * Math.Ceiling(SelectedStarFWHM));
                    BackgroundAreaWing     = MeasurementAreaWing;
                    BackgroundAreaGap      = 5;

                    SetBestAngle(bestAngle);
                }

                m_VideoController.RedrawCurrentFrame(false, true);
            }
            else if (m_OperationState == SpectroscopyState.ChoosingAngleManually && SelectedStar != null)
            {
                double atanAgnle = 180 * Math.Atan((SelectedStar.YDouble - e.Pixel.YDouble) / (e.Pixel.XDouble - SelectedStar.XDouble)) / Math.PI;
                if (atanAgnle < 0)
                {
                    atanAgnle = 360 + atanAgnle;
                }
                int   roughAngle = (int)atanAgnle;
                float bestAngle  = m_SpectroscopyController.LocateSpectraAngle(e.Gausian, roughAngle);
                if (!float.IsNaN(bestAngle))
                {
                    SetBestAngle(bestAngle);
                    m_VideoController.RedrawCurrentFrame(false, true);
                }
            }
        }
Exemple #4
0
        private void SetBestAngle(float bestAngle)
        {
            SelectedStarBestAngle = bestAngle;

            m_OperationState = SpectroscopyState.StarConfirmed;

            var reader = new SpectraReader(m_VideoController.GetCurrentAstroImage(false), bestAngle, PixelValueCoefficient);

            Spectra spectra = reader.ReadSpectra(
                (float)SelectedStar.XDouble,
                (float)SelectedStar.YDouble,
                MeasurementAreaWing,
                BackgroundAreaWing,
                BackgroundAreaGap,
                PixelCombineMethod.Average);

            m_ControlPanel.PreviewSpectra(spectra);
        }
        private void SetBestAngle(float bestAngle)
        {
            SelectedStarBestAngle = bestAngle;

            m_OperationState = SpectroscopyState.StarConfirmed;

            var reader = new SpectraReader(m_VideoController.GetCurrentAstroImage(false), bestAngle, PixelValueCoefficient);

            Spectra spectra = reader.ReadSpectra(
                (float)SelectedStar.XDouble,
                (float)SelectedStar.YDouble,
                MeasurementAreaWing,
                BackgroundAreaWing,
                BackgroundAreaGap,
                PixelCombineMethod.Average);

            m_ControlPanel.PreviewSpectra(spectra);
        }
        internal void StartMeasurements()
        {
            MeasurementAreaWing = m_SpectroscopyController.SpectraReductionContext.MeasurementAreaWing;
            BackgroundAreaWing = m_SpectroscopyController.SpectraReductionContext.BackgroundAreaWing;
            BackgroundAreaGap = m_SpectroscopyController.SpectraReductionContext.BackgroundAreaGap;
            PixelValueCoefficient = m_SpectroscopyController.SpectraReductionContext.PixelValueCoefficient;

            var starToTrack = new TrackedObjectConfig()
            {
                ApertureInPixels = (float)(SelectedStarFWHM * 2),
                MeasureThisObject = false,
                ApertureDX = 0,
                ApertureDY = 0,

                Gaussian = m_SelectedStarGaussian,
                ApertureStartingX = (float)m_SelectedStarGaussian.XCenter,
                ApertureStartingY = (float)m_SelectedStarGaussian.YCenter,
                TrackingType = TrackingType.OccultedStar,
                IsWeakSignalObject = false
            };

            m_Tracker = new SpectroscopyStarTracker(starToTrack);

            m_OperationState = SpectroscopyState.RunningMeasurements;
            m_AllFramesSpectra.Clear();

            m_ControlPanel.MeasurementsStarted();

            m_FirstMeasuredFrame = null;
            m_CancelMeasurementsRequested = false;
            m_FramePlayer.Start(FramePlaySpeed.Fastest, null, 1);
        }
        public void NextFrame(int frameNo, MovementType movementType, bool isLastFrame, AstroImage astroImage, int firstFrameInIntegrationPeriod, string fileName)
        {
            m_CurrentFrameNo = frameNo;

            if (m_OperationState == SpectroscopyState.RunningMeasurements)
            {
                if (m_FirstMeasuredFrame == null)
                {
                    m_FirstMeasuredFrame = m_CurrentFrameNo;
                    if (m_VideoController.HasEmbeddedTimeStamps()) m_FirstFrameTimeStamp = m_VideoController.GetCurrentFrameTime();
                    else if (m_VideoController.HasSystemTimeStamps()) m_FirstFrameTimeStamp = m_VideoController.GetCurrentFrameTime();
                    m_FrameBitmapPixels = astroImage.Pixelmap.DisplayBitmapPixels;
                }

                m_Tracker.NextFrame(frameNo, astroImage);
                if (m_Tracker.IsTrackedSuccessfully)
                {
                    TrackedObject trackedStar = m_Tracker.TrackedStar;
                    SelectedStar = trackedStar.Center;

                    m_Reader = new SpectraReader(astroImage, SelectedStarBestAngle, m_SpectroscopyController.SpectraReductionContext.PixelValueCoefficient);

                    Spectra thisFrameSpectra = m_Reader.ReadSpectra(
                        trackedStar.ThisFrameX,
                        trackedStar.ThisFrameY,
                        m_SpectroscopyController.SpectraReductionContext.MeasurementAreaWing,
                        m_SpectroscopyController.SpectraReductionContext.BackgroundAreaWing,
                        m_SpectroscopyController.SpectraReductionContext.BackgroundAreaGap,
                        m_SpectroscopyController.SpectraReductionContext.BackgroundMethod);

                    thisFrameSpectra.ZeroOrderFWHM = trackedStar.PSFFit != null ? (float)trackedStar.PSFFit.FWHM : float.NaN;

                    m_AllFramesSpectra.Add(thisFrameSpectra);
                }

                if (isLastFrame || m_CancelMeasurementsRequested || m_AllFramesSpectra.Count >= m_SpectroscopyController.SpectraReductionContext.FramesToMeasure)
                {
                    m_FramePlayer.Stop();

                    m_MasterSpectra = m_SpectroscopyController.ComputeResult(
                        m_AllFramesSpectra,
                        m_SpectroscopyController.SpectraReductionContext.FrameCombineMethod,
                        m_SpectroscopyController.SpectraReductionContext.UseFineAdjustments,
                        m_SpectroscopyController.SpectraReductionContext.AlignmentAbsorptionLinePos);

                    m_AllFramesSpectra.Clear();

                    m_MasterSpectra.MeasurementInfo = m_SpectroscopyController.GetMeasurementInfo();
                    m_MasterSpectra.MeasurementInfo.FirstMeasuredFrame = m_FirstMeasuredFrame.Value;
                    m_MasterSpectra.MeasurementInfo.LastMeasuredFrame = m_CurrentFrameNo;
                    m_MasterSpectra.MeasurementInfo.FirstFrameTimeStamp = m_FirstFrameTimeStamp;
                    if (m_VideoController.HasEmbeddedTimeStamps())
                        m_MasterSpectra.MeasurementInfo.LastFrameTimeStamp = m_VideoController.GetCurrentFrameTime();
                    else if (m_VideoController.HasSystemTimeStamps())
                        m_MasterSpectra.MeasurementInfo.LastFrameTimeStamp = m_VideoController.GetCurrentFrameTime();

                    FrameStateData frameStatus = m_VideoController.GetCurrentFrameState();
                    m_MasterSpectra.MeasurementInfo.Gain = frameStatus.Gain;
                    m_MasterSpectra.MeasurementInfo.ExposureSeconds = m_SpectroscopyController.SpectraReductionContext.ExposureSeconds;

                    m_MasterSpectra.MeasurementInfo.FrameBitmapPixels = m_FrameBitmapPixels;

                    m_SpectroscopyController.PopulateMasterSpectraObservationDetails(m_MasterSpectra);

                    m_OperationState = SpectroscopyState.DisplayingMeasurements;
                    m_ControlPanel.MeasurementsFinished();
                    DisplaySpectra();
                }

                Application.DoEvents();
            }
        }
        public override void MouseClick(ObjectClickEventArgs e)
        {
            if (m_OperationState == SpectroscopyState.ChoosingStar && e.Gausian != null && e.Gausian.IsSolved && e.Gausian.Certainty > 0.2)
            {
                float bestAngle = m_SpectroscopyController.LocateSpectraAngle(e.Gausian);

                if (float.IsNaN(bestAngle))
                {
                    SelectedStar = new ImagePixel(e.Gausian.XCenter, e.Gausian.YCenter);
                    SelectedStarFWHM = e.Gausian.FWHM;
                    m_SelectedStarGaussian = e.Gausian;
                    MeasurementAreaWing = (int)(2 * Math.Ceiling(SelectedStarFWHM));
                    BackgroundAreaWing = MeasurementAreaWing;
                    BackgroundAreaGap = 5;

                    SelectedAnglePoint = Point.Empty;
                    m_ControlPanel.ClearSpectra();

                    m_OperationState = SpectroscopyState.ChoosingAngleManually;
                }
                else
                {
                    SelectedStar = new ImagePixel(e.Gausian.XCenter, e.Gausian.YCenter);
                    SelectedStarFWHM = e.Gausian.FWHM;
                    m_SelectedStarGaussian = e.Gausian;
                    MeasurementAreaWing = (int)(2 * Math.Ceiling(SelectedStarFWHM));
                    BackgroundAreaWing = MeasurementAreaWing;
                    BackgroundAreaGap = 5;

                    SetBestAngle(bestAngle);
                }

                m_VideoController.RedrawCurrentFrame(false, true);
            }
            else if (m_OperationState == SpectroscopyState.ChoosingAngleManually && SelectedStar != null)
            {
                double atanAgnle = 180 * Math.Atan((SelectedStar.YDouble - e.Pixel.YDouble)/(e.Pixel.XDouble - SelectedStar.XDouble)) / Math.PI;
                if (atanAgnle < 0) atanAgnle = 360 + atanAgnle;
                int roughAngle = (int) atanAgnle;
                float bestAngle = m_SpectroscopyController.LocateSpectraAngle(e.Gausian, roughAngle);
                if (!float.IsNaN(bestAngle))
                {
                    SetBestAngle(bestAngle);
                    m_VideoController.RedrawCurrentFrame(false, true);
                }
            }
        }
        public bool InitializeOperation(IVideoController videoContoller, Panel controlPanel, IFramePlayer framePlayer, Form topForm)
        {
            m_VideoController = (VideoController)videoContoller;
            m_FramePlayer = framePlayer;

            if (m_ControlPanel == null)
            {
                lock (m_SyncRoot)
                {
                    if (m_ControlPanel == null)
                    {
                        m_ControlPanel = new ucSpectroscopy(this, (VideoController)videoContoller, m_SpectroscopyController, framePlayer);
                    }
                }
            }

            controlPanel.Controls.Clear();
            controlPanel.Controls.Add(m_ControlPanel);
            m_ControlPanel.Dock = DockStyle.Fill;

            m_OperationState = SpectroscopyState.ChoosingStar;
            SelectedStar = null;
            SelectedAnglePoint = Point.Empty;

            m_OriginalWidth = framePlayer.Video.Width;
            m_OriginalHeight = framePlayer.Video.Height;
            m_OriginalVideoFrame = new Rectangle(0, 0, m_OriginalWidth, m_OriginalHeight);

            return true;
        }
Exemple #10
0
        public void NextFrame(int frameNo, MovementType movementType, bool isLastFrame, AstroImage astroImage, int firstFrameInIntegrationPeriod, string fileName)
        {
            m_CurrentFrameNo = frameNo;

            if (m_OperationState == SpectroscopyState.RunningMeasurements)
            {
                if (m_FirstMeasuredFrame == null)
                {
                    m_FirstMeasuredFrame = m_CurrentFrameNo;
                    if (m_VideoController.HasEmbeddedTimeStamps())
                    {
                        m_FirstFrameTimeStamp = m_VideoController.GetCurrentFrameTime();
                    }
                    else if (m_VideoController.HasSystemTimeStamps())
                    {
                        m_FirstFrameTimeStamp = m_VideoController.GetCurrentFrameTime();
                    }
                    m_FrameBitmapPixels = astroImage.Pixelmap.DisplayBitmapPixels;
                }

                m_Tracker.NextFrame(frameNo, astroImage);
                if (m_Tracker.IsTrackedSuccessfully)
                {
                    TrackedObject trackedStar = m_Tracker.TrackedStar;
                    SelectedStar = trackedStar.Center;

                    m_Reader = new SpectraReader(astroImage, SelectedStarBestAngle, m_SpectroscopyController.SpectraReductionContext.PixelValueCoefficient);

                    Spectra thisFrameSpectra = m_Reader.ReadSpectra(
                        trackedStar.ThisFrameX,
                        trackedStar.ThisFrameY,
                        m_SpectroscopyController.SpectraReductionContext.MeasurementAreaWing,
                        m_SpectroscopyController.SpectraReductionContext.BackgroundAreaWing,
                        m_SpectroscopyController.SpectraReductionContext.BackgroundAreaGap,
                        m_SpectroscopyController.SpectraReductionContext.BackgroundMethod);

                    thisFrameSpectra.ZeroOrderFWHM = trackedStar.PSFFit != null ? (float)trackedStar.PSFFit.FWHM : float.NaN;

                    m_AllFramesSpectra.Add(thisFrameSpectra);
                }

                if (isLastFrame || m_CancelMeasurementsRequested || m_AllFramesSpectra.Count >= m_SpectroscopyController.SpectraReductionContext.FramesToMeasure)
                {
                    m_FramePlayer.Stop();

                    m_MasterSpectra = m_SpectroscopyController.ComputeResult(
                        m_AllFramesSpectra,
                        m_SpectroscopyController.SpectraReductionContext.FrameCombineMethod,
                        m_SpectroscopyController.SpectraReductionContext.UseFineAdjustments,
                        m_SpectroscopyController.SpectraReductionContext.AlignmentAbsorptionLinePos);

                    m_AllFramesSpectra.Clear();

                    m_MasterSpectra.MeasurementInfo = m_SpectroscopyController.GetMeasurementInfo();
                    m_MasterSpectra.MeasurementInfo.FirstMeasuredFrame  = m_FirstMeasuredFrame.Value;
                    m_MasterSpectra.MeasurementInfo.LastMeasuredFrame   = m_CurrentFrameNo;
                    m_MasterSpectra.MeasurementInfo.FirstFrameTimeStamp = m_FirstFrameTimeStamp;
                    if (m_VideoController.HasEmbeddedTimeStamps())
                    {
                        m_MasterSpectra.MeasurementInfo.LastFrameTimeStamp = m_VideoController.GetCurrentFrameTime();
                    }
                    else if (m_VideoController.HasSystemTimeStamps())
                    {
                        m_MasterSpectra.MeasurementInfo.LastFrameTimeStamp = m_VideoController.GetCurrentFrameTime();
                    }

                    FrameStateData frameStatus = m_VideoController.GetCurrentFrameState();
                    m_MasterSpectra.MeasurementInfo.Gain            = frameStatus.Gain;
                    m_MasterSpectra.MeasurementInfo.ExposureSeconds = m_SpectroscopyController.SpectraReductionContext.ExposureSeconds;

                    m_MasterSpectra.MeasurementInfo.FrameBitmapPixels = m_FrameBitmapPixels;

                    m_SpectroscopyController.PopulateMasterSpectraObservationDetails(m_MasterSpectra);

                    m_OperationState = SpectroscopyState.DisplayingMeasurements;
                    m_ControlPanel.MeasurementsFinished();
                    DisplaySpectra();
                }

                Application.DoEvents();
            }
        }