示例#1
0
        public bool InitializeOperation(IVideoController videoController, Panel controlPanel, IFramePlayer framePlayer, Form topForm)
        {
            TangraContext.Current.CanLoadFlatFrame = false;
            TangraContext.Current.CanLoadDarkFrame = false;
            TangraContext.Current.CanLoadBiasFrame = false;

            m_VideoController = videoController;

            if (m_ControlPanel == null)
            {
                lock (m_SyncRoot)
                {
                    if (m_ControlPanel == null)
                    {
                        m_ControlPanel = new ucMakeDarkFlatField(this);
                    }
                }
            }

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

            return(true);
        }
示例#2
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);
        }
        public bool InitializeOperation(IVideoController videoController, System.Windows.Forms.Panel controlPanel, Model.Video.IFramePlayer framePlayer, System.Windows.Forms.Form topForm)
        {
            m_VideoController = (VideoController)videoController;

            if (m_ControlPanel == null)
            {
                lock (m_SyncRoot)
                {
                    if (m_ControlPanel == null)
                    {
                        m_ControlPanel = new ucConvertVideoToAav(this, (VideoController)videoController);
                    }
                }
            }

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

            TangraContext.Current.CanPlayVideo = false;
            m_VideoController.UpdateViews();

            m_Converting = false;

            return(true);
        }
 public TestVideoMediaStreamSource(IVideoController videoController, ushort ssrcId, int frameWidth, int frameHeight)
 {
     this.frameWidth      = frameWidth;
     this.frameHeight     = frameHeight;
     this.videoController = videoController;
     this.ssrcId          = ssrcId;
 }
示例#5
0
        public bool InitializeOperation(IVideoController videoController, Panel controlPanel, IFramePlayer framePlayer, Form topForm)
        {
            m_Status          = ConvertVideoToFitsState.Configuring;
            m_VideoController = (VideoController)videoController;

            // We don't allow loading of calibration frames for now. Doing so with complicate the export
            TangraContext.Current.CanLoadFlatFrame = false;
            TangraContext.Current.CanLoadDarkFrame = false;
            TangraContext.Current.CanLoadBiasFrame = false;

            if (m_ControlPanel == null)
            {
                lock (m_SyncRoot)
                {
                    if (m_ControlPanel == null)
                    {
                        m_ControlPanel = new ucConvertVideoToFits(this, (VideoController)videoController);
                    }
                }
            }

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

            return(true);
        }
 private void MainWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
 {
     if (_video != null)
     {
         _video.StopVideo();
         _video = null;
     }
 }
示例#7
0
 public VideoMediaStreamSource(IVideoController videoController, IVideoQualityController videoQualityController, ushort ssrcId, int frameWidth, int frameHeight)
 {
     _frameWidth             = frameWidth;
     _frameHeight            = frameHeight;
     _videoController        = videoController;
     _videoQualityController = videoQualityController;
     _ssrcId = ssrcId;
 }
示例#8
0
        public void ShowModal(IVideoController videoController)
        {
            var frm = new frmAavStatusChannelOnlyView((VideoController)videoController, m_AAV);

            frm.StartPosition = FormStartPosition.CenterParent;

            ((VideoController)videoController).ShowForm(frm);
        }
示例#9
0
 public void Initialize(TimestampOCRData initializationData, IVideoController videoController, int performanceMode)
 {
     m_InitializationData     = initializationData;
     m_VideoController        = videoController;
     m_Processor              = null;
     m_UseNativePreProcessing = performanceMode > 0;
     m_ForceErrorReport       = initializationData.ForceErrorReport;
     m_CalibrationImages.Clear();
 }
示例#10
0
        public LCStateMachine(ReduceLightCurveOperation videoOperation, IVideoController videoController)
        {
            m_VideoController = videoController;
            VideoOperation    = videoOperation;

            m_CurrentStateObject = new LCStateSelectMeasuringStars(this);
            m_CurrentState       = LightCurvesState.SelectMeasuringStars;
            m_CurrentStateObject.Initialize();
        }
示例#11
0
        public frmGenerateStarFieldVideoModel(IVideoController videoController)
            : this()
        {
            m_VideoController = videoController;

            cbxVideoFormat.SelectedIndex       = 0;
            cbxAAVIntegration.SelectedIndex    = 5;
            cbxPhotometricFilter.SelectedIndex = 3;
            m_SimulatedDarkFrame = null;
        }
示例#12
0
        public VideoProvider(IDatabaseProvider dbProvider)
        {
            if (dbProvider == null)
            {
                throw new ArgumentNullException(nameof(dbProvider));
            }

            _dbProvider      = dbProvider;
            _videoController = new VideoController();
        }
        public frmGenerateStarFieldVideoModel(IVideoController videoController)
            : this()
        {
            m_VideoController = videoController;

            cbxVideoFormat.SelectedIndex = 0;
            cbxAAVIntegration.SelectedIndex = 5;
            cbxPhotometricFilter.SelectedIndex = 3;
            m_SimulatedDarkFrame = null;
        }
示例#14
0
 internal VtiTimeStampComposer(VideoFormat?format, int integratedAAVFrames, bool evenBeforeOdd, bool duplicatedFields, IVideoController videoController, ICalibrationErrorProcessor calibrationErrorProcessor, Func <uint[]> getCurrImageQuery)
 {
     m_VideoFormat               = format;
     m_IntegratedAAVFrames       = integratedAAVFrames;
     m_VideoController           = videoController;
     m_CalibrationErrorProcessor = calibrationErrorProcessor;
     m_GetCurrImageQuery         = getCurrImageQuery;
     m_EvenBeforeOdd             = evenBeforeOdd;
     m_DuplicatedFields          = duplicatedFields;
     m_Corrector.Reset(m_VideoFormat);
 }
示例#15
0
 public MediaSinkFactory(IAudioController audioController,
                         IVideoController videoController,
                         MediaConfig mediaConfig,
                         IMediaEnvironment mediaEnvironment,
                         IVideoQualityController videoQualityController)
 {
     _audioController        = audioController;
     _videoController        = videoController;
     _mediaConfig            = mediaConfig;
     _mediaEnvironment       = mediaEnvironment;
     _videoQualityController = videoQualityController;
 }
