• Stars
    star
    2,325
  • Rank 19,804 (Top 0.4 %)
  • Language
    C++
  • License
    Apache License 2.0
  • Created almost 4 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

The minimal opencv for Android, iOS, ARM Linux, Windows, Linux, MacOS, WebAssembly

opencv-mobile

License build download

Android iOS ARM Linux Windows Ubuntu MacOS Firefox Chrome

✔️ This project provides the minimal build of opencv library for the Android, iOS and ARM Linux platforms.

✔️ Packages for Windows, Linux, MacOS and WebAssembly are available now.

✔️ We provide prebuild binary packages for opencv 2.4.13.7, 3.4.18 and 4.6.0.

✔️ We also provide prebuild binary package for iOS with bitcode enabled, that the official package lacks.

✔️ All the binaries are compiled from source on github action, no virus, no backdoor, no secret code.

opencv 4.6.0 android package size
The official opencv 225MB
opencv-mobile 17.1MB
opencv 4.6.0 ios package size
The official opencv 182MB
opencv-mobile 15.6MB
opencv 4.6.0 ios with bitcode package size
The official opencv missing :(
opencv-mobile 54.6MB

Download

Android

(armeabi-v7a, arm64-v8a, x86, x86_64) build with ndk r25b and android api 24.

iOS

(armv7, arm64, arm64e, i386, x86_64) build with Xcode 12.4.

iOS with bitcode

(armv7, arm64, arm64e, i386, x86_64) build with Xcode 12.4.

ARM Linux

(arm-linux-gnueabi, arm-linux-gnueabihf, aarch64-linux-gnu) build with ubuntu cross compiler.

Windows

(x86, x64) build with VS2015, VS2017, VS2019 and VS2022.

Linux

(x86_64) build on Ubuntu-18.04, 20.04 and 22.04.

MacOS

(x86_64, arm64) build with Xcode 12.4.

WebAssembly

(basic, simd, threads, simd+threads) build with Emscripten 2.0.8.

Usage Android

  1. Extract archive to <project dir>/app/src/main/jni/
  2. Modify <project dir>/app/src/main/jni/CMakeListst.txt to find and link opencv
set(OpenCV_DIR ${CMAKE_SOURCE_DIR}/opencv-mobile-4.6.0-android/sdk/native/jni)
find_package(OpenCV REQUIRED)

target_link_libraries(your_jni_target ${OpenCV_LIBS})

Usage iOS and MacOS

  1. Extract archive, and drag opencv2.framework into your project

Usage ARM Linux, Windows, Linux, WebAssembly

  1. Extract archive to <project dir>/
  2. Modify <project dir>/CMakeListst.txt to find and link opencv
set(OpenCV_DIR ${CMAKE_SOURCE_DIR}/opencv-mobile-4.6.0-armlinux/arm-linux-gnueabihf/lib/cmake/opencv4)
find_package(OpenCV REQUIRED)

target_link_libraries(your_target ${OpenCV_LIBS})

How-to-build your custom package

step 1. download opencv source

wget -q https://github.com/opencv/opencv/archive/4.6.0.zip -O opencv-4.6.0.zip
unzip -q opencv-4.6.0.zip
cd opencv-4.6.0

step 2. strip zlib dependency and use stb-based highgui implementation (optional)

patch -p1 -i ../opencv-4.6.0-no-zlib.patch
truncate -s 0 cmake/OpenCVFindLibsGrfmt.cmake
rm -rf modules/gapi
rm -rf modules/highgui
cp -r ../highgui modules/

step 3. patch opencv source for no-rtti build (optional)

patch -p1 -i ../opencv-4.6.0-no-rtti.patch

step 4. apply your opencv options to opencv4_cmake_options.txt

step 5. build your opencv package with cmake

mkdir -p build
cd build
cmake -DCMAKE_INSTALL_PREFIX=install \
-DCMAKE_BUILD_TYPE=Release \
`cat ../../opencv4_cmake_options.txt` \
-DBUILD_opencv_world=OFF ..

step 6. make a package

zip -r -9 opencv-mobile-4.6.0.zip install

Some notes

  • The minimal opencv build contains most basic opencv operators and common image processing functions, with some handy additions like keypoint feature extraction and matching, image inpainting and opticalflow estimation.

  • Many computer vision algorithms that reside in dedicated modules are discarded, such as face detection etc. You could try deep-learning based algorithms with nerual network inference library optimized for mobile.

  • Image IO functions in highgui module, like cv::imread and cv::imwrite, are re-implemented using stb for smaller code size. GUI functions, like cv::imshow, are discarded.

  • cuda and opencl are disabled because there is no cuda on mobile, no opencl on ios, and opencl on android is slow. opencv on gpu is not suitable for real productions. Write metal on ios and opengles/vulkan on android if you need good gpu acceleration.

  • C++ RTTI and exceptions are disabled for minimal build on mobile platforms and webassembly build. Be careful when you write cv::Mat roi = image(roirect); :P

opencv modules included

module comment
opencv_core Mat, matrix operations, etc
opencv_imgproc resize, cvtColor, warpAffine, etc
opencv_highgui imread, imwrite
opencv_features2d keypoint feature and matcher, etc (not included in opencv 2.x package)
opencv_photo inpaint, etc
opencv_video opticalflow, etc

opencv modules discarded

module comment
opencv_androidcamera use android Camera api instead
opencv_calib3d camera calibration, rare uses on mobile
opencv_contrib experimental functions, build part of the source externally if you need
opencv_dnn very slow on mobile, try ncnn for nerual network inference on mobile
opencv_dynamicuda no cuda on mobile
opencv_flann feature matching, rare uses on mobile, build the source externally if you need
opencv_gapi graph based image processing, little gain on mobile
opencv_gpu no cuda/opencl on mobile
opencv_imgcodecs link with opencv_highgui instead
opencv_java wrap your c++ code with jni
opencv_js write native code on mobile
opencv_lagacy various good-old cv routines, build part of the source externally if you need
opencv_ml train your ML algorithm on powerful pc or server
opencv_nonfree the SIFT and SURF, use ORB which is faster and better
opencv_objdetect HOG, cascade detector, use deep learning detector which is faster and better
opencv_ocl no opencl on mobile
opencv_python no python on mobile
opencv_shape shape matching, rare uses on mobile, build the source externally if you need
opencv_stitching image stitching, rare uses on mobile, build the source externally if you need
opencv_superres do video super-resolution on powerful pc or server
opencv_ts test modules, useless in production anyway
opencv_videoio use android MediaCodec or ios AVFoundation api instead
opencv_videostab do video stablization on powerful pc or server
opencv_viz vtk is not available on mobile, write your own data visualization routines

More Repositories

1

waifu2x-ncnn-vulkan

waifu2x converter ncnn version, runs fast on intel / amd / nvidia / apple-silicon GPU with vulkan
C
2,963
star
2

realsr-ncnn-vulkan

RealSR super resolution implemented with ncnn library
C
1,077
star
3

rife-ncnn-vulkan

RIFE, Real-Time Intermediate Flow Estimation for Video Frame Interpolation implemented with ncnn library
C
775
star
4

realcugan-ncnn-vulkan

real-cugan converter ncnn version, runs fast on intel / amd / nvidia / apple-silicon GPU with vulkan
C
751
star
5

ncnn-android-yolov5

The YOLOv5 object detection android example
C++
621
star
6

dain-ncnn-vulkan

DAIN, Depth-Aware Video Frame Interpolation implemented with ncnn library
C
506
star
7

ncnn-android-nanodet

C++
355
star
8

srmd-ncnn-vulkan

SRMD super resolution implemented with ncnn library
C
324
star
9

ruapu

Detect CPU features with single-file
C
268
star
10

ncnn-android-scrfd

C++
208
star
11

ncnn-assets

Python
186
star
12

ncnn-small-board

ncnn benchmark on various single board computers
157
star
13

ncnn-android-squeezenet

The squeezenet image classification android example
C++
141
star
14

ncnn-webassembly-yolov5

Deploy YOLOv5 in your web browser with ncnn and webassembly
C++
138
star
15

cain-ncnn-vulkan

CAIN, Channel Attention Is All You Need for Video Frame Interpolation implemented with ncnn library
C
130
star
16

ncnn-webassembly-nanodet

Deploy nanodet, the super fast and lightweight object detection, in your web browser with ncnn and webassembly
C++
118
star
17

vkpeak

A tool which profiles Vulkan devices to find their peak capacities
C++
96
star
18

ifrnet-ncnn-vulkan

IFRNet: Intermediate Feature Refine Network for Efficient Frame Interpolation implemented with ncnn library
C
92
star
19

ncnn-android-mobilenetssd

The mobilenetssd object detection android example
Java
89
star
20

ncnn-android-styletransfer

The style transfer android example
C
84
star
21

ncnn-android-benchmark

ncnn android benchmark app
C++
83
star
22

ncnn_on_esp32

C
65
star
23

stable-diffusion-ncnn-vulkan

60
star
24

nihui

57
star
25

valgrind-android

55
star
26

ncnn-webassembly-scrfd

Deploy SCRFD, an efficient high accuracy face detection approach, in your web browser with ncnn and webassembly
C++
52
star
27

ncnn-webassembly-portrait-segmentation

Portrait segmentation in your web browser with ncnn and webassembly
C++
33
star
28

riscv-v-toolchain

prebuild package for cross compiling riscv
18
star
29

ncnn-android-vkpeak

C++
17
star
30

styletransfer-ncnn-vulkan

C
17
star
31

ncnn_on_xr806

C++
14
star
32

ncnn-vulkan-compute-sample

CMake
13
star
33

fxxk-tensorflow-lite-note

add custom op in both tensorflow and tensorflow-lite
Jupyter Notebook
7
star
34

zzzz

C++
6
star
35

milkv-duo-test

C
5
star
36

kuaide

A fast desktop environment based on KDE technology
C++
5
star
37

InferXLite

C++
4
star
38

eva-qq-protocol

qq protocol document for eva
3
star
39

action-protobuf

CMake
3
star
40

libnofetion

next generation of ofetion library
C
3
star
41

oxygenspread

C
3
star
42

xf86-video-siska

xf86 Driver for SIS Chipset
C
3
star
43

playground

C++
2
star
44

ksaolaji

C++
2
star
45

VulkanOnMetal

Vulkan On Metal
C
2
star
46

kio-kuaipan

C++
2
star
47

kfuseiso

C++
1
star
48

eva-qt4

C++
1
star
49

action-xmwk

1
star
50

kopete-qq

C++
1
star
51

kiconedit

C++
1
star
52

kde-thumbnailer

C++
1
star
53

kcm-fontadjust

C++
1
star
54

choqok-sina

C++
1
star
55

qsopcast

C++
1
star
56

choqok-tencent

C++
1
star
57

nihui-patch

nihui's patch collection
1
star
58

dozen

1
star
59

estelle

C++
1
star
60

kamule

C++
1
star
61

kdoubanfm

C++
1
star
62

kopete-fetion

C++
1
star
63

vendor-rockchip-common

common
C
1
star
64

plasma-webqq

C++
1
star
65

choqok-netease

C++
1
star