Reputation: 65
I'm trying to connect to an Amcrest IP camera via C# winforms. Here is what I am trying and the instructions from the Amcrest API manual. I don't get any errors running this code but my picturebox never updates. This is my first dive into working with an IP camera or doing any sort of server requests. Can anyone steer me in the right direction? Thanks in advance.
private void Connect()
{
// Omitting the username and password does not help either.
MJPEGStream stream = new MJPEGStream("http://192.168.1.108/cgi-bin/mjpg/video.cgi?channel=1&subtype=0&username=admin&password=pwd11");
stream.NewFrame += new NewFrameEventHandler(video_NewFrame);
stream.Start();
}
private void video_NewFrame(object sender, NewFrameEventArgs eventArgs)
{
Bitmap bmp = (Bitmap)eventArgs.Frame.Clone();
pictureBox1.Image = bmp;
}
There is this section in the manual regarding authentication.
Upvotes: 0
Views: 619
Reputation: 11
working.....
public Form1()
{
InitializeComponent();
stream = new MJPEGStream("http://192.168.1.108/cgi-bin/mjpg/video.cgi?channel=0&subtype=1");
stream.NewFrame += new NewFrameEventHandler(video_NewFrame);
}
private void video_NewFrame(object sender, NewFrameEventArgs eventArgs)
{
Bitmap bmp = (Bitmap)eventArgs.Frame.Clone();
pictureBox1.Image = bmp;
}
private void startbtn_Click(object sender, EventArgs e)
{
stream.Login = "admin";
stream.Password = "passwordx";
stream.Start();
}
private void stopbtn_Click(object sender, EventArgs e)
{
stream.Stop();
}
Upvotes: 1