我尝试连接IP摄像机,但是在videocapture中不起作用。读取timer1_Tick的部分。
我尝试读入变量'frame',但始终为假。
我想这不能打开视频,所以我试图在MPC-HC中打开相同的地址,它正在工作。
我不知道为什么看不懂视频帧。
public partial class Form1 : Form
string address = "rtsp://admin:1234567890z@192.168.0.201:554/Streaming/Channels/1.smp";
CvCapture capture;
IplImage src;
Mat frame;
VideoCapture video;
bool file = false;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
textBox1.Text = address;
}
private void timer1_Tick(object sender, EventArgs e)
{
frame = new Mat();
if (file)
{
//src = capture.QueryFrame();
}
else
{
if (video.Read(frame))
{
src = new IplImage();
src = frame.ToIplImage();
}
}
pictureBoxIpl1.ImageIpl = src;
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
Cv.ReleaseImage(src);
if (src != null) src.Dispose();
}
private void button2_Click(object sender, EventArgs e)
{
try
{
video = new VideoCapture("rtsp://admin:1234567890z@192.168.0.201:554/Streaming/Channels/1");
//video.Open("rtsp://admin:1234567890z@192.168.0.201:554/Streaming/Channels/1");
file = false;
timer1.Enabled = true;
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
timer1.Enabled = false;
}
}
}
}
先谢谢了。