Click here to Skip to main content
15,892,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello buddy
Currently i am working on a project related to IP Camera (Bosch). I can access the camera using web browser with ip address (ex: http://10.64.91.48). Now i want to display the video on a Window Form. Searching on the internet many times and using below code but i face an ArgumentException, and still can't resolve it. I try to get the content type from response (resp.ContentType), it show me text/html.
Could you please help me to resolve this issue? Any feedback will be very appreciated!
C#
string CameraUrl = this.txt_URL.Text;
            if (string.IsNullOrEmpty(CameraUrl) == false)
            {
                byte [] buffer=new byte[300000];
                int read, total = 0;
                //Create a HTTP Request
                HttpWebRequest req = (HttpWebRequest)WebRequest.Create(CameraUrl);
                //Request Credential
                req.Credentials = new NetworkCredential("user", "user");
                //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
                MemoryStream memstream = new MemoryStream(buffer, 0, total);
               
                Bitmap img = (Bitmap)Bitmap.FromStream(memstream); // Exception here
                this.pictureBox1.Image = img;
            }
Posted
Updated 13-May-13 18:52pm
v2
Comments
Sergey Alexandrovich Kryukov 14-May-13 0:48am    
You need to read the documentation to the camera. How else can you learn what video formats are used?
—SA
DUNGNV100509 14-May-13 0:57am    
the video format is M-JPEG Sergey. I can see on the web browser Stream 1 - Stream 2 and M-JPEG.
Sergey Alexandrovich Kryukov 14-May-13 1:46am    
Then you are doing wrong thing. I don't know video format based on the sequence of bitmaps. It would not make sense. Think by yourself: why sending metadata in each frame? Why sending two nearly identical frames, of you could send just the difference between then. Video compression has nothing to do with bitmap compression. You need to learn video format and codec, or find out available implementation decoding the stream.
—SA
DUNGNV100509 14-May-13 2:19am    
Thanks very much Sergey. Have you ever faced with Bosch VG4 Autodome? Could you suggest any methods to learn with IP camera like this please?
Sergey Alexandrovich Kryukov 14-May-13 2:24am    
No, I haven't, sorry... You can learn just the video format and decompression by reading documentation.
—SA

1 solution

Your only problem is your "CameraUrl".
Add to your ip "/snap.jpg"
Ex: string CameraUrl = "http://192.168.24.100/snap.jpg";
It worked for me!
 
Share this answer
 
Comments
Richard MacCutchan 18-Sep-15 12:56pm    
Please do not post in old questions. This is over two years old, the originator likely gave up a long time ago.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900