1.centos

2.官网下载源码

https://github.com/opencv/opencv/tagsicon-default.png?t=M276https://github.com/opencv/opencv/tags3.解压

unzip opencv-4.5.5.zip
cd opencv-4.5.5

4.配置

mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/data1/xxx/workspace/opencv/output ..

其中,CMAKE_BUILD_TYPE指定Release或者Debug

CMAKE_INSTALL_PREFIX指定编译以后,安装的目录

.. (点点)指定opencv源码更目录

更多配置选项,参考官网:

OpenCV configuration options referenceicon-default.png?t=M276https://docs.opencv.org/4.x/db/d05/tutorial_config_reference.html

由于本机已经存在了ffmpeg的老版本,导致编译报错,不想动老版本,于是把ffmepg禁用掉

cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/data1/xxx/workspace/opencv/output -D WITH_FFMPEG=OFF ..

5.编译

make
make install

6.hello opencv

cd ..
mkdir demo
cd demo
vim cvdemo.cpp
//cvdemo.cpp
#include "opencv2/opencv.hpp"

int main()
{
    printf("hello opencv!\r\n");
    return 0;
}

build:

g++ -g -Wall -std=c++11 cvdemo.cpp -o cvdemo -I../output/include/opencv4/ -L../output/lib64 -lopencv_ml -lopencv_core

执行

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/data1/moon/workspace/opencv/output/lib64/
~/workspace/opencv/mixdemo$ ./cvdemo 
hello opencv!

GitHub 加速计划 / li / linux-dash
10.39 K
1.2 K
下载
A beautiful web dashboard for Linux
最近提交(Master分支:2 个月前 )
186a802e added ecosystem file for PM2 4 年前
5def40a3 Add host customization support for the NodeJS version 4 年前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