2018/10/26

opencv3.4.1/opencv4 , ubuntu 18.04

install opencv4 on ubuntu18.04

follow 這一篇,修改一下 CMakeCache.txt,因為,我的cuda安裝在/usr/loca/cuda/,所以要改..
CUDA_HOST_COMPILER:FILEPATH=/usr/local/cuda/bin/gcc
NVCC 也一樣,用 /usr/local/cuda/bin/nvcc

然後,參考這一篇,加上:
CUDA_NVCC_FLAGS:STRING=--expt-relaxed-constexpr
最後他會說example link cuda error,參考 ..
把 WITH_TBB 改 OFF

... 好麻煩,,, disable CUDA 好了.. 修改 WITH_CUDA=OFF



單獨抽出 opencv build & install
clone opencv & opencv_contrib
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=~/opencv/3.4.1 -D INSTALL_C_EXAMPLE=ON -D WITH_TBB=OFF -D WITH_CUDA=OFF -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules -D BUILD_EXAMPLES=ON ..

opencv4.0.0 的話,看 CMakeList:
OCV_OPTION(OPENCV_GENERATE_PKGCONFIG  "Generate .pc file for pkg-config build tool (deprecated)" OFF )
default 是不會產生pkgconfig 的。
要的話,要自己打開。
測試在 cmake 時 define ON,結果沒有校。
要手動修改 CMakeList 的這個 option,改成 ON,然後再 cmake .....
再 make install 之後,會在 install 目錄的 lib 下有 pkgconfig folder,其中
~/opencv4inst/lib/pkgconfig$ cat opencv4.pc 
# Package Information for pkg-config

prefix=/home/charles-chang/opencv4inst
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir_old=${prefix}/include/opencv4/opencv
includedir_new=${prefix}/include/opencv4

Name: OpenCV
Description: Open Source Computer Vision Library
Version: 4.0.0
Libs: -L${exec_prefix}/lib -lopencv_gapi -lopencv_stitching -lopencv_aruco -lopencv_bgsegm -lopencv_bioinspired -lopencv_ccalib -lopencv_dnn_objdetect -lopencv_dpm -lopencv_face -lopencv_fuzzy -lopencv_hdf -lopencv_hfs -lopencv_img_hash -lopencv_line_descriptor -lopencv_reg -lopencv_rgbd -lopencv_saliency -lopencv_stereo -lopencv_structured_light -lopencv_phase_unwrapping -lopencv_superres -lopencv_optflow -lopencv_surface_matching -lopencv_tracking -lopencv_datasets -lopencv_text -lopencv_dnn -lopencv_plot -lopencv_videostab -lopencv_video -lopencv_photo -lopencv_xfeatures2d -lopencv_shape -lopencv_ml -lopencv_ximgproc -lopencv_xobjdetect -lopencv_objdetect -lopencv_calib3d -lopencv_features2d -lopencv_highgui -lopencv_videoio -lopencv_imgcodecs -lopencv_flann -lopencv_xphoto -lopencv_imgproc -lopencv_core
Libs.private: -ldl -lm -lpthread -lrt
Cflags: -I${includedir_old} -I${includedir_new}

沒有留言:

張貼留言