Viewing and storing images from an IP Camera 11

So you bought an IP camera and would like to store/see images from the camera using java. Recently I bought a couple of IP Cameras for testing purposes. I noticed that each IP camera has different surveillance tools and web interfaces. But most of them have in common that you can access the actual picture by entering an URL in your browser.

In this post I’ll show you how to see that image and store it using a very simple Java application. The camera I’ll use for the test is a LinkSys WVC200 “Wireless PTZ Internet Camera with Audio”. This is the cheapest wireless IPcam I found with at least some decent features.

Linksys WVC200

This camera has a nice web interface, but for visualization purposes you will need to be sitting in front of a windows desktop. This camera as many others uses an ActiveX control to show/control the image. The thing is that LinkSys is kind enough to offer the camera’s Firmware source code.

If you analyze the source code you can find some clues to get the URL where the static image is served (there’s an URL for video too ASF format, with some time you can develop an app to store and play the video). For this camera, the URL is “http://CAMERAIP/img/snapshot.cgi?size=640×480”.

With this information we can build an application to grab the image and show/store the image. If you have another type of camera, you can adapt the program by specifying the URL for that camera.

Extending this simple application or adding some functionality can bring a very good surveillance application.
If you analyze most commercial surveillance applications to use with different ipCameras you’ll notice┬áthat although they are very expensive the core of the application is similar to the 10 lines of code above.

Leave a comment

Your email address will not be published. Required fields are marked *

11 thoughts on “Viewing and storing images from an IP Camera

  • Marc Nuri

    Hi ‘CC’

    The problem with the above code is that each time you get a photo you must open a new connection/request which takes some time, depending on the network (but even with good Intranets, it’s slow). It would be the same as pressing the refresh [F5] button in your browser. This is why most cameras offer another type of stream, normally an mjpg (aka many jpg images joint together in one file). If you need such a quick refresh rate (15 fps) you can study capturing the mjpg stream and then separating each jpg from the stream. It’s more complicated but possible.

    To do this you should analayze the input stream and search for the BOMof a jpg then save that part of the stream to a separate jpg file.

    You can also try to find a library that can process mjpg or any other type of stream.


  • IP Camera Guru

    This is a great tool. The only problem is the static image can sometimes be password protected along with viewing the camera video. The way to get around this is via the FTP feature of the camera.

  • Kumail Haider

    Hello. Do you have any sample programs with complete codes that utilize this snippet? Would really appreciate the help! thanks

  • sjpapa

    Hello Marc,

    Many thanks for the code!

    I have only two issues(still):

    String encoding = new Base64Encoder(userPassword).processString();

    cannot find Base64Encoder import?

    and JLabel ? jLImagen imports:

    /* Show the image in a JLabel */

    jLImagen.setIcon(new ImageIcon(img));

    can you please advize?

  • sjpapa

    Cannot logon.

    I get the error: Server returned HTTP response code: 401 for URL:…

    any ideas why:

    BufferedImage img =;


    thank you