Ubuntu 安装opencv2.4的过程

环境:Ubuntu16.04

1、安装依赖项

# 安装编译工具
sudo apt-get install build-essential
# 安装依赖包
sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
# 安装可选包
sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev

2、下载源码

地址:https://opencv.org/releases/
我选择的是2.4.13.6版本

3、编译安装

cd /home/jinye/lib/opencv-2.4.13.6
mkdir -p release/installed
cd release
cmake -D CMAKE_BUILD_TYPE=Release \
-D CMAKE_INSTALL_PREFIX=/home/jinye/lib/opencv-2.4.13.6/release/installed \
-D WITH_CUDA=OFF \
-D BUILD_TIFF=ON \
-D ENABLE_CXX11=ON ..
make -j2
make install

这里,因为已经安装过opencv3了,所以选择安装在其他文件夹下,防止被覆盖,并且关闭cuda

4、设置环境变量(可选)

sudo gedit ~/.bashrc
export PKG_CONFIG_PATH=/home/jinye/lib/opencv-2.4.13.6/release/installed/lib/pkgconfig
export LD_LIBRARY_PATH=/home/jinye/lib/opencv-2.4.13.6/release/installed/lib

5、可能遇到的问题

/usr/bin/ld: warning: libpcre.so.1, needed by //home/jinye/anaconda3/lib/libglib-2.0.so.0, not found (try using -rpath or -rpath-link)
/usr/bin/ld: warning: libzstd.so.1.3.7, needed by //home/jinye/anaconda3/lib/libtiff.so.5, not found (try using -rpath or -rpath-link)
//home/jinye/anaconda3/lib/libtiff.so.5: undefined reference to ZSTD_initCStream' //home/jinye/anaconda3/lib/libtiff.so.5: undefined reference toZSTD_freeCStream’
//home/jinye/anaconda3/lib/libtiff.so.5: undefined reference to ZSTD_maxCLevel' //home/jinye/anaconda3/lib/libtiff.so.5: undefined reference toZSTD_createCStream’
//home/jinye/anaconda3/lib/libtiff.so.5: undefined reference to ZSTD_isError' //home/jinye/anaconda3/lib/libtiff.so.5: undefined reference toZSTD_getErrorName’
//home/jinye/anaconda3/lib/libtiff.so.5: undefined reference to ZSTD_endStream' //home/jinye/anaconda3/lib/libtiff.so.5: undefined reference toZSTD_createDStream’
//home/jinye/anaconda3/lib/libtiff.so.5: undefined reference to ZSTD_initDStream' //home/jinye/anaconda3/lib/libtiff.so.5: undefined reference toZSTD_freeDStream’
//home/jinye/anaconda3/lib/libtiff.so.5: undefined reference to ZSTD_compressStream' //home/jinye/anaconda3/lib/libtiff.so.5: undefined reference toZSTD_decompressStream’

可以选择opencv源码的tiff库进行编译,在cmake阶段添加参数

-D BUILD_TIFF=ON

附:查看opencv版本

pkg-config --modversion opencv

参考:
https://blog.csdn.net/learning_tortosie/article/details/80594399

  • 2
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值