树莓派中编译Opencv3.4.1和OpenCVSharp库

一、简介

  本文主要讲在树莓派中编译Opencv3.4.1和OpenCVSharp库,方便C#开发人员可以通过Mono或者Netcore运行C#通过OpenCVSharp写的OpenCV库。

二、过程

树莓派3b安装OPENCV3.4.1
apt-get install -y build-essential cmake \
libgtkglext1-dev libvtk6-dev \
zlib1g-dev libjpeg-dev libwebp-dev libpng-dev libtiff5-dev libopenexr-dev libgdal-dev && \
add-apt-repository "deb http://security.ubuntu.com/ubuntu xenial-security main" && apt update && apt install libjasper1 libjasper-dev && \
apt-get install -y libdc1394-22-dev libavcodec-dev libavformat-dev libswscale-dev libtheora-dev libvorbis-dev libxvidcore-dev libx264-dev yasm libopencore-amrnb-dev libopencore-amrwb-dev libv4l-dev libxine2-dev \
libtbb-dev libeigen3-dev \
python-dev python-tk python-numpy python3-dev python3-tk python3-numpy

OPENCV_VERSION=3.4.1
wget  ${OPENCV_VERSION}.zip && unzip ${OPENCV_VERSION}.zip && rm ${OPENCV_VERSION}.zip && mv opencv-${OPENCV_VERSION} OpenCV
wget https://github.com/opencv/opencv_contrib/archive/${OPENCV_VERSION}.zip && unzip ${OPENCV_VERSION}.zip && rm ${OPENCV_VERSION}.zip && mv opencv_contrib-${OPENCV_VERSION} OpenCV_contrib

下列命令执行时,注意检测OPENCV_EXTRA_MODULES_PATH设置的路径为刚刚解压的OpenCV_contrib路径。

apt-get install libhdf5-dev
apt-get install libtiff5-dev
apt-get install libtiffxx0c2

cd OpenCV && mkdir build && cd build && \
cmake \
-D OPENCV_EXTRA_MODULES_PATH=/usr/local/opencv/OpenCV_contrib/modules \
-D CMAKE_BUILD_TYPE=RELEASE \
-D BUILD_EXAMPLES=OFF \
-D BUILD_DOCS=OFF \
-D BUILD_PERF_TESTS=OFF \
-D BUILD_TESTS=OFF \
-D BUILD_opencv_java=OFF \
-D BUILD_opencv_python=OFF \
.. && make -j4 && make install && ldconfig


# Download OpenCvSharp
OPENCVSHARP_VERSION=3.4.1.20180605
git clone https://github.com/shimat/opencvsharp.git
cd opencvsharp && git fetch --all --tags --prune && git checkout ${OPENCVSHARP_VERSION}
mkdir /opencvsharp/make
cd /usr/local/opencv/OpenCvSharp/opencvsharp/make && cmake -D CMAKE_INSTALL_PREFIX=/usr/local/opencv/OpenCvSharp/opencvsharp/make /usr/local/opencv/OpenCvSharp/opencvsharp/src && make -j 4 && make install

三、使用

  编译好后,请把OpenCVSharp编译生成的/usr/local/opencv/OpenCvSharp/opencvsharp/make/lib下的所有文件和OpenCV编译生成的/usr/local/opencv/OpenCV/build/lib的文件Copy到/usr/lib下。

 

转载于:https://www.cnblogs.com/songxingzhu/p/9698020.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值