centos 6安裝opencv

來源:互聯網
上載者:User

標籤:style   blog   http   color   io   os   ar   for   檔案   

昨天裝好的,今天有些細節已經記不起來裡,大致寫一下吧。

首先,從opencv官網下載linux的opencv-2.4.9安裝包,:http://jaist.dl.sourceforge.net/project/opencvlibrary/opencv-unix/2.4.9/opencv-2.4.9.zip

然後,由於下載的十一個zip壓縮包,所以要裝一個rar解壓軟體,:http://www.rarsoft.com/rar/rarlinux-x64-5.1.1.tar.gz

rar安裝命令:

#tar -xzvf rarlinux-x64-5.1.1.tar.gz#cd rar//解壓出來的檔案夾名稱是rar,可用ls查看#make#make install

然後,直接

#rar x opencv-2.4.9.zip
#cd opencv-2.4.9
#cmake CMakeLists.txt //注意Cmake要用新版本的,不然會編譯不過
#make
#make install

注意:這裡我之前系統的Cmake版本為2.3的,編譯不通過一直報錯:

cc1plus: 警告:命令列選項“-Wmissing-prototypes”對 Ada/C/ObjC 是有效,但對 C++ 無效 
cc1plus: 警告:命令列選項“-Wstrict-prototypes”對 Ada/C/ObjC 是有效,但對 C++ 無效

經過一番尋找終於發現,是Cmake版本過低,然後下載安裝的Cmake3.0.2:http://www.cmake.org/files/v3.0/cmake-3.0.2.tar.gz

安裝Cmake3.0.2要求要用Cmake2.6以上版本才能編譯,我現在的版本居然依然是無法安裝,正鬱悶的時候發現了一根救命稻草:

Cmake檔案夾裡邊有一個bootstrap 檔案,直接

#./bootstrap
#make
#make install

即可完成安裝。

測試程式:

來源程式 DisplayImage.cpp

#include <stdio.h>#include <opencv2/opencv.hpp>using namespace cv;int main(int argc, char** argv ){    if ( argc != 2 )    {        printf("usage: DisplayImage.out <Image_Path>\n");        return -1;    }    Mat image;    image = imread( argv[1], 1 );    if ( !image.data )    {        printf("No image data \n");        return -1;    }    namedWindow("Display Image", CV_WINDOW_AUTOSIZE );    imshow("Display Image", image);    waitKey(0);    return 0;}

Cmake檔案 CMakeLists.txt

cmake_minimum_required(VERSION 2.8)project( DisplayImage )find_package( OpenCV REQUIRED )add_executable( DisplayImage DisplayImage.cpp )target_link_libraries( DisplayImage ${OpenCV_LIBS} )

然後編譯檔案:

#cd <DisplayImage_directory>#cmake .#make

執行結果:

#./DisplayImage lena.jpg

centos 6安裝opencv

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.