Skip to content

Commit 04ceb0f

Browse files
committed
2 parents 930300d + a54b877 commit 04ceb0f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+8246
-732
lines changed

.github/workflows/test_conan.yaml

Lines changed: 243 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,243 @@
1+
name: build test release
2+
3+
on:
4+
push:
5+
branches: ["conan"]
6+
tags:
7+
- "v*.*.*"
8+
# pull_request:
9+
# branches: [ "main" ]
10+
11+
env:
12+
ANDROID_NDK_VERSION: r26c
13+
OPENCV_VERSION: 4.9.0
14+
LIB_NAME: libopencv_dart
15+
16+
jobs:
17+
build-android:
18+
name: build-android
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v4
22+
with:
23+
submodules: true
24+
- name: setup
25+
run: |
26+
sudo apt-get update
27+
28+
sudo apt-get install -y build-essential libgtk-3-dev ffmpeg libavcodec-dev \
29+
cmake ninja-build ccache nasm libavformat-dev libavutil-dev libswscale-dev \
30+
libgflags-dev python3 unzip tree python3-pip
31+
32+
python3 -m pip install conan
33+
conan profile detect -f
34+
35+
cd ${{github.workspace}}
36+
mkdir -p build/android
37+
38+
wget -q -O build/android-ndk-$ANDROID_NDK_VERSION-linux.zip \
39+
https://dl.google.com/android/repository/android-ndk-$ANDROID_NDK_VERSION-linux.zip
40+
unzip -q -o build/android-ndk-$ANDROID_NDK_VERSION-linux.zip -d build/
41+
- name: build-android
42+
run: |
43+
conan build . -b missing -pr:h profiles/android-x86_64 \
44+
-c tools.android:ndk_path="`pwd`/build/android-ndk-$ANDROID_NDK_VERSION"
45+
conan build . -b missing -pr:h profiles/android-armv8 \
46+
-c tools.android:ndk_path="`pwd`/build/android-ndk-$ANDROID_NDK_VERSION"
47+
conan build . -b missing -pr:h profiles/android-armv7 \
48+
-c tools.android:ndk_path="`pwd`/build/android-ndk-$ANDROID_NDK_VERSION"
49+
- uses: actions/upload-artifact@v4
50+
name: upload-android-x86_64
51+
with:
52+
path: build/publish/libopencv_dart-android-x86_64.tar.gz
53+
name: libopencv_dart-android-x86_64.tar.gz
54+
55+
- uses: actions/upload-artifact@v4
56+
name: upload-android-arm64-v8a
57+
with:
58+
path: build/publish/libopencv_dart-android-arm64-v8a.tar.gz
59+
name: libopencv_dart-android-arm64-v8a.tar.gz
60+
61+
- uses: actions/upload-artifact@v4
62+
name: upload-android-armeabi-v7a
63+
with:
64+
path: build/publish/libopencv_dart-android-armeabi-v7a.tar.gz
65+
name: libopencv_dart-android-armeabi-v7a.tar.gz
66+
- name: Release
67+
uses: softprops/action-gh-release@v1
68+
if: startsWith(github.ref, 'refs/tags/')
69+
with:
70+
draft: true
71+
prerelease: false
72+
files: |
73+
build/publish/libopencv_dart-android-arm64-v8a.tar.gz
74+
build/publish/libopencv_dart-android-armeabi-v7a.tar.gz
75+
build/publish/libopencv_dart-android-x86_64.tar.gz
76+
77+
build-ubuntu:
78+
name: build-ubuntu
79+
runs-on: ubuntu-latest
80+
81+
steps:
82+
- name: setup
83+
run: |
84+
sudo apt-get update
85+
sudo apt-get install -y curl git wget python3 unzip build-essential \
86+
libgtk-3-dev ffmpeg libavcodec-dev \
87+
cmake ninja-build ccache nasm libavformat-dev libavutil-dev \
88+
libswscale-dev libgflags-dev \
89+
libjpeg-dev libpng-dev libtiff-dev python3-pip
90+
91+
python3 -m pip install conan
92+
conan profile detect -f
93+
94+
- uses: actions/checkout@v4
95+
with:
96+
submodules: true
97+
- name: build-opencv-dart
98+
run: |
99+
conan build . -b missing -c tools.cmake.cmaketoolchain:generator=Ninja
100+
- uses: subosito/flutter-action@v2
101+
with:
102+
# flutter-version: '3.16.9'
103+
channel: "stable"
104+
- uses: actions/upload-artifact@v4
105+
name: upload-linux-x64
106+
with:
107+
path: build/publish/libopencv_dart-linux-x64.tar.gz
108+
name: libopencv_dart-linux-x64.tar.gz
109+
- name: Run Test
110+
run: |
111+
export LD_LIBRARY_PATH=$GITHUB_WORKSPACE/linux:$LD_LIBRARY_PATH
112+
flutter pub get
113+
flutter test -x skip-workflow,no-local-files
114+
- name: Release
115+
uses: softprops/action-gh-release@v1
116+
if: startsWith(github.ref, 'refs/tags/')
117+
with:
118+
draft: true
119+
prerelease: false
120+
files: |
121+
build/publish/libopencv_dart-linux-x64.tar.gz
122+
123+
build-windows:
124+
name: build-windows
125+
runs-on: windows-latest
126+
127+
steps:
128+
- uses: actions/checkout@v4
129+
with:
130+
submodules: true
131+
- uses: actions/setup-python@v5
132+
with:
133+
python-version: "3.11"
134+
- name: build-opencv-dart
135+
run: |
136+
python3 -m pip install conan
137+
conan profile detect -f
138+
conan build . -b missing -s compiler.cppstd=20
139+
140+
- uses: actions/upload-artifact@v4
141+
name: upload-windows-x64
142+
with:
143+
path: build/publish/libopencv_dart-windows-x64.tar.gz
144+
name: libopencv_dart-windows-x64.tar.gz
145+
- uses: subosito/flutter-action@v2
146+
with:
147+
# flutter-version: '3.16.9'
148+
channel: "stable"
149+
- name: Run Test
150+
run: |
151+
$env:PATH = "${{github.workspace}}\windows;${env:PATH}"
152+
flutter pub get
153+
flutter test -x no-local-files
154+
- name: Release
155+
uses: softprops/action-gh-release@v1
156+
if: startsWith(github.ref, 'refs/tags/')
157+
with:
158+
draft: true
159+
prerelease: false
160+
files: |
161+
build/publish/libopencv_dart-windows-x64.tar.gz
162+
build-macos:
163+
name: build-macos
164+
runs-on: macos-latest
165+
steps:
166+
- uses: actions/checkout@v4
167+
with:
168+
submodules: true
169+
- name: setup
170+
run: |
171+
brew install --force --overwrite ninja ccache ffmpeg nasm
172+
python3 -m pip install conan
173+
conan profile detect -f
174+
cd ${{github.workspace}}
175+
- name: build
176+
run: |
177+
conan build . -b missing
178+
179+
- uses: actions/upload-artifact@v4
180+
name: upload-macos-x64
181+
with:
182+
path: build/publish/libopencv_dart-macos-x64.tar.gz
183+
name: libopencv_dart-macos-x64.tar.gz
184+
- uses: subosito/flutter-action@v2
185+
with:
186+
# flutter-version: '3.16.9'
187+
channel: "stable"
188+
- name: Run Test
189+
run: |
190+
ls -alh $GITHUB_WORKSPACE/macos
191+
export DYLD_LIBRARY_PATH=$GITHUB_WORKSPACE/macos:$DYLD_LIBRARY_PATH
192+
flutter pub get
193+
flutter test -x no-local-files
194+
- name: Release
195+
uses: softprops/action-gh-release@v1
196+
if: startsWith(github.ref, 'refs/tags/')
197+
with:
198+
draft: true
199+
prerelease: false
200+
files: |
201+
build/publish/libopencv_dart-macos-x64.tar.gz
202+
build-macos-arm64:
203+
name: build-macos-arm64
204+
runs-on: macos-14
205+
steps:
206+
- uses: actions/checkout@v4
207+
with:
208+
submodules: true
209+
- name: setup
210+
run: |
211+
# brew update
212+
brew install --force --overwrite ninja ccache ffmpeg nasm
213+
python3 -m pip install conan
214+
conan profile detect -f
215+
cd ${{github.workspace}}
216+
- name: build
217+
run: |
218+
conan build . -b missing
219+
ls -alh build/Macos
220+
221+
- uses: actions/upload-artifact@v4
222+
name: upload-macos-arm64
223+
with:
224+
path: build/publish/libopencv_dart-macos-arm64.tar.gz
225+
name: libopencv_dart-macos-arm64.tar.gz
226+
- uses: subosito/flutter-action@v2
227+
with:
228+
# flutter-version: '3.16.9'
229+
channel: "stable"
230+
- name: Run Test
231+
run: |
232+
ls -alh $GITHUB_WORKSPACE/macos
233+
export DYLD_LIBRARY_PATH=$GITHUB_WORKSPACE/macos:$DYLD_LIBRARY_PATH
234+
flutter pub get
235+
flutter test -x no-local-files
236+
- name: Release
237+
uses: softprops/action-gh-release@v1
238+
if: startsWith(github.ref, 'refs/tags/')
239+
with:
240+
draft: true
241+
prerelease: false
242+
files: |
243+
build/publish/libopencv_dart-macos-arm64.tar.gz

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ __pycache__
2424
small2.mp4
2525
test/models/
2626
*.dylib
27+
CMakeUserPresets*
2728

2829
# Files and directories created by pub
2930
.dart_tool/

.gitmodules

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +0,0 @@
1-
[submodule "src/gocv"]
2-
path = src/gocv
3-
url = https://github.com/rainyl/gocv.git
4-
[submodule "src/opencv"]
5-
path = src/opencv
6-
url = https://github.com/opencv/opencv.git
7-
[submodule "src/opencv_contrib"]
8-
path = src/opencv_contrib
9-
url = https://github.com/opencv/opencv_contrib.git

CMakeLists.txt

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
cmake_minimum_required(VERSION 3.15)
2+
3+
project(opencv_dart_library VERSION 0.0.1 LANGUAGES C CXX)
4+
set(library_name "opencv_dart")
5+
6+
set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE)
7+
8+
find_package(OpenCV REQUIRED)
9+
10+
set(OpenCV_LIBS
11+
opencv_aruco opencv_core opencv_calib3d opencv_dnn opencv_highgui
12+
opencv_features2d opencv_photo opencv_imgproc
13+
opencv_objdetect opencv_video opencv_videoio opencv_stitching
14+
)
15+
16+
if(ANDROID)
17+
list(APPEND OpenCV_LIBS camera2ndk mediandk -landroid)
18+
endif(ANDROID)
19+
20+
message(STATUS "OpenCV library status:")
21+
message(STATUS " config: ${OpenCV_DIR}")
22+
message(STATUS " version: ${OpenCV_VERSION}")
23+
message(STATUS " libraries: ${OpenCV_LIBS}")
24+
message(STATUS " include path: ${OpenCV_INCLUDE_DIRS}")
25+
26+
file(GLOB GOCV_FILES
27+
"${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp"
28+
29+
# "${CMAKE_CURRENT_SOURCE_DIR}/gocv/contrib/*.cpp"
30+
)
31+
file(GLOB GOCV_HEADERS
32+
"${CMAKE_CURRENT_SOURCE_DIR}/src/*.h"
33+
34+
# "${CMAKE_CURRENT_SOURCE_DIR}/gocv/contrib/*.cpp"
35+
)
36+
37+
add_library(${library_name} SHARED
38+
${GOCV_FILES}
39+
)
40+
target_include_directories(${library_name} SYSTEM PUBLIC
41+
"${CMAKE_CURRENT_SOURCE_DIR}/src"
42+
${OpenCV_INCLUDE_DIRS}
43+
)
44+
target_link_libraries(${library_name} PRIVATE ${OpenCV_LIBS})
45+
set_target_properties(${library_name} PROPERTIES
46+
47+
# PUBLIC_HEADER ${GOCV_HEADERS}
48+
OUTPUT_NAME ${library_name}
49+
CXX_VISIBILITY_PRESET default
50+
C_VISIBILITY_PRESET default
51+
LINK_FLAGS_RELEASE -s
52+
)
53+
54+
if(WIN32)
55+
set_target_properties(${library_name} PROPERTIES
56+
WINDOWS_EXPORT_ALL_SYMBOLS ON
57+
)
58+
endif(WIN32)
59+
60+
target_compile_definitions(${library_name} PUBLIC DART_SHARED_LIB)
61+
62+
if(WITH_OPENCV_DART_DEMO)
63+
add_executable(
64+
demo
65+
"demo.c"
66+
)
67+
target_link_libraries(
68+
demo
69+
PUBLIC
70+
${OpenCV_LIBS}
71+
${library_name}
72+
)
73+
endif()
74+
75+
# ## install
76+
install(TARGETS ${library_name}
77+
DESTINATION ${CMAKE_INSTALL_PREFIX})
78+
79+
if(WIN32)
80+
file(GLOB CV_DEPENDENCIES "${CMAKE_BINARY_DIR}/*.dll")
81+
elseif(APPLE)
82+
file(GLOB CV_DEPENDENCIES "${CMAKE_BINARY_DIR}/*.dylib")
83+
elseif(LINUX)
84+
file(GLOB CV_DEPENDENCIES "${CMAKE_BINARY_DIR}/*.so")
85+
endif()
86+
87+
install(FILES ${CV_DEPENDENCIES} DESTINATION ${CMAKE_INSTALL_PREFIX})

0 commit comments

Comments
 (0)