Hi,
I have this code snippet (see below) that I'm working with. I keep getting the above error. Can anyone tell me what I'm doing wrong and how to solve it? Thanks.
private static Image<Bgr, Byte> GetImageFromIPCam(string sourceURL)
{
byte[] buffer = new byte[300000];
int read, total = 0;
// create HTTP request
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(sourceURL);
// get response
WebResponse resp = req.GetResponse();
// get response stream
Stream stream = resp.GetResponseStream();
// read data from stream
while ((read = stream.Read(buffer, total, 1000)) != 0)
{
total += read;
}
// get bitmap
Bitmap bmp = (Bitmap)Bitmap.FromStream( //error occurs here
new MemoryStream(buffer, 0, total)); //error occurs here
Image<Bgr, Byte> img = new Image<Bgr, byte>(bmp);
return img;
}
}