Наследование: MonoBehaviour
Пример #1
0
        public void InitializePlayers()
        {
            ColorPlayer    = new FramePlayer <TColorFrame>();
            DepthPlayer    = new FramePlayer <TDepthFrame>();
            SkeletonPlayer = new FramePlayer <TSkeletonFrame>();

            ColorPlayer.FrameReady    += TColorFrameHandler;
            DepthPlayer.FrameReady    += TDepthFrameHandler;
            SkeletonPlayer.FrameReady += TSkeletonFrameHandler;
        }
Пример #2
0
        public void CreatePlayer()
        {
            DestroySession();
            easyarObject = Instantiate(EasyARSession);
            easyarObject.GetComponentInChildren <VideoCameraDevice>().gameObject.SetActive(false);
            easyarObject.GetComponentInChildren <FramePlayer>().gameObject.SetActive(true);
            easyarObject.GetComponentInChildren <FrameRecorder>().gameObject.SetActive(false);
            easyarObject.SetActive(true);
            var imageTracker = easyarObject.GetComponentInChildren <ImageTrackerFrameFilter>();

            controllerNamecard.Tracker = null;
            controllerIdback.Tracker   = null;
            controllerNamecard.Tracker = imageTracker;
            controllerIdback.Tracker   = imageTracker;

            recorder            = null;
            player              = easyarObject.GetComponentInChildren <FramePlayer>();
            player.FilePathType = WritablePathType.Absolute;
            player.FilePath     = filePath;
        }
Пример #3
0
        internal void Update()
        {
            if (m_UseIntegration ||
                m_UseClipping ||
                m_UseStretching ||
                m_UseBrightnessContrast ||
                m_UseReInterlacedMode ||
                m_UseHotPixelCorrection ||
                m_HotPixelConfiguration ||
                m_MaskAreaConfiguration)
            {
                if (m_UseIntegration)
                {
                    m_VideoController.SetupFrameIntegration(m_FramesToIntegrate, m_IntegrationMode, m_IntegrationType);
                }
                else
                {
                    m_VideoController.SetupFrameIntegration(1, FrameIntegratingMode.NoIntegration, PixelIntegrationType.Mean);
                }

                TangraCore.PreProcessors.ClearAll();

                if (m_UseStretching)
                {
                    TangraCore.PreProcessors.AddStretching(m_FromByte, m_ToByte);
                }
                else if (m_UseClipping)
                {
                    TangraCore.PreProcessors.AddClipping(m_FromByte, m_ToByte);
                }
                if (m_UseBrightnessContrast)
                {
                    TangraCore.PreProcessors.AddBrightnessContrast(m_Brightness, m_Contrast);
                }

                if (Math.Abs(TangraConfig.Settings.Photometry.EncodingGamma - 1) > 0.01)
                {
                    TangraCore.PreProcessors.AddGammaCorrection(TangraConfig.Settings.Photometry.EncodingGamma);
                }

                if (TangraConfig.Settings.Photometry.KnownCameraResponse != TangraConfig.KnownCameraResponse.Undefined)
                {
                    TangraCore.PreProcessors.AddCameraResponseCorrection(TangraConfig.Settings.Photometry.KnownCameraResponse, TangraConfig.Settings.Photometry.KnownCameraResponseParams);
                }

                HotPixelCorrector.ReconfigurePreProcessing();
                MaskAreaSelector.ReconfigurePreProcessing();

                //if (VideoContext.Current.DarkFrameBytes != null)
                //{
                //    Core.PreProcessors.AddDarkFrame(VideoContext.Current.DarkFrameBytes);
                //    //m_FramePreProcessor.AddPreProcessor(
                //    //    new FrameDarkFlatCorrector(
                //    //        VideoContext.Current.DarkFrameBytes,
                //    //        VideoContext.Current.FlatFrameMedian,
                //    //        true));
                //}

                //if (VideoContext.Current.FlatFrameBytes != null)
                //{
                //    Core.PreProcessors.AddFlatFrame(VideoContext.Current.FlatFrameBytes, VideoContext.Current.FlatFrameMedian);
                //}

                //m_FramePreProcessor.OnPreProcess(m_CurrFrame);

                m_CurrFrame = FramePlayer.GetFrame(m_CurrFrameNo, !m_UseIntegration);

                if (m_CurrFrame != null)
                {
                    frmFullSizePreview.EnsureFullPreviewVisible(m_CurrFrame, ParentForm);
                    frmFullSizePreview.Update(m_CurrFrame);
                }
            }
            else
            {
                TangraCore.PreProcessors.ClearAll();

                frmFullSizePreview.EnsureFullPreviewHidden();
            }
        }
Пример #4
0
 public VideoOperationController(Form mainFormView, FramePlayer framePlayer)
 {
     m_FramePlayer  = framePlayer;
     m_MainFormView = mainFormView;
 }
