Skip to content

Commit d040ef5

Browse files
committed
first commit
0 parents  commit d040ef5

File tree

6 files changed

+55
-0
lines changed

6 files changed

+55
-0
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.DS_Store
2+
opencv-android-build
3+
opencv
4+
opencv_contrib

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# 編譯 OpenCV for Android
2+
3+
本文件說明如何自行編譯適用於 Android 平台的 OpenCV 函式庫。
4+
5+
## 步驟
6+
7+
### 1. 下載原始碼
8+
9+
首先,從 GitHub 下載 OpenCV 和 OpenCV Contrib 的 4.5.2 版本原始碼。
10+
11+
```bash
12+
git clone -b 4.5.2 https://github.com/opencv/opencv.git
13+
git clone -b 4.5.2 https://github.com/opencv/opencv_contrib.git
14+
```
15+
16+
### 2. 執行編譯腳本
17+
18+
接著,賦予編譯腳本執行權限並執行它。
19+
20+
```bash
21+
chmod +x opencv_android_build.sh
22+
./opencv_android_build.sh
23+
```
24+
25+
此腳本將會自動處理編譯過程,產生包含 arm64-v8a, armeabi-v7a, x86, 和 x86_64 架構的 Android SDK。編譯完成後,可以在 `opencv-android-build/OpenCV-android-sdk` 目錄下找到所需的 `libopencv_world.so` 檔案以及相關的函式庫。

Screenshot/img1141122-1.png

165 KB
Loading

Screenshot/img1141122-2.png

143 KB
Loading

article.md

Whitespace-only changes.

opencv_android_build.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
OPENCV_SRC=$PWD/opencv
2+
OPENCV_CONTRIB=$PWD/opencv_contrib
3+
OPENCV_BUILD=$PWD/opencv-android-build # output folder
4+
ANDROID_SDK=$HOME/Library/Android/sdk
5+
ANDROID_NDK=$ANDROID_SDK/ndk/27.0.12077973 # change to your ndk folder ls ~/Library/Android/sdk/ndk/
6+
CONFIG_FILE=$PWD/ndk-27.config.py # adjust to match your NDK version
7+
8+
mkdir -p $OPENCV_BUILD
9+
cd $OPENCV_BUILD
10+
11+
if [ -d "$ANDROID_SDK/cmdline-tools/latest" ]; then
12+
if [ ! -d "$ANDROID_SDK/tools" ]; then
13+
echo "Creating symlink for cmdline-tools"
14+
ln -s "$ANDROID_SDK/cmdline-tools/latest" "$ANDROID_SDK/tools"
15+
fi
16+
fi
17+
18+
python3 $OPENCV_SRC/platforms/android/build_sdk.py \
19+
$OPENCV_BUILD \
20+
$OPENCV_SRC \
21+
--ndk_path $ANDROID_NDK \
22+
--sdk_path $ANDROID_SDK \
23+
--extra_modules_path $OPENCV_CONTRIB/modules \
24+
--config $CONFIG_FILE \
25+
--use_android_buildtools \
26+
--no_samples_build

0 commit comments

Comments
 (0)