예제 #1
0
        public static VideoInterpreter FromVideoOrImage(string aviFileLocation, PrefabInterpretationLogic logic)
        {
            VideoInterpreter i = new VideoInterpreter(logic);

            i._frames = new VideoFrames(aviFileLocation);

            i._interpretFrame          = new Thread(i._interpretFrame_DoWork);
            i._interpretFrame.Priority = ThreadPriority.Highest;
            i._interpretFrame.Start();

            i._framesCollection = new VirtualizingCollection <BitmapSource>(i.FrameCount, i.GetFramesInRange);

            return(i);
        }
예제 #2
0
        public static VideoInterpreter FromVideoOrImage(string aviFileLocation, PrefabInterpretationLogic logic)
        {
            VideoInterpreter i = new VideoInterpreter(logic);

            i._frames = new VideoFrames(aviFileLocation);

            i._interpretFrame = new Thread(i._interpretFrame_DoWork);
            i._interpretFrame.Priority = ThreadPriority.Highest;
            i._interpretFrame.Start();

            i._framesCollection = new VirtualizingCollection<BitmapSource>(i.FrameCount, i.GetFramesInRange);

            return i;
        }
예제 #3
0
        public static VideoInterpreter FromAnnotations(LayerInterpretationLogic logic)
        {
            VideoInterpreter i = new VideoInterpreter(logic);


            i._frames = VideoFrames.FromAnnotations(logic);

            i._interpretFrame          = new Thread(i._interpretFrame_DoWork);
            i._interpretFrame.Priority = ThreadPriority.Highest;
            i._interpretFrame.Start();

            i._framesCollection = new VirtualizingCollection <BitmapSource>(i.FrameCount, i.GetFramesInRange);

            return(i);
        }
예제 #4
0
        public static VideoInterpreter FromMultipleScreenshots(IEnumerable <string> files, PrefabInterpretationLogic logic)
        {
            VideoInterpreter             i           = new VideoInterpreter(logic);
            List <System.Drawing.Bitmap> screenshots = new List <System.Drawing.Bitmap>();

            foreach (string file in files)
            {
                System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(file);
                screenshots.Add(bmp);
            }


            i._frames                  = VideoFrames.FromMultipleScreenshots(screenshots);
            i._interpretFrame          = new Thread(i._interpretFrame_DoWork);
            i._interpretFrame.Priority = ThreadPriority.Highest;
            i._interpretFrame.Start();
            i._framesCollection = new VirtualizingCollection <BitmapSource>(i.FrameCount, i.GetFramesInRange);

            return(i);
        }
예제 #5
0
        void LoadInterpretationLogic(object sender, DoWorkEventArgs e)
        {


            if (_prefabInterpretationLogic == null)
            {
                
                switch (_studyCondition)
                {
                    case StudyCondition.Debug:
                    case StudyCondition.Layers:
                        _prefabInterpretationLogic = new LayerInterpretationLogic(TargetLayersDir);
                        break;

                    case StudyCondition.Single:
                        _prefabInterpretationLogic = new PrefabSingleLogic(SingleLayersDir);
                        break;
                }
            }

            try
            {
                _prefabInterpretationLogic.Load();
            }
            catch (Exception exp)
            {
                
                Dispatcher.BeginInvoke(_updateThread, UpdateType.LoadLayersFailed, exp);
                return;
            }

            if (_interpreter != null)
            {

            }
            else
            {
                _interpreter = VideoInterpreter.FromVideoOrImage(null, _prefabInterpretationLogic);
                _interpreter.FrameInterpreted += new EventHandler<VideoInterpreter.InterpretedFrame>(_interpreter_FrameInterpreted);
                _interpreter.RectsSnapped += new EventHandler<RectsSnappedArgs>(_interpreter_RectsSnapped);
                _interpreter.PrototypesBuilt += new EventHandler<PrototypesEventArgs>(_interpreter_PrototypesBuilt);
                _interpreter.PrototypesRemoved += new EventHandler<PrototypesEventArgs>(_interpreter_PrototypesRemoved);

            }

            UpdateLayers(e.Argument);
        }
예제 #6
0
        private void _interpreter_FrameInterpreted(object sender, VideoInterpreter.InterpretedFrame frame)
        {

                HelloWorldControl.WriteBackgroundAndRender(frame.Tree);
            
            Dispatcher.BeginInvoke(_updateThread, UpdateType.NewFrameInterpreted, frame);
        }
예제 #7
0
        private void OpenMenuItem_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Filter = "Video Files, Images | *.avi; *.png";
            ofd.Multiselect = true;
            if (ofd.ShowDialog().Value)
            {
                bool notnull = _interpreter != null;

                if (notnull)
                    _interpreter.Stop();

                if (ofd.FileNames.Length > 1)
                    _interpreter = VideoInterpreter.FromMultipleScreenshots(ofd.FileNames, _prefabInterpretationLogic);
                else
                    _interpreter = VideoInterpreter.FromVideoOrImage(ofd.FileName, _prefabInterpretationLogic);
                
                AnnotationThumbView.Screenshots = _interpreter.FrameCollection;

                _interpreter.FrameInterpreted += new EventHandler<VideoInterpreter.InterpretedFrame>(_interpreter_FrameInterpreted);
                _interpreter.RectsSnapped += new EventHandler<RectsSnappedArgs>(_interpreter_RectsSnapped);
                _interpreter.PrototypesBuilt += new EventHandler<PrototypesEventArgs>(_interpreter_PrototypesBuilt);
                _interpreter.PrototypesRemoved += new EventHandler<PrototypesEventArgs>(_interpreter_PrototypesRemoved);
                
                FrameSlider.Minimum = 1;
                FrameSlider.Maximum = _interpreter.FrameCount;
                FrameSlider.IsEnabled = true;
                TotalFrameCountLabel.Content = _interpreter.FrameCount.ToString();
                double old = FrameSlider.Value;
                
                FrameSlider.Value = 1;

                UseMultipleFramesCheckbox.IsEnabled = true;
                if(old != FrameSlider.Value || notnull)
                    InterpretCurrentFrame();
            }
        }
예제 #8
0
        private void OpenAnnotationsMenuItem_Click(object sender, RoutedEventArgs e)
        {
            if (_interpreter != null)
                _interpreter.Stop();
                

            _interpreter = VideoInterpreter.FromAnnotations(_prefabInterpretationLogic as LayerInterpretationLogic);
            
            AnnotationThumbView.Screenshots = _interpreter.FrameCollection;

            _interpreter.FrameInterpreted += new EventHandler<VideoInterpreter.InterpretedFrame>(_interpreter_FrameInterpreted);
            _interpreter.RectsSnapped += new EventHandler<RectsSnappedArgs>(_interpreter_RectsSnapped);
            _interpreter.PrototypesBuilt += new EventHandler<PrototypesEventArgs>(_interpreter_PrototypesBuilt);
            _interpreter.PrototypesRemoved += new EventHandler<PrototypesEventArgs>(_interpreter_PrototypesRemoved);

            FrameSlider.Minimum = 1;
            FrameSlider.Maximum = _interpreter.FrameCount;
            FrameSlider.IsEnabled = true;
            TotalFrameCountLabel.Content = _interpreter.FrameCount.ToString();


            SelectedFrameIndex = 0;
            InterpretCurrentFrame();
        }
예제 #9
0
        public static VideoInterpreter FromMultipleScreenshots(IEnumerable<string> files, PrefabInterpretationLogic logic)
        {
            VideoInterpreter i = new VideoInterpreter(logic);
            List<System.Drawing.Bitmap> screenshots = new List<System.Drawing.Bitmap>();
            foreach(string file in files)
            {
                System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(file);
                screenshots.Add(bmp);
            }


            i._frames = VideoFrames.FromMultipleScreenshots(screenshots);
            i._interpretFrame = new Thread(i._interpretFrame_DoWork);
            i._interpretFrame.Priority = ThreadPriority.Highest;
            i._interpretFrame.Start();
            i._framesCollection = new VirtualizingCollection<BitmapSource>(i.FrameCount, i.GetFramesInRange);

            return i;
        }
예제 #10
0
        public static VideoInterpreter FromAnnotations(LayerInterpretationLogic logic)
        {
            VideoInterpreter i = new VideoInterpreter(logic);


            i._frames = VideoFrames.FromAnnotations(logic);

            i._interpretFrame = new Thread(i._interpretFrame_DoWork);
            i._interpretFrame.Priority = ThreadPriority.Highest;
            i._interpretFrame.Start();

            i._framesCollection = new VirtualizingCollection<BitmapSource>(i.FrameCount, i.GetFramesInRange);

            return i;
        }
예제 #11
0
 private void UIThreadUpdate(VideoInterpreter.VideoCapture frame, Tree root, List<Tree> textNodes, IBoundingBox invalidated)
 {
     SetTextBoxes(textNodes, root);
     RenderImageThatMasksText(frame, invalidated);
 }
예제 #12
0
        private void RenderImageThatMasksText(VideoInterpreter.VideoCapture frame, IBoundingBox invalidatedRegion)
        {
            frame.CopyToWriteableBitmap(BackgroundOverlayImage, invalidatedRegion);
            BackgroundOverlay.Width = frame.Width;
            BackgroundOverlay.Height = frame.Height;

            foreach (var textLoc in TextLocations)
            {
                CopyBitmapToWriteableBitmap(_backgroundBitmap, BackgroundOverlayImage, textLoc.TreeNode);
            }
        }