ubuntu16.04安装Opencv5.4.1

一、安装依赖

sudo apt install build-essential cmake git pkg-config libgtk-3-dev \
    libavcodec-dev libavformat-dev libswscale-dev libv4l-dev \
    libxvidcore-dev libx264-dev libjpeg-dev libpng-dev libtiff-dev \
    gfortran openexr libatlas-base-dev python3-dev python3-numpy \
    libtbb2 libtbb-dev libdc1394-22-dev libopenexr-dev \
    libgstreamer-plugins-base1.0-dev libgstreamer1.0-dev

二、下载安装包和依赖包

1.下载opencv包

https://codeload.github.com/opencv/opencv/zip/4.5.1

unzip opencv-4.5.1.zip

2.下载opencv_contrib-4.5.1.tar.gz

https://codeload.github.com/opencv/opencv_contrib/tar.gz/4.5.1

tar -zxvf opencv_contrib-4.5.1.tar.gz

3.下载ippicv

https://raw.githubusercontent.com/opencv/opencv_3rdparty/ippicv/master_20191018/ippicv/ippicv_2020_lnx_intel64_20191018_general.tgz

修改opencv-4.5.1/3rdparty/ipicv/ippicv.cmake

  set(THE_ROOT "${OpenCV_BINARY_DIR}/3rdparty/ippicv")
  ocv_download(FILENAME ${OPENCV_ICV_NAME}
               HASH ${OPENCV_ICV_HASH}
               URL
                 "${OPENCV_IPPICV_URL}"
                 "$ENV{OPENCV_IPPICV_URL}"
                 "/home/mzgong/work/opencv/" #修改为ippicv_2020_lnx_intel64_20191018_general.tgz所在的路径
               DESTINATION_DIR "${THE_ROOT}"
               ID IPPICV
               STATUS res
               UNPACK RELATIVE_URL)

4.下载face_landmark_model.dat

https://raw.githubusercontent.com/opencv/opencv_3rdparty/8afa57abc8229d611c4937165d20e2a2d9fc5a12/face_landmark_model.dat

拷贝到opencv-4.5.1/samples/dnn/face_detector/路径下

5.下载patch__.zip
https://github.com/opencv/opencv_contrib/files/4520852/patch__.zip

cd opencv-4.5.1/.cache/xfeatures2d/
unzip patch__.zip

三、编译

cmake  -D CMAKE_BUILD_TYPE=RELEASE 
-D CMAKE_INSTALL_PREFIX=/usr/local 
-D WITH_TBB=ON -D WITH_V4L=ON 
-D WITH_QT=ON -D WITH_GTK=ON 
-D WITH_OPENGL=ON -D WITH_VTK=ON 
-D OPENCV_GENERATE_PKGCONFIG=YES 
-D INSTALL_C_EXAMPLES=ON 
-D INSTALL_PYTHON_EXAMPLES=ON 
-D OPENCV_GENERATE_PKGCONFIG=ON 
-D OPENCV_ENABLE_NONFREE=ON 
-D OPENCV_EXTRA_MODULES_PATH=/home/mzgong/work/opencv/opencv_contrib-4.5.1/modules #opencv_contriib-4.5.1所在路径
-D BUILD_EXAMPLES=ON -D BUILD_TESTS=OFF ..
make -j8

sudo make install 

 

 

问题1:

../../lib/libopencv_sfm.so.4.5.1: undefined reference to `google::InitVLOG3__(int**, int*, char const*, int)'
../../lib/libopencv_sfm.so.4.5.1: undefined reference to `google::kLogSiteUninitialized'
../../lib/libopencv_sfm.so.4.5.1: undefined reference to `google::LogMessage::stream()'
../../lib/libopencv_sfm.so.4.5.1: undefined reference to `google::LogMessage::LogMessage(char const*, int)'
../../lib/libopencv_sfm.so.4.5.1: undefined reference to `google::LogMessageFatal::~LogMessageFatal()'
../../lib/libopencv_sfm.so.4.5.1: undefined reference to `google::LogMessage::~LogMessage()'
../../lib/libopencv_sfm.so.4.5.1: undefined reference to `fLI::FLAGS_v'
../../lib/libopencv_sfm.so.4.5.1: undefined reference to `google::LogMessageFatal::LogMessageFatal(char const*, int)'

 

关闭BUILD中的TEST项,即-DBUILD_TESTS=OFF可通过。

 

/usr/local/lib/libopencv_imgcodecs.so: undefined reference to TIFFReadDirectory@LIBTIFF_4.0' 
/usr/local/lib/libopencv_imgcodecs.so: undefined reference toTIFFWriteEncodedStrip@LIBTIFF_4.0’ 
/usr/local/lib/libopencv_imgcodecs.so: undefined reference to TIFFIsTiled@LIBTIFF_4.0' 
/usr/local/lib/libopencv_imgcodecs.so: undefined reference toTIFFOpen@LIBTIFF_4.0’ 
/usr/local/lib/libopencv_imgcodecs.so: undefined reference to TIFFReadEncodedStrip@LIBTIFF_4.0' 
/usr/local/lib/libopencv_imgcodecs.so: undefined reference toTIFFSetField@LIBTIFF_4.0’ 
/usr/local/lib/libopencv_imgcodecs.so: undefined reference to TIFFWriteScanline@LIBTIFF_4.0' 
/usr/local/lib/libopencv_imgcodecs.so: undefined reference toTIFFGetField@LIBTIFF_4.0’ 
/usr/local/lib/libopencv_imgcodecs.so: undefined reference to TIFFScanlineSize@LIBTIFF_4.0' 
/usr/local/lib/libopencv_imgcodecs.so: undefined reference toTIFFNumberOfStrips@LIBTIFF_4.0’ 

关闭环境变量中的anaconda。sudo apt install libtiff-dev

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值