User Tools

Site Tools


howto:controlcamera

This is an old revision of the document!


Controlling the EEE PC webcam

The built-in webcam on the eeepc tends to become disabled at seeming random intervals. Normally, the only way to re-enable it is to reboot and re-enable the camera in the bios. Using the information below, you'll be able to gain a bit more control over the camera; including the ability to toggle it on and off at will.

Turning the Camera On/Off

The Manual Way

Enabling the camera

1. Open a terminal window

2. Run:

echo 1 > /proc/acpi/asus/camera

Disabling the camera

1. Open a terminal window

2. Run:

echo 0 > /proc/acpi/asus/camera

The following is a script I use to do the same thing from the command line. All you have to do is:

1. Run:

kwrite /home/user/camera &

2. Paste the following code onto the text editor window that opens:

#!/bin/bash
####################################################
#
#  Script to toggle camera. Valid options are on and off
#
####################################################
camera_file=/proc/acpi/asus/camera
case $1 in
  on)
    echo 1 > $camera_file
    ;;
  off)
    echo 0 > $camera_file
    ;;
  *)
    printf "\n Unknown option ${1}. Valid options are on and off\n"
    ;;
esac

3. Save the file and exit kwrite.

4. Give the camera file execute permissions:

chmod 700 /home/user/camera

Using this script, you can enable the camera using:

/home/user/camera on

and disable it using:

/home/user/camera off

If you put the script in /home/user/bin, and your bin directory is part of your path, then you only have to type:

camera on

or:

camera off

A Better Script

This script is a modification of the above script, but a little more flexible.

1. Use your favorite text editor to open /usr/bin/camera as root

sudo kwrite /usr/bin/camera

2. Insert the following into the file

#!/bin/bash
####################################################
#
#  Script to toggle camera. Valid options are on and off
#  Modified so that providing no option will simply
#  flip the switch
#
####################################################
camera_file=/proc/acpi/asus/camera
case $1 in
  on)
    echo 1 > $camera_file
    printf "Camera on\n"
    ;;
  off)
    echo 0 > $camera_file
    printf "Camera off\n"
    ;;
  *)
    status=`cat $camera_file`
    case $status in
      1)
        echo 0 > $camera_file
        printf "Camera off\n"
        ;;
      0)
        echo 1 > $camera_file
        printf "Camera on\n"
        ;;
      esac
    ;;
esac

3. Save and quit kwrite.

4. Give the script proper permissions:

sudo chmod 755 /usr/bin/camera

And you're done! Unlike the method above, this can be launched from anywhere, not just your home directly, simply by typing

camera

With no arguments, this will detect whether the camera is already off and switch it on, or turn if off if it's already on. This will allow you to add a desktop alias or panel launcher for a convenient toggle. That being said, this will also work the same as the above script, so typing

camera on

will make sure the camera is on and

camera off

will make sure the camera is off, regardless of initial state.

The Easy Way

From clipmarks.com

Open a terminal window and run the following commands:

sudo bash
cd /usr/bin
wget http://berkus.madfire.net/eeecamtray.gz
gunzip eeecamtray.gz
chmod +x eeecamtray
./eeecamtray

At this point, a small camera icon should appear in your task tray. (if you running in Ubuntu instead of the default Xandros, it will require installing a library, see below) The icon in the task tray will either show up as green for enabled or red for disabled. To make sure everything works, right-click on the icon and select either Enable camera or Disable camera a few times. You should see messages in the terminal window similar to the lines below.

A successful enable:

Trying to read camera status.
Trying to enable camera input.
**enabling write successful.
Trying to read camera status.

A successful disable:

Trying to read camera status.
Trying to disable camera input.
**disabling write successful.
Trying to read camera status.

If everything worked, you now need to edit some files to get the tray icon to launch at startup.

Auto-running eeecamtray in Easy mode

If you've closed your terminal, open it again and run:

sudo bash
cp /usr/bin/startsimple.sh /usr/bin/startsimple.sh.bak
kwrite /usr/bin/startsimple.sh

3. scroll down until you see line saying

wapmonitor &

4. directly after it type in

eeecamtray &

5. Save the file, exit kwrite and restart your eeepc. If everything worked, the small camera icon should appear.

Auto-running eeecamtray in Advanced mode

If you've closed your terminal, open it again. There is no need to run sudo bash.

  1. cd /home/user/.kde/Autostart
  2. ln -s /usr/bin/eeecamtray
  3. Either restart your eeepc or press CTRL + ALT + Backspace to restart X. If everything worked right, the camera icon should appear.

