我正在尝试创建从IP Camera显示视频的程序。
这是我的代码:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Emgu.CV; //
using Emgu.CV.CvEnum; // usual Emgu Cv imports
using Emgu.CV.Structure; //
using Emgu.CV.UI;
using System.IO;
using System.Reflection;
using System.Windows;
using System.Runtime.InteropServices;
using Emgu.Util;
using System.Net;
namespace WindowsFormsApplication1
{
public partial class Main : Form
{
public Main()
{
InitializeComponent();
}
public Capture _capture;
public Mat imgOriginal;
private void imageBox2_Click(object sender, EventArgs e)
{
}
private void label1_Click(object sender, EventArgs e)
{
}
public void button1_Click(object sender, EventArgs e)
{
_capture = new Capture("http://192.168.1.148:8080/video");
_capture.ImageGrabbed += ProcessFrame;
_capture.Start();
}
public void ProcessFrame(object sender, EventArgs arg)
{
imgOriginal= _capture.QueryFrame();
ibOriginal.Image = imgOriginal;
}
}
}
它陷入了这一步(没有期待):
imgOriginal= _capture.QueryFrame();
也许我应该调用方法,但我不知道怎么做。 我正在使用Emgu 3.1.0 Link to Doc
答案 0 :(得分:1)
我成功解决了这个问题。我犯了一些规范和语法错误。 我为社区提供了工作代码:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Emgu.CV; //
using Emgu.CV.CvEnum; // usual Emgu Cv imports
using Emgu.CV.Structure; //
using Emgu.CV.UI;
using System.IO;
using System.Reflection;
using System.Windows;
using System.Runtime.InteropServices;
using Emgu.Util;
using System.Net;
namespace WindowsFormsApplication1
{
public partial class Main : Form
{
public Main()
{
InitializeComponent();
Run();
}
public Capture _capture;
public Mat imgOriginal;
private void imageBox2_Click(object sender, EventArgs e)
{
}
private void label1_Click(object sender, EventArgs e)
{
}
void Run()
{
try
{
_capture = new Capture("http://192.168.1.148:8080/video");
}
catch (Exception e)
{
MessageBox.Show(e.Message);
return;
}
Application.Idle += ProcessFrame;
}
void ProcessFrame(object sender, EventArgs e)
{
Mat frame = _capture.QueryFrame();
ibOriginal.Image = frame;
}
public void button1_Click(object sender, EventArgs e)
{
}
}
}