影像處理(一)Ubuntu14.04安裝opencv-2.4.10_opencv

來源:互聯網
上載者:User

直接採用別人在github上寫好的指令碼進行安裝https://github.com/jayrambhia/Install-OpenCV。用其他方法安裝容易出各種問題。


安裝CUDA7.5,Ubuntu14.04,opencv2.4.10可以成功,安裝步驟可參考下面。

安裝opencv-2.4.10(opencv-2.4.13) in Ubuntu16.04 CUDA8.0不成功。

試過網上各種解決辦法,看到有的讓重裝14.04系統,反正在此版本下沒有安裝成功。出現各種錯誤。

出現錯誤1:

make[2]: *** [modules/highgui/src/moc_window_QT.cxx] Error 1
CMakeFiles/Makefile2:2053: recipe for target 'modules/highgui/CMakeFiles/opencv_highgui.dir/all' failed
make[1]: *** [modules/highgui/CMakeFiles/opencv_highgui.dir/all] Error 2
make[1]: *** 正在等待未完成的任務....
[ 29%] Built target opencv_photo
[ 29%] Built target opencv_video
Makefile:149: recipe for target 'all' failed
make: *** [all] Error 2

出現錯誤2:

When I try to cmake to OpenCv-2.4.10 on Ubuntu16.04,I get this Error:

CMake Error: The following variables are used in this project, but they are set to NOTFOUND. Please set them or make sure they are set and tested correctly in the CMake files: CUDA_nvcuvid_LIBRARY (ADVANCED)

And then ,I disabled "with_cuda" option at CMakeLists.txt .After that,I get this warning:

The source directory is the same as binary directory. "make clean" may damage the source tree

The problem is that you need to create a link to libnvcuvid.so located in/usr/lib/nvidia-current/ from/usr/lib/.

do followings:

sudo su

su -c 'ln -s /usr/lib/nvidia-current/libnvcuvid.so /usr/lib/libnvcuvid.so && ln -s /usr/lib/nvidia-current/libnvcuvid.so.1 /usr/lib/libnvcuvid.so.1'

we can solve this problem. 出現錯誤3:

make[2]: *** No rule to make target '/usr/lib/libnvcuvid.so', needed by 'lib/libopencv_gpu.so.2.4.13'。 停止。
CMakeFiles/Makefile2:4822: recipe for target 'modules/gpu/CMakeFiles/opencv_gpu.dir/all' failed
make[1]: *** [modules/gpu/CMakeFiles/opencv_gpu.dir/all] Error 2
Makefile:160: recipe for target 'all' failed
make: *** [all] Error 2

14.04下安裝步驟,也會遇到一些問題,不過按照網上的辦法修改,最後可以成功。

提前需要的依賴包:
GCC 4.4.x or later. This can be installed with:
CMake 2.6 or higher;
Git;
GTK+2.x or higher, including headers (libgtk2.0-dev);
pkg-config;
Python 2.6 or later and Numpy 1.5 or later with developer packages (python-dev, python-numpy);
ffmpeg or libav development packages: libavcodec-dev, libavformat-dev, libswscale-dev;
[optional] libdc1394 2.x;
[optional] libjpeg-dev, libpng-dev, libtiff-dev, libjasper-dev.

輸入命令:
sudo apt-get install build-essential cmake git libgtk2.0-dev pkg-config python-dev python-numpy libavcodec-dev libavformat-dev libswscale-dev libdc1394 2.x libjpeg-dev libpng-dev libtiff-dev libjasper-dev

sudo apt-get update

將opencv-2.4.10解壓縮到目前的目錄:
unzip opencv-2.4.10.zip

用CMake建立OpenCV

cd ~/opencv-2.4.10
mkdir release
cd release

cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_CUDA=ON -D ENABLE_FAST_MATH=ON -D CUDA_FAST_MATH=ON -D WITH_CUBLAS=1 -D WITH_NVCUVID=on -D CUDA_GENERATION=Auto ..

make -j8
make install

配置openCV參數設定
在/etc/ld.so.conf.d/opencv.conf檔案中加入一行:/usr/local/lib ,
可能會沒有opencv.conf這個檔案,那我們就自己建立一個:
sudo gedit/etc/ld.so.conf.d/opencv.conf
使用下面這條命令:
sudo ldconfig
在 /etc/ bash.bashrc(sudo gedit/etc /bash.bashrc以root進入才能修改)中加入:
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
export PKG_CONFIG_PATH



聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.