Running and Auto starting eeecamtray in Xubuntu

You will need to install the QT4 GUI library
sudo apt-get install libqt4-gui
Autostarting
  1. Select Applications - Settings - Autostarted applications
  2. Press ADD
    1. Enter “EEE Cam Tray” as name
    2. Enter “Camera control widget” as description
    3. Enter /usr/bin/eeecamtray as the command
  3. close
  4. Either restart your eeepc or press CTRL + ALT + Backspace to restart X. If everything worked right, the camera icon should appear.

Changing the default resolution

The default resolution settings for ucview on the EEE PC are for 320×240. However, the camera can support 640×480 resolution, too. Unfortunately, there is no way to change this from the ucview GUI. Rather, a manual change is required to the ucview settings file, /etc/ucview/default.ini. To make changes to this file we need to be root, too. The following step-by-step instructions should help you make the required changes:

  • open a terminal window (Ctrl-Alt-T in Easy mode, run konsole in Advanced)
  • to edit the settings file as root execute the following command:
sudo kwrite /etc/ucview/default.ini
  • once in the file, look for the section titled [VideoFormat]
  • in this section there are two lines of interest:
Width=320
Height=240
  • it is these two lines that we need to change to:
Width=640
Height=480
  • save and close the file

Next time you start ucview the image shown should be in 640×480 resolution. This will most certainly be larger than the ucview window, but fortunately there is an easy fix. Go into View menu and select Scale to Fit option. Now the image will always be scaled to fit ucview window size. This option survives ucview restart, too.

NOTE: Thanks to Surfer Dude who kindly provided this information here. However any comments as to the accuracy of the above should go to me (mrmot)!

Custom Exposure

The default settings for ucview on the EEE PC has the exposure set to automatic to help try and strike a balance between brightness and speed (frames-per-second). While it does a decent job at this, some users may want to set their own custom exposure level to improve the speed of their camera. This section will tell you how to disable and re-enable automatic exposure on the EEE PC.

Disabling Automatic Exposure (Enabling Custom Exposure)

1. Open a Terminal and run

ucview

(or use the Webcam app on the 'Play' Tab of the Asus Launcher)

2. Click on the 'Edit' menu option and select 'Adjustments', then click on the tab titled 'Extended'

3. Set 'Exposure, Auto' to 0 (actually any number will do, but just use 0)

4. Click on the 'Close' button

5. Click on the 'Device' menu option in UCView, and then click on 'Change Device' (the UCView window disappears)

6. Click on the 'OK' button of the 'Select Device' window that has just appeared

That's it!

Enabling Automatic Exposure (Disabling Custom Exposure)

1. Open a Terminal and run

ucview

(or use the Webcam app on the 'Play' Tab of the Asus Launcher)

2. Click on the 'Edit' menu option and select 'Adjustments', then click on the tab titled 'Extended'

3. Click on the 'Defaults' button

4. Click on the 'Close' button

Taking pictures from the command line

This can be very useful in scripts, but there seems not to be an easy way of doing it with just the preinstalled software.

  mplayer tv:// -tv driver=v4l:device=/dev/video0:width=320:height=240:outfmt=rgb24 -frames 1 -vo jpeg

should work, but it does not - mplayer needs some patches to work with the ucv camera. Most of other software supports just video4linux, while Asus EEE camera is video4linux2.

fswebcam seems to work:

1. download debian i386 package from http://www.firestorm.cx/fswebcam/ and save it somewhere (let's sat /tmp)

2. add xandros repositories and install libgd2-noxpm or libgd2-xpm :

  apt-get install libgd2-noxpm

3. install fswebcam:

  dpkg -i /tmp/fswebcam_20070108-1_i386.deb

To take the picture, use

  fswebcam -r 640x480 --jpeg 60 --save filename.jpg

where 60 is the jpeg quality. Unfortunately, the exposure seems to be wrong (brightness can be increased by e.g.

-s brightness=80%

switch, but then you risk overexposure), the picture has green tint and sometimes the camera records just colourful stripes. But it is better than nothing. Adding the delay switch to the command might help too. e.g.

 -D 1.5

Here, a delay of 1.5 seconds is used to get rid of the stripes, not altogether though.

rio b and you sfr rio sosh code rio

howto/controlcamera.1327692642.txt.gz · Last modified: 2012/01/27 19:30 by hello