private void menuItemCameraCapture_Click(object sender, EventArgs e)
{
// 部分代码已省略...
try
{
capture = new Capture();
previousFrame = capture.RetrieveBgrFrame(); // 第一帧
capture.ImageGrabbed += OnCameraCapture_ImageGrabbed;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void OnCameraCapture_ImageGrabbed(object sender, EventArgs e)
{
currentFrame = capture.RetrieveBgrFrame();
++frameCount;
imageBoxCameraCapture.Image = currentFrame;
imageBoxResult.Image = currentFrame.Sub(previousFrame); //帧差
previousFrame = currentFrame.Clone(); //请使用'Clone'而不是'='
// 部分代码已省略...
}