This is a script that will install OpenCV on a debian-based development machine. The script will add the debian testing repositories and install OpenCV and its dependencies. The repositories are then removed to avoid conflicts with existing packages during regular updates.

Probably the easiest place to start is by using [http://www.angstrom-distribution.org/narcissus/ narcissus]. Choose beagleboard as the machine type and unstable for the release. In order for highgui to work (necessary for camera capture unless you are using GStreamer), you must build an image with X11 support. Therefore, choose X11 for the user environment. The choice for the X11 desktop environment is not critical, but it would be wise to choose something fairly lightweight, such as Enlightenment. It took several hours for Gnome to configure upon first boot. Once the filesystem has been extracted to a properly formatted SD card with an appropriate kernel on the boot partition (we tested this using 2.6.29), you should be able to boot. Upon boot, you will need to run opkg update. After this, you will need to run opkg install with the following packages:

Due to the large volume of sample data needed to create a effective Haar Cascade (about 1000 positive images) it is easier to gather video of a positive target and then break apart the video frame by frame and use the results as images. There are 2 two types of images, good and background. Both types of images are important in order for the cascade to be trained accurately.

+

+

=== Create Index File ===

+

There are two index files needing to be created in order for the system to train on the images, a background index file creating a list of filelocations, and a positive index file containing the positive file locations, the number of objects in the picture and the rectangular locations for the object.

+

==== Creating the Negative Index File ====

+

Use the following automated script from within the background images folder:

+

<pre>

+

#!/bin/bash

+

+

find ./*.jpg -maxdepth 2 -print > background.idx

+

find ./*.png -maxdepth 2 -print >> background.idx

+

find ./*.bmp -maxdepth 2 -print >> background.idx

+

find ./*.jpeg -maxdepth 2 -print >> background.idx

+

</pre>

+

==== Creating the Positive Index File ====

+

Use the following source code to create a training program that allows the user to click on the upper left and lower right of a object to select it and then press a key to return.

Also, there is another way to crop the positive samples from sample set. Using images clipper tools can help to crop the positive samples directly from the image sets. And the find command and identify command (from ImageMagick) will find and gather images' information like width and height.

Using the positive samples the creasamples cammand can apply transforms to the images and add them to the background images creating a wider range of images to train on. The syntax for this command is:

+

<pre>

+

Usage: ./createsamples

+

[-info <description_file_name>]

+

[-img <image_file_name>]

+

[-vec <vec_file_name>]

+

[-bg <background_file_name>]

+

[-num <number_of_samples = 1000>]

+

[-bgcolor <background_color = 0>]

+

[-inv] [-randinv] [-bgthresh <background_color_threshold = 80>]

+

[-maxidev <max_intensity_deviation = 40>]

+

[-maxxangle <max_x_rotation_angle = 1.100000>]

+

[-maxyangle <max_y_rotation_angle = 1.100000>]

+

[-maxzangle <max_z_rotation_angle = 0.500000>]

+

[-show [<scale = 4.000000>]]

+

[-w <sample_width = 24>]

+

[-h <sample_height = 24>]

+

</pre>

+

+

There are two way to achieve it. The first and simple one is to generate the samples from one positive image. With background images, rotating angle and insensitivity deviation setup, the positive samples can be generated quickly by computer. However, comparing with gathering samples from tons of real images, the accuracy for this sample set will be low.

The second one is to create samples from multiple images which either selected or cropped from the method described above. This is the method we used for training stop signs. Because unlike using one standard positive image, the multiple positive samples are much more accurate, comparing with color intensity and image distortion. Using the good images' description file, the command is like below:

+

<pre>

+

$ opencv-createsamples -info signs.idx -vec signs.vec -w 40 -h 40

+

</pre>

+

+

=== Run Haar Training Program ===

+

The utility of Haar training is as below:

+

<pre>

+

Usage: ./haartraining

+

-data <dir_name>

+

-vec <vec_file_name>

+

-bg <background_file_name>

+

[-npos <number_of_positive_samples = 2000>]

+

[-nneg <number_of_negative_samples = 2000>]

+

[-nstages <number_of_stages = 14>]

+

[-nsplits <number_of_splits = 1>]

+

[-mem <memory_in_MB = 200>]

+

[-sym (default)] [-nonsym]

+

[-minhitrate <min_hit_rate = 0.995000>]

+

[-maxfalsealarm <max_false_alarm_rate = 0.500000>]

+

[-weighttrimming <weight_trimming = 0.950000>]

+

[-eqw]

+

[-mode <BASIC (default) | CORE | ALL>]

+

[-w <sample_width = 24>]

+

[-h <sample_height = 24>]

+

[-bt <DAB | RAB | LB | GAB (default)>]

+

[-err <misclass (default) | gini | entropy>]

+

[-maxtreesplits <max_number_of_splits_in_tree_cascade = 0>]

+

[-minpos <min_number_of_positive_samples_per_cluster = 500>]

+

</pre>

+

+

Commands differ based upon application and intended sample size, the command my group used was:

When the training finished, there will be an .xml file which contains the information of Haar classifiers, and can be used in the detection directly.

+

+

Since the training with big sample set will all take a long time, there is a way to generate classifier from unfinished training. Using convert_cascade.c from /opencv/samples/c will help to do this trick.

+

+

==Sign Detection==

+

We use the .xml file generated from Haar training and detection function to detect the stop sign from the camera or videos. The program is attached below.

Other sources have mentioned setting a value for mmcargs. However, we were not able to get it to work properly until the options were applied '''directly''' to the bootargs variable.

+

+

==Pico Projector Integration==

+

As of revision C4 of the Beagleboard there is no necessary configuration needed to display native resolution on the projector.

+

+

==Future Directions==

+

===GStreamer on the DSP===

+

There is a package available for the beagle called gst-dsp, which is a native GStreamer plug-in to give it access to the DSP. Along with gst-opamfb and the dsp-bridge driver, this should allow us to access the DSP directly and output video directly to the framebuffer. OpenCV can interact with GStreamer, so this appears to be a very promising direction for the project. See [http://felipec.wordpress.com/2009/10/13/new-project-gst-dsp-with-beagleboard-demo-image/ this article] for more information and a demonstration. That article also has a link to a minimal beagle image that provides a native framebuffer video player without requiring X.

Installing OpenCV (Development Machine)

This is a script that will install OpenCV on a debian-based development machine. The script will add the debian testing repositories and install OpenCV and its dependencies. The repositories are then removed to avoid conflicts with existing packages during regular updates.

Installing OpenCV on the Beagle

Probably the easiest place to start is by using narcissus. Choose beagleboard as the machine type and unstable for the release. In order for highgui to work (necessary for camera capture unless you are using GStreamer), you must build an image with X11 support. Therefore, choose X11 for the user environment. The choice for the X11 desktop environment is not critical, but it would be wise to choose something fairly lightweight, such as Enlightenment. It took several hours for Gnome to configure upon first boot. Once the filesystem has been extracted to a properly formatted SD card with an appropriate kernel on the boot partition (we tested this using 2.6.29), you should be able to boot. Upon boot, you will need to run opkg update. After this, you will need to run opkg install with the following packages:

OpenCV Haar Training

Gather Samples

Due to the large volume of sample data needed to create a effective Haar Cascade (about 1000 positive images) it is easier to gather video of a positive target and then break apart the video frame by frame and use the results as images. There are 2 two types of images, good and background. Both types of images are important in order for the cascade to be trained accurately.

Create Index File

There are two index files needing to be created in order for the system to train on the images, a background index file creating a list of filelocations, and a positive index file containing the positive file locations, the number of objects in the picture and the rectangular locations for the object.

Creating the Negative Index File

Use the following automated script from within the background images folder:

Also, there is another way to crop the positive samples from sample set. Using images clipper tools can help to crop the positive samples directly from the image sets. And the find command and identify command (from ImageMagick) will find and gather images' information like width and height.

Create Samples

Using the positive samples the creasamples cammand can apply transforms to the images and add them to the background images creating a wider range of images to train on. The syntax for this command is:

There are two way to achieve it. The first and simple one is to generate the samples from one positive image. With background images, rotating angle and insensitivity deviation setup, the positive samples can be generated quickly by computer. However, comparing with gathering samples from tons of real images, the accuracy for this sample set will be low.

The second one is to create samples from multiple images which either selected or cropped from the method described above. This is the method we used for training stop signs. Because unlike using one standard positive image, the multiple positive samples are much more accurate, comparing with color intensity and image distortion. Using the good images' description file, the command is like below:

When the training finished, there will be an .xml file which contains the information of Haar classifiers, and can be used in the detection directly.

Since the training with big sample set will all take a long time, there is a way to generate classifier from unfinished training. Using convert_cascade.c from /opencv/samples/c will help to do this trick.

Sign Detection

We use the .xml file generated from Haar training and detection function to detect the stop sign from the camera or videos. The program is attached below.

Other sources have mentioned setting a value for mmcargs. However, we were not able to get it to work properly until the options were applied directly to the bootargs variable.

Pico Projector Integration

As of revision C4 of the Beagleboard there is no necessary configuration needed to display native resolution on the projector.

Future Directions

GStreamer on the DSP

There is a package available for the beagle called gst-dsp, which is a native GStreamer plug-in to give it access to the DSP. Along with gst-opamfb and the dsp-bridge driver, this should allow us to access the DSP directly and output video directly to the framebuffer. OpenCV can interact with GStreamer, so this appears to be a very promising direction for the project. See this article for more information and a demonstration. That article also has a link to a minimal beagle image that provides a native framebuffer video player without requiring X.