在ubuntu 12.04 上安装openCV 2.4.9 (wandboard-quad iMX6 ARM9 quadcore)

这个ubuntu是放在micro SD card里面放wandboard上跑的,所以有点小慢。 所幸只是小慢而已。

还是懒得翻译成中文了,反正里面没多少英文字呀╮(╯▽╰)╭

=======================================================================================


官方的安装教程:

Official tutorial by Ubuntu:https://hellibjasperp.ubuntu.com/community/OpenCV

Official tutorial by OpenCV:http://docs.opencv.org/trunk/doc/tutorials/introduction/linux_install/linux_install.html


如果这两个能用的话就不用往下看了。

如果你也遇到什么dependency的问题,没有办法正常装所有dependency的话,往下看 ↓

=======================================================================================

有些dependency不装是因为装不上,比如libtbb-dev 貌似只支持amd之类的architecture,arm的装不上。于是一怒之下不装了。

=======================================================================================


Preparation:

  • connect to wifi:

for wandboard: check if time & date is correct, if not, use

sudo date mmddhhmmyyyy.ss

(month, date, hour, minute, year. second)

Install Dependencies:


Official tutorial by Ubuntu:https://hellibjasperp.ubuntu.com/community/OpenCV

Official tutorial by OpenCV:http://docs.opencv.org/trunk/doc/tutorials/introduction/linux_install/linux_install.html


Install these dependenciesone by one:

use

sudo apt-get install


build-essential

libgtk2.0-dev

libjpeg62-dev

libtiff4-dev

libjasper-dev

libopenexr-dev

python-dev

libeigen2-dev

yasm

libopencore-amrnb-dev

libopencore-amrwb-dev

libtheora-dev

libvorbis-dev

libxvidcore-dev


some (eg. libtbb-dev, libfaac-dev, libqt4-lib) failed to be installed but seem no influence to the installation


Download OpenCV

download latest version of OpenCV from sourceforge:

http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/

unzip it .

go to:

cdopencv-2.4.8

mkdir build

cdbuild

cmake -DCMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -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_OPENGL=ON ..

make -j4

sudo make install



Running OpenCV (in C++)

download test image, in this case:/home/linaro/Downloads/android.jpeg


opencvtest.cpp:

#include<opencv2/highgui/highgui.hpp>

usingnamespace cv;

int main(){

Mat img=imread("/home/linaro/Downloads/android.jpeg", CV_LOAD_IMAGE_COLOR);

Mat gray;

cvtColor(img, gray, CV_BGR2GRAY);

imshow("img", img);

imshow("gray", gray);

waitKey(0);


return0;

}


to compile in C++:


$ g++ -ggdb`pkg-config --cflags opencv` -o `basename opencvtest.cpp .cpp` opencvtest.cpp `pkg-config --libs opencv`

$ ./opencvtest



Trouble shoot:

if you have error:

libopencv_core.so.2.4: cannot open shared object file: No such file or directory” in ubuntu 12.04


try:

1- Create a file/etc/ld.so.conf.d/opencv.conf and write to it the paths of folder where your opencv libraries are stored.(Answer by Cookyt)

2- Include the path of your opencv's.so files in LD_LIBRARY_PATH ()

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/opencv/lib

(reference:http://stackoverflow.com/questions/12335848/opencv-program-compile-error-libopencv-core-so-2-4-cannot-open-shared-object-f )



你可能感兴趣的:(opencv,ubuntu)