Skip to content

Instantly share code, notes, and snippets.

@dimitre
Forked from AhiyaHiya/setup_opencv_macos.sh
Created October 26, 2020 14:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dimitre/045167fb9c0aa4f7ea42bbd691f38565 to your computer and use it in GitHub Desktop.
Save dimitre/045167fb9c0aa4f7ea42bbd691f38565 to your computer and use it in GitHub Desktop.
Download and build OpenCV framework for macOS
#!/bin/bash
set -o errexit
set -o pipefail
set -o nounset
setup_opencv()
{
printf "*********************************\n${FUNCNAME[0]}\n"
local readonly PARENT_FOLDER=${1:-third_party}
local readonly BASE_PATH=$CURRENT_PATH/$PARENT_FOLDER
#########################################
printf "download\n"
mkdir -p ${BASE_PATH}/opencv/source/
cd ${BASE_PATH}/opencv/source/
git clone https://github.com/opencv/opencv.git . --depth 1
#########################################
printf "build\n"
cd ${BASE_PATH}/opencv/
mkdir macos_build
cd ${BASE_PATH}/opencv/macos_build
python ../source/platforms/osx/build_framework.py osx
#########################################
printf "move framework\n"
mkdir -p ${BASE_PATH}/opencv/mac/
mv osx/opencv2.framework/ ${BASE_PATH}/opencv/mac/opencv2.framework/
#########################################
printf "delete source and build folder\n"
cd ${BASE_PATH}/opencv/
rm -Rf ${BASE_PATH}/opencv/source
rm -Rf ${BASE_PATH}/opencv/macos_build
cd $CURRENT_PATH
}
main()
{
local PARENT_PATH=${1:?"You need to pass in a parent folder"}
setup_opencv $PARENT_PATH
}
CURRENT_PATH=$PWD
main $1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment