本文整理汇总了C#中Emgu.CV.Capture.Pause方法的典型用法代码示例。如果您正苦于以下问题:C# Capture.Pause方法的具体用法?C# Capture.Pause怎么用?C# Capture.Pause使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Emgu.CV.Capture
的用法示例。
在下文中一共展示了Capture.Pause方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestFileCapturePause
public void TestFileCapturePause()
{
int totalFrames1 = 0;
Capture capture1 = new Capture(EmguAssert.GetFile("tree.avi"));
//capture one will continute capturing all the frames.
EventHandler captureHandle1 = delegate
{
Mat img = new Mat();
capture1.Retrieve(img);
totalFrames1++;
Trace.WriteLine(String.Format("capture 1 frame {0}: {1}", totalFrames1, DateTime.Now.ToString()));
};
capture1.ImageGrabbed += captureHandle1;
capture1.Start();
System.Threading.Thread.Sleep(2);
int totalFrames2 = 0;
Capture capture2 = new Capture(EmguAssert.GetFile("tree.avi"));
int counter = 0;
//capture 2 will capture 2 frames, pause for 1 seconds, then continute;
EventHandler captureHandle = delegate
{
counter++;
totalFrames2++;
bool needPause = (counter >= 2);
if (needPause)
{
capture2.Pause();
counter = 0;
}
Mat img = new Mat();
capture2.Retrieve(img);
Trace.WriteLine(String.Format("capture 2 frame {0}: {1}", totalFrames2, DateTime.Now.ToString()));
if (needPause)
{
System.Threading.ThreadPool.QueueUserWorkItem(delegate
{
Trace.WriteLine("Sleep for 1 sec");
System.Threading.Thread.Sleep(1000);
capture2.Start();
});
}
};
capture2.ImageGrabbed += captureHandle;
capture2.Start();
//int totalFrames = 69;
Stopwatch s = Stopwatch.StartNew();
while (! (totalFrames1 == totalFrames2))
{
System.Threading.Thread.Sleep(1000);
if (s.ElapsedMilliseconds > 120 * 1000)
{
EmguAssert.IsTrue(false, "Unable to finished reading frames in 2 mins");
break;
}
}
capture1.Dispose();
capture2.Dispose();
}