build: fix for homebrew pkg-config conflict #254
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Windows | |
on: | |
pull_request: | |
push: | |
branches: | |
- dev | |
- release | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
build-windows: | |
runs-on: windows-2022 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: '1.22' | |
cache: true | |
- name: Restore cached OpenCV source | |
uses: actions/cache/restore@v4 | |
id: cache-opencv-source | |
with: | |
key: opencv-source-4100-windows-v1a | |
path: | | |
./opencv/opencv-4.10.0 | |
./opencv/opencv_contrib-4.10.0 | |
- name: Download OpenCV source | |
if: steps.cache-opencv-source.outputs.cache-hit != 'true' | |
shell: bash | |
run: | | |
mkdir -p ./opencv | |
curl -Lo ./opencv/opencv-4.10.0.zip https://github.com/opencv/opencv/archive/4.10.0.zip | |
curl -Lo ./opencv/opencv_contrib-4.10.0.zip https://github.com/opencv/opencv_contrib/archive/4.10.0.zip | |
- name: Extract OpenCV source | |
if: steps.cache-opencv-source.outputs.cache-hit != 'true' | |
shell: bash | |
run: | | |
cd ./opencv | |
mkdir -p opencv-4.10.0 | |
mkdir -p opencv_contrib-4.10.0 | |
7z x opencv-4.10.0.zip | |
7z x opencv_contrib-4.10.0.zip | |
- name: Save cached OpenCV source | |
uses: actions/cache/save@v4 | |
if: steps.cache-opencv-source.outputs.cache-hit != 'true' | |
with: | |
key: ${{ steps.cache-opencv-source.outputs.cache-primary-key }} | |
path: | | |
./opencv/opencv-4.10.0 | |
./opencv/opencv_contrib-4.10.0 | |
- name: Restore cached OpenCV build | |
uses: actions/cache/restore@v4 | |
id: cache-opencv-build | |
with: | |
key: opencv-build-4100-windows-v1d | |
path: | | |
./opencv/build | |
- name: Build OpenCV | |
if: steps.cache-opencv-build.outputs.cache-hit != 'true' | |
run: | | |
mkdir -p ./opencv/build | |
cd ./opencv/build | |
cmake -G "MinGW Makefiles" -DENABLE_CXX11=ON -DOPENCV_EXTRA_MODULES_PATH="../opencv_contrib-4.10.0/modules" -DBUILD_SHARED_LIBS=ON -DWITH_IPP=OFF -DWITH_MSMF=OFF -DBUILD_EXAMPLES=OFF -DBUILD_TESTS=OFF -DBUILD_PERF_TESTS=ON -DBUILD_opencv_java=OFF -DBUILD_opencv_python=OFF -DBUILD_opencv_python2=OFF -DBUILD_opencv_python3=OFF -DBUILD_DOCS=OFF -DENABLE_PRECOMPILED_HEADERS=OFF -DBUILD_opencv_saliency=OFF -DBUILD_opencv_wechat_qrcode=ON -DCPU_DISPATCH= -DOPENCV_GENERATE_PKGCONFIG=ON -DWITH_OPENCL_D3D11_NV=OFF -DOPENCV_ALLOCATOR_STATS_COUNTER_TYPE=int64_t -DOPENCV_ENABLE_NONFREE=ON -Wno-dev ../opencv-4.10.0 | |
cmake --build . --target install | |
- name: Save cached OpenCV build | |
uses: actions/cache/save@v4 | |
if: steps.cache-opencv-build.outputs.cache-hit != 'true' | |
with: | |
key: ${{ steps.cache-opencv-build.outputs.cache-primary-key }} | |
path: | | |
./opencv/build | |
- name: Set GoCV env | |
run: | | |
go env | |
echo "CGO_CXXFLAGS=--std=c++11" >> $env:GITHUB_ENV | |
echo "CGO_CPPFLAGS=-I${env:GITHUB_WORKSPACE}\opencv\build\install\include" >> $env:GITHUB_ENV | |
echo "CGO_LDFLAGS=-L${env:GITHUB_WORKSPACE}\opencv\build\install\x64\mingw\lib -lopencv_core4100 -lopencv_face4100 -lopencv_videoio4100 -lopencv_imgproc4100 -lopencv_highgui4100 -lopencv_imgcodecs4100 -lopencv_objdetect4100 -lopencv_features2d4100 -lopencv_video4100 -lopencv_dnn4100 -lopencv_xfeatures2d4100 -lopencv_plot4100 -lopencv_tracking4100 -lopencv_img_hash4100 -lopencv_calib3d4100 -lopencv_bgsegm4100 -lopencv_photo4100 -lopencv_aruco4100 -lopencv_wechat_qrcode4100 -lopencv_ximgproc4100 -lopencv_xphoto4100" >> $env:GITHUB_ENV | |
echo "${env:GITHUB_WORKSPACE}/opencv/build/install/x64/mingw/bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append | |
- name: Install Tensorflow test model | |
run: | | |
mkdir -p ./testdata | |
curl -sL https://storage.googleapis.com/download.tensorflow.org/models/inception5h.zip > ./testdata/inception5h.zip | |
unzip -o ./testdata/inception5h.zip tensorflow_inception_graph.pb -d ./testdata | |
- name: Install ONNX test model | |
run: | | |
curl -sL https://github.com/onnx/models/raw/main/validated/vision/classification/inception_and_googlenet/googlenet/model/googlenet-9.onnx > ./testdata/googlenet-9.onnx | |
curl -sL https://github.com/opencv/opencv_zoo/raw/refs/heads/main/models/face_recognition_sface/face_recognition_sface_2021dec.onnx > ./testdata/face_recognition_sface_2021dec.onnx | |
curl -sL https://github.com/opencv/opencv_zoo/raw/refs/heads/main/models/face_detection_yunet/face_detection_yunet_2023mar.onnx > ./testdata/face_detection_yunet_2023mar.onnx | |
- name: Install GOTURN test model | |
shell: bash | |
run: | | |
curl -sL https://raw.githubusercontent.com/opencv/opencv_extra/c4219d5eb3105ed8e634278fad312a1a8d2c182d/testdata/tracking/goturn.prototxt > ./testdata/goturn.prototxt | |
curl -sL https://github.com/opencv/opencv_extra/raw/c4219d5eb3105ed8e634278fad312a1a8d2c182d/testdata/tracking/goturn.caffemodel.zip.001 > ./testdata/goturn.caffemodel.zip.001 | |
curl -sL https://github.com/opencv/opencv_extra/raw/c4219d5eb3105ed8e634278fad312a1a8d2c182d/testdata/tracking/goturn.caffemodel.zip.002 > ./testdata/goturn.caffemodel.zip.002 | |
curl -sL https://github.com/opencv/opencv_extra/raw/c4219d5eb3105ed8e634278fad312a1a8d2c182d/testdata/tracking/goturn.caffemodel.zip.003 > ./testdata/goturn.caffemodel.zip.003 | |
curl -sL https://github.com/opencv/opencv_extra/raw/c4219d5eb3105ed8e634278fad312a1a8d2c182d/testdata/tracking/goturn.caffemodel.zip.004 > ./testdata/goturn.caffemodel.zip.004 | |
cat ./testdata/goturn.caffemodel.zip.00* > ./testdata/goturn.caffemodel.zip | |
unzip -o ./testdata/goturn.caffemodel.zip goturn.caffemodel -d ./testdata/ | |
- name: Set GoCV model env | |
run: | | |
go env | |
echo "GOCV_TENSORFLOW_TEST_FILES=${env:GITHUB_WORKSPACE}\testdata" >> $env:GITHUB_ENV | |
echo "GOCV_ONNX_TEST_FILES=${env:GITHUB_WORKSPACE}\testdata" >> $env:GITHUB_ENV | |
echo "GOCV_TRACKER_GOTURN_TEST_FILES=${env:GITHUB_WORKSPACE}\testdata" >> $env:GITHUB_ENV | |
- name: Test GoCV | |
run: | | |
go test -v -tags="matprofile,customenv" . | |
- name: Test GoCV Contrib | |
run: | | |
go test -v -tags="matprofile,customenv" ./contrib |