PageSourceSearch

https://blog.marcnuri.com/component---src-components-templates-pos…an-ip-camera-en-mdx-c63555a394027cad4261.js

js marcnuri.com collected 2026-09-24 19:54:38 UTC 5,001 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_marcnuri_blog_marcnuri_com=self.webpackChunk_marcnuri_blog_marcnuri_com||[]).push([[3669],{65193:function(e,t,a){a.r(t),a.d(t,{default:function(){return l}});var n=a(28453),i=a(96540);function r(e){const t=Object.assign({p:"p",a:"a",img:"img",code:"code",pre:"pre"},(0,n.RP)(),e.components);return i.createElement(i.Fragment,null,i.createElement(t.p,null,"If you’ve recently purchased an IP camera and want to programmatically retrieve and store images using ",i.createElement(t.a,{href:"tag#java"},"Java"),", this post is for you.\nRecently I bought a couple of IP Cameras for testing purposes.\nI noticed that each IP camera has different surveillance tools and web interfaces.\nBut most of these IP cameras have in common that they provide a static image URL that you can access directly via your browser.\nLeveraging this feature, you can build a simple Java application to grab and store those images."),"\n",i.createElement(t.p,null,"In this post, I'll show you how to see that image and store it using a very simple Java application.\nFor this demonstration, I’ll be using a LinkSys ",i.createElement(t.a,{href:"https://web.archive.org/web/20080409012253/http://www.linksys.com/servlet/Satellite?c=L_Product_C2&childpagename=US%2FLayout&cid=1175229403526&pagename=Linksys%2FCommon%2FVisitorWrapper&lid=0352686883B01"},"WVC200"),' "Wireless PTZ Internet Camera with Audio".\nThis camera was the most affordable option I found with decent features at the time of purchase.'),"\n",i.createElement("div",{style:{maxWidth:"380px",margin:"0 auto"}},i.createElement(t.img,{src:"./linksys-wvc200.png",alt:"A picture of the LinkSys WVC200 IP camera"})),"\n",i.createElement(t.p,null,"This camera includes a functional web interface.\nHowever, for visualization, you’re tied to a ",i.createElement(t.a,{href:"tag#windows"},"Windows")," desktop since it relies on an ActiveX control to display and control the image.\nThankfully, LinkSys provides the camera’s firmware ",i.createElement(t.a,{href:"https://web.archive.org/web/20071113022146/http://www.linksys.com/servlet/Satellite?c=L_CASupport_C1&childpagename=US%2FLayout&cid=1169671246380&pagename=Linksys%2FCommon%2FVisitorWrapper&lid=4638012899B01#WVC200"},"source code"),", which gives helpful insights, including the URL to access the static image."),"\n",i.createElement(t.p,null,"If you analyze the source code you can find some hints to get the URL where the static image is served (there's an URL for ASF video format too, with some time you can develop an app to store and play the video).\nFor this camera, the URL is ",i.createElement(t.code,null,"http://CAMERAIP/img/snapshot.cgi?size=640x480"),"."),"\n",i.createElement(t.p,null,"With this information, we can create a simple Java application to grab and store the image.\nIf you have a different type of camera, you can adapt the program by specifying the URL for that camera."),"\n",i.createElement(t.pre,null,i.createElement(t.code,{className:"language-java",title:"IPCameraImageFetcher.java"},'public class IPCameraImageFetcher {\n  public static void main(String[] args) {\n    try {\n      // Build a new URL specifying the path to where the image is served\n      URL url = new URL ( "http://192.168.10.80/img/snapshot.cgi?size=640x480");\n      // String with the user and password to access the camera interface\n      // (userName and password that you would enter in the browser\n      String userPassword = "USER:PASSWORD";
1\n      // We must encode with Base64 to supply it with the header.\n      String encoding = new Base64Encoder(userPassword).processString();\n      // Open the connection\n      URLConnection uc = url.openConnection();\n      // Specify the authorization\n      uc.setRequestProperty ("Authorization", "Basic " + encoding);\n      // Load a copy of the image into memory\n      BufferedImage img = ImageIO.read(uc.getInputStream());\n      // Store the image in the specified path\n      ImageIO.write(img, "jpg", new File("pathToFile"));\n    } catch (MalformedURLException ex) {\n      ex.printStackTrace();\n    } catch (IOException ex) {\n      ex.printStackTrace();\n    }\n  }\n}\n')),"\n",i.createElement(t.p,null,"With just a few lines of code, you can extend this application's functionality to create a robust surveillance application or tool.\nMany commercial surveillance systems share the same basic functionality as the 10 lines of code above, despite their higher price tags. With some effort, you could even add features like periodic image capture, video archiving, or advanced controls."))}var o=function(e){void 0===e&&(e={});const{wrapper:t}=Object.assign({},(0,n.RP)(),e.components);return t?i.createElement(t,e,i.createElement(r,e)):r(e)},c=a(37698);const s=e=>i.createElement(c.TP,{pageContext:e.pageContext},i.createElement(c.n$,Object.assign({comments:e.pageContext.comments,frontmatter:e.pageContext.frontmatter},e)));function l(e){return i.createElement(s,e,i.createElement(o,e))}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.