示例#16
0
        internal ucLCFileInfo(LCFile lcFile, IVideoController videoController)
        {
            InitializeComponent();

            m_lcFile = lcFile;
            m_VideoController = videoController;
            DisplayLCFileInfo();

            // Only analogue video (or derived from it) has fields
            VideoFileFormat videoFileFormat = m_lcFile.Header.GetVideoFileFormat();
            btnShowFields.Visible = videoFileFormat == VideoFileFormat.AVI || videoFileFormat.IsAAV();
            m_ShowingFields = false;
        }
示例#17
0
        internal ucLCFileInfo(LCFile lcFile, IVideoController videoController)
        {
            InitializeComponent();

            m_lcFile          = lcFile;
            m_VideoController = videoController;
            DisplayLCFileInfo();

            // Only analogue video (or derived from it) has fields
            VideoFileFormat videoFileFormat = m_lcFile.Header.GetVideoFileFormat();

            btnShowFields.Visible = videoFileFormat == VideoFileFormat.AVI || videoFileFormat.IsAAV();
            m_ShowingFields       = false;
        }
示例#18
0
        public PlateObjectResolver(
            IAstrometryController astrometryController,
            IVideoController videoController,
            AstroImage image,
            LeastSquareFittedAstrometry impSol,
            List <IStar> stars,
            double maxMagForAstrometry)
        {
            m_AstrometryController = astrometryController;
            m_VideoController      = videoController;

            m_Image               = image;
            m_Astrometry          = impSol;
            m_Stars               = stars;
            m_MaxMagForAstrometry = maxMagForAstrometry;
        }
示例#19
0
        public PlateObjectResolver(
			IAstrometryController astrometryController,
			IVideoController videoController,
			AstroImage image,
			LeastSquareFittedAstrometry impSol,
			List<IStar> stars,
			double maxMagForAstrometry)
        {
            m_AstrometryController = astrometryController;
            m_VideoController = videoController;

            m_Image = image;
            m_Astrometry = impSol;
            m_Stars = stars;
            m_MaxMagForAstrometry = maxMagForAstrometry;
        }
示例#20
0
        public void Initialize(SettingsBase settings) //throws Exception
        {
            //Get the Foscam camera type (MJPEG or HD)
            FoscamCameraType cameraType;
            string           cameraTypeStr = (string)settings[VideoSettings.SETTING_CAMERA_TYPE];

            if (cameraTypeStr == null || cameraTypeStr == "")
            {
                cameraType = DEFAULT_CAMERA_TYPE;
            }
            else
            if (string.Equals(cameraTypeStr, SETTING_CAMERA_FOSCAM_HD, StringComparison.OrdinalIgnoreCase))
            {
                cameraType = FoscamCameraType.FoscamHD;
            }
            else if (string.Equals(cameraTypeStr, SETTING_CAMERA_FOSCAM_MJPEG, StringComparison.OrdinalIgnoreCase))
            {
                cameraType = FoscamCameraType.FoscamMJPEG;
            }
            else
            {
                throw new ArgumentNullException(VideoSettings.SETTING_CAMERA_TYPE);
            }

            //Get the camera URL
            string url = (string)settings[VideoSettings.SETTING_CAMERA_URL];

            if (url == null || url == "")
            {
                throw new ArgumentNullException(VideoSettings.SETTING_CAMERA_URL);
            }

            //Get the username
            string username = (string)settings[VideoSettings.SETTING_CAMERA_USERNAME] ?? DEFAULT_USERNAME;

            //Get the password
            string password = (string)settings[VideoSettings.SETTING_CAMERA_PASSWORD] ?? DEFAULT_PASSWORD;

            //Create video controller
            _video = FoscamVideo.CreateFoscamVideoController(cameraType, url, username, password, DEFAULT_VLC_OPTIONS);
        }
示例#21
0
        public bool InitializeOperation(IVideoController videoController, Panel controlPanel, IFramePlayer framePlayer, Form topForm)
        {
            m_Status          = ConvertVideoToFitsState.Configuring;
            m_VideoController = (VideoController)videoController;

            // We don't allow loading of calibration frames for now. Doing so with complicate the export
            TangraContext.Current.CanLoadFlatFrame = false;
            TangraContext.Current.CanLoadDarkFrame = false;
            TangraContext.Current.CanLoadBiasFrame = false;

            if (m_ControlPanel == null)
            {
                lock (m_SyncRoot)
                {
                    if (m_ControlPanel == null)
                    {
                        m_ControlPanel = new ucConvertVideoToFits(this, (VideoController)videoController);
                    }
                }
            }

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

            if (topForm.Height < 736)
            {
                // Make sure all controls of the panel are visible
                topForm.Height = 736;
            }

            var videoFileFormat = m_VideoController.GetVideoFileFormat();

            if (videoFileFormat == VideoFileFormat.AAV &&
                m_VideoController.CurrentFrameIndex == m_VideoController.VideoFirstFrame)
            {
                m_VideoController.StepForward();
            }

            return(true);
        }
示例#22
0
        public static bool CheckAndCorrectBadMaxPixelValue(string fileName, IVideoController videoController)
        {
            // MergeOverlappingAAVFiles(@"", @"");
            // FixOccuRecEveryFrameSavedInPeriod(fileName);
            // FixOccuRecEveryFrameNoLockedSavedInPeriod(fileName);

            try
            {
                byte aavVer;

                using (FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read))
                    using (BinaryReader rdr = new BinaryReader(fs))
                    {
                        int magic = rdr.ReadInt32();
                        if (magic != 0x46545346)
                        {
                            return(false);
                        }

                        aavVer = rdr.ReadByte();
                    }

                if (aavVer == 1)
                {
                    return(ProcessAAVv1File(fileName, videoController));
                }
                else if (aavVer == 2)
                {
                    return(ProcessAAVv2File(fileName, videoController));
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine(Model.Helpers.Extensions.GetFullStackTrace(ex));
                return(false);
            }
        }
        private void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            FoscamCameraType cameraType =
        #if USE_FOSCAM_HD_CAMERA
                FoscamCameraType.FoscamHD;
        #else
                FoscamCameraType.FoscamMJPEG;
        #endif

            _video  = FoscamVideo.CreateFoscamVideoController(cameraType, CAMERA_URL, USERNAME, PASSWORD);
            _motion = FoscamMotion.CreateFoscamMotionController(cameraType, CAMERA_URL, USERNAME, PASSWORD);
            _zoom   = FoscamZoom.CreateFoscamZoomController(cameraType, CAMERA_URL, USERNAME, PASSWORD);

            if (_video != null)
            {
                UIElement player = _video.VideoDisplay;
                player.SetValue(Grid.RowProperty, 0);
                //player.SetValue(Canvas.ZIndexProperty, -1);
                LayoutRoot.Children.Add(player);
                _video.StartVideo();
            }
        }
