private void OnFrameEvent(object sender, EventArgs e) { Parallel.Invoke(() => { uEye.Camera camera = sender as uEye.Camera; if (camera.IsOpened) { ++m_s32FrameCoutTotal; if (camera.Video.Running) { camera.Video.GetLostCount(out m_s32FrameLost); camera.Video.GetFrameCount(out m_s32FrameSaved); } if (m_s32FrameSaved > 0 && m_s32FrameSaved >= 2 * 9000) { RecordVideo(path + "_" + aux.ToString()); aux = aux + 1; } if (stack || display) { IntPtr handle = new IntPtr(); camera.Memory.GetActive(out handle); System.Drawing.Rectangle rect; camera.Size.AOI.Get(out rect); using (IplImage image = new IplImage(new OpenCV.Net.Size(rect.Width, rect.Height), IplDepth.U8, 1, handle)) { if (stack) { this.Send <Frame>(new Frame(image.Clone(), m_s32FrameCoutTotal, targetFrameRate, ID)); } if (display) { imVis.Show(image.Clone()); } if (st == 0) { firstFrame.image = image.Clone(); st = 1; } } } } }); }
private void onFrameEvent(object sender, EventArgs e) { uEye.Camera camera = sender as uEye.Camera; if (camera.IsOpened) { ++m_s32FrameCoutTotal; if (camera.Video.Running) { camera.Video.GetLostCount(out m_s32FrameLost); camera.Video.GetFrameCount(out m_s32FrameSaved); } if (m_s32FrameSaved > 0 && m_s32FrameSaved >= 2 * 9000) { RecordVideo(path + "_" + aux.ToString()); aux = aux + 1; } if (stack || display) { IntPtr handle = new IntPtr(); camera.Memory.GetActive(out handle); System.Drawing.Rectangle rect; camera.Size.AOI.Get(out rect); using (IplImage image = new IplImage(new OpenCV.Net.Size(rect.Width, rect.Height), IplDepth.U8, 1, handle)) { if (stack) { if (queue.Count > 100) { queue.Clear(); } queue.Push(new Frame(image.Clone(), m_s32FrameCoutTotal)); } if (display) { imVis.Show(image.Clone()); } } } } }