-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
171 lines (156 loc) · 6.03 KB
/
ubuntu22.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
name: Ubuntu 22.04
on:
pull_request:
types: [synchronize, opened]
push:
branches:
- main
env:
DEBIAN_FRONTEND: noninteractive
OPENCV_VERSION: 4.10.0
OPENCV_CACHE_VERSION: 1
jobs:
build:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
path: opencvsharp
- name: Install dependencies
run: |
sudo apt-get update -y
sudo apt-get install -y --no-install-recommends \
apt-transport-https \
software-properties-common \
ca-certificates \
g++ \
make \
cmake \
libtbb-dev \
libatlas-base-dev \
libgtk2.0-dev \
libavcodec-dev \
libavformat-dev \
libswscale-dev \
libdc1394-dev \
libxine2-dev \
libv4l-dev \
libtheora-dev \
libvorbis-dev \
libxvidcore-dev \
libopencore-amrnb-dev \
libopencore-amrwb-dev \
x264 \
libtesseract-dev
- name: Cache OpenCV
id: opencv-cache
uses: actions/cache@v4
with:
path: ${{ github.workspace }}/opencv_artifacts/
key: opencv-${{ env.OPENCV_VERSION }}-rev${{ env.OPENCV_CACHE_VERSION }}
- name: Checkout OpenCV
if: steps.opencv-cache.outputs.cache-hit != 'true'
uses: actions/checkout@v4
with:
repository: opencv/opencv
path: opencv
ref: ${{ env.OPENCV_VERSION }}
- name: Checkout OpenCV Contrib
if: steps.opencv-cache.outputs.cache-hit != 'true'
uses: actions/checkout@v4
with:
repository: opencv/opencv_contrib
path: opencv_contrib
ref: ${{ env.OPENCV_VERSION }}
- name: Build OpenCV
if: steps.opencv-cache.outputs.cache-hit != 'true'
run: |
mkdir opencv/build && cd opencv/build
cmake \
-D CMAKE_BUILD_TYPE=Release \
-D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules \
-D BUILD_SHARED_LIBS=OFF \
-D ENABLE_CXX11=ON \
-D BUILD_EXAMPLES=OFF \
-D BUILD_DOCS=OFF \
-D BUILD_PERF_TESTS=OFF \
-D BUILD_TESTS=OFF \
-D BUILD_JAVA=OFF \
-D BUILD_opencv_apps=OFF \
-D BUILD_opencv_barcode=OFF \
-D BUILD_opencv_java_bindings_generator=OFF \
-D BUILD_opencv_python_bindings_generator=OFF \
-D BUILD_opencv_python_tests=OFF \
-D BUILD_opencv_ts=OFF \
-D BUILD_opencv_js=OFF \
-D BUILD_opencv_js_bindings_generator=OFF \
-D BUILD_opencv_bioinspired=OFF \
-D BUILD_opencv_ccalib=OFF \
-D BUILD_opencv_datasets=OFF \
-D BUILD_opencv_dnn_objdetect=OFF \
-D BUILD_opencv_dpm=OFF \
-D BUILD_opencv_fuzzy=OFF \
-D BUILD_opencv_gapi=ON \
-D BUILD_opencv_intensity_transform=OFF \
-D BUILD_opencv_mcc=OFF \
-D BUILD_opencv_objc_bindings_generator=OFF \
-D BUILD_opencv_rapid=OFF \
-D BUILD_opencv_reg=OFF \
-D BUILD_opencv_stereo=OFF \
-D BUILD_opencv_structured_light=OFF \
-D BUILD_opencv_surface_matching=OFF \
-D BUILD_opencv_wechat_qrcode=ON \
-D BUILD_opencv_videostab=OFF \
-D WITH_GSTREAMER=OFF \
-D WITH_ADE=OFF \
-D OPENCV_ENABLE_NONFREE=ON \
-D CMAKE_INSTALL_PREFIX=${GITHUB_WORKSPACE}/opencv_artifacts ..
make -j2
make install
sudo ldconfig
cd ${GITHUB_WORKSPACE}
ls
- name: Build OpenCvSharpExtern
run: |
mkdir opencvsharp/src/build && cd $_
cmake -D CMAKE_PREFIX_PATH=${GITHUB_WORKSPACE}/opencv_artifacts ..
make -j2
ls OpenCvSharpExtern
cp OpenCvSharpExtern/libOpenCvSharpExtern.so ${GITHUB_WORKSPACE}/opencvsharp/nuget/
- name: Check OpenCvSharpExtern
run: |
cd ${GITHUB_WORKSPACE}/opencvsharp/nuget/
ldd libOpenCvSharpExtern.so
nm libOpenCvSharpExtern.so
echo -ne "#include <stdio.h> \n int core_Mat_sizeof(); int main(){ int i = core_Mat_sizeof(); printf(\"sizeof(Mat) = %d\", i); return 0; }" > test.c
gcc -I./ -L./ test.c -o test -lOpenCvSharpExtern
LD_LIBRARY_PATH=. ./test
- name: Install .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
- name: Create NuGet package
env:
BETA: ""
run: |
yyyymmdd=`date '+%Y%m%d'`
echo $yyyymmdd
cd ${GITHUB_WORKSPACE}/opencvsharp
sed -E --in-place=.bak \
"s/<version>[0-9]\.[0-9]{1,2}\.[0-9]{1,2}.[0-9]{8}(-beta[0-9]*)?<\/version>/<version>${OPENCV_VERSION}.${yyyymmdd}${BETA}<\/version>/" \
nuget/OpenCvSharp4.official.runtime.linux-x64.nuspec
cat nuget/OpenCvSharp4.official.runtime.linux-x64.nuspec
dotnet pack nuget/OpenCvSharp4.official.runtime.linux-x64.csproj -o ${GITHUB_WORKSPACE}/artifacts_ubuntu
ls ${GITHUB_WORKSPACE}/artifacts_ubuntu
- uses: actions/upload-artifact@v4
with:
name: artifacts_ubuntu_22
path: artifacts_ubuntu
- name: Test
run: |
cd ${GITHUB_WORKSPACE}/opencvsharp/test/OpenCvSharp.Tests
dotnet build -c Release -f net8.0
cp ${GITHUB_WORKSPACE}/opencvsharp/nuget/libOpenCvSharpExtern.so ${GITHUB_WORKSPACE}/opencvsharp/test/OpenCvSharp.Tests/bin/Release/net8.0/
cp ${GITHUB_WORKSPACE}/opencvsharp/nuget/libOpenCvSharpExtern.so ${GITHUB_WORKSPACE}/opencvsharp/test/OpenCvSharp.Tests/
sudo cp ${GITHUB_WORKSPACE}/opencvsharp/nuget/libOpenCvSharpExtern.so /usr/lib/
LD_LIBRARY_PATH=. dotnet test OpenCvSharp.Tests.csproj -c Release -f net8.0 --runtime linux-x64 --logger "trx;LogFileName=test-results.trx" < /dev/null