Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for building with opencv_contrib #24

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions buildAndPackageOpenCV.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Copyright(c) JetsonHacks (2017-2018)

OPENCV_VERSION=3.4.1
OPENCV_CONTRIB_VERSION=${OPENCV_CONTRIB_VERSION:-$OPENCV_VERSION}
# Jetson TX2
ARCH_BIN=6.2
# Jetson TX1
Expand All @@ -14,6 +15,10 @@ INSTALL_DIR=/usr/local
# Make sure that you set this to YES
# Value should be YES or NO
DOWNLOAD_OPENCV_EXTRAS=NO
# Download and compile with opencv_contrib:
# https://github.com/opencv/opencv_contrib
# Will download and compile next to opencv source
WITH_OPENCV_CONTRIB=NO
# Source code directory
OPENCV_SOURCE_DIR=$HOME
WHEREAMI=$PWD
Expand Down Expand Up @@ -62,6 +67,10 @@ if [ $DOWNLOAD_OPENCV_EXTRAS == "YES" ] ; then
echo "Also installing opencv_extras"
fi

if [ $WITH_OPENCV_CONTRIB == "YES" ] ; then
echo "Also installing opencv_contrib"
fi

# Repository setup
sudo apt-add-repository universe
sudo apt-get update
Expand Down Expand Up @@ -126,6 +135,15 @@ if [ $DOWNLOAD_OPENCV_EXTRAS == "YES" ] ; then
git checkout -b v${OPENCV_VERSION} ${OPENCV_VERSION}
fi

OPENCV_CONTRIB_COMPILE=""
if [ $WITH_OPENCV_CONTRIB == "YES" ] ; then
echo "Installing opencv_contrib"
cd $OPENCV_SOURCE_DIR
git clone https://github.com/opencv/opencv_contrib.git
git checkout -b v${OPENCV_CONTRIB_VERSION} ${OPENCV_CONTRIB_VERSION}
OPENCV_CONTRIB_COMPILE="-D OPENCV_EXTRA_MODULES_PATH=${OPENCV_SOURCE_DIR}/opencv_contrib/modules"
fi

cd $OPENCV_SOURCE_DIR/opencv
mkdir build
cd build
Expand All @@ -139,6 +157,7 @@ cd build
# Check OpenCV documentation for details



time cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} \
-D WITH_CUDA=ON \
Expand All @@ -153,6 +172,7 @@ time cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D WITH_QT=ON \
-D WITH_OPENGL=ON \
-D CPACK_BINARY_DEB=ON \
$OPENCV_CONTRIB_COMPILE \
../

if [ $? -eq 0 ] ; then
Expand Down
20 changes: 20 additions & 0 deletions buildOpenCV.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Copyright(c) JetsonHacks (2017-2018)

OPENCV_VERSION=3.4.1
OPENCV_CONTRIB_VERSION=${OPENCV_CONTRIB_VERSION:-$OPENCV_VERSION}
# Jetson TX2
ARCH_BIN=6.2
# Jetson TX1
Expand All @@ -14,6 +15,10 @@ INSTALL_DIR=/usr/local
# Make sure that you set this to YES
# Value should be YES or NO
DOWNLOAD_OPENCV_EXTRAS=NO
# Download and compile with opencv_contrib:
# https://github.com/opencv/opencv_contrib
# Will download and compile next to opencv source
WITH_OPENCV_CONTRIB=${WITH_OPENCV_CONTRIB:-"NO"}
# Source code directory
OPENCV_SOURCE_DIR=$HOME
WHEREAMI=$PWD
Expand Down Expand Up @@ -62,6 +67,10 @@ if [ $DOWNLOAD_OPENCV_EXTRAS == "YES" ] ; then
echo "Also installing opencv_extras"
fi

if [ $WITH_OPENCV_CONTRIB == "YES" ] ; then
echo "Also installing opencv_contrib"
fi

# Repository setup
sudo apt-add-repository universe
sudo apt-get update
Expand Down Expand Up @@ -126,6 +135,15 @@ if [ $DOWNLOAD_OPENCV_EXTRAS == "YES" ] ; then
git checkout -b v${OPENCV_VERSION} ${OPENCV_VERSION}
fi

OPENCV_CONTRIB_COMPILE=""
if [ $WITH_OPENCV_CONTRIB == "YES" ] ; then
echo "Installing opencv_contrib"
cd $OPENCV_SOURCE_DIR
git clone https://github.com/opencv/opencv_contrib.git
git checkout -b v${OPENCV_CONTRIB_VERSION} ${OPENCV_CONTRIB_VERSION}
OPENCV_CONTRIB_COMPILE="-D OPENCV_EXTRA_MODULES_PATH=${OPENCV_SOURCE_DIR}/opencv_contrib/modules"
fi

cd $OPENCV_SOURCE_DIR/opencv
mkdir build
cd build
Expand All @@ -138,6 +156,7 @@ cd build
# There are also switches which tell CMAKE to build the samples and tests
# Check OpenCV documentation for details


time cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} \
-D WITH_CUDA=ON \
Expand All @@ -151,6 +170,7 @@ time cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D WITH_GSTREAMER_0_10=OFF \
-D WITH_QT=ON \
-D WITH_OPENGL=ON \
${OPENCV_CONTRIB_COMPILE} \
../

if [ $? -eq 0 ] ; then
Expand Down
34 changes: 11 additions & 23 deletions removeOpenCVSources.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function usage
while [ "$1" != "" ]; do
case $1 in
-d | --directory ) shift
OPENCV_SOURCE_DIR=$1
OPENCV_SOURCE_DIR=$1
;;
-h | --help ) usage
exit
Expand All @@ -31,25 +31,13 @@ done
echo "Removing opencv directory from $OPENCV_SOURCE_DIR"
cd $OPENCV_SOURCE_DIR

if [ -d "opencv" ] ; then
if [ -L "opencv" ] ; then
echo "opencv is a symlink, unable to remove"
else
echo "Removing opencv sources"
sudo rm -r opencv
fi
else
echo "Could not find opencv directory"
fi

if [ -d "opencv_extra" ] ; then
if [ -L "opencv_extra" ] ; then
echo "opencv_extra is a symlink, unable to remove"
else
echo "Removing opencv_extra sources"
sudo rm -r opencv_extra
fi
else
echo "Could not find opencv_extra directory"
fi

for remove_dir in "opencv" "opencv_extra" "opencv_contrib"; do
if [ -d ${remove_dir} ] ; then
if [ -L ${remove_dir} ] ; then
echo "${remove_dir} is a symlink, unable to remove"
else
echo "Removing ${remove_dir} sources"
rm -r ${remove_dir}
fi
fi
done