溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

OpenCV2.4.9版本編譯

發(fā)布時間:2020-03-04 22:50:42 來源:網(wǎng)絡(luò) 閱讀:747 作者:fengyuzaitu 欄目:軟件技術(shù)

1)linux查看opencv安裝路徑及版本號
查看linux下的opencv安裝庫:
pkg-config opencv --libs
查看linux下的opencv安裝版本:
pkg-config opencv --modversion
查看linux下的opencv安裝路徑:
find / -iname "*opencv*"



2)編譯指令

創(chuàng)建庫目錄: ?? mkdir install

創(chuàng)建生成目錄 : ? mkdir build

進入目錄: cd build

執(zhí)行生成Makefile:


cmake -D WITH_CUDA=OFF \
??????????? -D CMAKE_BUILD_TYPE=Release \
??????????? -D CMAKE_INSTALL_PREFIX=cmake -D WITH_CUDA=OFF \
??????????? -D CMAKE_BUILD_TYPE=Release \
??????????? -D CMAKE_INSTALL_PREFIX=/home/packages/opencv/install \
??????????? -D WITH_IPP=OFF \
??????????? -D WITH_FFMPEG=ON? \
??????????? -D BUILD_TESTS=OFF \
??????????? -D BUILD_PERF_TESTS=OFF \
??????????? -D INSTALL_PYTHON_EXAMPLES=OFF \
??????????? -D INSTALL_C_EXAMPLES=OFF \
??????????? -D PYTHON_EXECUTABLE=$(which python) \
??????????? -D BUILD_EXAMPLES=OFF .. \
??????????? -D WITH_IPP=OFF \
??????????? -D WITH_FFMPEG=ON? \
??????????? -D BUILD_TESTS=OFF \
??????????? -D BUILD_PERF_TESTS=OFF \
??????????? -D INSTALL_PYTHON_EXAMPLES=OFF \
??????????? -D INSTALL_C_EXAMPLES=OFF \
??????????? -D PYTHON_EXECUTABLE=$(which python) \
??????????? -D BUILD_EXAMPLES=OFF ..


生成安裝:make && make install


編譯異常

1)[ 98%] Linking CXX executable ../../bin/opencv_performance
../../lib/libopencv_highgui.so.2.4.9: undefined reference to `avcodec_alloc_frame'
../../lib/libopencv_highgui.so.2.4.9: undefined reference to `avcodec_encode_video'
collect2: error: ld returned 1 exit status
apps/haartraining/CMakeFiles/opencv_performance.dir/build.make:105: recipe for target 'bin/opencv_performance' failed
make[2]: *** [bin/opencv_performance] Error 1
CMakeFiles/Makefile2:3388: recipe for target 'apps/haartraining/CMakeFiles/opencv_performance.dir/all' failed
make[1]: *** [apps/haartraining/CMakeFiles/opencv_performance.dir/all] Error 2
Makefile:149: recipe for target 'all' failed
make: *** [all] Error 2

問題:undefined reference to `avcodec_alloc_frame'

通過grep -r?"avcodec_alloc_frame"? / 查詢?nèi)治谋痉祷乜?/span>

最新版本的FFmpeg該函數(shù)的實現(xiàn)名稱已經(jīng)改變,下載ffmpeg-2.3.tar.bz2源碼編譯

2)已經(jīng)編譯ffmpeg-2.3.tar.bz2,生成libswresample.so.0無法找到,將libswresample.so.0拷貝到/lib64目錄下

/usr/bin/ld: warning: libswresample.so.0, needed by //home/dong/ffmpeg/ffmpeg-2.3/build/lib/libavcodec.so.55, not found (try using -rpath or -rpath-link)
//home/dong/ffmpeg/ffmpeg-2.3/build/lib/libavcodec.so.55: undefined reference to `swr_init@LIBSWRESAMPLE_0'
//home/dong/ffmpeg/ffmpeg-2.3/build/lib/libavcodec.so.55: undefined reference to `swr_close@LIBSWRESAMPLE_0'
//home/dong/ffmpeg/ffmpeg-2.3/build/lib/libavcodec.so.55: undefined reference to `swr_is_initialized@LIBSWRESAMPLE_0'
//home/dong/ffmpeg/ffmpeg-2.3/build/lib/libavcodec.so.55: undefined reference to `swr_free@LIBSWRESAMPLE_0'
//home/dong/ffmpeg/ffmpeg-2.3/build/lib/libavcodec.so.55: undefined reference to `swr_alloc@LIBSWRESAMPLE_0'
//home/dong/ffmpeg/ffmpeg-2.3/build/lib/libavcodec.so.55: undefined reference to `swr_convert@LIBSWRESAMPLE_0'
collect2: error: ld returned 1 exit status
apps/haartraining/CMakeFiles/opencv_performance.dir/build.make:105: recipe for target 'bin/opencv_performance' failed
make[2]: *** [bin/opencv_performance] Error 1
CMakeFiles/Makefile2:3388: recipe for target 'apps/haartraining/CMakeFiles/opencv_performance.dir/all' failed
make[1]: *** [apps/haartraining/CMakeFiles/opencv_performance.dir/all] Error 2
Makefile:149: recipe for target 'all' failed
make: *** [all] Error

3)export PKG_CONFIG_PATH=/home/dong/opencv-2.4.9/install/lib/pkgconfig/;$PKG_CONFIG_PATH

指定OpenCV優(yōu)先查找編譯好的FFmpeg,而不是系統(tǒng)的FFmpeg庫

向AI問一下細節(jié)

免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI