.jpg out of .cgi with java (IP Webcam)

322 views Asked by At

hy there, i hope i can explain my question:

i´ve an ip webcam and i want to read&save a .jpg file out of the path

webacm-ip-adr:8084/snapshot.cgi

i´ve little java experience and would like to program it in processing to keep it simple:

i´ve found this link:

https://www.java.net/node/702486

but its a slight overkill for me to understand it would be great if i can work with the 2 processing examples: web/loadingimages and net/httpClient

or do i make an logic mistake and its not solveable this way ?

1

There are 1 answers

3
Peter Pan On BEST ANSWER

You can use java lib "Apache Commons IO" to done it.

My Simple Code:

URL url = new URL("http://webacm-ip-adr:8084/snapshot.cgi");
InputStream input = url.openStream();
String jpg = "sample.jpg";
FileOutputStream output = new FileOutputStream(jpg);
IOUtils.copy(input, output);

Class "IOUtils" is a common tool for IO stream operation in commons-io jar.