namespace WebCam
{
public partial class Form1 : Form
{
private Capture _capture = null; // 影像機
private bool _captureInProgress; // 是否擷取中
------------------------------------------------------------------------------------------------------------------------------------
private void ProcessFrame(object sender, EventArgs arg)
{
Image<Bgr, Byte> frame = _capture.RetrieveBgrFrame();
Image<Gray, Byte> grayFrame = frame.Convert<Gray, Byte>();
Image<Gray, Byte> smallGrayFrame = grayFrame.PyrDown();
Image<Gray, Byte> smoothedGrayFrame = smallGrayFrame.PyrUp();
Image<Gray, Byte> cannyFrame = smoothedGrayFrame.Canny(100, 60);
captureImageBox.Image = frame;
grayscaleImageBox.Image = grayFrame;
smoothedGrayscaleImageBox.Image = smoothedGrayFrame;
cannyImageBox.Image = cannyFrame;
}
------------------------------------------------------------------------------------------------------------------------------------
private void button1_Click(object sender, EventArgs e)
{
if (_capture != null)
{
if (_captureInProgress)
{ //stop the capture
captureButton.Text = "Start Capture";
//_capture.Pause();
_capture.Stop();
}
else
{
//start the capture
captureButton.Text = "Stop";
_capture.Start();
}
_captureInProgress = !_captureInProgress;
}
}
------------------------------------------------------------------------------------------------------------------------------------
private void button2_Click(object sender, EventArgs e)
{
if (_capture != null) _capture.FlipHorizontal = !_capture.FlipHorizontal;
}
------------------------------------------------------------------------------------------------------------------------------------
private void button3_Click(object sender, EventArgs e)
{
if (_capture != null) _capture.FlipVertical = !_capture.FlipVertical;
}
------------------------------------------------------------------------------------------------------------------------------------
留言列表