private bool closeWriterSafely() { if ((writer != null) && (writer.IsOpened)) { stream.OnNewImage -= NewImageGrabbed; stream = null; Image <Bgr, byte> frame = null; while (imageBuffer.TryDequeue(out frame)) { //Empty the queue, saving any frames to the file writer.Write(frame.Mat); } writer.Dispose(); writer = null; return(true); } else { //Something may have happened, but this isn't a successful stop, so just try and clean up what we can. if (writer != null) { writer.Dispose(); } writer = null; if (stream != null) { stream.OnNewImage -= NewImageGrabbed; } stream = null; return(false); } }
private void FlirCameraStream_OnSourceChanged(FlirCameraStream sender, FlirCamera Source) { if (Source == null) { CameraFeed.Invoke(new Action(() => { CameraFeed.Image = null; })); FPSStatusLabel.Text = ((int)0).ToString("N2").PadLeft(3) + " FPS"; } }
private void FlirCameraStream_OnNewImage(FlirCameraStream sender, Image <Bgr, byte> Image) { FpsCount++; if (FpsCount >= 4) //About 15 fps { FpsCount = 0; CameraFeed.Invoke(new Action(() => { CameraFeed.Image = (Image == null) ? null : Image.Bitmap; })); FPSStatusLabel.Text = sender.FPS.ToString("N2").PadLeft(3) + " FPS"; } }
public CameraOptionsUI(Panel Panel, FlirCameraStream stream, string libraryVersion) { this.panel = new OptionsPanel(Panel); this.Stream = stream; options.Add(new CameraInfoUI(this, panel, libraryVersion)); options.Add(new GainUI(this, panel)); options.Add(new ExposureUI(this, panel)); //TODO add events from stream input.on //input.OnStreamEnded += onStreamEnded; }
public bool Start(FlirCameraStream stream) { lock (this) { if (((writer != null) && (writer.IsOpened)) || !savingThread.IsAlive) { return(false); } FlirCamera camera = stream.SourceCamera; if (camera == null) { return(false); } long width = 0; long height = 0; if (!camera.Properties.Width.TryGetValue(ref width) || !camera.Properties.Height.TryGetValue(ref height)) { return(false); } double FPS = 0D; if (!camera.Properties.FPS.TryGetValue(ref FPS)) { FPS = 48D; } if (FPS == 0) { FPS = 48; } Console.WriteLine("Detected Camera FPS: {0}", FPS); if (File.Exists(filepath)) { File.Delete(filepath); } writer = new VideoWriter(filepath, VideoWriter.Fourcc('M', 'P', '4', '2'), FPS, new Size((int)width, (int)height), true); if (writer.IsOpened) { this.stream = stream; imageBuffer = new ConcurrentQueue <Image <Bgr, byte> >(); stream.OnNewImage += NewImageGrabbed; OnRecordingChanged?.Invoke(this, true); return(true); } else { writer.Dispose(); writer = null; return(false); } } }
public OptionEntry(string name, Property <FlirProperties, TNode> property, FlirCameraStream stream) { this.stream = stream; this.cameraProperty = property; this.EntryName = name; entryLabel = new Label(); entryLabel.Text = name + ": "; entryLabel.Location = new Point(3, 5); entryControl = generateControl(ControlXPos); invokeAction(new Action(() => { addValueChangedEvent(entryControl, OnValueChangedEvent); })); Update(); }
private void NewImageGrabbed(FlirCameraStream sender, Image <Bgr, byte> image) { if (savingThread.IsAlive) { imageBuffer.Enqueue(image); } else { sender.OnNewImage -= NewImageGrabbed; lock (this) { if (!markedDead) { markedDead = true; closeWriterSafely(); OnRecordingForcedClosed?.Invoke(this); } } } }
public NumericalEntry(string name, Property <FlirProperties, TNode> property, FlirCameraStream stream) : base(name, property, stream) { }
public TestPatternMenu(ToolStripMenuItem BaseMenu, FlirCameraStream stream) : base(BaseMenu, stream, TestPatternEnums.NUM_TESTPATTERN, true) { }
public StringEntry(string name, Property <FlirProperties, Flir.Nodes.StringNode> property, FlirCameraStream stream) : base(name, property, stream) { }
public IntegerEntry(string name, Property <FlirProperties, IntegerNode> property, FlirCameraStream stream) : base(name, property, stream) { }
public FloatEntry(string name, Property <FlirProperties, FloatNode> property, FlirCameraStream stream) : base(name, property, stream) { }
public EnumEntry(string name, EnumType DefaultValue, EnumType?IgnoreCase, Property <FlirProperties, EnumNode <EnumType> > property, FlirCameraStream stream) : base(name, property, stream) { defaultValue = DefaultValue; ignoreCase = IgnoreCase; }
private void CameraStream_OnSourceChanged(FlirCameraStream sender, FlirCamera source) { cameraOptions.Update(); }
public CameraOptionsForm(FlirCameraManager cameraManager, FlirCameraStream stream) { InitializeComponent(); cameraOptions = new CameraOptionsUI(SettingsPanel, stream, cameraManager.GetSpinnakerLibraryVersion()); stream.OnSourceChanged += CameraStream_OnSourceChanged; }