示例#24
0
        public static bool CheckAndCorrectBadMaxPixelValue(string fileName, IVideoController videoController)
        {
            try
            {
                byte aavVer;

                using (FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read))
                    using (BinaryReader rdr = new BinaryReader(fs))
                    {
                        int magic = rdr.ReadInt32();
                        if (magic != 0x46545346)
                        {
                            return(false);
                        }

                        aavVer = rdr.ReadByte();
                    }

                if (aavVer == 1)
                {
                    return(ProcessAAVv1File(fileName, videoController));
                }
                else if (aavVer == 2)
                {
                    return(ProcessAAVv2File(fileName, videoController));
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.GetFullStackTrace());
                return(false);
            }
        }
示例#25
0
        public LCStateMachine(ReduceLightCurveOperation videoOperation, IVideoController videoController)
        {
            m_VideoController = videoController;
            VideoOperation = videoOperation;

            m_CurrentStateObject = new LCStateSelectMeasuringStars(this);
            m_CurrentState = LightCurvesState.SelectMeasuringStars;
            m_CurrentStateObject.Initialize();
        }
示例#26
0
 public BackgroundProvider(IVideoController videoController)
 {
     m_VideoController = videoController;
 }
        public bool InitializeOperation(IVideoController videoController, System.Windows.Forms.Panel controlPanel, Model.Video.IFramePlayer framePlayer, System.Windows.Forms.Form topForm)
        {
            m_VideoController = (VideoController)videoController;

            if (m_ControlPanel == null)
            {
                lock (m_SyncRoot)
                {
                    if (m_ControlPanel == null)
                    {
                        m_ControlPanel = new ucConvertVideoToAav(this, (VideoController)videoController);
                    }
                }
            }

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

            TangraContext.Current.CanPlayVideo = false;
            m_VideoController.UpdateViews();

            m_Converting = false;

            return true;
        }
示例#28
0
 public void Initialize(TimestampOCRData initializationData, IVideoController videoController, int performanceMode)
 {
     m_InitializationData = initializationData;
     m_VideoController = videoController;
 }
示例#29
0
        public static StarMagnitudeFit PerformFit(
			IAstrometryController astrometryController,
			IVideoController videoController,
			int bitPix,
            uint maxSignalValue,
			FitInfo astrometricFit,
			TangraConfig.PhotometryReductionMethod photometryReductionMethod,
			TangraConfig.PsfQuadrature psfQuadrature,
			TangraConfig.PsfFittingMethod psfFittingMethod,
			TangraConfig.BackgroundMethod photometryBackgroundMethod,
			TangraConfig.PreProcessingFilter filter,
			List<IStar> catalogueStars,
            Guid magnitudeBandId,
			float encodingGamma,
			TangraConfig.KnownCameraResponse reverseCameraResponse,
			float? aperture,
			float? annulusInnerRadius,
			int? annulusMinPixels,
			ref float empericalPSFR0)
        {
            uint saturatedValue = TangraConfig.Settings.Photometry.Saturation.GetSaturationForBpp(bitPix, maxSignalValue);

            MeasurementsHelper measurer = new MeasurementsHelper(
                bitPix,
                photometryBackgroundMethod,
                TangraConfig.Settings.Photometry.SubPixelSquareSize,
                saturatedValue);

            measurer.SetCoreProperties(
                annulusInnerRadius ?? TangraConfig.Settings.Photometry.AnnulusInnerRadius,
                annulusMinPixels ?? TangraConfig.Settings.Photometry.AnnulusMinPixels,
                CorePhotometrySettings.Default.RejectionBackgroundPixelsStdDev,
                2 /* TODO: This must be configurable */);

            var bgProvider = new BackgroundProvider(videoController);
            measurer.GetImagePixelsCallback += new MeasurementsHelper.GetImagePixelsDelegate(bgProvider.measurer_GetImagePixelsCallback);

            List<double> intencities = new List<double>();
            List<double> magnitudes = new List<double>();
            List<double> colours = new List<double>();
            List<double> residuals = new List<double>();
            List<bool> saturatedFlags = new List<bool>();
            List<IStar> stars = new List<IStar>();
            List<PSFFit> gaussians = new List<PSFFit>();

            List<MagFitRecord> fitRecords = new List<MagFitRecord>();

            AstroImage currentAstroImage = videoController.GetCurrentAstroImage(false);
            Rectangle osdRectToExclude = astrometryController.OSDRectToExclude;
            Rectangle rectToInclude = astrometryController.RectToInclude;
            bool limitByInclusion = astrometryController.LimitByInclusion;

            int matSize = CorePhotometrySettings.Default.MatrixSizeForCalibratedPhotometry;

            double a = double.NaN;
            double b = double.NaN;
            double c = double.NaN;
            int excludedStars = 0;
            double empericalFWHM = double.NaN;

            try
            {
                foreach (PlateConstStarPair pair in astrometricFit.AllStarPairs)
                {
                    if (limitByInclusion && !rectToInclude.Contains((int)pair.x, (int)pair.y)) continue;
                    if (!limitByInclusion && osdRectToExclude.Contains((int)pair.x, (int)pair.y)) continue;

                    IStar star = catalogueStars.Find(s => s.StarNo == pair.StarNo);
                    if (star == null || double.IsNaN(star.Mag) || star.Mag == 0) continue;

                    uint[,] data = currentAstroImage.GetMeasurableAreaPixels((int)pair.x, (int)pair.y, matSize);

                    PSFFit fit = new PSFFit((int)pair.x, (int)pair.y);
                    fit.Fit(data, PSF_FIT_AREA_SIZE);
                    if (!fit.IsSolved) continue;

                    MagFitRecord record = new MagFitRecord();
                    record.Star = star;
                    record.Pair = pair;
                    record.PsfFit = fit;
                    record.Saturation = IsSaturated(data, matSize, saturatedValue);

                    if (!EXCLUDE_SATURATED_STARS || !record.Saturation)
                        fitRecords.Add(record);
                }

                // We need the average R0 if it hasn't been determined yet
                if (float.IsNaN(empericalPSFR0))
                {
                    empericalPSFR0 = 0;
                    foreach (MagFitRecord rec in fitRecords)
                    {
                        empericalPSFR0 += (float)rec.PsfFit.R0;
                    }
                    empericalPSFR0 /= fitRecords.Count;
                }

                empericalFWHM = 2 * Math.Sqrt(Math.Log(2)) * empericalPSFR0;

                foreach (MagFitRecord record in fitRecords)
                {
                    ImagePixel center = new ImagePixel(255, record.Pair.x, record.Pair.y);
                    int areaSize = filter == TangraConfig.PreProcessingFilter.NoFilter ? 17 : 19;

                    int centerX = (int)Math.Round(center.XDouble);
                    int centerY = (int)Math.Round(center.YDouble);

                    uint[,] data = currentAstroImage.GetMeasurableAreaPixels(centerX, centerY, areaSize);
                    uint[,] backgroundPixels = currentAstroImage.GetMeasurableAreaPixels(centerX, centerY, 35);

                    measurer.MeasureObject(
                        center,
                        data,
                        backgroundPixels,
                        currentAstroImage.Pixelmap.BitPixCamera,
                        filter,
                        photometryReductionMethod,
                        psfQuadrature,
                        psfFittingMethod,
                        aperture != null ? aperture.Value : (float)Aperture(record.PsfFit.FWHM),
                        record.PsfFit.FWHM,
                        (float)empericalFWHM,
                        new FakeIMeasuredObject(record.PsfFit),
                        null,
                        null,
                        false);

                    double intensity = measurer.TotalReading - measurer.TotalBackground;
                    if (intensity > 0)
                    {
                        var mag = record.Star.GetMagnitudeForBand(magnitudeBandId);
                        var clr = record.Star.MagJ - record.Star.MagK;

                        if (!double.IsNaN(mag) && !double.IsNaN(clr) && !double.IsInfinity(mag) && !double.IsInfinity(clr))
                        {
                            intencities.Add(intensity);
                            magnitudes.Add(record.Star.GetMagnitudeForBand(magnitudeBandId));
                            colours.Add(record.Star.MagJ - record.Star.MagK);

                            gaussians.Add(record.PsfFit);
                            stars.Add(record.Star);
                            saturatedFlags.Add(measurer.HasSaturatedPixels || record.PsfFit.IMax >= measurer.SaturationValue);
                        }
                    }
                }

                // Remove stars with unusual PSF fit radii (once only)
                double sum = 0;
                for (int i = 0; i < gaussians.Count; i++)
                {
                    sum += gaussians[i].R0;
                }
                double averageR = sum / gaussians.Count;

                residuals.Clear();
                sum = 0;
                for (int i = 0; i < gaussians.Count; i++)
                {
                    residuals.Add(averageR - gaussians[i].R0);
                    sum += (averageR - gaussians[i].R0) * (averageR - gaussians[i].R0);
                }
                double stdDev = Math.Sqrt(sum) / gaussians.Count;

                if (EXCLUDE_BAD_RESIDUALS)
                {
                    for (int i = residuals.Count - 1; i >= 0; i--)
                    {
                        if (Math.Abs(residuals[i]) > 6 * stdDev)
                        {
                            intencities.RemoveAt(i);
                            magnitudes.RemoveAt(i);
                            colours.RemoveAt(i);
                            stars.RemoveAt(i);
                            gaussians.RemoveAt(i);
                            saturatedFlags.RemoveAt(i);
                        }
                    }
                }

                double maxResidual = Math.Max(0.1, TangraConfig.Settings.Photometry.MaxResidualStellarMags);

                for (int itter = 1; itter <= MAX_ITERR; itter++)
                {
                    residuals.Clear();

                    SafeMatrix A = new SafeMatrix(intencities.Count, 3);
                    SafeMatrix X = new SafeMatrix(intencities.Count, 1);

                    int idx = 0;
                    for (int i = 0; i < intencities.Count; i++)
                    {
                        A[idx, 0] = magnitudes[i];
                        A[idx, 1] = colours[i];
                        A[idx, 2] = 1;

                        X[idx, 0] = -2.5 * Math.Log10(intencities[i]);

                        idx++;
                    }

                    SafeMatrix a_T = A.Transpose();
                    SafeMatrix aa = a_T * A;
                    SafeMatrix aa_inv = aa.Inverse();
                    SafeMatrix bx = (aa_inv * a_T) * X;

                    double Ka = bx[0, 0];
                    double Kb = bx[1, 0];
                    double Kc = bx[2, 0];

                    // -2.5 * a * Log(Median-Intensity) = A * Mv + B * Mjk + C - b
                    // -2.5 * Log(Median-Intensity) = Ka * Mv + Kb * Mjk + Kc
                    // Mv = -2.5 * a * Log(Median-Intensity) - b * Mjk - c
                    a = 1 / Ka;
                    b = -Kb / Ka;
                    c = -Kc / Ka;

                    int starsExcludedThisTime = 0;

                    if (EXCLUDE_BAD_RESIDUALS)
                    {
                        List<int> indexesToRemove = new List<int>();
                        for (int i = 0; i < intencities.Count; i++)
                        {
                            double computed = a * -2.5 * Math.Log10(intencities[i]) + b * colours[i] + c;

                            double diff = Math.Abs(computed - magnitudes[i]);
                            if (itter < MAX_ITERR)
                            {
                                if (Math.Abs(diff) > maxResidual)
                                {
                                    indexesToRemove.Add(i);
                                }
                            }
                            else
                                residuals.Add(diff);
                        }

                        for (int i = indexesToRemove.Count - 1; i >= 0; i--)
                        {
                            int idxToRemove = indexesToRemove[i];
                            intencities.RemoveAt(idxToRemove);
                            magnitudes.RemoveAt(idxToRemove);
                            colours.RemoveAt(idxToRemove);
                            stars.RemoveAt(idxToRemove);
                            gaussians.RemoveAt(idxToRemove);
                            saturatedFlags.RemoveAt(idxToRemove);

                            excludedStars++;
                            starsExcludedThisTime++;
                        }
                    }

                    if (starsExcludedThisTime == 0)
                        break;
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.ToString());
            }

            return new StarMagnitudeFit(
                currentAstroImage,
                bitPix,
                intencities, magnitudes, colours, stars, gaussians, new List<double>(),
                saturatedFlags, a, b, c, encodingGamma, reverseCameraResponse, excludedStars, filter, empericalFWHM,
                photometryReductionMethod, photometryBackgroundMethod, psfQuadrature, psfFittingMethod, measurer, aperture);
        }
        public bool InitializeOperation(IVideoController videoContoller, Panel controlPanel, IFramePlayer framePlayer, Form topForm)
        {
            m_NumberFramesWithBadTracking = 0;

            m_VideoController = (VideoController)videoContoller;
            m_ControlPanelHolder = controlPanel;

            var configForm = new frmSelectReductionType(m_VideoController, framePlayer);
            if (configForm.ShowDialog(topForm) == DialogResult.OK)
            {
                EnsureControlPanel(controlPanel);

                BeginConfiguration();

                TangraContext.Current.CanChangeTool = true;

                if (m_VideoController.IsPlainAviVideo &&
                    !TangraConfig.Settings.Generic.OcrInitialSetupCompleted)
                {
                    var frm = new frmChooseFirstTimeOcrSettings();
                    frm.ShowDialog(topForm);
                }

                return true;
            }

            TangraContext.Current.CanLoadBiasFrame = true;
            TangraContext.Current.CanLoadDarkFrame = true;
            TangraContext.Current.CanLoadFlatFrame = true;

            return false;
        }
示例#31
0
        private static bool ProcessAAVv1File(string fileName, IVideoController videoController)
        {
            Tuple <long, string> aavNormValTag;
            int expectedMaxPixelVal;

            using (FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read))
                using (BinaryReader rdr = new BinaryReader(fs))
                {
                    int  magic  = rdr.ReadInt32();
                    byte aavVer = rdr.ReadByte();
                    if (magic != 0x46545346 || aavVer != 1)
                    {
                        // Not an AAVv1 File
                        return(false);
                    }

                    fs.Seek(12, SeekOrigin.Current);

                    long systemTableOffs = rdr.ReadInt64();
                    long userTableOffs   = rdr.ReadInt64();

                    fs.Seek(systemTableOffs, SeekOrigin.Begin);
                    var sysTags = ReadTagsVer1(rdr);

                    fs.Seek(userTableOffs, SeekOrigin.Begin);
                    var userTags = ReadTagsVer1(rdr);

                    if (!sysTags.ContainsKey("BITPIX") ||
                        !sysTags.ContainsKey("EFFECTIVE-FRAME-RATE") ||
                        !sysTags.ContainsKey("NATIVE-FRAME-RATE") ||
                        !sysTags.ContainsKey("AAV16-NORMVAL"))
                    {
                        return(false);
                    }

                    int bitPix = int.Parse(sysTags["BITPIX"].Item2);
                    if (bitPix == 8)
                    {
                        // This is an 8-bit file and it is not affected by a MaxPixelValue issue.
                        return(false);
                    }

                    double effectiveFrameRate = double.Parse(sysTags["EFFECTIVE-FRAME-RATE"].Item2, CultureInfo.InvariantCulture);
                    double nativeFrameRate    = double.Parse(sysTags["NATIVE-FRAME-RATE"].Item2, CultureInfo.InvariantCulture);

                    expectedMaxPixelVal = (int)Math.Round(256 * nativeFrameRate / effectiveFrameRate);

                    if (sysTags.ContainsKey("AAV16-NORMVAL"))
                    {
                        aavNormValTag = sysTags["AAV16-NORMVAL"];
                    }
                    else if (userTags.ContainsKey("AAV16-NORMVAL"))
                    {
                        aavNormValTag = userTags["AAV16-NORMVAL"];
                    }
                    else
                    {
                        return(false);
                    }

                    int maxPixelValue = int.Parse(aavNormValTag.Item2);

                    if (expectedMaxPixelVal >= maxPixelValue)
                    {
                        // The MaxPixelValue s correct for this file. Nothing to do
                        return(false);
                    }

                    if (videoController.ShowMessageBox(
                            string.Format("This AAV file appears to have an incorrect MaxPixelValue which can result in incorrectly displayed object brightness. Press 'Yes' to fix the MaxPixelValue to the correct value of {0}.", expectedMaxPixelVal),
                            "Tangra",
                            MessageBoxButtons.YesNo,
                            MessageBoxIcon.Question) == DialogResult.No)
                    {
                        return(false);
                    }
                }

            string expectedStringValue = expectedMaxPixelVal.ToString();

            if (expectedStringValue.Length > aavNormValTag.Item2.Length)
            {
                videoController.ShowMessageBox(string.Format("Error changing MaxPixelValue from {0} to {1}", aavNormValTag.Item2, expectedMaxPixelVal), "Tangra", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }

            expectedStringValue = expectedStringValue.PadLeft(aavNormValTag.Item2.Length, '0');

            using (FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Write))
                using (BinaryWriter wrt = new BinaryWriter(fs))
                {
                    fs.Seek(aavNormValTag.Item1 + 1, SeekOrigin.Begin);
                    wrt.Write(Encoding.UTF8.GetBytes(expectedStringValue));
                }

            return(true);
        }
