Sunday, October 13, 2013

How to use webcam with BeagleBoard-xM

You should have installed Ubuntu 12.04 on your BeagleBoard-xM to use make these things work.

Install SSH (to allow remote access and a host of other useful linux networking featuressuch as scp)
● sudo apt-get install ssh
(this may take a while)
Install man and info so you can read man pages
● sudo apt-get install man info
Install camera utilities
● sudo apt-get install libwebcam0
(note, as time proceeds, the package name may change. make sure to take a look at
sudo apt-cache search libwebcam to make sure you're getting the latest version.
● sudo apt-get install uvcdynctrl
● sudo apt-get install streamer
Finally, plug in the web cam and query the system to check whether it is present and
detected
● ls /dev/ | grep video (you should see /dev/video0)

Configuring the operating system environment
It is convenient to set up a couple scripts for commonly used commands. This mainly applies to the minimal beagleboard-xM image that was used in this set of documents.

cd ~ (change to home directory)
mkdir scripts;cd script (create scripts directory and cd)

Use an editor (such as nano to create the text files. Use chmod goa+x filename)

Ethernet
Ethernet needs to be set up each time. This can be added to ~/.bash_profile instead to have it run every time.
sudo dhclient eth0

Ramdisk
Sets up a ramdisk of 64M and mounts it at /tmp/ramdisk
sudo mkdir /tmp/ramdisk
sudo chmod 777 /tmp/ramdisk
sudo mount -t tmpfs -o size=64M tmpfs /tmp/ramdisk

USB Camera Linux Command-line
Webcams are handled by a linux library/api called video4linux, v4l for short. Devices which conform to this standard are called “video4linux” devices. When plugged in, if video4linux detects a compatible device, it will mount the webcam under /dev/video0 if it is the first video device, /dev/video1 if it is the second video device, etc.

streamerstreamer records images and video from the webcam.
A sample command to grab one frame and save a jpeg:
streamer -c/dev/video1 -s 1920×1080 -j 100 -o /tmp/ramdisk/picture.jpeg
● -c[video4linux device]: a path to the device. video1 is the second webcam installed in
the system.
● -s [size]: resolution to capture
● -j [quality: 1-100]: specifies the quality of the jpeg. 100 is very little compression
● -o [filename.jpeg]: important to name the file with extension .jpeg, the streamer
program decides output format based on this.
 
uvcdynctrl
uvcdynctrl is a command-line interface to adjust the parameters of the webcam.
● uvcdynctrl -c lists available controls for a device. eg., uvcdynctrl /dev/video1 -c
● uvcdynctrl -g [control] gets the value of a control
● uvcdynctrl -s [control] [value] sets the value of a control eg., uvcdynctrl /dev/
video1 -s Contrast 64
Default values will be restored upon reboot.

You can install OpenCV to make applications related to image processing and video processing after this.

No comments: