PDA

Bekijk de volledige versie : [HOW-TO] webcam



wpte
24-09-2008, 11:53
UPDATE: in the beta firmware on http://wl500g.googlecode.com you can use the refresh-time in the web admin with the same end result as in this how-to. Might be even easier :-)

Well, I decided to make a little how to for simple webcamming via the admin-interface.
Everybody knows that rcamd isn't really the best way to stream your webcam since it uses all your cpu... but I have a solution for that;)
Also, not every motion detection program seems to work with webcams supported by the router, but rcamd usually does.

allright, here we go:

Step 1
First of all we need a compatible webcam, you can look in the forums for a good one that works. http://wl500g.info/showthread.php?t=63&highlight=%5Busb%5D+webcam

I myself have the Logitech Quickcam 4000 pro connected.
So next thing we do is connect it to the router, and then configure the settings in the webadmin interface.
http://wpte.kicks-ass.net/tutorials/webcam/webcamsettings.jpg
you can make it look similair like this if you want.
note that the webcam driver should be loaded automatically, so it doesn't matter what you select.
Just save the settings and reboot the device.

Step 2
Now log in via putty into your router.
make sure you have putty maximized so your screen is completely filled with putty
issue the command

ps
or

ps axf
to see the list of active processes

in that list of processes you will find something similair to this:

rcamd -p 7777 -s 0 -z MET-1METDST,M3.5.0/2,M10.5.0/3 -a 0 -t 0 -r 0 -f 640x480 -m 100 -c 100
note that it will appear 3 times in the list, if it does not, your webcam is probably not supported!

just select this piece with your mouse so it'll become white:
http://wpte.kicks-ass.net/tutorials/webcam/putty.jpg
now just open up notepad and press control + c to paste it into notepad.

Now make sure, that everytime I call my copied rcamd process, you use your own copied version, as it might differ!

Step 3
Now we will do some magic
rcamd -p 7777 -s 0 -z MET-1METDST,M3.5.0/2,M10.5.0/3 -a 0 -t 0 -r 0 -f 640x480 -m 100 -c 100
the bold piece in this code is importand, you need to change it.
-s is an option that allows you to lower the framerate, so also the cpu usage;)
at this time it says 0, so it will capture an unlimited frames per second, till the cpu or the webcam can't handle any faster, we are about to change that.
now if we change the 0 into a 4, the webcam will send every 4 seconds 1 image. so that will give you a framerate of 0.25fps
no worries, it won't show up as only 1/4 of your screen:p
You can adjust this number to your own wish, but I like the 4, because you won't notice the webcam is runnig on the performance;)
Now also place a "&" behind the whole line, and end up having something similair to this:

rcamd -p 7777 -s 4 -z MET-1METDST,M3.5.0/2,M10.5.0/3 -a 0 -t 0 -r 0 -f 640x480 -m 100 -c 100 &

Step 4
now we are still in putty will make the final hand to the evil process:

vi /tmp/local/sbin/post-mount
Now paste somewhere in this file the following:

#Restart rcamd with proper settings
killall rcamd
sleep 3

after this lines, paste your own rcamd copy!
so it will look like this:

#Restart rcamd with proper settings
killall rcamd
sleep 3
rcamd -p 7777 -s 4 -z MET-1METDST,M3.5.0/2,M10.5.0/3 -a 0 -t 0 -r 0 -f 640x480 -m 100 -c 100 &

now save the file and:

flashfs save && flashfs commit && flashfs enable && reboot
now to be sure it works, just issue "ps" to look at the cpu usage, and check if rcamd is using hardly any cpu:)

Final step
YES! now you can finally watch your webcam!:D
huh? what not working?
probably you have problems with the activeX webcam program on the webcam site.
if you don't know what the site is...
http://yourasusip:7776
;)

As far as I know the active X version only works with IE
first go to control panel of windows, then to internet options:
http://wpte.kicks-ass.net/tutorials/webcam/internet.jpg
go to the security tab
select trusted websites
lower the the security level to lowest
click on websites to add a new website to be trusted

