# opencv-mobile **Repository Path**: LockzhinerAI/opencv-mobile ## Basic Information - **Project Name**: opencv-mobile - **Description**: No description available - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: LockzhinerVisionModule - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2024-08-09 - **Last Updated**: 2024-09-26 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # opencv-mobile ![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg?style=for-the-badge) ![build](https://img.shields.io/github/actions/workflow/status/nihui/opencv-mobile/release.yml?style=for-the-badge) ![download](https://img.shields.io/github/downloads/nihui/opencv-mobile/total.svg?style=for-the-badge) ![Android](https://img.shields.io/badge/Android-3DDC84?style=for-the-badge&logo=android&logoColor=white) ![iOS](https://img.shields.io/badge/iOS-000000?style=for-the-badge&logo=ios&logoColor=white) ![ARM Linux](https://img.shields.io/badge/ARM_Linux-FCC624?style=for-the-badge&logo=linux&logoColor=black) ![Windows](https://img.shields.io/badge/Windows-0078D6?style=for-the-badge&logo=windows&logoColor=white) ![Ubuntu](https://img.shields.io/badge/Ubuntu-E95420?style=for-the-badge&logo=ubuntu&logoColor=white) ![MacOS](https://img.shields.io/badge/mac%20os-000000?style=for-the-badge&logo=apple&logoColor=white) ![Firefox](https://img.shields.io/badge/Firefox-FF7139?style=for-the-badge&logo=Firefox-Browser&logoColor=white) ![Chrome](https://img.shields.io/badge/Chrome-4285F4?style=for-the-badge&logo=Google-chrome&logoColor=white) :heavy_check_mark: This project provides the minimal build of opencv library for the **Android**, **iOS** and **ARM Linux** platforms. :heavy_check_mark: Packages for **Windows**, **Linux**, **MacOS** and **WebAssembly** are available now. :heavy_check_mark: We provide prebuild binary packages for opencv **2.4.13.7**, **3.4.20** and **4.10.0**. :heavy_check_mark: We also provide prebuild package for **Mac-Catalyst**, **watchOS**, **tvOS**, **visionOS** and **Apple xcframework**. :heavy_check_mark: All the binaries are compiled from source on github action, **no virus**, **no backdoor**, **no secret code**. :heavy_check_mark: ***NEW FEATURE*** [`cv::putText` supports full-width CJK characters](#cvputtext-supports-full-width-cjk-characters) |opencv 4.10.0 package size|The official opencv|opencv-mobile| |:-:|:-:|:-:| |source zip|95.2 MB|8.25 MB| |android|292 MB|17.7 MB| |ios|207 MB|3.97 MB|
Technical Exchange QQ Group
623504742(opencv-mobile夸夸群)
# Download https://github.com/nihui/opencv-mobile/releases/latest
Source [](https://github.com/nihui/opencv-mobile/releases/latest/download/opencv-mobile-2.4.13.7.zip) [](https://github.com/nihui/opencv-mobile/releases/latest/download/opencv-mobile-3.4.20.zip) [](https://github.com/nihui/opencv-mobile/releases/latest/download/opencv-mobile-4.10.0.zip)
Android [](https://github.com/nihui/opencv-mobile/releases/latest/download/opencv-mobile-2.4.13.7-android.zip) [](https://github.com/nihui/opencv-mobile/releases/latest/download/opencv-mobile-3.4.20-android.zip) [](https://github.com/nihui/opencv-mobile/releases/latest/download/opencv-mobile-4.10.0-android.zip)
iOS [](https://github.com/nihui/opencv-mobile/releases/latest/download/opencv-mobile-2.4.13.7-ios.zip) [](https://github.com/nihui/opencv-mobile/releases/latest/download/opencv-mobile-3.4.20-ios.zip) [](https://github.com/nihui/opencv-mobile/releases/latest/download/opencv-mobile-4.10.0-ios.zip)
iOS-Simulator [](https://github.com/nihui/opencv-mobile/releases/latest/download/opencv-mobile-2.4.13.7-ios-simulator.zip) [](https://github.com/nihui/opencv-mobile/releases/latest/download/opencv-mobile-3.4.20-ios-simulator.zip) [](https://github.com/nihui/opencv-mobile/releases/latest/download/opencv-mobile-4.10.0-ios-simulator.zip)
macOS [](https://github.com/nihui/opencv-mobile/releases/latest/download/opencv-mobile-2.4.13.7-macos.zip) [](https://github.com/nihui/opencv-mobile/releases/latest/download/opencv-mobile-3.4.20-macos.zip) [](https://github.com/nihui/opencv-mobile/releases/latest/download/opencv-mobile-4.10.0-macos.zip)
Mac-Catalyst [](https://github.com/nihui/opencv-mobile/releases/latest/download/opencv-mobile-2.4.13.7-mac-catalyst.zip) [](https://github.com/nihui/opencv-mobile/releases/latest/download/opencv-mobile-3.4.20-mac-catalyst.zip) [](https://github.com/nihui/opencv-mobile/releases/latest/download/opencv-mobile-4.10.0-mac-catalyst.zip)
watchOS [](https://github.com/nihui/opencv-mobile/releases/latest/download/opencv-mobile-2.4.13.7-watchos.zip) [](https://github.com/nihui/opencv-mobile/releases/latest/download/opencv-mobile-3.4.20-watchos.zip) [](https://github.com/nihui/opencv-mobile/releases/latest/download/opencv-mobile-4.10.0-watchos.zip)
watchOS-Simulator [](https://github.com/nihui/opencv-mobile/releases/latest/download/opencv-mobile-2.4.13.7-watchos-simulator.zip) [](https://github.com/nihui/opencv-mobile/releases/latest/download/opencv-mobile-3.4.20-watchos-simulator.zip) [](https://github.com/nihui/opencv-mobile/releases/latest/download/opencv-mobile-4.10.0-watchos-simulator.zip)
tvOS [](https://github.com/nihui/opencv-mobile/releases/latest/download/opencv-mobile-2.4.13.7-tvos.zip) [](https://github.com/nihui/opencv-mobile/releases/latest/download/opencv-mobile-3.4.20-tvos.zip) [](https://github.com/nihui/opencv-mobile/releases/latest/download/opencv-mobile-4.10.0-tvos.zip)
tvOS-Simulator [](https://github.com/nihui/opencv-mobile/releases/latest/download/opencv-mobile-2.4.13.7-tvos-simulator.zip) [](https://github.com/nihui/opencv-mobile/releases/latest/download/opencv-mobile-3.4.20-tvos-simulator.zip) [](https://github.com/nihui/opencv-mobile/releases/latest/download/opencv-mobile-4.10.0-tvos-simulator.zip)
visionOS [](https://github.com/nihui/opencv-mobile/releases/latest/download/opencv-mobile-2.4.13.7-visionos.zip) [](https://github.com/nihui/opencv-mobile/releases/latest/download/opencv-mobile-3.4.20-visionos.zip) [](https://github.com/nihui/opencv-mobile/releases/latest/download/opencv-mobile-4.10.0-visionos.zip)
visionOS-Simulator [](https://github.com/nihui/opencv-mobile/releases/latest/download/opencv-mobile-2.4.13.7-visionos-simulator.zip) [](https://github.com/nihui/opencv-mobile/releases/latest/download/opencv-mobile-3.4.20-visionos-simulator.zip) [](https://github.com/nihui/opencv-mobile/releases/latest/download/opencv-mobile-4.10.0-visionos-simulator.zip)
Apple xcframework [](https://github.com/nihui/opencv-mobile/releases/latest/download/opencv-mobile-2.4.13.7-apple.zip) [](https://github.com/nihui/opencv-mobile/releases/latest/download/opencv-mobile-3.4.20-apple.zip) [](https://github.com/nihui/opencv-mobile/releases/latest/download/opencv-mobile-4.10.0-apple.zip)
Ubuntu-20.04 [](https://github.com/nihui/opencv-mobile/releases/latest/download/opencv-mobile-2.4.13.7-ubuntu-2004.zip) [](https://github.com/nihui/opencv-mobile/releases/latest/download/opencv-mobile-3.4.20-ubuntu-2004.zip) [](https://github.com/nihui/opencv-mobile/releases/latest/download/opencv-mobile-4.10.0-ubuntu-2004.zip)
Ubuntu-22.04 [](https://github.com/nihui/opencv-mobile/releases/latest/download/opencv-mobile-2.4.13.7-ubuntu-2204.zip) [](https://github.com/nihui/opencv-mobile/releases/latest/download/opencv-mobile-3.4.20-ubuntu-2204.zip) [](https://github.com/nihui/opencv-mobile/releases/latest/download/opencv-mobile-4.10.0-ubuntu-2204.zip)
VS2015 [](https://github.com/nihui/opencv-mobile/releases/latest/download/opencv-mobile-2.4.13.7-windows-vs2015.zip) [](https://github.com/nihui/opencv-mobile/releases/latest/download/opencv-mobile-3.4.20-windows-vs2015.zip) [](https://github.com/nihui/opencv-mobile/releases/latest/download/opencv-mobile-4.10.0-windows-vs2015.zip)
VS2017 [](https://github.com/nihui/opencv-mobile/releases/latest/download/opencv-mobile-2.4.13.7-windows-vs2017.zip) [](https://github.com/nihui/opencv-mobile/releases/latest/download/opencv-mobile-3.4.20-windows-vs2017.zip) [](https://github.com/nihui/opencv-mobile/releases/latest/download/opencv-mobile-4.10.0-windows-vs2017.zip)
VS2019 [](https://github.com/nihui/opencv-mobile/releases/latest/download/opencv-mobile-2.4.13.7-windows-vs2019.zip) [](https://github.com/nihui/opencv-mobile/releases/latest/download/opencv-mobile-3.4.20-windows-vs2019.zip) [](https://github.com/nihui/opencv-mobile/releases/latest/download/opencv-mobile-4.10.0-windows-vs2019.zip)
VS2022 [](https://github.com/nihui/opencv-mobile/releases/latest/download/opencv-mobile-2.4.13.7-windows-vs2022.zip) [](https://github.com/nihui/opencv-mobile/releases/latest/download/opencv-mobile-3.4.20-windows-vs2022.zip) [](https://github.com/nihui/opencv-mobile/releases/latest/download/opencv-mobile-4.10.0-windows-vs2022.zip)
WebAssembly [](https://github.com/nihui/opencv-mobile/releases/latest/download/opencv-mobile-2.4.13.7-webassembly.zip) [](https://github.com/nihui/opencv-mobile/releases/latest/download/opencv-mobile-3.4.20-webassembly.zip) [](https://github.com/nihui/opencv-mobile/releases/latest/download/opencv-mobile-4.10.0-webassembly.zip)
ARM-Linux [](https://github.com/nihui/opencv-mobile/releases/latest/download/opencv-mobile-2.4.13.7-armlinux.zip) [](https://github.com/nihui/opencv-mobile/releases/latest/download/opencv-mobile-3.4.20-armlinux.zip) [](https://github.com/nihui/opencv-mobile/releases/latest/download/opencv-mobile-4.10.0-armlinux.zip)
* Android package build with ndk r26c and android api 21 * iOS / MacOS / Mac-Catalyst / watchOS / tvOS / visionOS package build with Xcode 15.2 * ARM Linux package build with cross-compiler on Ubuntu-22.04 * WebAssembly package build with Emscripten 3.1.28 ### opencv-mobile package for development boards
milkv-duo
milkv-duo

riscv64-linux-musl
✅ HW JPG decoder
✅ MIPI CSI camera
opencv4-milkv-duo
licheerv-nano
licheerv-nano

riscv64-linux-musl
✅ HW JPG decoder
✅ MIPI CSI camera
opencv4-licheerv-nano
luckfox-pico
luckfox-pico

arm-linux-uclibcgnueabihf
✅ HW JPG encoder
✅ MIPI CSI camera
✅ DPI LCD screen
opencv4-luckfox-pico
yuzuki-lizard
yuzuki-lizard

arm-linux-uclibcgnueabihf
opencv4-yuzuki-lizard
tinyvision
tinyvision

arm-linux-uclibcgnueabihf
✅ HW JPG decoder
✅ HW JPG encoder
✅ MIPI CSI camera
✅ SPI LCD screen
opencv4-tinyvision
yuzuki-chameleon
yuzuki-chameleon

arm-openwrt-linux-gnueabi
✅ HW JPG decoder
✅ HW JPG encoder
opencv4-yuzuki-chameleon
purple-pi
purple-pi

arm-linux-uclibcgnueabihf
opencv4-purple-pi
myir-t113i
myir-t113i

arm-linux-gnueabi
✅ HW JPG decoder
✅ HW JPG encoder
opencv4-myir-t113i
2k0300-fengniao
2k0300-fengniao

loongarch64-linux-gnu
opencv4-2k0300-fengniao
# Usage Android 1. Extract archive to ```/app/src/main/jni/``` 2. Modify ```/app/src/main/jni/CMakeListst.txt``` to find and link opencv ```cmake set(OpenCV_DIR ${CMAKE_SOURCE_DIR}/opencv-mobile-4.10.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``` or ```opencv2.xcframework``` into your project # Usage ARM Linux, Windows, Linux, WebAssembly 1. Extract archive to ```/``` 2. Modify ```/CMakeListst.txt``` to find and link opencv 3. Pass ```-DOpenCV_STATIC=ON``` to cmake option for windows build ```cmake set(OpenCV_DIR ${CMAKE_SOURCE_DIR}/opencv-mobile-4.10.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 We reduce the binary size of opencv-mobile in 3 ways 1. Reimplement some modules (such as highgui) and functions (such as putText) 2. Apply patches to disable rtti/exceptions and do not install non-essential files 3. Carefully select cmake options to retain only the modules and functions you want Steps 1 and 2 are relatively cumbersome and difficult, and require intrusive changes to the opencv source code. If you want to know the details, please refer to the steps in `.github/workflows/release.yml` The opencv-mobile source code package is the result of steps 1 and 2. Based on it, we can adjust the cmake option to compile our own package and further delete and add modules and other functions. **step 1. download opencv-mobile source** ```shell wget -q https://github.com/nihui/opencv-mobile/releases/latest/download/opencv-mobile-4.10.0.zip unzip -q opencv-mobile-4.10.0.zip cd opencv-mobile-4.10.0 ``` **step 2. apply your opencv option changes to options.txt** ```shell vim options.txt ``` **step 3. build your opencv package with cmake** ```shell mkdir -p build cd build cmake -DCMAKE_INSTALL_PREFIX=install \ -DCMAKE_BUILD_TYPE=Release \ `cat ../options.txt` \ -DBUILD_opencv_world=OFF .. make -j4 make install ``` **step 4. make a package** ```shell zip -r -9 opencv-mobile-4.10.0-mypackage.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 neural network inference library optimized for mobile.](https://github.com/Tencent/ncnn) * Image IO functions in highgui module, like ```cv::imread``` and ```cv::imwrite```, are re-implemented using [stb](https://github.com/nothings/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 ## `cv::putText` supports full-width CJK characters 1. Open https://nihui.github.io/opencv-mobile/patches/fontface.html or `opencv-mobile-X.Y.Z/fontface.html` in your browser. 2. In the opened page, enter all the text to be drawn, select the TTF font file (optional), click the `Convert to Font Header` button to download the fontface header. This step is completely local operation, without connecting to a remote server, your data is private and safe. 3. Include the generated fontface header, initialize a fontface instance, and pass it as the argument to `cv::putText`. The source file must be encoded in UTF-8. Since all characters have been converted to embedded bitmap, the drawing routine does not depend on freetype library or any font files at runtime. ```cpp #include #include #include #include "myfontface.h" int main() { cv::Mat bgr = cv::imread("atari.jpg", 1); // use this font MyFontFace myfont; // draw full-width text with myfont const char* zhtext = "称呼机器人为破铜烂铁,\n违反了禁止歧视机器人法!"; cv::putText(bgr, zhtext, cv::Point(30, 250), cv::Scalar(127, 0, 127), myfont, 20); // get bounding rect cv::Rect rr = cv::getTextSize(bgr.size(), zhtext, cv::Point(30, 250), myfont, 20); cv::imwrite("out.jpg", bgr); return 0; } ``` # 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 neural 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_legacy|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|