树莓派中编译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.dearcloud.cn