Skip to content

Instantly share code, notes, and snippets.

@AhiyaHiya
Last active March 16, 2024 02:48
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save AhiyaHiya/aff1535a081118d773ffd19b3b7a874f to your computer and use it in GitHub Desktop.
Save AhiyaHiya/aff1535a081118d773ffd19b3b7a874f 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 .
#########################################
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
@dimitre
Copy link

dimitre commented Oct 26, 2020

Thank you!

@AhiyaHiya
Copy link
Author

You're welcome 😁

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment