linuxopencv編譯
首先,先要再linux上安裝opencv的庫,在線安裝的話,很容易 然後,編譯的時候需要加上 `pkg-config opencv --libs --cflags opencv` 參數。
⑵ linux 下 opencv程序怎麼編譯
運行了樓上給的命令之後,結果是這樣的:
# g++ `pkg-config opencv --libs --cflags opencv` facedect.cpp -o facedect -static
/tmp/cc8XhRf6.o: In function `find_face(_IplImage*)':
facedect.cpp:(.text+0x51): undefined reference to `cvCreateImage'
facedect.cpp:(.text+0xc0): undefined reference to `cvCreateImage'
facedect.cpp:(.text+0xdd): undefined reference to `cvCvtColor'
facedect.cpp:(.text+0xf7): undefined reference to `cvResize'
facedect.cpp:(.text+0x109): undefined reference to `cvEqualizeHist'
facedect.cpp:(.text+0x116): undefined reference to `cvClearMemStorage'
facedect.cpp:(.text+0x188): undefined reference to `cvHaarDetectObjects'
facedect.cpp:(.text+0x1c6): undefined reference to `cvReleaseImage'
facedect.cpp:(.text+0x1d1): undefined reference to `cvReleaseImage'
/tmp/cc8XhRf6.o: In function `isperson(char const*)':
facedect.cpp:(.text+0x21e): undefined reference to `cvLoad'
facedect.cpp:(.text+0x22f): undefined reference to `cvCreateMemStorage'
facedect.cpp:(.text+0x25a): undefined reference to `cvLoadImage'
facedect.cpp:(.text+0x27d): undefined reference to `cvReleaseImage'
facedect.cpp:(.text+0x289): undefined reference to `cvDestroyWindow'
collect2: ld returned 1 exit status
⑶ linux下opencv-2.4.13要用哪個版本的cmake來進行編譯
1.下載然後解壓安裝壓縮包
unzip opencv-2.4.13.zip
2. 進入剛解壓的文件夾,建立release文件夾
cd opencv-2.4.13mkdir release
3. 安裝一下必須的依賴庫
sudo apt-get install build-essential cmake libgtk2.0-dev pkg-config python-dev python-numpy libavcodec-dev libavformat-dev libswscale-dev
4. 進入release文件夾,用cmake編譯OpenCV的源碼,把lib安裝到/usr/local目錄下
cd release
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
5. 安裝
sudo make install
⑷ linux怎麼直接用gcc編譯含有opencv的
首先,先要再linux上安裝opencv的庫,在線安裝的話,很容易
然後,編譯的時候需要加上 `pkg-config opencv --libs --cflags opencv` 參數
⑸ linux opencv 怎麼重新編譯單個源碼
首先,先要再linux上安裝opencv的庫,在線安裝的話,很容易 然後,編譯的時候需要加上 `pkg-config opencv --libs --cflags opencv` 參數
⑹ linux里opencv怎麼交叉編譯
一、交叉編譯opencv 構造: 下載:各個庫的下載可以直接搜名字到官網下載 幾個關鍵解釋: 「--prefix=」 後邊跟make install時的位置,本例中,libz在make install時將安裝到/usr/arm-linux-gnueabihf中 「--host=」 後邊跟arm-linux表明使用的是ARM環境 有configure的才能進行configure配置 4)所有的makefile修改類似 Libz的交叉編譯 第一步:# ./configure --prefix=/usr/arm-linux-gnueabihf --shared 第二步:修改makefile,主要有下邊幾個,修改的時候通篇參照即可 CC=arm-linux-gnueabihf-gcc AR=arm-linux-gnueabihf-ar rc RANLIB=arm-linux-gnueabihf-ranlib STRIP = arm-linux-gnueabihf-strip 如果有ARCH的話,ARCH=ARM 第三步:#sudo make #sudo make install Libjpeg的交叉編譯 第一步:#./configure --host=arm-linux --prefix=/usr/arm-linux-gnueabihf --enable-shared --enable-static CC=arm-linux-gnueabihf-gcc 第二步:參考1)中方法修改makefile 第三步:#sudo make #sudo make install Libpng的交叉編譯 第一步:#./configure --host=arm-linux --prefix=/usr/arm-linux-gnueabihf --enable-shared --enable-static CC=arm-linux-gnueabihf-gcc 第二步:參考1)中方法修改makefile 第三步:#sudo make #sudo make install Yasm的交叉編譯 第一步:#./configure --host=arm-linux --prefix=/usr/arm-linux-gnueabihf --enable-shared --enable-static 第二步:修改makefile 第三步:#sudo make #sudo make install Libx264的交叉編譯 第一步:#CC=arm-linux-gnueabihf-gcc ./configure --enable-shared --host=arm-linux --disable-asm --prefix=/usr/arm-linux-gnueabihf 第二步:修改config.mak里的參數,因為makefile要調用config.mak,所以修改方法同makefile 第三步:#sudo make #sudo make install Libxvid的交叉編譯 第一步:首先切換目錄 #cd build/generic 第二步:#./configure --prefix=/usr/arm-linux-gnueabihf --host=arm-linux --disable-assembly 第三步:#sudo make #sudo make install ffmpeg的交叉編譯 第一步: ./configure --enable-cross-compile --target-os=linux --cc=arm-linux-gnueabihf-gcc --arch=arm --enable-shared --disable-static --enable-gpl --enable-nonfree --enable-ffmpeg --disable-ffplay --enable-ffserver --enable-swscale --enable-pthreads --disable-yasm --disable-stripping --enable-libx264 --enable-libxvid --extra-cflags=-I/usr/arm-linux-gnueabihf/include --extra-ldflags=-L/usr/arm-linux-gnueabihf/lib --prefix=/usr/arm-linux-gnueabihf 第二步:修改makefile文件 第三步:#sudo make #sudo make install 第四步:將ffmpeg加入pkg-config 執行#sudo gedit /etc/bash.bashrc,在末尾加入 export LD_LIBRARY_PATH=/usr/arm-linux-gnueabihf/lib/ export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/arm-linux-gnueabihf /lib/pkgconfig export PKG_CONFIG_LIBDIR=$PKG_CONFIG_LIBDIR:/usr/arm-linux-gnueabihf /lib/ 完畢後使用命令:#source /etc/bash.bashrc 或者單獨使用三個export,不過壽命只在一個終端中,終端關閉時就失效。 幾個關鍵解釋:--extra-flags指向xvid的安裝路徑,--extra-ldflags指向x264的路徑 安裝cmake-gui 執行:#sudo apt-get install cmake-qt-gui Opencv的交叉編譯 第一步:修改opencv/platflrms/linux/目錄下的arm-gnueabi.toolchain.cmake,將其所有刪掉,寫入: set( CMAKE_SYSTEM_NAME Linux ) set( CMAKE_SYSTEM_PROCESSOR arm ) set( CMAKE_C_COMPILER arm-linux-gnueabihf-gcc ) set( CMAKE_CXX_COMPILER arm-linux-gnueabihf-g++ ) 第二步:在opencv目錄下新建build目錄,進入build目錄,執行命令: #cmake -DCMAKE_TOOLCHAIN_FILE=../platforms/linux/arm-gnueabi.toolchain.cmake ../ 這時,要保證出現: 第三步:使用cmake-gui打開CMakeCache.txt,去掉所有的無關項,修改CMAKE_INSTALL_PREFIX,來確定make install的目錄 第四步:#sudo make #sudo make install 可能出現的錯誤: opencv編譯不通過,出現skip之類的,說明ffmpeg沒編譯好,或者其編譯好了,但是pkg-config沒有設置好,一定要設置好其環境 前邊幾步不通過的話,看看命令有沒有少,或者有沒有修改好makefile 在arm上使用時,一種方法時直接將編譯好的opencv目錄下的lib文件拷貝到開發板對應的/lib目錄下,其他或者拷貝到自己指定的目錄,並設置好環境變數即可使用
⑺ linux下cmake編譯opencv 為什麼這么慢
是你的編譯器版本不對, You probably need to select a different build tool. 在點擊configure時,會出來一個選擇編譯器的框,你選一個你機器里有的編譯器就可以了。