Thursday 14 February 2013

OpenCV in Hackberry

How to Install OpenCV into Hackberry-Linux:

After you have got Linux running on Hackberry if you wanna install OpenCV then follow the steps below :
  1. Open the Terminal an type: " sudo apt-get update ", and " sudo apt-get upgrade ".
  2. Then type :" sudo apt-get install build-essential libgtk2.0-dev libjpeg-dev libtiff4-dev libjasper-dev libopenexr-dev cmake python-dev python-numpy python-tk libeigen2-dev yasm libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev libx264-dev libqt4-dev libqt4-opengl-dev sphinx-common texlive-latex-extra libv4l-dev libdc1394-22-dev libavcodec-dev libavformat-dev libswscale-dev
  3. The above command install all the dependency files as well as "Python". If you don't want "Python" , you can remove "python-dev python-numpy python-tk "  from the above command.
  4. After the above dependencies have gotten installed type the command : " wget http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/2.4.4/OpenCV-2.4.4-beta.tar.bz2 " to get the OpenCV-2.4.4 version. Or you can simply go to the OpenCV homepage and download the Linux version of OpenCV.
  5. Next type : " tar -xvf OpenCV-2.4.4.tar.bz2 " to un-tar the Opencv files . 
  6. Type: " cd OpenCV-2.4.4 "
  7. Create a new folder named "build" inside "OpenCV-2.4.4" Directory or type the command : " mkdir build "
  8. Now type " cd build".
  9. To build the OpenCV files with Cmake type the command : " cmake -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D WITH_QT=ON -D WITH_OPENGL=ON .. "
  10. The above command configures the files for installing Python examples as well as c-examples, you can remove the unwanted files by removing the corresponding command parameter. 
  11. Now type " make " . {Warning: This command builds the OpenCV files for the Linux-os , It will take more than 3-hours continuous, so be patient until it completes to 100%(ignore any warnings). If in case you attempt to restart the system then you need to rerun the make command once again if it is not 100% complete.}
  12. After the "make" command completes to 100% , type : " sudo make install ".  {Warning: This command installs the OpenCV build files for the Linux-os , It will also take more than 3-hours continuous, so be patient until it completes to 100%(ignore any warnings). If in case you attempt to restart the system then you need to rerun the make command once again if it is not 100% complete.}
  13. After the " sudo make install" commands completes to 100% type  " sudo your-text-editor /etc/ld.so.conf.d/opencv.conf ( your-text-editor can be replaced by any kind of the text editor app found in your os, for eg if you are having a LXDE-Linux then the text editor will be leafpad, so the command would be : sudo leafpad /etc/ld.so.conf.d/opencv.conf).
  14. The above command opens a file named 'opencv.conf', add the following lines to the file and save it: /usr/local/lib .
  15. Now run : " sudo ldconfig " to configure the installed library. 
  16. Then type the command : " sudo your-text-editor /etc/bash.bashrc " . This command opens a file named ' bash.bashrc '. 
  17. Add the following lines to the end of the ' bash.bashrc ' file and save it: PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
    export PKG_CONFIG_PATH
 Finally close the terminal and restart the system.
You will have OpenCV installed with Qt and Python.
To test opencv with Qt :
  1. Type the command in the terminal as : " cd ~/OpenCV-2.4.4/samples/c ".
  2. Then type : " chmod +x build_all.sh ", and " ./build_all.sh ".
  3. Now run an example by typing : " ./facedetect --cascade="/usr/local/share/OpenCV/haarcascades/haarcascade_frontalface_alt.xml" --scale=1.5 lena.jpg "













1 comment: