sh 获取最新版本的opencv以及构建和安装它的说明。从http://docs.opencv.org/trunk/d7/获取的一些说明

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh 获取最新版本的opencv以及构建和安装它的说明。从http://docs.opencv.org/trunk/d7/获取的一些说明相关的知识,希望对你有一定的参考价值。

#!/bin/bash

if ! [[ "$1" =~ -v([[:digit:]]+)$ ]]; then
    echo "Usage: $0 -vN"
    exit 1
fi

version_pat="v?${BASH_REMATCH[1]}(\.[0-9]{1,}){1,}$"
curr_branch="$(git branch | pcregrep -o1 '^\*\s+(.+)$')"

# fetch the latest releases
echo -e "\tRetrieving latest changes from upstream..." && git pull --tags
echo -e "\n\tDone"
version="$(git tag | egrep $version_pat | sort --version-sort -r | head -n1)"

if [ -z "$version" ]; then
    echo "That version number does not exist: ${1/-/}"
    exit 1
fi

# See if we already have this release checked out
for v in $(echo -n "$curr_branch" "$(git branch | egrep -o $version_pat)"); do
    if [[ "$v" =~ "$version" ]]; then
        if [[ "$v" == "$curr_branch" ]]; then
            echo "You are already on the latest release: $curr_branch"
        else
            echo "You already have the latest version: $v"
        fi
        exit 0
    fi

done

echo "Found a more recent release: $version"
git checkout "$version" -b "v$version"

echo -e "\nUse the following command to build and install opencv:\n"
cat <<'END'
1. mkdir -p release && pushd release

2. cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local \
-D PYTHON2_EXECUTABLE=/usr/bin/python2 \
-D PYTHON2_INCLUDE_DIR=/usr/include/python2.7/ \
-D PYTHON2_INCLUDE_DIR2=/usr/include/x86_64-linux-gnu/python2.7/ \
-D PYTHON2_LIBRARY=/usr/lib/x86_64-linux-gnu/libpython2.7.so \
-D PYTHON2_NUMPY_INCLUDE_DIRS=/usr/lib/python2.7/dist-packages/numpy/core/include/ \
-D PYTHON3_EXECUTABLE=/usr/bin/python3 \
-D PYTHON3_INCLUDE_DIR=/usr/include/python3.5/ \
-D PYTHON3_INCLUDE_DIR2=/usr/include/x86_64-linux-gnu/python3.5m/ \
-D PYTHON3_LIBRARY=/usr/lib/x86_64-linux-gnu/libpython3.5m.so \
-D CMAKE_PREFIX_PATH=/opt/Qt/5.7/gcc_64/lib/cmake ..

3. make -j7 # runs 7 jobs in parallel

4. sudo make install

5. popd
END

echo -e "\n\t** Make sure to replace the paths with\n\tones corresponding to your machine **"

以上是关于sh 获取最新版本的opencv以及构建和安装它的说明。从http://docs.opencv.org/trunk/d7/获取的一些说明的主要内容,如果未能解决你的问题,请参考以下文章

opencv的跨平台的安装以及多版本并存

最新Pycharm安装调用opencv-python步骤,以及遇到的问题: opencv已经安装成功;cmd环境下python可以import cv2 ;但pycharm下会出错

OpenCV 预构建的二进制文件没有安装 DLL

sh StriderCD配置。为最新版本构建所有软件包以获得稳定和仅赢

VisualStudio下如何编译和使用最新版本的OpenCV(修正版)

源文件未使用最新版本的 DEV C++ 和 OpenCV 3.X 版本编译