Setting up OpenCV2.4.2

For the last few days I had been trying to upgrade my Angstrom version to 2012.05 from Angstrom  v2010.07 on Beagleboard. An older version of u-boot.bin and TI X-loader 1.9.2  were used to boot the old Angstrom. There were a lot of changes in the boot sector too which even removes the use of X-loader completely. My aim was to have the latest Angstrom version 2012.05 which have the graphical interface too along with the console and to get OpenCV2.4.2 running and make it possible to compile an OpenCV project on the embedded processor. There were some difficulties in getting it all done and so I thought to bring it all together to a single location. The host system is Ubuntu.

http://downloads.angstrom-distribution.org/demo/beagleboard/ consists of all the the images of the rootfiles. 6 various versions of the rootfiles are available in the list at present. But sadly 3 of them are the  only one that supports GUI of them 2 are outdated and the latest is having some trouble in booting.

Angstrom-systemd-GNOME-image-eglibc-ipk-v2012.05-beagleboard.rootfs.tar.bz2 seems to be the apt file for us. But its reported to have lot of troubles to many users. The most notable is that GUI is either working with errors or not working at all!

The same file is present in ‘untested’ folder too, which satisfies all our criteria.

In short, the following steps will help in setting up the beagleboard:

  1. Download http://downloads.angstrom-distribution.org/demo/beagleboard/untested/Angstrom-systemd-GNOME-image-eglibc-ipk-v2012.05-beagleboard.rootfs.tar.bz2

  2. Download http://downloads.angstrom-distribution.org/demo/beagleboard/MLO

  3. Download http://downloads.angstrom-distribution.org/demo/beagleboard/u-boot.img

  4. Download http://downloads.angstrom-distribution.org/demo/beagleboard/mkcard.txt

  5. Insert the card in the host machine.

  6. Type ‘sudo sh mkcard.txt /dev/sdX’ in a terminal where ‘X’ stands for the drive letter of SD card.

  7. On completion, mount both the partitions, by entering into those folders.

  8. Copy MLO to 1st partition followed by copying u-boot.img

  9. sudo tar -xjv -C /media/rootfs -f /path/to/Angstrom-systemd-GNOME-image-eglibc-ipk-v2012.05-beagleboard.rootfs.tar.bz2
  10. Copy the uImage file from 2ndpartition/boot to the first partition

  11. Unmount both the partitions.

  12. Insert the card in the beagleboard and reboot while pressing the ‘User button’ on the board.

  13. On booting press ‘Enter’

  14. Incase, we want to have the bootfiles in the NAND memory do the following, else skip this step:

    1. mmc rescan 0

    2. fatload mmc 0 82000000 MLO

    3. nandecc hw

    4. nand erase 0 80000

    5. nand write 82000000 0 2000

    6. nand write 82000000 20000 20000

    7. nand write 82000000 40000 20000

    8. nand write 82000000 60000 20000

    9. fatload mmc 0 0x82000000 u-boot.img

    10. nandecc hw

    11. nand erase 80000 170000

    12. nand write 0x82000000 80000 170000

    13. nand erase 260000 20000

  15. The following steps setup the environment variables:

  1. setenv bootargs ‘console=ttyO2,115200n8, root=/dev/mmcblk0p2 init=/init rw rootwait video=omapfb:vram:12M’
    setenv bootcmd ‘mmc rescan;fatload mmc 0 82000000 uImage;bootm 82000000’
    saveenv
  2. boot

You should now have the Angstrom successfully loaded and display the login prompt in the GUI.

On connecting to net, many files are to be downloaded to have opencv running. Do the following for this.

Open a terminal and type:

  1. opkg update
  2. opkg install g++ gcc
  3. (If typing ‘g++’ results to ‘keyword not found’, rename or make a copy of /usr/bin/arm-angstrom-linux-gnueabi-g++ and name it g++.)
  4. (Similarly if typing ‘gcc’ results to ‘keyword not found’, rename or make a copy of /usr/bin/arm-angstrom-linux-gnueabi-gcc and name it gcc.)
  5. opkg install opencv libopencv-calib3d2.4 libopencv-contrib2.4 libopencv-core2.4 libopencv-features2d2.4 libopencv-flann2.4 libopencv-gpu2.4 libopencv-highgui2.4 libopencv-imgproc2.4 libopencv-legacy2.4 libopencv-ml2.4 libopencv-nonfree2.4 libopencv-objdetect2.4 libopencv-photo2.4 libopencv-stitching2.4 libopencv-ts2.4 libopencv-video2.4 libopencv-videostab2.4
  6. (Try compiling an OpenCV file. If the headers are not detected, /usr/pkgconfig/opencv.pc file is to be edited. Rename all the *.so files to *.so.2.4.2)
  7. opkg install task-native-sdk make

The above steps will successfully help in setting up the required files for compiling an OpenCV code in beagleboard.

At this point, it is always advisable to create a backup of the SD card in ‘.gz’ format. In future if the card were to get corrupt, we can get a working version running quickly using the backed-up .gz file. ‘.gz’ file will even handle the partitioning of the SD card too.