示例#32
0
        public static StarMagnitudeFit PerformFit(
            IAstrometryController astrometryController,
            IVideoController videoController,
            int bitPix,
            uint maxSignalValue,
            FitInfo astrometricFit,
            TangraConfig.PhotometryReductionMethod photometryReductionMethod,
            TangraConfig.PsfQuadrature psfQuadrature,
            TangraConfig.PsfFittingMethod psfFittingMethod,
            TangraConfig.BackgroundMethod photometryBackgroundMethod,
            TangraConfig.PreProcessingFilter filter,
            List <IStar> catalogueStars,
            Guid magnitudeBandId,
            float encodingGamma,
            TangraConfig.KnownCameraResponse reverseCameraResponse,
            float?aperture,
            float?annulusInnerRadius,
            int?annulusMinPixels,
            ref float empericalPSFR0)
        {
            uint saturatedValue = TangraConfig.Settings.Photometry.Saturation.GetSaturationForBpp(bitPix, maxSignalValue);

            MeasurementsHelper measurer = new MeasurementsHelper(
                bitPix,
                photometryBackgroundMethod,
                TangraConfig.Settings.Photometry.SubPixelSquareSize,
                saturatedValue);

            measurer.SetCoreProperties(
                annulusInnerRadius ?? TangraConfig.Settings.Photometry.AnnulusInnerRadius,
                annulusMinPixels ?? TangraConfig.Settings.Photometry.AnnulusMinPixels,
                CorePhotometrySettings.Default.RejectionBackgroundPixelsStdDev,
                2 /* TODO: This must be configurable */);

            var bgProvider = new BackgroundProvider(videoController);

            measurer.GetImagePixelsCallback += new MeasurementsHelper.GetImagePixelsDelegate(bgProvider.measurer_GetImagePixelsCallback);

            List <double> intencities    = new List <double>();
            List <double> magnitudes     = new List <double>();
            List <double> colours        = new List <double>();
            List <double> residuals      = new List <double>();
            List <bool>   saturatedFlags = new List <bool>();
            List <IStar>  stars          = new List <IStar>();
            List <PSFFit> gaussians      = new List <PSFFit>();

            List <MagFitRecord> fitRecords = new List <MagFitRecord>();

            AstroImage currentAstroImage = videoController.GetCurrentAstroImage(false);
            Rectangle  osdRectToExclude  = astrometryController.OSDRectToExclude;
            Rectangle  rectToInclude     = astrometryController.RectToInclude;
            bool       limitByInclusion  = astrometryController.LimitByInclusion;

            int matSize = CorePhotometrySettings.Default.MatrixSizeForCalibratedPhotometry;

            double a             = double.NaN;
            double b             = double.NaN;
            double c             = double.NaN;
            int    excludedStars = 0;
            double empericalFWHM = double.NaN;

            try
            {
                foreach (PlateConstStarPair pair in astrometricFit.AllStarPairs)
                {
                    if (limitByInclusion && !rectToInclude.Contains((int)pair.x, (int)pair.y))
                    {
                        continue;
                    }
                    if (!limitByInclusion && osdRectToExclude.Contains((int)pair.x, (int)pair.y))
                    {
                        continue;
                    }

                    IStar star = catalogueStars.Find(s => s.StarNo == pair.StarNo);
                    if (star == null || double.IsNaN(star.Mag) || star.Mag == 0)
                    {
                        continue;
                    }

                    uint[,] data = currentAstroImage.GetMeasurableAreaPixels((int)pair.x, (int)pair.y, matSize);

                    PSFFit fit = new PSFFit((int)pair.x, (int)pair.y);
                    fit.Fit(data, PSF_FIT_AREA_SIZE);
                    if (!fit.IsSolved)
                    {
                        continue;
                    }

                    MagFitRecord record = new MagFitRecord();
                    record.Star       = star;
                    record.Pair       = pair;
                    record.PsfFit     = fit;
                    record.Saturation = IsSaturated(data, matSize, saturatedValue);

                    if (!EXCLUDE_SATURATED_STARS || !record.Saturation)
                    {
                        fitRecords.Add(record);
                    }
                }

                // We need the average R0 if it hasn't been determined yet
                if (float.IsNaN(empericalPSFR0))
                {
                    empericalPSFR0 = 0;
                    foreach (MagFitRecord rec in fitRecords)
                    {
                        empericalPSFR0 += (float)rec.PsfFit.R0;
                    }
                    empericalPSFR0 /= fitRecords.Count;
                }

                empericalFWHM = 2 * Math.Sqrt(Math.Log(2)) * empericalPSFR0;

                foreach (MagFitRecord record in fitRecords)
                {
                    ImagePixel center   = new ImagePixel(255, record.Pair.x, record.Pair.y);
                    int        areaSize = filter == TangraConfig.PreProcessingFilter.NoFilter ? 17 : 19;

                    int centerX = (int)Math.Round(center.XDouble);
                    int centerY = (int)Math.Round(center.YDouble);

                    uint[,] data             = currentAstroImage.GetMeasurableAreaPixels(centerX, centerY, areaSize);
                    uint[,] backgroundPixels = currentAstroImage.GetMeasurableAreaPixels(centerX, centerY, 35);

                    measurer.MeasureObject(
                        center,
                        data,
                        backgroundPixels,
                        currentAstroImage.Pixelmap.BitPixCamera,
                        filter,
                        photometryReductionMethod,
                        psfQuadrature,
                        psfFittingMethod,
                        aperture != null ? aperture.Value : (float)Aperture(record.PsfFit.FWHM),
                        record.PsfFit.FWHM,
                        (float)empericalFWHM,
                        new FakeIMeasuredObject(record.PsfFit),
                        null,
                        null,
                        false);

                    double intensity = measurer.TotalReading - measurer.TotalBackground;
                    if (intensity > 0)
                    {
                        var mag = record.Star.GetMagnitudeForBand(magnitudeBandId);
                        var clr = record.Star.MagJ - record.Star.MagK;

                        if (!double.IsNaN(mag) && !double.IsNaN(clr) && !double.IsInfinity(mag) && !double.IsInfinity(clr))
                        {
                            intencities.Add(intensity);
                            magnitudes.Add(record.Star.GetMagnitudeForBand(magnitudeBandId));
                            colours.Add(record.Star.MagJ - record.Star.MagK);

                            gaussians.Add(record.PsfFit);
                            stars.Add(record.Star);
                            saturatedFlags.Add(measurer.HasSaturatedPixels || record.PsfFit.IMax >= measurer.SaturationValue);
                        }
                    }
                }


                // Remove stars with unusual PSF fit radii (once only)
                double sum = 0;
                for (int i = 0; i < gaussians.Count; i++)
                {
                    sum += gaussians[i].R0;
                }
                double averageR = sum / gaussians.Count;

                residuals.Clear();
                sum = 0;
                for (int i = 0; i < gaussians.Count; i++)
                {
                    residuals.Add(averageR - gaussians[i].R0);
                    sum += (averageR - gaussians[i].R0) * (averageR - gaussians[i].R0);
                }
                double stdDev = Math.Sqrt(sum) / gaussians.Count;

                if (EXCLUDE_BAD_RESIDUALS)
                {
                    for (int i = residuals.Count - 1; i >= 0; i--)
                    {
                        if (Math.Abs(residuals[i]) > 6 * stdDev)
                        {
                            intencities.RemoveAt(i);
                            magnitudes.RemoveAt(i);
                            colours.RemoveAt(i);
                            stars.RemoveAt(i);
                            gaussians.RemoveAt(i);
                            saturatedFlags.RemoveAt(i);
                        }
                    }
                }

                double maxResidual = Math.Max(0.1, TangraConfig.Settings.Photometry.MaxResidualStellarMags);

                for (int itter = 1; itter <= MAX_ITERR; itter++)
                {
                    residuals.Clear();

                    SafeMatrix A = new SafeMatrix(intencities.Count, 3);
                    SafeMatrix X = new SafeMatrix(intencities.Count, 1);

                    int idx = 0;
                    for (int i = 0; i < intencities.Count; i++)
                    {
                        A[idx, 0] = magnitudes[i];
                        A[idx, 1] = colours[i];
                        A[idx, 2] = 1;

                        X[idx, 0] = -2.5 * Math.Log10(intencities[i]);

                        idx++;
                    }

                    SafeMatrix a_T    = A.Transpose();
                    SafeMatrix aa     = a_T * A;
                    SafeMatrix aa_inv = aa.Inverse();
                    SafeMatrix bx     = (aa_inv * a_T) * X;

                    double Ka = bx[0, 0];
                    double Kb = bx[1, 0];
                    double Kc = bx[2, 0];

                    // -2.5 * a * Log(Median-Intensity) = A * Mv + B * Mjk + C - b
                    // -2.5 * Log(Median-Intensity) = Ka * Mv + Kb * Mjk + Kc
                    // Mv = -2.5 * a * Log(Median-Intensity) - b * Mjk - c
                    a = 1 / Ka;
                    b = -Kb / Ka;
                    c = -Kc / Ka;

                    int starsExcludedThisTime = 0;

                    if (EXCLUDE_BAD_RESIDUALS)
                    {
                        List <int> indexesToRemove = new List <int>();
                        for (int i = 0; i < intencities.Count; i++)
                        {
                            double computed = a * -2.5 * Math.Log10(intencities[i]) + b * colours[i] + c;

                            double diff = Math.Abs(computed - magnitudes[i]);
                            if (itter < MAX_ITERR)
                            {
                                if (Math.Abs(diff) > maxResidual)
                                {
                                    indexesToRemove.Add(i);
                                }
                            }
                            else
                            {
                                residuals.Add(diff);
                            }
                        }


                        for (int i = indexesToRemove.Count - 1; i >= 0; i--)
                        {
                            int idxToRemove = indexesToRemove[i];
                            intencities.RemoveAt(idxToRemove);
                            magnitudes.RemoveAt(idxToRemove);
                            colours.RemoveAt(idxToRemove);
                            stars.RemoveAt(idxToRemove);
                            gaussians.RemoveAt(idxToRemove);
                            saturatedFlags.RemoveAt(idxToRemove);

                            excludedStars++;
                            starsExcludedThisTime++;
                        }
                    }

                    if (starsExcludedThisTime == 0)
                    {
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.ToString());
            }

            return(new StarMagnitudeFit(
                       currentAstroImage,
                       bitPix,
                       intencities, magnitudes, colours, stars, gaussians, new List <double>(),
                       saturatedFlags, a, b, c, encodingGamma, reverseCameraResponse, excludedStars, filter, empericalFWHM,
                       photometryReductionMethod, photometryBackgroundMethod, psfQuadrature, psfFittingMethod, measurer, aperture));
        }
示例#33
0
        private static bool ProcessAAVv2File(string fileName, IVideoController videoController)
        {
            Tuple <long, string> currMaxPixelValue;
            Tuple <long, string> currMaxPixelValueImgSec;
            int expectedMaxPixelVal;

            using (FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read))
                using (BinaryReader rdr = new BinaryReader(fs))
                {
                    int  magic  = rdr.ReadInt32();
                    byte aavVer = rdr.ReadByte();
                    if (magic != 0x46545346 || aavVer != 2)
                    {
                        // Not an AAVv2 File
                        return(false);
                    }

                    fs.Seek(12, SeekOrigin.Current);

                    long sysMetaOffs = rdr.ReadInt64();

                    long userMetaOffs = rdr.ReadInt64();

                    fs.Seek(1, SeekOrigin.Current);

                    string stream1 = ReadString(rdr);

                    fs.Seek(24, SeekOrigin.Current);

                    string stream2 = ReadString(rdr);
                    fs.Seek(24, SeekOrigin.Current);

                    rdr.ReadByte();
                    string section1   = ReadString(rdr);
                    long   imgSecOffs = rdr.ReadInt64();

                    if (stream1 != "MAIN" || stream2 != "CALIBRATION" || section1 != "IMAGE")
                    {
                        // Not a standard AAVv2 File
                        return(false);
                    }

                    fs.Seek(sysMetaOffs, SeekOrigin.Begin);
                    var sysTags = ReadTags(rdr);

                    fs.Seek(userMetaOffs, SeekOrigin.Begin);
                    var userTags = ReadTags(rdr);
                    foreach (var kvp in userTags)
                    {
                        sysTags[kvp.Key] = kvp.Value;
                    }

                    fs.Seek(imgSecOffs + 10, SeekOrigin.Begin);
                    byte numLayouts = rdr.ReadByte();
                    for (int i = 0; i < numLayouts; i++)
                    {
                        fs.Seek(3, SeekOrigin.Current);
                        int tagsCount = rdr.ReadByte();
                        ReadTags(rdr, tagsCount);
                    }
                    int imgTagsCnt = rdr.ReadByte();
                    var imgTags    = ReadTags(rdr, imgTagsCnt);

                    if (!sysTags.ContainsKey("BITPIX") ||
                        !sysTags.ContainsKey("EFFECTIVE-FRAME-RATE") ||
                        !sysTags.ContainsKey("NATIVE-FRAME-RATE") ||
                        !sysTags.ContainsKey("AAV16-NORMVAL") ||
                        !imgTags.ContainsKey("IMAGE-MAX-PIXEL-VALUE"))
                    {
                        return(false);
                    }

                    int bitPix = int.Parse(sysTags["BITPIX"].Item2);
                    if (bitPix == 8)
                    {
                        // This is an 8-bit file and it is not affected by a MaxPixelValue issue.
                        return(false);
                    }

                    double effectiveFrameRate = double.Parse(sysTags["EFFECTIVE-FRAME-RATE"].Item2, CultureInfo.InvariantCulture);
                    double nativeFrameRate    = double.Parse(sysTags["NATIVE-FRAME-RATE"].Item2, CultureInfo.InvariantCulture);

                    expectedMaxPixelVal = (int)Math.Round(256 * nativeFrameRate / effectiveFrameRate);
                    int maxPixelValue       = int.Parse(sysTags["AAV16-NORMVAL"].Item2);
                    int maxPixelValueImgSec = int.Parse(imgTags["IMAGE-MAX-PIXEL-VALUE"].Item2);

                    if (expectedMaxPixelVal == maxPixelValue && expectedMaxPixelVal == maxPixelValueImgSec)
                    {
                        // The MaxPixelValue s correct for this file. Nothing to do
                        return(false);
                    }

                    if (videoController.ShowMessageBox(
                            string.Format("This AAV file appears to have an incorrect MaxPixelValue which can result in incorrectly displayed object brightness. Press 'Yes' to fix the MaxPixelValue to the correct value of {0}.", expectedMaxPixelVal),
                            "Tangra",
                            MessageBoxButtons.YesNo,
                            MessageBoxIcon.Question) == DialogResult.No)
                    {
                        return(false);
                    }

                    currMaxPixelValue       = sysTags["AAV16-NORMVAL"];
                    currMaxPixelValueImgSec = imgTags["IMAGE-MAX-PIXEL-VALUE"];
                }

            string expectedStringValue = expectedMaxPixelVal.ToString();

            if (expectedStringValue.Length > currMaxPixelValue.Item2.Length || expectedStringValue.Length > currMaxPixelValueImgSec.Item2.Length)
            {
                videoController.ShowMessageBox(string.Format("Error changing MaxPixelValue from {0}|{1} to {2}", currMaxPixelValue.Item2, currMaxPixelValueImgSec.Item2, expectedMaxPixelVal), "Tangra", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }

            expectedStringValue = expectedStringValue.PadLeft(currMaxPixelValue.Item2.Length, '0');

            using (FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Write))
                using (BinaryWriter wrt = new BinaryWriter(fs))
                {
                    fs.Seek(currMaxPixelValue.Item1 + 2, SeekOrigin.Begin);
                    wrt.Write(Encoding.UTF8.GetBytes(expectedStringValue));

                    fs.Seek(currMaxPixelValueImgSec.Item1 + 2, SeekOrigin.Begin);
                    wrt.Write(Encoding.UTF8.GetBytes(expectedStringValue));
                }

            return(true);
        }
示例#34
0
 public BackgroundProvider(IVideoController videoController)
 {
     m_VideoController = videoController;
 }
        public bool InitializeOperation(IVideoController videoController, Panel controlPanel, IFramePlayer framePlayer, Form topForm)
        {
            m_Status = ConvertVideoToFitsState.Configuring;
            m_VideoController = (VideoController)videoController;

            // We don't allow loading of calibration frames for now. Doing so with complicate the export
            TangraContext.Current.CanLoadFlatFrame = false;
            TangraContext.Current.CanLoadDarkFrame = false;
            TangraContext.Current.CanLoadBiasFrame = false;

            if (m_ControlPanel == null)
            {
                lock (m_SyncRoot)
                {
                    if (m_ControlPanel == null)
                    {
                        m_ControlPanel = new ucConvertVideoToFits(this, (VideoController)videoController);
                    }
                }
            }

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

            return true;
        }
示例#36
0
 public void NewMission(Location loc, Airframe plane, User user, Camera camera, IMavLinkListener callback, IVideoController videoController)
 {
     frmCreateMission createMission = new frmCreateMission();
     if (createMission.ShowDialog() == System.Windows.Forms.DialogResult.OK)
     {
         IsLive = createMission.IsLive;
         if (createMission.IsLive)
         {
             missionReader = new MissionPlannerLiveConnector("127.0.0.1", "56781", callback);
             if (missionReader.Open(false, DateTime.Now))
             {
                 mission = new Mission(loc, plane, user, camera, createMission.Description, createMission.VideoFile, createMission.LogFile);
                 this.videoController = videoController;
             }
         }
         else
         {
             if (File.Exists(createMission.LogFile) && File.Exists(createMission.VideoFile))
             {
                 mission = new Mission(loc, plane, user, camera, createMission.Description, createMission.VideoFile, createMission.LogFile);
                 missionReader = new MissionPlannerLogReader(createMission.LogFile, false, callback);
                 this.videoController = videoController;
             }
         }
     }
 }
示例#37
0
 public void Initialize(TimestampOCRData initializationData, IVideoController videoController, int performanceMode)
 {
     m_InitializationData = initializationData;
     m_VideoController = videoController;
     m_Processor = null;
     m_UseNativePreProcessing = performanceMode > 0;
     m_ForceErrorReport = initializationData.ForceErrorReport;
     m_FrameStep = -1;
     m_CalibrationImages.Clear();
 }
        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;
        }
示例#39
0
        public bool InitializeOperation(IVideoController videoController, Panel controlPanel, IFramePlayer framePlayer, Form topForm)
        {
            TangraContext.Current.CanLoadFlatFrame = false;
            TangraContext.Current.CanLoadDarkFrame = false;
            TangraContext.Current.CanLoadBiasFrame = false;

            m_VideoController = videoController;

            if (m_ControlPanel == null)
            {
                lock(m_SyncRoot)
                {
                    if (m_ControlPanel == null)
                    {
                        m_ControlPanel = new ucMakeDarkFlatField(this);
                    }
                }
            }

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

            return true;
        }
示例#40
0
 public VideoSinkAdapter(CaptureSource captureSource, IVideoController mediaController, IVideoQualityController videoQualityController)
 {
     CaptureSource           = captureSource;
     _mediaController        = mediaController;
     _videoQualityController = videoQualityController;
 }
示例#41
0
 public void Initialize(TimestampOCRData initializationData, IVideoController videoController, int performanceMode)
 {
     m_InitializationData = initializationData;
     m_VideoController    = videoController;
 }
        internal void EnterViewLightCurveMode(LCFile lcFile, IVideoController videoController, Panel controlPanelHolder)
        {
            m_ControlPanelHolder = controlPanelHolder;

            m_VideoController = (VideoController)videoController;
            EnsureControlPanel(m_ControlPanelHolder);

            m_LightCurveController.SetLcFile(lcFile);

            m_Measuring = false;
            m_Refining = false;
            m_ViewingLightCurve = true;
            m_Configuring = false;

            m_StateMachine = new LCStateMachine(this, m_VideoController);
            m_StateMachine.ChangeState(LightCurvesState.Viewing);

            m_StateMachine.SelectedMeasuringStar = -1;
            m_StateMachine.SelectedObject = null;

            m_MeasurementInterval = 1;
            m_CurrFrameNo = -1;
            m_CurrFileName = null;

            m_ControlPanel.BeginConfiguration(m_StateMachine, m_VideoController);
            m_ControlPanel.SetupLCFileInfo(m_LightCurveController.LcFile);
            m_ControlPanel.UpdateState();
        }