PDA

Bekijk de volledige versie : Adjust JPEG compression on display.jpg



Muffe
17-05-2005, 15:11
I have an Asus WL-500g with a Logitech Quickcam Pro 4000 webcam. The picture (http://your.routers.ip.addr:7776/display.jpg) is heavy compressed, and the quality is poor. Does it exist any options to change the JPEG compression? Is it possible if I compile the firmware myself, or do i just have to edit a config file? Or is it not possible at all?

The plan is to get a picture with super quality in 320x240, resize it up to 400x300 and compress it before it's uploaded to my hosts FTP server. This upload process is handeled by an external server, running linux.

I have also noticed that the quality of the stream on port 7777 is relatively good. No lossy compression like the JPEG picture. Can I use my external linux box to capture a picture from this stream and use that picture instead? What type of stream is it? I have STF, but could only find a stream viewer for Windows, not any for linux.

And at last a question to Oleg (or somebody else who knows): Will it (in the future) be possible to capture pictures with a higher resolution than what's possible today? Just dreaming of 640x480...

Thanks.

RoofCat
17-05-2005, 16:55
On 1927-CR4 I am currently using pwc and pwcx taken from this thread (http://wl500g.info/showthread.php?t=1362&page=2). For my Phillips ToUCam it allows 640x480 resolution with low FPS.

usage looks smthg like this in post-mount



insmod videodev.o
ln -s /dev/v4l/video0 /dev/video
insmod pwc.o power_save=0
...

For that driver setpwc program exists to change camera settings including compression settings.

As a sample of working setup please find attached "bird portrait", taking by motion detection software, running on asus box.

So it goes
Roofcat

Muffe
17-05-2005, 19:21
Do you have to use Palantir, or can you use the built-in program?

RoofCat
17-05-2005, 19:43
Do you have to use Palantir, or can you use the built-in program?
No and No! :cool:

Since I use it as burglar monitoring and hopefully recording (I hate that surveil-something word, never managed to spell it correctly :) ) I use motion (http://www.lavrsen.dk/twiki/bin/view/Motion/WebHome) software if my wl-500g box booted from USB drive, or mvc (http://www.turbolinux.com.cn/~merlin/mvc/) (simpler motion detector) if wl-500g is booted from internal flash.

In both cases files are scp-ed to remote Unix computer using wl-500g ssh, cron and shell scripts. On Unix computer another cron job creates movies from separate frames using mencoder.

And back to thread subject - I've tried to play with quality of jpeg using motion software config options, but found that jpeg quality becomes too low for extreme lighting conditions (we kinda have a lot of snow here in winter and bright sun in spring :)

So it goes
Roofcat

Muffe
17-05-2005, 20:48
Sorry for asking so many silly questions, but i don't have a lot of experience with this unit.

I do not want any motion detection, I just want to capture one picture every 60. second, and publish this on the internet. The way it is done now is that my linux server sends a HTTP request to the WL-500g in port 7776 for display.jpg. It is stored on my computer, and the original is tranfered via FTP together with a resized copy to my webhost. Then is the copy on my computer deleted. This is done by a cron job executing a shell script every 60. second (if somebody is intrested in the script, please PM me).

What I want is something that can do the same job, with or without the help of my computer. I just want 640x480 pictures uploaded to my host every minute or any other apropriate interval.

I also need help to install the files provided by Tom here (http://wl500g.info/showpost.php?p=8610&postcount=17). I have extracted the data.tar.gz and have the files stored on my computer (running Linux), but what do I have to do now to reach my goal? It's not too much helpfiles og manuals attached, so it's a bit difficult for a newbee to understand it.

One off-topic question: Why is the image you supplied mirrored?

Thanks.

Kanga
17-05-2005, 20:55
Is there any chance you guys could draft up an 'how to' from start to finish of the above solution?

Thanks.

RoofCat
17-05-2005, 23:20
I do not want any motion detection, I just want to capture one picture every 60. second, and publish this on the internet. The way it is done now is that my linux server sends a HTTP request to the WL-500g in port 7776 for
display.jpg. It is stored on my computer, and the original is tranfered via FTP together with a resized copy to my webhost. Then is the copy on my computer deleted. This is done by a cron job executing a shell script every
60. second (if somebody is intrested in the script, please PM me).

What I want is something that can do the same job, with or without the help of my computer. I just want 640x480 pictures uploaded to my host every minute or any other apropriate interval.

I also need help to install the files provided by Tom here (http://wl500g.info/showpost.php?p=8610&postcount=17). I have extracted the data.tar.gz and have
the files stored on my computer (running Linux), but what do I have to do now to reach my goal? It's not too much helpfiles og manuals attached, so it's a bit difficult for a newbee to understand it.
Below there was a request for step by step instruction, so here it goes.

I assume you have ASUS wl-500g, with custom software (Oleg's FW 1.9.2.7 CR4 or higher), you have web camera, supported by pwc driver. My configuration uses USB flash drive and while writing this HOWTO I realize that my configuration will not work without it, since size of all files to store is larger than 64K - maximum of flashfs to store. So you will also need USB flash drive supported by ASUS software or arrange dynamic load of gzipped archive from UNIX computer in post-boot. Anyway:

1. You need to download ipkg file provided by Tom here (http://wl500g.info/showpost.php?p=8610&postcount=17), uncompress and untar it, locate data.tar.gz extracted from package, uncompress and untar it. You may do this on other computer and then scp files to asus box, or do all on asus box, provided it is connected to Internet and you can ssh to it from your desktop. In the later case it looks smthg like (below I assume you've got USB flashdrive mounted in ASUS as /mnt):



[admin@router mnt]$ wget http://tom.stoeveken.com/programme/philips-webcam/philips-webcam_0.1_mipsel.ipk
Connecting to tom.stoeveken.com[213.203.199.171]:80
philips-webcam_0.1_m 100% |*****************************| 191 KB 00:00 ETA
[admin@router mnt]$ tar zxpvf philips-webcam_0.1_mipsel.ipk
./debian-binary
./data.tar.gz
./control.tar.gz
[admin@router mnt]$ tar zxpvf data.tar.gz
.
./www
./www/CamClient.class
./www/CamClient.html
./www/CamMonitor.class
./www/CamMonitor.html
./www/offline.jpg
./bin
./bin/mvc
./bin/setpwc
./bin/camsrv
./lib
./lib/modules
./lib/modules/2.4.20
./lib/modules/2.4.20/pwc.o
./lib/modules/2.4.20/pwcx.o
[admin@router 1]$ls -la
drwxr-sr-x 5 admin root 1024 May 18 01:06 .
drwxr-xr-x 5 admin root 13312 May 18 01:04 ..
drwxr-sr-x 2 admin root 1024 May 18 01:06 bin
-rw-r--r-- 1 1000 1000 399 Dec 23 21:46 control.tar.gz
-rw-r--r-- 1 1000 1000 195859 Dec 23 21:46 data.tar.gz
-rw-r--r-- 1 1000 1000 4 Dec 23 21:46 debian-binary
drwxr-sr-x 3 admin root 1024 May 18 01:06 lib
-rw-r--r-- 1 admin root 196314 May 18 01:05 philips-webcam_0.1_mipsel.ipk
drwxr-sr-x 2 admin root 1024 May 18 01:06 www
[admin@router mnt]$
Now you have all files necessary for the task inside the Asus box. To save space you may delete some files downloaded and extracted.


[admin@router mnt]$ rm philips-webcam_0.1_mipsel.ipk
[admin@router mnt]$ rm control.tar.gz
[admin@router mnt]$ rm data.tar.gz
[admin@router mnt]$ rm debian-binary
[admin@router mnt]$ rm -rf www
[admin@router mnt]$ rm bin/camsrv
[admin@router mnt]$ ls -lR
.:
drwxr-sr-x 2 admin root 1024 May 18 01:13 bin
drwxr-sr-x 3 admin root 1024 May 18 01:06 lib

./bin:
-rwxr-xr-x 1 admin root 109948 Dec 13 23:07 mvc
-rwxr-xr-x 1 admin root 23020 Dec 22 16:10 setpwc

./lib:
drwxr-sr-x 3 admin root 1024 May 18 01:06 modules

./lib/modules:
drwxr-sr-x 2 admin root 1024 May 18 01:06 2.4.20

./lib/modules/2.4.20:
-rw-r--r-- 1 admin root 69036 Dec 22 20:40 pwc.o
-rw-r--r-- 1 admin root 59310 Dec 22 20:40 pwcx.o

All these files will be necessary for out task, so it is better to keep it on USB flash drive.

2. Switch off webcam support in web interface of ASUS.

3. Create /usr/local/sbin/post-mount file with following lines in it.


#!/bin/sh
# device init
insmod videodev.o
# v4l device support
ln -s /dev/v4l/video0 /dev/video
# create "canonical" v4l device
insmod /mnt/lib/modules/2.4.20/pwc.o size=vga fps=4 power_save=0
# install pwc
# size= defines image size to capture
# fps= defines frames per second
# power_save= is some magic
insmod /mnt/lib/modules/2.4.20/pwcx.o
# install compression module

#Now lets sleep a bit...
sleep 30
# ... and start webcam software.

/mnt/bin/mvc -D -d /dev/video -t -w 2 -s 640x480 -c 70 -O /mnt/tmp/ -o -l /mnt/log/mvc.log
#
# this is my configuration, yours may vary
# -D Start mvc as a Daemon.
# -d device Specify v4l device (default: /dev/video0).
# -w delaytime Specify interval for each capture(seconds), Default: 0.5 second.
# -s XxY Specify the image capture size, default 320x240.
# -c value
# Specify threshold of block color difference. Range [0-765] Usu-
# ally, 30-200 is a better value for common use. More smaller more
# sensitive. Default value is 50
# Probably if you don't need motion detect at all -c 765 will switch it off
# -O directory
# Specify base directory for output images. default is current
# dir.
# -o Don't create sub-directories for output. Use this option, all
# image files will be put on one directory.
# -l logfile
# Specify the logfile name to be used in daemon mode. default is
# null.
#
# And now lets get Pid of mvc to kill it later.
# pid extraction

ps | grep "mvc " | grep -v 'grep' | sed -e 's/ admin.*//' -e 's/^ *//' >/var/run/mvc.pid
Let me stress again - basically this is my setup, using USB flashdrive to store data. Probably it is possible to start rcamd from flash instead of mvc, thus saving space and eliminating the need in usb flashdrive but I've never tried.

And don't forget to save resulting config (flashfs save && flashfs commit && flashfs enable)

4. Now we should arrange periodic image capture from mvc. To achieve this we will use USR1 signal, which cause mvc to save captured image (details may be found in http://www.turbolinux.com.cn/~merlin/mvc/README)

I use cron, but I only do 30 mins captures. So in my case I created shell script with following lines


kill -USR1 `cat /var/run/mvc.pid`
sleep 5
# file processing follows...
and add cron job to execute this script each half an hour (1 minute in your case). In file processing section I just scp file to remote computer to web accessible directory.

Another way of doing the same is running infinite loop in the end of post-mount with smthg similar to:

while true; do sleep 1800; killall -USR1 mvc; sleep 5; scp <scp instructions go here> ; done
(In this case you even do not need pid extraction in post-mount)

Probably I've missed some (important?) details here, but basically this is one of the possible ways to accomplish the task.

HTH
Roofcat


One off-topic question: Why is the image you supplied mirrored?
Because my Phillips camera provides me with mirrored image and I could not find simple way to config it the other way around. And I found difficult to flip it mentally all the time. :)

Muffe
24-05-2005, 20:02
Is it possible to start MVC without doing motion detection, alternatly use another program for capturing? I just want to do simple, regulary captures...

BTW: Thanks for a great guide.

Muffe
24-05-2005, 21:18
Just forget it. I figured it out myself:


./camsrv -r VGA -f /tmp/harddisk/tmp/display.jpg -D /dev/video

You have to change the path to the camsrv binary to where it is located.

Muffe
25-05-2005, 16:21
Just another silly question from me: How do I do an automatic SCP? I can't find any way to automatically provide it with the password to the Asus box...

For information: I SCP from an external bok into my Asus box to grab the picture. NOT the other way.

mistraller
24-02-2007, 13:38
mvc has one advantage which palantir is lacking of;

mvc places time/date stamp on the image. I didn't find a feature in palantir to get this into the image itself.
mvc does it automatically, so I think I'll stick with mvc.

(I have a philips toucam II which uses the OV51x driver.)

There's only one problem, the readme of mvc is not longer online! Can someone post the contents of the readme?

codeninja
11-07-2009, 16:06
Although original link to mvc no longer works, the source tarball is still avialable at:

http://www.packetstormsecurity.org/linux/security/mvc-0.8.9.tar.gz

README can be found inside the tarball, but pasting it here for convenience:


License: GPLv2
Author: Merlin Ma<merlin@turbolinux.com.cn>
URL: http://www.turbolinux.com.cn/~merlin/mvc/

Description:
MVC is a text mode v4l video capture program that features motion
detection. It is very small and easy to use, and could be used to
monitor and record the peoples that enter your room.

Ther v4l part of this program referenced code vidcat.c
which comes from w3cam. w3cam is an excellent CGI program
by Rasca<fcii@gmx.de>

URL for webcam is:
http://home.pages.de/~rasca/w3cam/

Its motion detection algorithm is designed by me.

Build:
In source directory, just type 'make'.
To change default settings, modify config.h, then rebuild.
To build rpm, just type rpmbuild -ta mvc-0.8.6.tar.gz

Install: type 'make install'


Usage: mvc [options]

Options are:

-B brightness
Specify picture brightness value.

-C contrast
Specify picture contrast value.

-D Start mvc as a Daemon.

-O directory
Specify base directory for output images. default is current
dir.

-o Don't create sub-directories for output. Use this option, all
image files will be put on one directory.

-t Print timestamp on output image.

-d device
Specify v4l device (default: /dev/video0).

-e program
excute a external program while motion detected.

-f {jpeg|png}
Select output file format. default is jpeg.

-i channel
Specify the v4l device input channel number to use. The first
input is 0, and the second input is 1, etc. Usually, for bttv
card, input 0 is used for TV, input 1 is composite1, input 2 is
composite2 and input 3 is a S-Video port.

The default value of this option is depend on how many input
channel the device have. If the device only have one input (like
ov511 webcam), it will be used as default input. If the device
have more than 1 port (such bttv driver), mvc will use channel
number 1 as default, because channel number 0 often used as TV
input, so, skip it.

-m use mono color (grayscale) for capture.

-n {pal|ntsc|secam|auto}
Specify the video norm of input signal, default: PAL

-s XxY Specify the image capture size, default 320x240. Example: -s
640x480

-a HxV Specify the division number for image process in Horizantal and
Vertical. default is 16x8. Usually, up to 32x16 blocks is good
enough for common use. Example: -a 32x8

-b number
Specify threshold of hot block number. Range: from 1 to total
splited blocks. Usually, 1% - 10% of total blocks is a good
choice, for example: the image divide by 32x8 in x-direction and
y-direction, total blocks is 32*8=256. Then, 256*0.01=3 to
256*0.1=25 is a better choice range. Default value is total
blocks/64+1, In above case, this value is 32*8/64 + 1 = 5. More
smaller value more sensitive for smaller and farther object
detection.

-c value
Specify threshold of block color difference. Range [0-765] Usu-
ally, 30-200 is a better value for common use. More smaller more
sensitive. Default value is 50.

-q quality
Specify jpeg quality value [1-100], default: 90.

-w delaytime
Specify interval for each capture(seconds), Default: 0.5 second.
Suggest: 0.2-2, Default value is 0.5 second.
Example: -w 1

-l logfile
Specify the logfile name to be used in daemon mode. default is
null.

-h Print brief help.

-v Increase verbose level, it can be multiple applied for more and
more debug info.

By default, if run mvc without parameters, it will use /dev/video0 as
v4l device, Composite1 as input, PAL norm, picture size 320x240, color mode,
block division is 16x8, hotblock threshold is total blocks/64+1, in this
case is 16*8/64+1=3, color diff threshold is 50, if use mono color,
suggest use -c 25, delay time is 0.5 second between each capture, program
run in foreground. All image files will be saved in directory named by
date and file named by time, such as ./2003-06-20/18/img-182633-0.jpg.

If you start program in foreground, you still can switch it into daemon
mode just by pressing Ctrl-Z. So, you can then logout from your terminal,
the program will run in background and log all message into the file
specified by -l option, by default, all message will be dropped.

Examples:

1. Write all files and subdirectories into /home/httpd/html/pics, and
use ntsc norm for input signal.

mvc -O /home/httpd/html/pics -n ntsc

It will automatically create date named sub-directories and store
images in them.

2. Run mvc in Daemon mode and log all message into /var/log/mvc.log,
and use png for output file format.

mvc -D -l /var/log/mvc.log -f png

3. If you have 2 capture card, you could use them at same time by
starting 2 copies of mvc like this:

mvc -D -l /var/log/mvc0.log -d /dev/video0 -O /home/mvc/myroom
mvc -D -l /var/log/mvc1.log -d /dev/video1 -O /home/mvc/garden

So, device video0 output to directory /home/mvc/myroom/, and
device video1 output to directory /home/mvc/garden/.

4. If you don't want to put image files in time-named subdirectories
separately, use -o option.

mvc -O /tmp/mvc/ -o -i 2 -s 640x480

This will put all captured images in /tmp/mvc, and don't create
sub-dir such as /tmp/mvc/2003-06-22/21/, image will be stored
in same directory - /tmp/mvc and named as img-20030622-215501.jpg.
Use comp2 port as input and image size 640 x 480.

5. Use -vvv option to active detailed debug info for your -b and -c
reference.

mvc -n PAL -s 640x480 -a 20x10 -vvv

6. If you want to execute your own program while motion detected,
use -e option like this:

Assume there is a program named beep, it make alarm sound. Run
'beep 1' to start alarm, and 'beep 0' to stop the alarm.

So, if we want make 20 second alarm while motion detected, start
mvc like this:

mvc -n PAL -e 'beep 1; sleep 20; beep 0'

while alarm, mvc still do captures by its default interval. And,
before the command line is finished, mvc does not start another
copy of user program. It is useful for avoid the program stacked.

7. If there are any other assistant program used to detect the inbreak,
for example: Infrared sensor, Doppler sensor, or we just want to
do a hourly capture whatever if motion detected or not.

Just send a USR1 signal to the mvc process to force one capture.

Use 'killall -USR1 mvc' under command line, or
use kill(mvcpid, SIGUSR1) in your program is ok.

Do a half-hourly capture:
shell> while true; do sleep 1800; killall -USR1 mvc; done

8. If you want to show time and date on image, use -t option,
it will print capture time on image.