coooolll.
looking for just the thing. My fridge is in the fridge out the back.
can you post the how to pls
OK, essentially there are 2 parts:
The part that takes a pic every "however" long.
And the part that sticks it on the webpage.
Taking the pic:
Plug in your webcam.
In terminal, type "lsusb", check that the webcam shows up.
To take a pic, type the following:
Code:
streamer -f jpeg -o image.jpeg
If that doesn't work, install streamer
Code:
sudo apt-get install streamer
If it still doesn't work, try it with sudo
Code:
sudo streamer -f jpeg -o image.jpeg
If that's all working then we just need to get it running often.
Let's start with once per minute.
In Ubuntu, type
Add the following line at the bottom:
Code:
* * * * * streamer -f jpeg -o /var/www/html/image.jpeg
(omit the "html" bit if you don't have that folder)
[Note: I don't know how to edit cron for other Unix os's. Maybe someone else can help with that, or Google it]
Exit crontab
Wait a minute, check if image.jpeg has showed up in the right folder, and that it's pointing in the right direction.
Editting the webpage:
Back up your index.php
Then, edit this line:
to this:
Code:
<body onload="JavaScript:timedRefresh(60000);">
Then, add this just before the </body> tag:
Code:
<canvas id="x" width="600" height="600"/>
<script type="text/JavaScript">
var x=0, y=0;
var canvas, context, img;
function timedRefresh(timeoutPeriod)
{
canvas = document.getElementById("x");
context = canvas.getContext("2d");
img = new Image();
img.src = "image.jpeg?t=" + new Date().getTime();
img.onload = function() {
context.drawImage(img, x, y);
setTimeout("timedRefresh("+timeoutPeriod+")",timeoutPeriod);
};
}
</script>
Save, and refresh your webpage.
You should be all set
Note:
This is almost definitely not the optimum way to do this, but it works, and took me 5 minutes to do. I may optimise it this weekend when I get a chance.
I'm keen to get it taking a pic a second, but that requires extra work as cron only works in minutes.