In this part of the guide we’re going to try and figure out that special url you need in order to pull the images directly off the CCD of your IP cam, which is what you need in order to make the scripts from the previous part of the guide work properly.
I’m going to assume zero prior knowledge so am going to try and explain everything as we go along.
For this exercise this is the camera I’ll be using. It’s just a standard cheapo Wanscam one off ebay. It’s not the IP camera I actually use for our CCTV system but it works the same so will illustrate just how similarly they all work:
ok so what we need to do is find the special url which lets us grab still images off the camera’s CCD, then figure out what parameters we need to add to that to call the url directly and get given a jpeg in return. This *should* be pretty straightforward but that will depend somewhat on your camera’s interface. If you find this approach doesn’t work for you you can let me know in the comments or email me and I’ll see if we can figure out how to do it in your case.
Your camera might use a slightly different setup but so far the ones i’ve worked with have all worked roughly along the same lines so hopefully you can apply the same principles even if it’s not exactly the same.
Connect to the IP camera
So connect to your camera in your browser and you should get a login screen like this:
Login as admin for now. Cameras often have a number of user levels giving different permissions and there’s valid reasons for picking particular levels of security but we can worry about that later. For now logging in as admin is fine.
Once logged in you’re likely to have a screen like this which gives you a choice of the type of interface to have depending on the browser or device you’re using..these are the screens I get on both my cameras. As you can see they’re pretty similar. There’s normally an internet explorer option (ugh), a firefox/chrome-type option, and a mobile/tablet type option:
Grabbing the image
Here I’d recommend trying to go with the most basic option – i.e. the one for mobile phones/tablets, which in this case gives you a very basic page which just updates automatically and has the least code to go through. The page on mine looks like this:
As you can see – super simple, which makes our job easier. If you have this option getting the special url *should* be just as simple as right clicking on the image and picking “open image in new tab” or “copy image url” and open it a new tab and paste the url in…
With a bit of luck now you should have the same image, but it won’t be updating automatically. The url should look a bit like this:
Breaking that down – the first part is the ip address of your camera, the “snapshot.cgi” part is the url of the CCD, and then the querystring (the bit after the “?”) will pass in the username and password along with a random number/timestamp.
You should find that the image won’t update automatically like on the previous page, but if you refresh it manually the image will update.
Because you’re passing the username and password in there’s no logging in required and just hitting that url should give you the image. Try it out on different browsers, from your phone or whatever and see but it should work.
If you got this far then congrats! – that’s the special url we were looking for which we can insert into the bash scripts to do the logging. You can skip the next bit and go straight to the “bringing it all together” bit (next post).
What if that didn’t work?
If you find that your camera doesn’t have the mobile phone/tablet interface option then finding the special url will take a bit more work. You’ll have to look through the interface source code for “.cgi” references and try plugging those urls in (likely with the username/password format as above.
You may also find that you need to work through several layers of frames/iframes before you get to the actual code. Your best bet is to try and do a “view frame source” when hovering over part of the actual interface itself (though probably won’t work directly over the camera image).
If you still have no joy finding a snapshot CGI (as would be the case on this camera’s interface which only lists a videostream.cgi, look for a “save still image”/snapshot button. Again, most cameras have some sort of feature like this and like on this camera, clicking that button takes me to another page which lists the snapshot.cgi url.
If all else fails, just try plugging “snapshot.cgi” into the url instead of whatever else the camera is using since that seems to be a pretty common way of accessing the stills part of the camera, or comment/drop me an email and I’ll try to help you figure it out 🙂
Part 3 of this guide – “Bringing it all together” coming up soon 🙂