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); }
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; }
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); }
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); }
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); }
private void _interpreter_FrameInterpreted(object sender, VideoInterpreter.InterpretedFrame frame) { HelloWorldControl.WriteBackgroundAndRender(frame.Tree); Dispatcher.BeginInvoke(_updateThread, UpdateType.NewFrameInterpreted, frame); }
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(); } }
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(); }
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; }
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; }
private void UIThreadUpdate(VideoInterpreter.VideoCapture frame, Tree root, List<Tree> textNodes, IBoundingBox invalidated) { SetTextBoxes(textNodes, root); RenderImageThatMasksText(frame, invalidated); }
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); } }