|
Running a WebcamWhat Do I NeedHere are some initial hurdles before you can use WebCamApplet. I assume:
OK, I lied here are some more, your camera/software must do ONE of the following:
Maybe $10 for that camera really was too good to be true... How Do I Serve The Image?This is the hard part. I know how to do this, take me to the examples! Take a deep breath, it might not be that bad. First a little diversion... You need to understand that WebCamApplet (being an applet) runs in a web page i.e. directly within someone else browser. But, since your webcam is here on your PC it needs to access your camera remotely. It does this via a url, say http://myserver/me/cam/image.jpg (I made that up, no really). So far so good then. But there are many very sensible constraints placed upon an applet when it's running in a web browser. One of these is that it cannot merrily collect your credit card details and holiday snaps and post them for sale on eBay. While you'd be mad to do so, you might keep all your secrets in a web page (don't laugh) that's only visible, you hope, behind your firewall. All modern companies do this. I said don't laugh. If applets were allowed to freely access any url then you might inadvertently browse to a site that loaded a malicious applet into your web page. If it can see (and post to) any url then it can see your holiday snaps and eBay at the same time. Enough said, what's the reserve price? This is prevented by a very simple mechanism: applets are absolutely prevented by the browser from accessing files/urls that come from ANYWHERE EXCEPT where the applet was downloaded from. Why was I telling you all this? Oh yes, I remember... it means that wherever on your web site you put the WebCamApplet files, the image from your webcam must go in the same place. Or it just won't work, at all. Ever. And this is where all the complexity lies. Firstly you need to look at the software that came supplied with your webcam and see what it can do. With that in mind you can decide how your webcam and WebCamApplet are going to co-habit. There are several ways to do this depending on your circumstances, skill levels and wallet thickness:
How Do I Use WebCam Applet?So, by fair means or foul you've achieved at the following:
You need to copy the webcamappletXXXX.jar file (where XXXX is the version) to dir. Now all you need to is create a web page in dir in which will contain your web cam, paste in the HTML tags from one of the examples and modify them as appropriate. (In fact you can have your HTML somewhere else, it's only the applet in it's jar file that needs to be in dir. But my fingers are tired, so you can read more about applets and the <applet> tag here) HTML For The <applet>The HTML below is an example of what you'll need. You can find live examples here. Note that in this example the images served are all 160x120. With a label height of 20 pixels. That means the height of the applet must be 140 pixels if you want to see the whole image. <applet code="org.webcamapplet.WebCamApplet_0_1_1.class"
archive="webcamapplet_0_1_1.jar" name="Applet1" width="160"
height="140" VIEWASTEXT> Parameter Descriptionswidth: The same as the width in the applet tag (won't be needed soon). height: The same as the height in the applet tag (won't be needed soon). labelHeight: The height in pixels of the label at the bottom of the applet. delayMillis: A badly named parameter. It represents not a delay, but the MAXIMUM FREQUENCY (in milliseconds, 1000 = 1 second) that the applet will attempt to get a fresh image. There's no point being optimistic, if it takes 3 seconds for the applet to fetch the image then setting this parameter to less than 3000 will have no effect. You may also want to protect your server from thousands of applets all sucking images as fast as they can. camviewLimitMins: The number of minutes the applet will operate for before turning off and just displaying limitimage.jpg. If the web page is reloaded then the timer starts from scratch. This is not so much a privacy feature but to avoid the applet wasting bandwidth if someone starts up your webcam and then goes on holiday to Neptune. camRetrySecs: If your camera is turned off, this is the interval that the applet uses to continuously re-check and see if the camera is back on. If you habitually turn the camera off for hours at a time then there's not much point in having a really low value, say 10 seconds or less. There's also not much point in a hugely high value, say approaching camviewLimitMins. labelReloadSecs: The frequency with which the label contents changes. title: A custom value for the label. This will be shown after the frames per second value and version number. onImage: The URL of your cameras jpeg file/stream. offImage: The URL of the image shown if your camera is off. limitImage: The URL of the image shown after camRetrySecs has elapsed. click: The URL launched in a new browser window if the applet is clicked on. logging: true or false. Turns on logging of the applets internals in the Java console
|