Пример #5
0
        public void OpenLcFile(string fileName)
        {
            var    fi = new FileInfo(fileName);
            double expectedMemoryMbNeeded = 500 /* For Tangra to operate*/ + 20 * fi.Length / (1024 * 1024) /* For the .lc file to be unpacked and loaded in memory */;

            double availableMemoryMb = CrossPlaform.GetAvailableMemoryInMegabytes();

            if (expectedMemoryMbNeeded > availableMemoryMb)
            {
                if (MessageBox.Show(
                        m_MainFormView,
                        string.Format("It appears that you may be running in a low memory conditions and opening this file will require at least {0}Gb of free memory. Do you wish to continue?", (Math.Ceiling(expectedMemoryMbNeeded / 512.0) / 2).ToString("0.0")),
                        "Warning",
                        MessageBoxButtons.YesNo,
                        MessageBoxIcon.Warning) == DialogResult.No)
                {
                    return;
                }
            }

            m_MainFormView.Cursor = Cursors.WaitCursor;
            LCFile lcFile = null;

            try
            {
                m_MainFormView.Update();

                lcFile = LCFile.Load(fileName, m_VideoController);
                if (lcFile != null)
                {
                    ReduceLightCurveOperation operation = (ReduceLightCurveOperation)m_VideoController.SetOperation <ReduceLightCurveOperation>(this, false);
                    operation.SetLCFile(lcFile);

                    bool flipVertically;
                    bool flipHorizontally;
                    FramePlayer.TranslateFlipRotate(lcFile.Footer.RotateFlipType, out flipVertically, out flipHorizontally);

                    object videoFile = GetVideoFileMatchingLcFile(lcFile, fileName);
                    if (videoFile is string &&
                        !string.IsNullOrEmpty((string)videoFile) &&
                        File.Exists((string)videoFile))
                    {
                        if (m_VideoController.OpenVideoFile((string)videoFile, new TangraOpenFileArgs {
                            FrameRate = lcFile.Header.FramesPerSecond, BitPix = lcFile.Footer.DataBitPix, SerTiming = lcFile.Header.SerTimingType
                        }))
                        {
                            TangraContext.Current.CanPlayVideo = false;
                            m_VideoController.UpdateViews();
                        }
                    }
                    else if (videoFile is string[] &&
                             ((string[])videoFile).Length > 0)
                    {
                        var fitsFiles = (string[])videoFile;
                        if (m_VideoController.OpenFitsFileSequence(Path.GetDirectoryName(fitsFiles[0]), fitsFiles, new LCFITSTimeStampReader(lcFile), null, 0, flipVertically, flipHorizontally, (int)lcFile.Data[0][0].CurrFrameNo))
                        {
                            TangraContext.Current.CanPlayVideo = false;
                            if (lcFile.Footer.FitsDynamicFromValue != -1 && lcFile.Footer.FitsDynamicToValue != -1)
                            {
                                m_VideoController.SetDisplayIntensifyMode(DisplayIntensifyMode.Dynamic, lcFile.Footer.FitsDynamicFromValue, lcFile.Footer.FitsDynamicToValue);
                            }

                            m_VideoController.UpdateViews();
                        }
                    }
                    else
                    {
                        // NOTE: No video file found, just show the saved averaged frame
                        bool oldCanProcessLightCurvePixels = TangraContext.Current.CanProcessLightCurvePixels;
                        TangraContext.Current.Reset();
                        TangraContext.Current.CanProcessLightCurvePixels = oldCanProcessLightCurvePixels;

                        if (lcFile.Footer.AveragedFrameBytes != null)
                        {
                            if (m_VideoController.SingleBitmapFile(lcFile))
                            {
                                TangraContext.Current.CanPlayVideo = false;
                                m_VideoController.UpdateViews();

                                PSFFit.SetDataRange(lcFile.Footer.DataBitPix, lcFile.Footer.DataAav16NormVal);
                            }
                        }

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

                    m_Context        = new LightCurveContext(lcFile);
                    m_LightCurveForm = new frmLightCurve(this, m_AddinsController, lcFile, fileName);
                    m_LightCurveForm.SetGeoLocation(m_VideoController.GeoLocation);
                    m_LightCurveForm.Show(m_MainFormView);
                    m_LightCurveForm.Update();

                    // TODO: Review the VideoController-LightCurveController-ReduceLightCurveOperation relation and how they are initialized
                    // TODO: Provide a clean way of initializing the controller/operation state when opening an .lc file!
                    operation.EnterViewLightCurveMode(lcFile, m_VideoController, m_VideoController.ControlerPanel);

                    RegisterRecentFile(RecentFileType.LightCurve, fileName);

                    if (!string.IsNullOrEmpty(m_VideoController.CurrentVideoFileType))
                    {
                        // Move to the first frame in the light curve
                        m_VideoController.MoveToFrame((int)lcFile.Header.MinFrame);
                    }

                    TangraContext.Current.FileName   = Path.GetFileName(fileName);
                    TangraContext.Current.FileFormat = m_lcFile.Header.SourceInfo;
                    m_VideoController.UpdateViews();
                }
            }
            catch (IOException ioex)
            {
                MessageBox.Show(ioex.Message, "Tangra", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                m_MainFormView.Cursor = Cursors.Default;
            }
        }
Пример #6
0
        public void InitializePlayers()
        {
            ColorPlayer = new FramePlayer<TColorFrame>();
            DepthPlayer = new FramePlayer<TDepthFrame>();
            SkeletonPlayer = new FramePlayer<TSkeletonFrame>();

            ColorPlayer.FrameReady += TColorFrameHandler;
            DepthPlayer.FrameReady += TDepthFrameHandler;
            SkeletonPlayer.FrameReady += TSkeletonFrameHandler;
        }