http://wpte.kicks-ass.net/tutorials/webcam/domain.jpg
enter your asus ip adress or domain to add into the trusted websites
make sure you have https selection off, otherwise you won't be able to add something.

now apply everything and refresh your webcam page
just install the activeX, and when promted if you want to run the object on your pc, answer yes
and tata, here is your webcam feed:D
Be sure the time changes in the picture
you probably need to adjust the focus of the webcam too, for a sharp image, just turn around the lens wheel (with most webcams)
http://wpte.kicks-ass.net/tutorials/webcam/cam.jpg

now if you use the activeX version, yo can left click and right click on the image.
left click will capture a screenshot and save it to somewhere on your disk
right click will capture a movie to your harddisk:D

I hope this works for ppl:)

poiu
24-09-2008, 23:04
Tnx alot wpte, this is much easy to folow for me, maybe others too.
Restarting manually the process step on my nerves ^^.

wpte
24-09-2008, 23:49
Tnx alot wpte, this is much easy to folow for me, maybe others too.
Restarting manually the process step on my nerves ^^.

haha, yes I know, but if you don't kill the original process...
you hardly will be able to do anything:eek:

oh and the "&" is most likely to be the most importand, otherwise it'll stop working after an hour of 2:p

I also corrected a little mistake in the how-to, didn't change anything to the scripts:)
I hope it's all clear, and I didn't make a mess of it:p

dude69
04-05-2009, 13:47
Sorry for this noobquestion - but:

After testing all my webcams i found just one which is "working": an old Creative Webcam III :)

Works like a charm - but with ONE problem: I need to plug it in when the device is booted completely... otherwise i have no rcamd process except of rcamdmain.

I can fix it by pulling the cam out of the usb jack and replugging it - which is not a good solution for a fixed installation of course :)

So is there *any* way to re-initate that USBdriver / device recognition / init / whatever without hands on the hardware?

Any hints are highly appreciated....

mandgeo
25-05-2009, 18:18
This is what i got: wl-500gp router, latest oleg firmware, philips webcam.

This is what i've tried:
1. webcam (rcamd) started from administration page. works, but at certain point it crashes
2. rcamd killed and started in post-boot (for slower framerate). it crashes also
3. i've installed motion, but i didn't got it started. i've started the driver but it didn't worked

Please, can someone make a tutorial for using webcam as a surveilance cam...?? I want to get mails with pictures if something is moving in front of the webcam.

I've managed to make rcamd send mail, but it doesn't use the server i've set...and it crashes.

I've read that Palantir works simply as streaming server. It doesn't send mail alerts, and i did'n tried to install it.

Please help. Thanks

wpte
18-07-2009, 00:55
well... does your webcam work with rcamd?

otherwise different software won't work either most likely... (drivers maybe don't support your webcam)

anyway...
sourceforge: http://sourceforge.net/search/?words=webcam+surveillance&type_of_search=soft&pmode=0&inex=1&sortselect=trove__199&registration_date__0=&trove__225=456&trove__274=369&trove__160=584&trove__199=201&trove__13=14&trove__1=534&trove__6=7&trove__496=499&newfilter=Apply

google: http://www.linux.com/news/hardware/peripherals/8211-five-fun-ways-to-use-a-linux-webcam

maybe you find some program that is usefull for you, then you might be able to compile it yourself... or I'll give it a go:)

velcrow
23-07-2009, 12:03
Hi Wpte & thanks for the how to -

Have been using this for a while but would now like to backup the images that are taken.

I am assuming at the moment that display.jpg is just overwritten with every refresh, but I would like to store these images instead.

Is this possible - is there a setting in rcamd that I can use or could I create a script to copy/move display.jpg every time it is modified.

Thanks in advance for any help with this.

** BTW: the reason I am doing this is I want to create a stop-motion video of a plant growing ***

I can see that display.jpg is symlinked to /var/tmp/display.jpg and in turn this file is dynamically syslinked to record0.jpg - record5.jpg

this seems to be the last 6 images - is there a way to change the symlinks to the usb drive and to set it to record the last 100 images instead of the last 5??

wpte
23-07-2009, 16:58
Hey velcrow,

I made this little script here:

#!/bin/sh
#Seconds of sleep before doing another copy
SLEEP=15
#Source JPG file that needs to be copied.
SOURCEJPG=/var/tmp/display.jpg
#Output folder which will contain all the JPG files
OUTPUT=/mnt/webcamimages
#Choose between a counting name or date
#COUNTING or DATE
MODE=COUNTING

COUNT=0


if [ $MODE="COUNTING" ]; then
while /bin/true; do
/bin/cp $SOURCEJPG $OUTPUT/$COUNT.jpg
COUNT=$(($COUNT + 1))
/bin/sleep $SLEEP
done
fi
else
if [ $MODE="DATE" ]; then
while /bin/true; do
/bin/cp $SOURCEJPG $OUTPUT/img\_$(/bin/date '+%Y%m%d_%H%M%S').jpg
/bin/sleep $SLEEP
done
fi

it's quite self explaining:)
unfortunately my plan for saving it by date+time in the filename didn't worked out too well, since I'm not too familiar with the bash syntax.
however the counting filename works fantastic:)

just edit it to personal preferences...
and execute it like this:

../sbin/webcammon.sh &
so you can shut down your pc while the router keeps the images rolling in:D

The limitation so far is, that I have no idea what the maximum number for count is... probably around 32000 or 65000 keep an eye on it
I hope you find it usefull, and maybe someone can fix my horrible mistake of the date saving thing;)

EDIT:
Thanks to EdP the date and time thing is working now :)

a little example of a result:
http://wpte.kicks-ass.net/downloads/timelapse.mpg

EdP
23-07-2009, 18:40
Hi,

Here's a suggestion on how to fix the date thing:

replace that cp sentence by the following:

/bin/cp $SOURCEJPG $OUTPUT/img\_$(/bin/date '+%Y%m%d_%H%M%S').jpg

Or something similar. That way your files will be named
/mnt/webcamimages/img_20090723_193943.jpg (etc.)

wpte
23-07-2009, 19:09
Hi,

Here's a suggestion on how to fix the date thing:

replace that cp sentence by the following:

/bin/cp $SOURCEJPG $OUTPUT/img\_$(/bin/date '+%Y%m%d_%H%M%S').jpg

Or something similar. That way your files will be named
/mnt/webcamimages/img_20090723_193943.jpg (etc.)

Ah, thank you EdP:)
bash is a bit different than I'm used to:)

EdP
23-07-2009, 19:16
Żou're very welcome. It's not much different from sh, ksh, even pretty similar to csh and tcsh which were popular back in the day ;)

wpte
23-07-2009, 19:22
Żou're very welcome. It's not much different from sh, ksh, even pretty similar to csh and tcsh which were popular back in the day ;)

I don't even know those:D
I program things like c and c++:p
bash does look a bit like qbasic, which I used when I was little:)

EdP
23-07-2009, 19:26
Qbasic *cough* :eek: *cough* :(

Be careful, or you'll sound like a barbarian :D
Tcsh should be much to your liking then. OK back on topic I guess ...

wpte
24-07-2009, 01:12
Qbasic *cough* :eek: *cough* :(

Be careful, or you'll sound like a barbarian :D
Tcsh should be much to your liking then. OK back on topic I guess ...
hey don't underestimate the sheer power of qbasic;):p

anyway, this is the latest version of the script, which gives a harddrive time to spin down by temporary storing the files in /tmp/imag

I tested it, and it worked great:D
here it is:

#!/bin/sh
#Seconds of sleep before doing another copy
SLEEP=15
#Source JPG file that needs to be copied.
SOURCEJPG=/var/tmp/display.jpg
#Output folder which will contain all the JPG files
OUTPUT=/mnt/webcamimages
#Choose between a counting name or date(not working yet)
#COUNTING or DATE
MODE=COUNTING

#Optimize for Harddrive spindown? (TRUE or FALSE)
OPTIMIZE=TRUE
#Save files up to ... in flash
#The max size of an jpeg file is about 65KB so 65*150=9,75MB wich leaves enough of the ~14,5MB flash.
#And if the images are taken every 15sec you will leave the hdd untouched for 37min!
#Please keep in mind that if you set it too high there won't be memory left in /tmp
FLASHSAVE=150
#Flash directory to save in
FLASHDIR=/tmp/imag



COUNT=0
if [ $OPTIMIZE="TRUE" ]; then
if ( [ ! -d $FLASHDIR ] ); then
/bin/mkdir $FLASHDIR
fi
/bin/rm $FLASHDIR/*
if [ $MODE="COUNTING" ]; then
while /bin/true; do
for i in $(seq 1 $FLASHSAVE); do
/bin/cp $SOURCEJPG $FLASHDIR/$COUNT.jpg
COUNT=$(($COUNT + 1))
/bin/sleep $SLEEP
done
/bin/cp $FLASHDIR/* $OUTPUT/
/bin/rm $FLASHDIR/*
done
fi
else
if [ $MODE="DATE" ]; then
while /bin/true; do
for i in $(seq 1 $FLASHSAVE); do
/bin/cp $SOURCEJPG $FLASHDIR/img\_$(/bin/date '+%Y%m%d_%H%M%S').jpg
/bin/sleep $SLEEP
done
/bin/cp $FLASHDIR/* $OUTPUT/
/bin/rm $FLASHDIR/*
done
fi
fi
else
if [ $OPTIMIZE="FALSE" ]; then
if [ $MODE="COUNTING" ]; then
while /bin/true; do
/bin/cp $SOURCEJPG $OUTPUT/$COUNT.jpg
COUNT=$(($COUNT + 1))
/bin/sleep $SLEEP
done
fi
else
if [ $MODE="DATE" ]; then
while /bin/true; do
/bin/cp $SOURCEJPG $OUTPUT/img\_$(/bin/date '+%Y%m%d_%H%M%S').jpg
/bin/sleep $SLEEP
done
fi
fi

another example of the script result:
http://www.youtube.com/watch?v=5LW9RsETEBk

velcrow
25-07-2009, 16:31
Thanks wpte & Edp -

This is great, I spent some time trying the rcamd commands but with no luck...

what does the -r setting do?



rcamd -p 7777 -s 4 -z MET-1METDST,M3.5.0/2,M10.5.0/3 -a 0 -t 0 -r 0 -f 640x480 -m 100 -c 100 &


and why does it record 6 files - record0.jpg - record5.jpg?

Really appreciate this, as there was no chance of me solving this in such an elegant way ;)

Velcrow

wpte
25-07-2009, 20:46
Thanks wpte & Edp -

This is great, I spent some time trying the rcamd commands but with no luck...

what does the -r setting do?



rcamd -p 7777 -s 4 -z MET-1METDST,M3.5.0/2,M10.5.0/3 -a 0 -t 0 -r 0 -f 640x480 -m 100 -c 100 &


and why does it record 6 files - record0.jpg - record5.jpg?

Really appreciate this, as there was no chance of me solving this in such an elegant way ;)

Velcrow

what about using the -h parameter:p

rcamd -h
Usage: rcamd [options]
-d <debug level>
-m <max difference threshold=0-255> (lower->more updates, default=30)
-s <seconds between frames> (default==1)
-f <WidthxHeight obey supported size> define size of the output image (default:640x480)
-p <port to listen for connections>
-b <brightness=1-500> (default=400 available only cameratype=1)
-g <gain=0-4> corresponding to a gain of 2^<gain> (default=0)
-t <cameratype=0,1> corresponding to a camera driver (0:pwc or 1:ov511 default=0)
-r <record interval=0-65535> (default=60 minutes)
-a <alert=0,1> define if alert is on or off)
-s <max count for difference threshold=0-999999> (default=100)
-z <time zone string>

for me it only records 3 shots

but I don't understand completely... couldn't you get the bash script working?:confused:

velcrow
25-07-2009, 21:05
-h lol ;)

No script is great - - just trying to see if rcamd has any "native" commands that could be used.

One question where should the script be created / saved - /opt/sbin/?

I plan to use cron to gzip the folder at night

Thanks again for the help...

wpte
25-07-2009, 21:31
-h lol ;)

No script is great - - just trying to see if rcamd has any "native" commands that could be used.

One question where should the script be created / saved - /opt/sbin/?

I plan to use cron to gzip the folder at night

Thanks again for the help...

you can place the script anywhere you want, even on the harddrive:p
I tested in on a hdd, and it still spun-down good, so I guess it's a perfect script:cool:

np mate, any time :)

EdP
25-07-2009, 23:38
and why does it record 6 files - record0.jpg - record5.jpg?


it always makes those record*.jpg files and uses them to compare, motion can only be detected by comparing images after all.

velcrow
26-07-2009, 00:36
Thanks Edp - Yes, makes sense.

rcamd - our (my) misunderstood friend.

Jarex
30-07-2009, 11:42
Does anyone have a webcam running on WL-500gP v2? I have two different cameras which no go. I checked them with spca, pwc and ovc and they are not recognized. Spent to much time trying make it work. Give me please a webcam name which is working for sure under Oleg or dd-wrt firmware and I will buy it.

EdP
30-07-2009, 19:33
Check out the WL500g Reported Compatible Hardware > Webcams (http://wl500g.info/showthread.php?t=63) section.

mandgeo
20-08-2009, 08:37
I've recently reinstalled everything. Rcamd worked fine (even 24 hours), until i've installed rtorrent and i've started to download files. Now rcamd crashes in some minutes.

I think that CPU is to weak for that many tasks.

wpte
20-08-2009, 21:56
I've recently reinstalled everything. Rcamd worked fine (even 24 hours), until i've installed rtorrent and i've started to download files. Now rcamd crashes in some minutes.

I think that CPU is to weak for that many tasks.

try the beta firmware: http://code.google.com/p/wl500g/
it's easier to slow down the framerate for the webcam... limiting the cpu usage again.

I don't have any problems running them together.:)

mandgeo
22-08-2009, 10:14
Thanks. I've upgraded the firmware. I'm gonna put some more torrents to transfer :)...

Can you recomend me the best firewall configuration? I need to open some ports for ftp, ssh, webadmin, web, torrents, torrents_dth and that's it. I saw to many sugestions and i still don't think i have the right configuration.

wpte
22-08-2009, 10:30
Thanks. I've upgraded the firmware. I'm gonna put some more torrents to transfer :)...

Can you recomend me the best firewall configuration? I need to open some ports for ftp, ssh, webadmin, web, torrents, torrents_dth and that's it. I saw to many sugestions and i still don't think i have the right configuration.

Uhm... well just opening the ports in iptables should be good. in addition the beta firmware also has brute-force ftp and ssh blocking (check the firewall in the webinterface).

for the webcam, I forgot to tell, you don't need to restart rcamd or something, you can just adjust the "Refresh Time in seconds" value in the web interface. It'll just start the rcamd process directly in the right mode and keeps running forever:)

mandgeo
22-08-2009, 11:08
I saw this new and very usefull options.

Did something changed in security detection? I know that in the past the system tried to send the email, but not thru the right email server.

LE. Alert doesn't work. I've set the email where the message/picture should be send (yahoo mail), the email server (smtp.rdslink.ro...the isp server, the only one that let's me send mail) and asus still tries to sent mails to another server (98.137.54.237...yahoo server).

"
286 ? S 0:00 sendalarm /var/tmp/record5.jpg /var/tmp/record0.jpg /var/tmp/record1.jpg /var/tmp/record2.jpg /var/tmp/record3.jpg
299 ? S 0:00 \_ sh -c cat /var/tmp/alarmmail | mini_sendmail -s98.137.54.237 xxxxxx@yahoo.com
301 ? S 0:00 \_ mini_sendmail -s98.137.54.237 xxxxx@yahoo.com
"

Can i do something to make this work??