public override void InitialiseState(CameraStateManager stateManager)
        {
            lockedIntegrationRate = lastIntegratedFrameIntegration;
            numberOfDroppedFrames = 0;

            // We don't call the base class in order not to stuff up the stats
        }
        public override void ProcessFrame(CameraStateManager stateManager, Helpers.VideoFrameWrapper frame)
        {
            if (frame.IntegrationRate.HasValue && frame.IntegrationRate.Value > 1)
                lastIntegratedFrameIntegration = frame.IntegrationRate.Value;

            if (frame.DroppedFramesSinceLocked.HasValue)
                numberOfDroppedFrames = frame.DroppedFramesSinceLocked.Value;
        }
        public override void ProcessFrame(CameraStateManager stateManager, Helpers.VideoFrameWrapper frame)
        {
            base.ProcessFrame(stateManager, frame);

            if (status == CalibrationStatus.CollectingData)
            {
                if (frame.PerformedAction.HasValue && frame.PerformedAction.Value == 1)
                {
                    if (frame.PerformedActionProgress.HasValue && (Math.Abs(frame.PerformedActionProgress.Value - 1) < 0.001))
                    {
                        // Calibration data collection has finished. Need to get the data and complete the calibration
                        Dictionary<float, List<float>> calibrationData = NativeHelpers.GetIntegrationCalibrationData();
                        status = CalibrationStatus.CalculatingBestSettings;
                        ThreadPool.QueueUserWorkItem(FindBestIntegrationDetectionSettings, calibrationData);
                    }
                }
            }
            else if (status == CalibrationStatus.Finished)
            {
                stateManager.CancelIntegrationCalibration(calibrationSuccessful);
            }
        }
예제 #4
0
        public VideoRenderingController(frmMain mainForm, CameraStateManager stateManager, FrameAnalysisManager analysisManager)
        {
            m_MainForm = mainForm;
            this.stateManager = stateManager;
            this.analysisManager = analysisManager;

            running = true;
            previewOn = true;

            m_DisplayIntensifyMode = Settings.Default.DisplayIntensifyMode;
            m_DisplayInvertedMode = Settings.Default.UseInvertedDisplayMode;
            m_DisplayHueIntensityMode = Settings.Default.UseHueIntensityDisplayMode;

            m_MainForm.tsmiHueIntensity.Checked = m_DisplayHueIntensityMode;
            m_MainForm.tsmiInverted.Checked = m_DisplayInvertedMode;
            m_MainForm.tsmiOff.Checked = m_DisplayIntensifyMode == DisplayIntensifyMode.Off;
            m_MainForm.tsmiLo.Checked = m_DisplayIntensifyMode == DisplayIntensifyMode.Lo;
            m_MainForm.tsmiHigh.Checked = m_DisplayIntensifyMode == DisplayIntensifyMode.Hi;

            cameraImage = new CameraImage();

            ThreadPool.QueueUserWorkItem(new WaitCallback(DisplayVideoFrames));
        }
예제 #5
0
        public virtual void ProcessFrame(CameraStateManager stateManager, Helpers.VideoFrameWrapper frame)
        {
            if (lastIntegratedFrameNumber != frame.FrameNumber)
            {
                readFrameNo++;

                if (lastIntegratedFrameIntegration <= 0)
                {
                    if (frame.IntegrationRate != null)
                    {
                        lastIntegratedFrameIntegration = frame.IntegrationRate.Value;
                        numberConsequtiveSameIntegrationIntegratedFrames = 0;
                    }
                    else
                    {
                        lastIntegratedFrameIntegration = -1;
                        numberConsequtiveSameIntegrationIntegratedFrames = 0;
                    }
                }
                else if (frame.IntegrationRate != null && lastIntegratedFrameIntegration == frame.IntegrationRate.Value)
                {
                    if (lastReadFrameNumber == readFrameNo - 1)
                        numberConsequtiveSameIntegrationIntegratedFrames++;
                    else
                        numberConsequtiveSameIntegrationIntegratedFrames = 0;
                }
                else
                {
                    numberConsequtiveSameIntegrationIntegratedFrames = 0;
                    if (frame.IntegrationRate != null)
                        lastIntegratedFrameIntegration = frame.IntegrationRate.Value;
                }

                lastReadFrameNumber = readFrameNo;
            }
        }
예제 #6
0
파일: frmMain.cs 프로젝트: hpavlov/occurec
        public frmMain()
        {
            InitializeComponent();

            statusStrip.SizingGrip = false;

            m_StateManager = new CameraStateManager();
            m_StateManager.CameraDisconnected();

            m_ObservatoryController = new ObservatoryController();
            m_ObservatoryController.TelescopeConnectionChanged += TelescopeConnectionChanged;
            m_ObservatoryController.FocuserConnectionChanged += FocuserConnectionChanged;
            m_ObservatoryController.VideoConnectionChanged += VideoConnectionChanged;
            m_ObservatoryController.TelescopeStateUpdated += TelescopeStateUpdated;
            m_ObservatoryController.FocuserStateUpdated += FocuserStateUpdated;
            m_ObservatoryController.FocuserPositionUpdated += FocuserPositionUpdated;
            m_ObservatoryController.VideoStateUpdated += VideoStateUpdated;
            m_ObservatoryController.VideoError += VideoError;

            m_AnalysisManager = new FrameAnalysisManager(m_ObservatoryController);
            m_VideoRenderingController = new VideoRenderingController(this, m_StateManager, m_AnalysisManager);
            m_VideoFrameInteractionController = new VideoFrameInteractionController(this, m_VideoRenderingController);

            Version occuRecVersion = Assembly.GetExecutingAssembly().GetName().Version;
            bool isBeta = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(BetaReleaseAttribute), false).Length == 1;
            appVersion = string.Format("v{0}.{1}{2}", occuRecVersion.Major, occuRecVersion.Minor, isBeta ? " BETA" : "");

            Text = string.Format("OccuRec {0}", appVersion);

            CheckForUpdates(false);

            UpdateState(null);

            ASCOMClient.Instance.Initialise(Settings.Default.ASCOMLoadInSeparateAppDomain);
            TelescopeConnectionChanged(ASCOMConnectionState.Disconnected);
            FocuserConnectionChanged(ASCOMConnectionState.Disconnected);
            VideoConnectionChanged(ASCOMConnectionState.Disconnected);

            UpdateASCOMConnectivityState();
        }
예제 #7
0
 public virtual void InitialiseState(CameraStateManager stateManager)
 {
     ResetIntegrationStats();
 }
 public override void InitialiseState(CameraStateManager stateManager)
 {
     status = CalibrationStatus.CollectingData;
     calibrationSuccessful = false;
 }
 public override void ProcessFrame(CameraStateManager stateManager, Helpers.VideoFrameWrapper frame)
 {
     // Nothing to do
 }
        private void ProcessFrame(CameraStateManager stateManager, int[,] pixels, int width, int height)
        {
            if (pixels != null)
            {
                int imageWidth = pixels.GetLength(1);
                int imageHeight = pixels.GetLength(0);

                uint[] data = new uint[imageWidth * imageHeight];

                if (imageWidth == width && imageHeight == height)
                {
                    for (int y = 0; y < imageHeight; y++)
                    {
                        for (int x = 0; x < imageWidth; x++)
                        {
                            data[x + y*imageWidth] = (uint) pixels[y, x];
                        }
                    }
                }
                else if (imageWidth == height && imageHeight == width)
                {
                    imageWidth = width;
                    imageHeight = height;

                    for (int y = 0; y < imageHeight; y++)
                    {
                        for (int x = 0; x < imageWidth; x++)
                        {
                            data[x + y * imageWidth] = (uint)pixels[x, y];
                        }
                    }
                }

                if (LocateTimestampPosition(data, imageWidth, imageHeight))
                {
            #if DEBUG
                    if (Settings.Default.SimulateFailedVtiOsdDetection)
                    {
                        m_AttemptedFrames++;
                        return;
                    }
            #endif

                    if (m_IdenfitiedFrames == 0)
                    {
                        m_IdenfitiedFromLine = m_FromLine;
                        m_IdenfitiedtoLine = m_ToLine;

                        m_IdenfitiedFrames++;
                    }
                    else if (
                        m_IdenfitiedFromLine == m_FromLine &&
                        m_IdenfitiedtoLine == m_ToLine)
                    {
                        m_IdenfitiedFrames++;

                        if (m_IdenfitiedFrames >= 3)
                        {
                            Settings.Default.PreserveVtiOsdFirstRawAuto = m_FromLine;
                            Settings.Default.PreserveVtiOsdLastRawAuto = m_ToLine;

                            NativeHelpers.SetupTimestampPreservation(true, Settings.Default.PreserveVtiOsdFirstRawAuto, (Settings.Default.PreserveVtiOsdLastRawAuto - Settings.Default.PreserveVtiOsdFirstRawAuto) / 2);

                            // Keep showing the AssumedVtiOsd lines for another 5 sec for user's visual confirmation that they are correct
                            OccuRecContext.Current.ShowAssumedVtiOsdPositionUntil = DateTime.Now.AddSeconds(5);

                            stateManager.ChangeState(UndeterminedIntegrationCameraState.Instance);
                        }
                    }
                    else
                    {
                        m_IdenfitiedFrames = 0;
                    }
                }
                else
                {
                    m_AttemptedFrames++;
                }

                if (VtiOsdAutomaticDetectionFailed)
                {
                    if (!Settings.Default.PreserveVTIUserSpecifiedValues)
                    {
                        if (!m_ConfigureMessageSent)
                            stateManager.VideoObject.OnInfo("Please configure the VTI-OSD position.");

                        m_ConfigureMessageSent = true;
                    }
                    else
                    {
                        if (!m_ConfirmMessageSent)
                            stateManager.VideoObject.OnInfo("Please confirm the VTI-OSD position.");

                        m_ConfirmMessageSent = true;
                    }
                }
            }
        }
 public override void ProcessFrame(CameraStateManager stateManager, Helpers.VideoFrameWrapper frame)
 {
     if (!Settings.Default.VTIMustConfirmManually)
     {
         if (frame.ImageArray is int[,] && frame.PreviewBitmap != null)
             ProcessFrame(stateManager, (int[,])frame.ImageArray, frame.PreviewBitmap.Width, frame.PreviewBitmap.Height);
         else if (frame.PreviewBitmap != null)
         {
             var pixels = (int[,])ImageUtils.GetPixelArray(frame.PreviewBitmap.Width, frame.PreviewBitmap.Height, frame.PreviewBitmap);
             ProcessFrame(stateManager, pixels, frame.PreviewBitmap.Width, frame.PreviewBitmap.Height);
         }
     }
 }
        public override void InitialiseState(CameraStateManager stateManager)
        {
            base.InitialiseState(stateManager);

            m_AttemptedFrames = 0;
            m_IdenfitiedFrames = 0;
            m_IdenfitiedFromLine = 0;
            m_IdenfitiedtoLine = 0;
            m_StateManager = stateManager;

            m_ConfigureMessageSent = false;
            m_ConfirmMessageSent = false;

            m_ReportSaved = false;

            Settings.Default.PreserveVtiOsdFirstRawAuto = 0;
            Settings.Default.PreserveVtiOsdLastRawAuto = 0;

            // We want frames to be output one by one while configuring the VTI-OSD location
            NativeHelpers.UnlockIntegration();

            if (Settings.Default.VTIMustConfirmManually)
                m_StateManager.VideoObject.OnInfo("Please confirm the VTI-OSD position manually.");
        }
 public override void ProcessFrame(CameraStateManager stateManager, Helpers.VideoFrameWrapper frame)
 {
     throw new NotImplementedException();
 }