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

build: add GH action for macOS #1202

Merged
merged 3 commits into from
Aug 22, 2024
Merged
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
55 changes: 55 additions & 0 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: macOS
on:
pull_request:
push:
branches:
- dev
- release

jobs:
build:
strategy:
matrix:
os: [macos-13, macos-14]
runs-on: ${{ matrix.os }}
steps:
- name: Install OpenCV
run: |
rm /usr/local/bin/2to3*
rm /usr/local/bin/idle3*
rm /usr/local/bin/pydoc*
rm /usr/local/bin/python3*
brew install opencv
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: '1.23'
cache: true
- name: Checkout
uses: actions/checkout@v4
- name: Install Caffe test model
run: |
mkdir -p ${GITHUB_WORKSPACE}/testdata
curl -sL https://raw.githubusercontent.com/opencv/opencv_extra/master/testdata/dnn/bvlc_googlenet.prototxt > ${GITHUB_WORKSPACE}/testdata/bvlc_googlenet.prototxt
curl -sL http://dl.caffe.berkeleyvision.org/bvlc_googlenet.caffemodel > ${GITHUB_WORKSPACE}/testdata/bvlc_googlenet.caffemodel
curl -sL https://raw.githubusercontent.com/WeChatCV/opencv_3rdparty/wechat_qrcode/detect.caffemodel > ${GITHUB_WORKSPACE}/testdata/detect.caffemodel
curl -sL https://raw.githubusercontent.com/WeChatCV/opencv_3rdparty/wechat_qrcode/detect.prototxt > ${GITHUB_WORKSPACE}/testdata/detect.prototxt
curl -sL https://raw.githubusercontent.com/WeChatCV/opencv_3rdparty/wechat_qrcode/sr.caffemodel > ${GITHUB_WORKSPACE}/testdata/sr.caffemodel
curl -sL https://raw.githubusercontent.com/WeChatCV/opencv_3rdparty/wechat_qrcode/sr.prototxt > ${GITHUB_WORKSPACE}/testdata/sr.prototxt
- name: Install Tensorflow test model
run: |
mkdir -p ${GITHUB_WORKSPACE}/testdata
curl -sL https://storage.googleapis.com/download.tensorflow.org/models/inception5h.zip > ${GITHUB_WORKSPACE}/testdata/inception5h.zip
unzip -o ${GITHUB_WORKSPACE}/testdata/inception5h.zip tensorflow_inception_graph.pb -d ${GITHUB_WORKSPACE}/testdata
- name: Install ONNX test model
run: |
mkdir -p ${GITHUB_WORKSPACE}/testdata
curl -sL https://github.com/onnx/models/blob/master/vision/classification/inception_and_googlenet/googlenet/model/googlenet-9.onnx\?raw\=true > ${GITHUB_WORKSPACE}/testdata/googlenet-9.onnx
- name: Run main tests
run: go test -v -tags matprofile .
env:
GOCV_CAFFE_TEST_FILES: ${{ github.workspace }}/testdata
GOCV_TENSORFLOW_TEST_FILES: ${{ github.workspace }}/testdata
NO_GOCV_ONNX_TEST_FILES: ${{ github.workspace }}/testdata
- name: Run contrib tests
run: go test -v -tags matprofile ./contrib
13 changes: 13 additions & 0 deletions features2d_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package gocv

import (
"image/color"
"runtime"
"testing"
)

Expand Down Expand Up @@ -523,6 +524,10 @@ func TestDrawKeyPoints(t *testing.T) {
}

func TestDrawMatches(t *testing.T) {
if runtime.GOOS == "darwin" {
t.Skip("skipping test on macos")
}

queryFile := "images/box.png"
trainFile := "images/box_in_scene.png"

Expand Down Expand Up @@ -593,6 +598,10 @@ func TestDrawMatches(t *testing.T) {
}

func TestSIFT(t *testing.T) {
if runtime.GOOS == "darwin" {
t.Skip("skipping test on macos")
}

img := IMRead("./images/face.jpg", IMReadGrayScale)
if img.Empty() {
t.Error("Invalid Mat in SIFT test")
Expand Down Expand Up @@ -633,6 +642,10 @@ func TestSIFT(t *testing.T) {
}

func TestSIFTWithParams(t *testing.T) {
if runtime.GOOS == "darwin" {
t.Skip("skipping test on macos")
}

img := IMRead("./images/face.jpg", IMReadGrayScale)
if img.Empty() {
t.Error("Invalid Mat in SIFT test")
Expand Down
9 changes: 9 additions & 0 deletions imgproc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"math"
"os"
"reflect"
"runtime"
"testing"
)

Expand Down Expand Up @@ -1140,6 +1141,10 @@ func TestHoughCirclesWithParams(t *testing.T) {
}

func TestHoughLines(t *testing.T) {
if runtime.GOOS == "darwin" {
t.Skip("skipping test on macos")
}

img := IMRead("images/face-detect.jpg", IMReadGrayScale)
if img.Empty() {
t.Error("Invalid read of Mat in HoughLines test")
Expand Down Expand Up @@ -1179,6 +1184,10 @@ func TestHoughLines(t *testing.T) {
}

func TestHoughLinesP(t *testing.T) {
if runtime.GOOS == "darwin" {
t.Skip("skipping test on macos")
}

img := IMRead("images/face-detect.jpg", IMReadGrayScale)
if img.Empty() {
t.Error("Invalid read of Mat in HoughLinesP test")
Expand Down
6 changes: 3 additions & 3 deletions objdetect.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ func (a *QRCodeDetector) DetectMulti(input Mat, points *Mat) bool {
// For usage please see TestQRCodeDetector
// For further details, please see:
// https://docs.opencv.org/master/de/dc3/classcv_1_1QRCodeDetector.html#a188b63ffa17922b2c65d8a0ab7b70775
func (a *QRCodeDetector) DetectAndDecodeMulti(input Mat, decoded *[]string, points *Mat, qrCodes *[]Mat) bool {
func (a *QRCodeDetector) DetectAndDecodeMulti(input Mat, decoded []string, points *Mat, qrCodes []Mat) bool {
cDecoded := C.CStrings{}
defer C.CStrings_Close(cDecoded)
cQrCodes := C.struct_Mats{}
Expand All @@ -261,11 +261,11 @@ func (a *QRCodeDetector) DetectAndDecodeMulti(input Mat, decoded *[]string, poin
}

for _, qr := range tmpCodes {
*qrCodes = append(*qrCodes, qr)
qrCodes = append(qrCodes, qr)
}

for _, s := range toGoStrings(cDecoded) {
*decoded = append(*decoded, s)
decoded = append(decoded, s)
}
return bool(success)
}
8 changes: 4 additions & 4 deletions objdetect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ func TestQRCodeDetector(t *testing.T) {
q.Close()
}
}()
success := detector.DetectAndDecodeMulti(img2, &decoded, &multiBox2, &qrCodes)
success := detector.DetectAndDecodeMulti(img2, decoded, &multiBox2, qrCodes)
if !success {
t.Errorf("Error in TestQRCodeDetector Multi test: returned false")
}
Expand All @@ -188,14 +188,14 @@ func TestQRCodeDetector(t *testing.T) {
defer tmpInput.Close()
tmpDecoded = detector.Decode(tmpInput, tmpPoints, &tmpQr)
if tmpDecoded != s {
t.Errorf("Error in TestQRCodeDetector Multi test: decoded straight QR code=%s, decoded[%d] =%s", tmpDecoded, i, s)
t.Errorf("Error in TestQRCodeDetector Multi test: decoded straight QR code=%s, decoded[%d] = %s", tmpDecoded, i, s)
}
}

emptyMat := NewMatWithSize(100, 200, MatTypeCV8UC3)
success = detector.DetectAndDecodeMulti(emptyMat, &decoded, &multiBox2, &qrCodes)
success = detector.DetectAndDecodeMulti(emptyMat, decoded, &multiBox2, qrCodes)
if success {
t.Errorf("Error in TestQRCodeDetector Multi test: empty Mat returned sucess=true")
t.Errorf("Error in TestQRCodeDetector Multi test: empty Mat returned success=true")
}
emptyMat.Close()
}
Expand Down
5 changes: 5 additions & 0 deletions svd_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
package gocv

import (
"runtime"
"testing"
)

func TestSVDCompute(t *testing.T) {
if runtime.GOOS == "darwin" {
t.Skip("skipping test on macos")
}

var resultW = []float32{6.167493, 3.8214223}
var resultU = []float32{-0.1346676, -0.99089086, 0.9908908, -0.1346676}
var resultVt = []float32{0.01964448, 0.999807, -0.999807, 0.01964448}
Expand Down
Loading