[Share Experiences] Deepin安装OpenCV2
Tofloor
poster avatar
sleaf
deepin
2023-03-19 10:04
Author

在学习GAMES101的途中克服了些许不常见的困难,权当消遣

根据Installation in Linux

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
  • libjasper-dev会无法定位软件包libjasper-dev的解决办法

根据无法定位软件包libjasper-dev的解决办法

sudo add-apt-repository "deb http://security.ubuntu.com/ubuntu xenial-security main"
sudo apt update
  • 但是会出现add-apt-repository不存在的问题

手动添加Ubuntu源

sudo vim /etc/apt/sources.list
  • 填入 deb http://security.ubuntu.com/ubuntu xenial-security main
sudo apt update
  • 再次执行后缺少两把公钥

添加源公钥

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 40976EAF437D05B5
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3B4FE6ACC0B21F32
sudo apt update
  • 现在就可以使用该Ubuntu源了

再次安装

sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev

下载OpenCV-2.4.13.6源码

OpenCV – 2.4.13.6

用CMake构建

  • 注意opencv的目录应该是这样子的
3rdparty  cmake  CONTRIBUTING.md  doc      index.rst  modules    README.md  samples   apps      CMakeLists.txt  data             include  LICENSE    platforms
  • 进入到opencv目录并输入
    • 当然 opencv-2.4.13.6应该更换成你的opencv目录
cd ~/opencv-2.4.13.6
mkdir release
cd release
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
  • make
make
sudo make install

opencv 报错 error: 'CODEC_FLAG_GLOBAL_HEADER' was not declared

  • opencv-2.4.13.6/modules/videoio/src/cap_ffmpeg_impl.hpp顶端,添加如下宏定义代码
    • 当然 opencv-2.4.13.6应该更换成你的opencv目录
#define AV_CODEC_FLAG_GLOBAL_HEADER (1 << 22)
#define CODEC_FLAG_GLOBAL_HEADER AV_CODEC_FLAG_GLOBAL_HEADER
#define AVFMT_RAWPICTURE 0x0020

姊妹篇:关于OpenCV2键盘映射可能出错的问题

Reply Favorite View the author
All Replies
Amber
deepin
2023-03-19 20:32
#1

感谢分享kissing_heart

Reply View the author