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;
}

------------------------------------------------------------------------------------------------------------------------------------

image

sample code

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 me1237guy 的頭像
    me1237guy

    天天向上

    me1237guy 發表在 痞客邦 留言(0) 人氣()