我如何使用emgucv从IP摄像头捕获视频

时间:2016-07-30 22:00:30

标签: c# camera

请有人可以在c#visual studio中使用emgucv访问ip camera,在其他帖子中分享代码

capture = new Emgu.CV.CvInvoke.cvCreateFileCapture(" Url ip camera");

当我运行代码时说" tv cvCreateFileCapture在CvInvoke中不存在"

有人知道使用emgucv访问ip camera的其他形式,但正在工作......谢谢!

1 个答案:

答案 0 :(得分:2)

这是我的例子,它适用于我,我使用EmguCV V3

public partial class Form1 : Form
{
    private Capture _capture = null;
    private bool _captureInProgress;
    public Form1()
    {
        InitializeComponent();
        CvInvoke.UseOpenCL = false;
        try
        {
            _capture = new Capture("http://webcam.st-malo.com/axis-cgi/mjpg/video.cgi?");//
            _capture.ImageGrabbed += ProcessFrame;
        }
        catch (NullReferenceException excpt)
        {
            MessageBox.Show(excpt.Message);
        }
    }

    private void ProcessFrame(object sender, EventArgs arg)
    {
        Mat frame = new Mat();
        _capture.Retrieve(frame, 0);

        captureImageBox.Image = frame;

    }

    private void captureButton_Click(object sender, EventArgs e)
    {
        if (_capture != null)
        {
            if (_captureInProgress)
            {  //stop the capture
                captureButton.Text = "Start Capture";
                _capture.Pause();
            }
            else
            {
                //start the capture
                captureButton.Text = "Stop";
                _capture.Start();
            }

            _captureInProgress = !_captureInProgress;
        }
    }
}

enter image description here

相关问题