Giter Site home page Giter Site logo

nihui / opencv-mobile Goto Github PK

View Code? Open in Web Editor NEW
2.1K 50.0 300.0 511 KB

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

License: Apache License 2.0

CMake 4.44% C++ 90.24% C 5.32%
opencv android ios arm-linux windows linux macos webassembly

opencv-mobile's Introduction

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.20 and 4.9.0.

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

✔️ We also provide prebuild binary package for Mac-Catalyst and Apple xcframework, that the official package lacks.

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

opencv 4.9.0 package size The official opencv opencv-mobile
source zip 93.0 MB 9.91 MB
android 242 MB 17.6 MB
ios 202 MB 9.57 MB
ios+bitcode missing :( 33.7 MB

Download

https://github.com/nihui/opencv-mobile/releases/latest

Source



Android (armeabi-v7a, arm64-v8a, x86, x86_64)



iOS (armv7, arm64, arm64e) iOS-Simulator (i386, x86_64, arm64)





macOS (x86_64, arm64) Mac-Catalyst (x86_64, arm64)





Apple xcframework (ios, ios-simulator, ios-maccatalyst, macos)



Ubuntu-20.04 (x86_64) Ubuntu-22.04 (x86_64)





ARM-Linux (arm-linux-gnueabi, arm-linux-gnueabihf, aarch64-linux-gnu)



VS2015 (x86, x64) VS2017 (x86, x64) VS2019 (x86, x64) VS2022 (x86, x64)









WebAssembly (basic, simd, threads, simd+threads)



  • Android package build with ndk r26b and android api 21
  • iOS / iOS-Simulator / MacOS / Mac-Catalyst package build with Xcode 13.4.1
  • 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
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
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

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.9.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 <project dir>/
  2. Modify <project dir>/CMakeListst.txt to find and link opencv
  3. Pass -DOpenCV_STATIC=ON to cmake option for windows build
set(OpenCV_DIR ${CMAKE_SOURCE_DIR}/opencv-mobile-4.9.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

wget -q https://github.com/nihui/opencv-mobile/releases/latest/download/opencv-mobile-4.9.0.zip
unzip -q opencv-mobile-4.9.0.zip
cd opencv-mobile-4.9.0

step 2. apply your opencv option changes to options.txt

vim options.txt

step 3. build your opencv package with cmake

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

zip -r -9 opencv-mobile-4.9.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.

  • 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 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

opencv-mobile's People

Contributors

dependabot[bot] avatar hokamilkv avatar nihui avatar zchrissirhcz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

opencv-mobile's Issues

Need guidence on how to build opencv-mobile

It's a very useful repo!!! I have a suggestion that owners can release a guide on how to build opencv-mobile library on target platform with this repo and opencv official repo. Users can use this guide to do more custom changes and get a smaller package.

imread imdecode 支持jpg exif

目前很多手机图片都带旋转,前置摄像头的~

opecv3.2x以上的版本 loadsave.cpp
static void ApplyExifOrientation(const String& filename, Mat& img) 接口~

iOS and and Android

Is it possible to have the instructions to build for ios and android in the README? Thanks

How to use opencv-mobile in AOSP

From the instructions, there's how to use opencv-mobile in an Android APP. How can I use it in AOSP, or more specifically, android framework.

imwrite not working properly

undefined reference to `cv::imwrite(std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator > const&, cv::_InputArray const&, std::__ndk1::vector<int, std::__ndk1::allocator > const&)'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)

for. time-being I have replaced SDK with original openCV android SDK and this error was gone.

cv::imencode bmp write wrong header

Mat frame;
...
std::vector buf(1);
cv::imencode(".bmp", frame, buf);

I use full feature opencv in ios work normally but when I use opencv minimize 4.54 work abnormally.

compile for arm fails

Getting this error
more undefined references to `std::__cxx11::basic_stringstream<char, std::char_traits, std::allocator >::basic_stringstream()'

enhance highgui module with hardware acceleration

cv::imread / cv::imdecode

  • jpeg on milkv-duo
  • jpeg on yuzuki-lizard
  • jpeg on tinyvision

cv::imwrite / cv::imencode

  • jpeg on milkv-duo
  • jpeg on yuzuki-lizard
  • jpeg on tinyvision
  • jpeg on luckfox-pico

cv::VideoCapture

  • v4l camera on luckfox-pico
  • v4l camera on tinyvision
  • cvi camera on milkv-duo

添加calib3d模块的opencv-mobile编译方法

感谢大佬提供的移动端opencv库,本人需要用到人脸检测矫正函数,所以需要添加calib3d模块,但是calib3d默认使用了rtti选项,这里通过一个死方法,打开了rtti选项才将calib3d模块成功添加后才编译通过,模型有点大;ncnn也必须开启rtti,才能同时使用ncnn和opencv。这里是具体的解决办法 开启rtti选项源码编译android的ncnn库,有时间准备改改calib3d的源码把rtti去掉,不过也期望大佬能够改改calib3d的源码把使用到rtti的源码去掉

编译没有生成install目录

cmake -DCMAKE_INSTALL_PREFIX=install \
> -DCMAKE_BUILD_TYPE=Release \
> `cat ../../opencv4_cmake_options.txt` \
> -DBUILD_opencv_world=OFF ..
-- The CXX compiler identification is GNU 7.5.0
-- The C compiler identification is GNU 7.5.0
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- ocv_init_download: OpenCV source tree is not fetched as git repository. 3rdparty resources will be downloaded from github.com by default.
-- Detected processor: x86_64
-- Could NOT find PythonInterp (missing:  PYTHON_EXECUTABLE) (Required is at least version "2.7")
-- Found PythonInterp: /usr/bin/python3 (found suitable version "3.6.9", minimum required is "3.2") 
-- Found PythonLibs: /usr/lib/x86_64-linux-gnu/libpython3.6m.so (found suitable exact version "3.6.9") 
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'numpy'
-- Looking for ccache - not found
-- Performing Test HAVE_CXX_FSIGNED_CHAR
-- Performing Test HAVE_CXX_FSIGNED_CHAR - Success
-- Performing Test HAVE_C_FSIGNED_CHAR
-- Performing Test HAVE_C_FSIGNED_CHAR - Success
-- Performing Test HAVE_CXX_W
-- Performing Test HAVE_CXX_W - Success
-- Performing Test HAVE_C_W
-- Performing Test HAVE_C_W - Success
-- Performing Test HAVE_CXX_WALL
-- Performing Test HAVE_CXX_WALL - Success
-- Performing Test HAVE_C_WALL
-- Performing Test HAVE_C_WALL - Success
-- Performing Test HAVE_CXX_WRETURN_TYPE
-- Performing Test HAVE_CXX_WRETURN_TYPE - Success
-- Performing Test HAVE_C_WRETURN_TYPE
-- Performing Test HAVE_C_WRETURN_TYPE - Success
-- Performing Test HAVE_CXX_WNON_VIRTUAL_DTOR
-- Performing Test HAVE_CXX_WNON_VIRTUAL_DTOR - Success
-- Performing Test HAVE_C_WNON_VIRTUAL_DTOR
-- Performing Test HAVE_C_WNON_VIRTUAL_DTOR - Failed
-- Performing Test HAVE_CXX_WADDRESS
-- Performing Test HAVE_CXX_WADDRESS - Success
-- Performing Test HAVE_C_WADDRESS
-- Performing Test HAVE_C_WADDRESS - Success
-- Performing Test HAVE_CXX_WSEQUENCE_POINT
-- Performing Test HAVE_CXX_WSEQUENCE_POINT - Success
-- Performing Test HAVE_C_WSEQUENCE_POINT
-- Performing Test HAVE_C_WSEQUENCE_POINT - Success
-- Performing Test HAVE_CXX_WFORMAT
-- Performing Test HAVE_CXX_WFORMAT - Success
-- Performing Test HAVE_C_WFORMAT
-- Performing Test HAVE_C_WFORMAT - Success
-- Performing Test HAVE_CXX_WFORMAT_SECURITY
-- Performing Test HAVE_CXX_WFORMAT_SECURITY - Success
-- Performing Test HAVE_C_WFORMAT_SECURITY
-- Performing Test HAVE_C_WFORMAT_SECURITY - Success
-- Performing Test HAVE_CXX_WMISSING_DECLARATIONS
-- Performing Test HAVE_CXX_WMISSING_DECLARATIONS - Success
-- Performing Test HAVE_C_WMISSING_DECLARATIONS
-- Performing Test HAVE_C_WMISSING_DECLARATIONS - Success
-- Performing Test HAVE_CXX_WMISSING_PROTOTYPES
-- Performing Test HAVE_CXX_WMISSING_PROTOTYPES - Failed
-- Performing Test HAVE_C_WMISSING_PROTOTYPES
-- Performing Test HAVE_C_WMISSING_PROTOTYPES - Success
-- Performing Test HAVE_CXX_WSTRICT_PROTOTYPES
-- Performing Test HAVE_CXX_WSTRICT_PROTOTYPES - Failed
-- Performing Test HAVE_C_WSTRICT_PROTOTYPES
-- Performing Test HAVE_C_WSTRICT_PROTOTYPES - Success
-- Performing Test HAVE_CXX_WUNDEF
-- Performing Test HAVE_CXX_WUNDEF - Success
-- Performing Test HAVE_C_WUNDEF
-- Performing Test HAVE_C_WUNDEF - Success
-- Performing Test HAVE_CXX_WINIT_SELF
-- Performing Test HAVE_CXX_WINIT_SELF - Success
-- Performing Test HAVE_C_WINIT_SELF
-- Performing Test HAVE_C_WINIT_SELF - Success
-- Performing Test HAVE_CXX_WPOINTER_ARITH
-- Performing Test HAVE_CXX_WPOINTER_ARITH - Success
-- Performing Test HAVE_C_WPOINTER_ARITH
-- Performing Test HAVE_C_WPOINTER_ARITH - Success
-- Performing Test HAVE_CXX_WSHADOW
-- Performing Test HAVE_CXX_WSHADOW - Success
-- Performing Test HAVE_C_WSHADOW
-- Performing Test HAVE_C_WSHADOW - Success
-- Performing Test HAVE_CXX_WSIGN_PROMO
-- Performing Test HAVE_CXX_WSIGN_PROMO - Success
-- Performing Test HAVE_C_WSIGN_PROMO
-- Performing Test HAVE_C_WSIGN_PROMO - Failed
-- Performing Test HAVE_CXX_WUNINITIALIZED
-- Performing Test HAVE_CXX_WUNINITIALIZED - Success
-- Performing Test HAVE_C_WUNINITIALIZED
-- Performing Test HAVE_C_WUNINITIALIZED - Success
-- Performing Test HAVE_CXX_WSUGGEST_OVERRIDE
-- Performing Test HAVE_CXX_WSUGGEST_OVERRIDE - Success
-- Performing Test HAVE_C_WSUGGEST_OVERRIDE
-- Performing Test HAVE_C_WSUGGEST_OVERRIDE - Failed
-- Performing Test HAVE_CXX_WNO_DELETE_NON_VIRTUAL_DTOR
-- Performing Test HAVE_CXX_WNO_DELETE_NON_VIRTUAL_DTOR - Success
-- Performing Test HAVE_C_WNO_DELETE_NON_VIRTUAL_DTOR
-- Performing Test HAVE_C_WNO_DELETE_NON_VIRTUAL_DTOR - Failed
-- Performing Test HAVE_CXX_WNO_UNNAMED_TYPE_TEMPLATE_ARGS
-- Performing Test HAVE_CXX_WNO_UNNAMED_TYPE_TEMPLATE_ARGS - Failed
-- Performing Test HAVE_C_WNO_UNNAMED_TYPE_TEMPLATE_ARGS
-- Performing Test HAVE_C_WNO_UNNAMED_TYPE_TEMPLATE_ARGS - Failed
-- Performing Test HAVE_CXX_WNO_COMMENT
-- Performing Test HAVE_CXX_WNO_COMMENT - Success
-- Performing Test HAVE_C_WNO_COMMENT
-- Performing Test HAVE_C_WNO_COMMENT - Success
-- Performing Test HAVE_CXX_WIMPLICIT_FALLTHROUGH_3
-- Performing Test HAVE_CXX_WIMPLICIT_FALLTHROUGH_3 - Success
-- Performing Test HAVE_C_WIMPLICIT_FALLTHROUGH_3
-- Performing Test HAVE_C_WIMPLICIT_FALLTHROUGH_3 - Success
-- Performing Test HAVE_CXX_WNO_STRICT_OVERFLOW
-- Performing Test HAVE_CXX_WNO_STRICT_OVERFLOW - Success
-- Performing Test HAVE_C_WNO_STRICT_OVERFLOW
-- Performing Test HAVE_C_WNO_STRICT_OVERFLOW - Success
-- Performing Test HAVE_CXX_FDIAGNOSTICS_SHOW_OPTION
-- Performing Test HAVE_CXX_FDIAGNOSTICS_SHOW_OPTION - Success
-- Performing Test HAVE_C_FDIAGNOSTICS_SHOW_OPTION
-- Performing Test HAVE_C_FDIAGNOSTICS_SHOW_OPTION - Success
-- Performing Test HAVE_CXX_WNO_LONG_LONG
-- Performing Test HAVE_CXX_WNO_LONG_LONG - Success
-- Performing Test HAVE_C_WNO_LONG_LONG
-- Performing Test HAVE_C_WNO_LONG_LONG - Success
-- Performing Test HAVE_CXX_PTHREAD
-- Performing Test HAVE_CXX_PTHREAD - Success
-- Performing Test HAVE_C_PTHREAD
-- Performing Test HAVE_C_PTHREAD - Success
-- Performing Test HAVE_CXX_FOMIT_FRAME_POINTER
-- Performing Test HAVE_CXX_FOMIT_FRAME_POINTER - Success
-- Performing Test HAVE_C_FOMIT_FRAME_POINTER
-- Performing Test HAVE_C_FOMIT_FRAME_POINTER - Success
-- Performing Test HAVE_CXX_FFUNCTION_SECTIONS
-- Performing Test HAVE_CXX_FFUNCTION_SECTIONS - Success
-- Performing Test HAVE_C_FFUNCTION_SECTIONS
-- Performing Test HAVE_C_FFUNCTION_SECTIONS - Success
-- Performing Test HAVE_CXX_FDATA_SECTIONS
-- Performing Test HAVE_CXX_FDATA_SECTIONS - Success
-- Performing Test HAVE_C_FDATA_SECTIONS
-- Performing Test HAVE_C_FDATA_SECTIONS - Success
-- Performing Test HAVE_CXX_MSSE (check file: cmake/checks/cpu_sse.cpp)
-- Performing Test HAVE_CXX_MSSE - Success
-- Performing Test HAVE_CXX_MSSE2 (check file: cmake/checks/cpu_sse2.cpp)
-- Performing Test HAVE_CXX_MSSE2 - Success
-- Performing Test HAVE_CXX_MSSE3 (check file: cmake/checks/cpu_sse3.cpp)
-- Performing Test HAVE_CXX_MSSE3 - Success
-- Performing Test HAVE_CXX_MSSSE3 (check file: cmake/checks/cpu_ssse3.cpp)
-- Performing Test HAVE_CXX_MSSSE3 - Success
-- Performing Test HAVE_CXX_MSSE4_1 (check file: cmake/checks/cpu_sse41.cpp)
-- Performing Test HAVE_CXX_MSSE4_1 - Success
-- Performing Test HAVE_CXX_MPOPCNT (check file: cmake/checks/cpu_popcnt.cpp)
-- Performing Test HAVE_CXX_MPOPCNT - Success
-- Performing Test HAVE_CXX_MSSE4_2 (check file: cmake/checks/cpu_sse42.cpp)
-- Performing Test HAVE_CXX_MSSE4_2 - Success
-- Performing Test HAVE_CXX_MF16C (check file: cmake/checks/cpu_fp16.cpp)
-- Performing Test HAVE_CXX_MF16C - Success
-- Performing Test HAVE_CXX_MFMA
-- Performing Test HAVE_CXX_MFMA - Success
-- Performing Test HAVE_CXX_MAVX (check file: cmake/checks/cpu_avx.cpp)
-- Performing Test HAVE_CXX_MAVX - Success
-- Performing Test HAVE_CXX_MAVX2 (check file: cmake/checks/cpu_avx2.cpp)
-- Performing Test HAVE_CXX_MAVX2 - Success
-- Performing Test HAVE_CXX_MAVX512F (check file: cmake/checks/cpu_avx512.cpp)
-- Performing Test HAVE_CXX_MAVX512F - Success
-- Performing Test HAVE_CXX_MAVX512F_MAVX512CD (check file: cmake/checks/cpu_avx512common.cpp)
-- Performing Test HAVE_CXX_MAVX512F_MAVX512CD - Success
-- Performing Test HAVE_CXX_MAVX512F_MAVX512CD_MAVX512VL_MAVX512BW_MAVX512DQ (check file: cmake/checks/cpu_avx512skx.cpp)
-- Performing Test HAVE_CXX_MAVX512F_MAVX512CD_MAVX512VL_MAVX512BW_MAVX512DQ - Success
-- Performing Test HAVE_CPU_BASELINE_FLAGS
-- Performing Test HAVE_CPU_BASELINE_FLAGS - Success
-- Performing Test HAVE_CPU_DISPATCH_FLAGS_SSE4_1
-- Performing Test HAVE_CPU_DISPATCH_FLAGS_SSE4_1 - Success
-- Performing Test HAVE_CPU_DISPATCH_FLAGS_SSE4_2
-- Performing Test HAVE_CPU_DISPATCH_FLAGS_SSE4_2 - Success
-- Performing Test HAVE_CPU_DISPATCH_FLAGS_FP16
-- Performing Test HAVE_CPU_DISPATCH_FLAGS_FP16 - Success
-- Performing Test HAVE_CPU_DISPATCH_FLAGS_AVX
-- Performing Test HAVE_CPU_DISPATCH_FLAGS_AVX - Success
-- Performing Test HAVE_CPU_DISPATCH_FLAGS_AVX2
-- Performing Test HAVE_CPU_DISPATCH_FLAGS_AVX2 - Success
-- Performing Test HAVE_CPU_DISPATCH_FLAGS_AVX512_SKX
-- Performing Test HAVE_CPU_DISPATCH_FLAGS_AVX512_SKX - Success
-- Performing Test HAVE_CXX_FVISIBILITY_HIDDEN
-- Performing Test HAVE_CXX_FVISIBILITY_HIDDEN - Success
-- Performing Test HAVE_C_FVISIBILITY_HIDDEN
-- Performing Test HAVE_C_FVISIBILITY_HIDDEN - Success
-- Performing Test HAVE_CXX_FVISIBILITY_INLINES_HIDDEN
-- Performing Test HAVE_CXX_FVISIBILITY_INLINES_HIDDEN - Success
-- Performing Test HAVE_C_FVISIBILITY_INLINES_HIDDEN
-- Performing Test HAVE_C_FVISIBILITY_INLINES_HIDDEN - Failed
-- Performing Test HAVE_LINK_AS_NEEDED
-- Performing Test HAVE_LINK_AS_NEEDED - Success
-- Performing Test HAVE_LINK_NO_UNDEFINED
-- Performing Test HAVE_LINK_NO_UNDEFINED - Success
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for posix_memalign
-- Looking for posix_memalign - found
-- Looking for malloc.h
-- Looking for malloc.h - found
-- Looking for memalign
-- Looking for memalign - found
-- Check if the system is big endian
-- Searching 16 bit integer
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of unsigned short
-- Check size of unsigned short - done
-- Using unsigned short
-- Check if the system is big endian - little endian
-- Try OpenMP C flag = [-fopenmp]
-- Performing Test OpenMP_FLAG_DETECTED
-- Performing Test OpenMP_FLAG_DETECTED - Success
-- Try OpenMP CXX flag = [-fopenmp]
-- Performing Test OpenMP_FLAG_DETECTED
-- Performing Test OpenMP_FLAG_DETECTED - Success
-- Found OpenMP: -fopenmp  
-- libva: missing va.h header (VA_INCLUDE_DIR)
-- Could not find OpenBLAS include. Turning OpenBLAS_FOUND off
-- Could not find OpenBLAS lib. Turning OpenBLAS_FOUND off
-- Could NOT find Atlas (missing:  Atlas_CBLAS_INCLUDE_DIR Atlas_CLAPACK_INCLUDE_DIR Atlas_CBLAS_LIBRARY Atlas_BLAS_LIBRARY Atlas_LAPACK_LIBRARY) 
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - found
-- Found Threads: TRUE  
-- A library with BLAS API not found. Please specify library location.
-- LAPACK requires BLAS
-- A library with LAPACK API not found. Please specify library location.
-- VTK is not found. Please set -DVTK_DIR in CMake to VTK build directory, or to VTK install subdirectory with VTKConfig.cmake file
-- Allocator metrics storage type: 'long long'
-- Excluding from source files list: modules/imgproc/src/imgwarp.lasx.cpp
-- Excluding from source files list: modules/imgproc/src/resize.lasx.cpp
-- Performing Test HAVE_CXX_WNO_DEPRECATED_DECLARATIONS
-- Performing Test HAVE_CXX_WNO_DEPRECATED_DECLARATIONS - Success
-- Found 'misc' Python modules from /home/wangzhi/opencv-mobile-19/opencv-4.8.0/modules/python/package/extra_modules
-- Found 'mat_wrapper;utils' Python modules from /home/wangzhi/opencv-mobile-19/opencv-4.8.0/modules/core/misc/python/package
-- 
-- General configuration for OpenCV 4.8.0 =====================================
--   Version control:               unknown
-- 
--   Platform:
--     Timestamp:                   2023-09-08T02:40:19Z
--     Host:                        Linux 5.4.0-150-generic x86_64
--     CMake:                       3.6.3
--     CMake generator:             Unix Makefiles
--     CMake build tool:            /usr/bin/make
--     Configuration:               Release
-- 
--   CPU/HW features:
--     Baseline:                    SSE SSE2 SSE3
--       requested:                 SSE3
--     Dispatched code generation:  SSE4_1 SSE4_2 FP16 AVX AVX2 AVX512_SKX
--       requested:                 SSE4_1 SSE4_2 AVX FP16 AVX2 AVX512_SKX
--       SSE4_1 (14 files):         + SSSE3 SSE4_1
--       SSE4_2 (1 files):          + SSSE3 SSE4_1 POPCNT SSE4_2
--       FP16 (0 files):            + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 AVX
--       AVX (3 files):             + SSSE3 SSE4_1 POPCNT SSE4_2 AVX
--       AVX2 (27 files):           + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2
--       AVX512_SKX (3 files):      + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2 AVX_512F AVX512_COMMON AVX512_SKX
-- 
--   C/C++:
--     Built as dynamic libs?:      NO
--     C++ standard:                11
--     C++ Compiler:                /usr/bin/c++  (ver 7.5.0)
--     C++ flags (Release):         -fsigned-char -W -Wall -Wreturn-type -Wnon-virtual-dtor -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -fopenmp -O3 -DNDEBUG  -DNDEBUG
--     C++ flags (Debug):           -fsigned-char -W -Wall -Wreturn-type -Wnon-virtual-dtor -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -fopenmp -g  -O0 -DDEBUG -D_DEBUG
--     C Compiler:                  /usr/bin/cc
--     C flags (Release):           -fsigned-char -W -Wall -Wreturn-type -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -fopenmp -O3 -DNDEBUG  -DNDEBUG
--     C flags (Debug):             -fsigned-char -W -Wall -Wreturn-type -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -fopenmp -g  -O0 -DDEBUG -D_DEBUG
--     Linker flags (Release):      -Wl,--gc-sections -Wl,--as-needed -Wl,--no-undefined  
--     Linker flags (Debug):        -Wl,--gc-sections -Wl,--as-needed -Wl,--no-undefined  
--     ccache:                      NO
--     Precompiled headers:         NO
--     Extra dependencies:          dl m pthread rt
--     3rdparty dependencies:
-- 
--   OpenCV modules:
--     To be built:                 core features2d highgui imgproc photo video
--     Disabled:                    calib3d dnn flann imgcodecs ml objdetect stitching videoio world
--     Disabled by dependency:      -
--     Unavailable:                 java python2 python3 ts
--     Applications:                -
--     Documentation:               NO
--     Non-free algorithms:         NO
-- 
--   GUI: 
--     VTK support:                 NO
-- 
--   Media I/O: 
--     ZLib:                        build (ver )
-- 
--   Video I/O:
--     DC1394:                      NO
-- 
--   Parallel framework:            OpenMP
-- 
--   Other third-party libraries:
--     VA:                          NO
--     Lapack:                      NO
--     Custom HAL:                  NO
-- 
--   Python (for build):            /usr/bin/python3
-- 
--   Install to:                    /home/wangzhi/opencv-mobile-19/opencv-4.8.0/build/install
-- -----------------------------------------------------------------
-- 
-- Configuring done
-- Generating done
-- Build files have been written to: /home/wangzhi/opencv-mobile-19/opencv-4.8.0/build

编译日志如上,请帮忙看下是哪里的问题呢?

An example of O3 optimization that cause segfault

Code

example.cpp

#include <opencv2/core.hpp>
#include <vector>
 
using namespace cv;
using namespace std;
 
int main()
{
    Mat im(176, 176, CV_8U);
    vector<uint8_t> buf(sizeof(void*) * im.rows + 1);
    const uint8_t** rowTab = (const uint8_t**) (buf.data() + 1);
    for (int y = 0; y < im.rows; ++y) // 这里 gcc 会自动做SSE2优化,因指针的指针不是16字条对齐,导致crash
        rowTab[y] = im.ptr(y);
}

Test Environment

OpenCV: tag 4.5.1
System: Linux x64, ubuntu 16.04
Compiler: GCC 5.5.0

│gcc (Ubuntu 5.5.0-12ubuntu1~16.04) 5.5.0 20171010
│Copyright (C) 2015 Free Software Foundation, Inc.
│This is free software; see the source for copying conditions.  There is NO
│warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Compile options for opencv:
edit cmake/OpenCVCompilerDefenses.cmake, scroll to last lines, comment them out the replacement of O3 to O2
image

Then compile opencv with these options:

cmake ../.. \                                     
    -DCMAKE_BUILD_TYPE=Release \                  
    -DCMAKE_INSTALL_PREFIX=./install \            
    -DBUILD_TESTS=OFF \                           
    -DBUILD_PERF_TESTS=OFF \                      
    -DWITH_CUDA=OFF \                             
    -DWITH_VTK=OFF \                              
    -DWITH_MATLAB=OFF \                           
    -DBUILD_DOCS=OFF \                            
    -DBUILD_opencv_python3=OFF \                  
    -DBUILD_opencv_python2=OFF \                  
    -DWITH_IPP=OFF \                              
    -DBUILD_LIST='core,imgcodecs,imgproc,highgui' 

Can not build project

I can not build project, Can you help me please? [
https://stackoverflow.com/questions/76658507/builde-open-cv-android

todo list

  • fix android cmake link libz
  • strip opencv2 libopencv_info
  • package ios fat library
  • ios bitcode
  • create release

cv::imdecode 接口读取jpg图片异常

imdecode 直接读取内存的jpg图片解析异常
但是把图片存入文件,用imread解析文件正常

#if 0
    std::vector<unsigned char> buff(jpg, jpg + len);
    // cv::Mat m = cv::imdecode(cv::Mat(buff), 1);
    cv::Mat m = cv::imdecode(buff, 1);
#else
    std::string filename("test.jpg");
    std::ofstream ofs(filename.c_str());
    ofs.write((const char*)jpg, len);
    ofs.close();
    cv::Mat m = cv::imread(filename.c_str(), 1);
    double meanValue = blurdetection(m);
    rsq["meanValue"] = meanValue;
#endif

opencv resize函数导致cpu占用率过高

nihui 大大,最近在搞项目的时候,用了你的 ncnnopencv-mobile ,大体是依据这个大佬的项目修改的,其他环境是

ncnn-20210720-android-vulkan
opencv-mobile-3.4.16-android

我在运行的时候发现 resize 函数cpu占用率特别高,处理器是骁龙865,手机是find x
image
后面我想自己编译一下是否也一样,就用了其他人编译好的应该是官方库,链接在这, 结果占用率直接降下来了,当然这过程也会有一个 ncnn 的编译问题,我是按照你在ncnn issue中的回答编译的, 我换完库后cpu占用立马下来了
image
所以 nihui 大大如果有时间可以看下 opencv-mobile 中的 resize 是否有问题,哈哈哈

大大,我刚又去测了一下,官方版本的 android 版本 3 和 4 都不会出现问题,所以可能是 opencv-mobile 库的问题

link error: many undefined references

Firstly, thank the awesome work you did.
I use the opencv-mobile-4.5.3-armlinux.zip in my project. When I build my project, the compiler gives:

/usr/lib/gcc-cross/aarch64-linux-gnu/8/../../../../aarch64-linux-gnu/bin/ld: smooth.dispatch.cpp:(.text._ZN2cv12GaussianBlurERKNS_11_InputArrayERKNS_12_OutputArrayENS_5Size_IiEEddi+0xa5c): undefined reference to `cv::softdouble::operator==(cv::softdouble const&) const'
/usr/lib/gcc-cross/aarch64-linux-gnu/8/../../../../aarch64-linux-gnu/bin/ld: smooth.dispatch.cpp:(.text._ZN2cv12GaussianBlurERKNS_11_InputArrayERKNS_12_OutputArrayENS_5Size_IiEEddi+0xab4): undefined reference to `cv::softdouble::operator+(cv::softdouble const&) const'
/usr/lib/gcc-cross/aarch64-linux-gnu/8/../../../../aarch64-linux-gnu/bin/ld: smooth.dispatch.cpp:(.text._ZN2cv12GaussianBlurERKNS_11_InputArrayERKNS_12_OutputArrayENS_5Size_IiEEddi+0xae4): undefined reference to `cv::softdouble::operator==(cv::softdouble const&) const'
/usr/lib/gcc-cross/aarch64-linux-gnu/8/../../../../aarch64-linux-gnu/bin/ld: smooth.dispatch.cpp:(.text._ZN2cv12GaussianBlurERKNS_11_InputArrayERKNS_12_OutputArrayENS_5Size_IiEEddi+0xf0c): undefined reference to `cv::softdouble::operator+(cv::softdouble const&) const'
/usr/lib/gcc-cross/aarch64-linux-gnu/8/../../../../aarch64-linux-gnu/bin/ld: smooth.dispatch.cpp:(.text._ZN2cv12GaussianBlurERKNS_11_InputArrayERKNS_12_OutputArrayENS_5Size_IiEEddi+0xf3c): undefined reference to `cv::softdouble::operator==(cv::softdouble const&) const'
/usr/lib/gcc-cross/aarch64-linux-gnu/8/../../../../aarch64-linux-gnu/bin/ld: smooth.dispatch.cpp:(.text._ZN2cv12GaussianBlurERKNS_11_InputArrayERKNS_12_OutputArrayENS_5Size_IiEEddi+0xf94): undefined reference to `cv::softdouble::operator+(cv::softdouble const&) const'
/usr/lib/gcc-cross/aarch64-linux-gnu/8/../../../../aarch64-linux-gnu/bin/ld: smooth.dispatch.cpp:(.text._ZN2cv12GaussianBlurERKNS_11_InputArrayERKNS_12_OutputArrayENS_5Size_IiEEddi+0xfc4): undefined reference to `cv::softdouble::operator==(cv::softdouble const&) const'
/usr/lib/gcc-cross/aarch64-linux-gnu/8/../../../../aarch64-linux-gnu/bin/ld: /root/work_space/codes/accv/download/arm/opencv-mobile-4.5.3-armlinux/aarch64-linux-gnu/lib/libopencv_core.a(check.cpp.o): in function `cv::detail::check_failed_MatDepth(int, int, cv::detail::CheckContext const&)':
check.cpp:(.text._ZN2cv6detail21check_failed_MatDepthEiiRKNS0_12CheckContextE+0x40): undefined reference to `std::__cxx11::basic_stringstream<char, std::char_traits<char>, std::allocator<char> >::basic_stringstream()'

How to fix it?
my compiler information:

aarch64-linux-gnu-g++ --version
aarch64-linux-gnu-g++ (Debian 8.3.0-2) 8.3.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
aarch64-linux-gnu-gcc --version
aarch64-linux-gnu-gcc (Debian 8.3.0-2) 8.3.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Look forward for reply. 😊😊😊😊

rk3588 调用opencv4存在问题,阿辉姑娘

mpp解码cmakelists.txt

cmake_minimum_required(VERSION 2.8)

project(h264_mpp_yuv)
set(CMAKE_CXX_FLAGS "-std=c++11 ")

#find_package(OpenCV REQUIRED)
#include_directories(${OpenCV_INCLUDE_DIRS})
#MESSAGE(STATUS "OpenCV_DIR: ${OpenCV_DIR}")
#MESSAGE(STATUS "OpenCV_LIBS: ${OpenCV_LIBS}")
#MESSAGE(STATUS "OpenCV_VERSION: ${OpenCV_VERSION}")
#MESSAGE(STATUS "OpenCV_INSTALL_PATH: ${OpenCV_INSTALL_PATH}")
#MESSAGE(STATUS "OpenCV_INCLUDE_DIRS: ${OpenCV_INCLUDE_DIRS}")
set(OpenCV_DIR ${CMAKE_SOURCE_DIR}/opencv-mobile-4.6.0-armlinux/aarch64-linux-gnu/lib/cmake/opencv4)
find_package(OpenCV REQUIRED)

include_directories(${CMAKE_SOURCE_DIR}/include)
aux_source_directory(./mpp SRC_LIST) # 搜索当前目录下的所有.cpp文件,存储在变量SRC_LIST中
add_executable(h264_mpp_yuv main.cpp ${SRC_LIST})
target_link_libraries(h264_mpp_yuv rockchip_mpp drm ${OpenCV_LIBS})

报错结果

| ^
[100%] Linking CXX executable h264_mpp_yuv
/usr/bin/ld: ../opencv-mobile-4.6.0-armlinux/aarch64-linux-gnu/lib/libopencv_core.a(matrix_wrap.cpp.o): in function cv::_InputArray::getOGlBuffer() const': matrix_wrap.cpp:(.text._ZNK2cv11_InputArray12getOGlBufferEv+0x44): undefined reference to __libc_single_threaded'
/usr/bin/ld: matrix_wrap.cpp:(.text._ZNK2cv11_InputArray12getOGlBufferEv+0x48): undefined reference to __libc_single_threaded' /usr/bin/ld: ../opencv-mobile-4.6.0-armlinux/aarch64-linux-gnu/lib/libopencv_core.a(system.cpp.o): in function cv::TLSDatacv::CoreTLSData::deleteDataInstance(void*) const':
system.cpp:(.text._ZNK2cv7TLSDataINS_11CoreTLSDataEE18deleteDataInstanceEPv[_ZNK2cv7TLSDataINS_11CoreTLSDataEE18deleteDataInstanceEPv]+0x1c): undefined reference to __libc_single_threaded' /usr/bin/ld: system.cpp:(.text._ZNK2cv7TLSDataINS_11CoreTLSDataEE18deleteDataInstanceEPv[_ZNK2cv7TLSDataINS_11CoreTLSDataEE18deleteDataInstanceEPv]+0x20): undefined reference to __libc_single_threaded'
/usr/bin/ld: system.cpp:(.text._ZNK2cv7TLSDataINS_11CoreTLSDataEE18deleteDataInstanceEPv[_ZNK2cv7TLSDataINS_11CoreTLSDataEE18deleteDataInstanceEPv]+0x70): undefined reference to __libc_single_threaded' /usr/bin/ld: ../opencv-mobile-4.6.0-armlinux/aarch64-linux-gnu/lib/libopencv_core.a(system.cpp.o):system.cpp:(.text._ZN2cv7TLSDataINS_11CoreTLSDataEED2Ev[_ZN2cv7TLSDataINS_11CoreTLSDataEED5Ev]+0x138): more undefined references to __libc_single_threaded' follow
/usr/bin/ld: ../opencv-mobile-4.6.0-armlinux/aarch64-linux-gnu/lib/libopencv_core.a(system.cpp.o): in function `cv::utils::getConfigurationParameterPaths(char const*, std::vector<std::__cxx11::basic_string<char, std::char_traits, std::alloc

低版本测试通过
cmake_minimum_required(VERSION 2.8)

project(h264_mpp_yuv)
set(CMAKE_CXX_FLAGS "-std=c++11 ")

#find_package(OpenCV REQUIRED)
#include_directories(${OpenCV_INCLUDE_DIRS})
#MESSAGE(STATUS "OpenCV_DIR: ${OpenCV_DIR}")
#MESSAGE(STATUS "OpenCV_LIBS: ${OpenCV_LIBS}")
#MESSAGE(STATUS "OpenCV_VERSION: ${OpenCV_VERSION}")
#MESSAGE(STATUS "OpenCV_INSTALL_PATH: ${OpenCV_INSTALL_PATH}")
#MESSAGE(STATUS "OpenCV_INCLUDE_DIRS: ${OpenCV_INCLUDE_DIRS}")
set(OpenCV_DIR ${CMAKE_SOURCE_DIR}/opencv-mobile-3.4.18-armlinux/aarch64-linux-gnu/lib/cmake/opencv4)
find_package(OpenCV REQUIRED)

include_directories(${CMAKE_SOURCE_DIR}/include)
aux_source_directory(./mpp SRC_LIST) # 搜索当前目录下的所有.cpp文件,存储在变量SRC_LIST中
add_executable(h264_mpp_yuv main.cpp ${SRC_LIST})
target_link_libraries(h264_mpp_yuv rockchip_mpp drm ${OpenCV_LIBS} )

vs2019 x64 failed to use prebuilt package

Description

基于 cmake 的 vs2019 x64 工程, 使用 opencv-mobile 预编译包 opencv-mobile-4.5.4-windows-vs2019.zip, 报错提示 opencv 版本呢不兼容。

Error Message

-- Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.19042.
-- The C compiler identification is MSVC 19.29.30138.0
-- The CXX compiler identification is MSVC 19.29.30138.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- OpenCV ARCH: x64
-- OpenCV RUNTIME: vc14
-- OpenCV STATIC: OFF
CMake Warning at D:/artifacts/opencv-mobile/4.5.4/opencv-mobile-4.5.4-windows-vs2019/x64/OpenCVConfig.cmake:190 (message):
  Found OpenCV Windows Pack but it has no binaries compatible with your
  configuration.

  You should manually point CMake variable OpenCV_DIR to your build of OpenCV
  library.
Call Stack (most recent call first):
  CMakeLists.txt:6 (find_package)


CMake Error at CMakeLists.txt:6 (find_package):
  Found package configuration file:

    D:/artifacts/opencv-mobile/4.5.4/opencv-mobile-4.5.4-windows-vs2019/x64/OpenCVConfig.cmake

  but it set OpenCV_FOUND to FALSE so package "OpenCV" is considered to be
  NOT FOUND.


-- Configuring incomplete, errors occurred!
See also "D:/test/build/vs2019-x64/CMakeFiles/CMakeOutput.log".
请按任意键继续. . .

Reproduce

CMakeLists.txt:

cmake_minimum_required(VERSION 3.20)
project(hello)
set(CMAKE_CXX_STANDARD 11)

set(OpenCV_DIR "D:/artifacts/opencv-mobile/4.5.4/opencv-mobile-4.5.4-windows-vs2019/x64")
find_package(OpenCV REQUIRED)

add_executable(hello main.cpp)
target_link_libraries(hello ${OpenCV_LIBS})

Full package:
test.zip

Visual Studio Version

Microsoft Visual Studio Community 2019
版本 16.11.8

libhighgui.a was not linked in the CMake project

Hi,
I was able to use some OpenCV functions in my CMake project after I followed the "How-to-build your custom package" steps in README.md. However, problems occurs when I used cv::cvtColor(...).

main.cpp:(.text+0xd0): undefined reference to `cv::imread(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)'

I printed out the make command by executing make VERBOSE=1 and realized libopencv_highgui.a was not included in the g++ command

/usr/local/linaro-aarch64-2018.08-gcc8.2/bin//aarch64-linux-gnu-g++     CMakeFiles/hello_audrey.dir/main.cpp.o  -o hello_audrey -Wl,-rpath,/host/sutony/tmp/opencv/build libalign.so /host/sutony/git/opencv-mobile/opencv-4.5.3/build/install/lib/libopencv_calib3d.a /host/sutony/git/opencv-mobile/opencv-4.5.3/build/install/lib/libopencv_core.a /host/sutony/git/opencv-mobile/opencv-4.5.3/build/install/lib/libopencv_features2d.a /host/sutony/git/opencv-mobile/opencv-4.5.3/build/install/lib/libopencv_flann.a /host/sutony/git/opencv-mobile/opencv-4.5.3/build/install/lib/libopencv_imgproc.a /host/sutony/git/opencv-mobile/opencv-4.5.3/build/install/lib/libopencv_core.a -ldl -lm -lpthread -lrt /host/sutony/AMB/linaro-aarch64-2018.08-gcc8.2/aarch64-linux-gnu/libc/usr/lib/libgomp.so /host/sutony/AMB/linaro-aarch64-2018.08-gcc8.2/aarch64-linux-gnu/libc/usr/lib/libpthread.so 

If I manually added libopencv_highgui.a to the g++ command or added it to the CMakeList, it works.

find_package(OpenMP REQUIRED)
set(OpenCV_DIR /path/to/opencv-4.5.3/build/install/lib/cmake/opencv4)
find_package(OpenCV REQUIRED)

add_executable(main main.cpp)
target_link_libraries(main /path/to/opencv-4.5.3/build/install/lib/libopencv_highgui.a ${OpenCV_LIBS} OpenMP::OpenMP_CXX )

I think it would be better to change something in opencv-4.5.3/build/install/lib/cmake/opencv4 to make libopencv_highgui.a linked automatically, but it is beyond my ability. Could you help? Thanks.

【文档】自己编译 ARM 版 opencv-mobile 解决编译器版本导致的 `undefined reference to std::__cxx11::basic_stringstream` 问题

起因

因项目需要在 arm 中进行简单的图形运算,于是打算直接用 opencv-mobile 仓库预编译好的 opencv-mobile-4.5.4-armlinux.zip。但果然因为生产环境依赖的编译器版本太旧,在编译过程遇到了因为 ABI 接口导致的错误:

undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)
undefined reference to `std::__cxx11::basic_stringstream<char, std::char_traits<char>, std::allocator<char> > const&)
...

尝试直接使用 -D _GLIBCXX_USE_CXX11_ABI=0,无效
搜索一圈无果,(#20 #25 #27)

于是决定自己编译一遍,解决问题,顺便编写这个文档,方便后人查阅。

最后的运行结果

image-20220518154610943

具体步骤

很抱歉我把文档发到了博客,目的是骗点点击量,希望大家不要介意:

https://www.cnblogs.com/singlex/p/16285234.html

最后在末尾推荐使用,PRemoteM 来打开 SSH、SFTP、RDP 远程会话。

imwrite function save one image 4 times, color space changed

Hi nihui, when i save one image 4 times like this. And i found the plate2.jpg and plate4.jpg color space has changed.

opencv-mobile version:
1.opencv-mobile-4.6.0-ubuntu-1804
2.opencv-mobile-3.4.18-ubuntu-1804

cv::Mat temp = cv::imread("plate.jpg");
cv::imwrite("./plate1.jpg",temp);
cv::imwrite("./plate2.jpg",temp);
cv::imwrite("./plate3.jpg",temp);
cv::imwrite("./plate4.jpg",temp);

plate1
plate2
plate3
plate4

'opencv2/opencv.hpp' file not found

Xcode Version 12.4
Framework source in use : https://opencv.org/releases/
It works correctly

I wanted to use a lightweight framework, so I tried to replace it.

  • opencv-mobile-3.4.13-ios-bitcode
  • opencv-mobile-4.5.1-ios-bitcode

error : 'opencv2/opencv.hpp' file not found

No settings have changed from working correctly. Just changed the framework

Error: ld: error: undefined symbol: omp_get_max_threads

ERROR Messgage:

ld: error: undefined symbol: omp_get_max_threads

referenced by parallel.cpp
parallel.cpp.o:(_GLOBAL__sub_I_parallel.cpp) in archive F:/work/TestOpenCVMobile/app/main/jni/opencv-mobile-4.6.0-android/sdk/native/staticlibs/arm64-v8abopencv_core.a

I do a opencv-mobile demo followed the instruction of

https://github.com/nihui/opencv-mobile#usage-android

but got above error .

I think it may loss the dependency of openmp . I don't know if it is a bug .


I add ncnn and pass the build , may due to the openmp is contained by ncnn .

Request for providing dynamic libraries 请求提供动态库版本

Hello, @nihui,

First off, thank you for providing this streamlined version of OpenCV. It's a very useful resource for many developers.

In examining your binary packages, I noticed there are no dynamic library versions included. In many scenarios, especially when trying to develop with other programming languages, dynamic libraries can be immensely useful. Therefore, I would like to kindly request that, if possible, you include a version with dynamic libraries in your binary packages?

Such an improvement would make it more convenient for developers using other programming languages to take advantage of your project.

Thank you again for your contributions, I look forward to your response.

Best regards

首先,感谢您为开源社区提供这个精简的 OpenCV 项目,它对于许多开发者来说是一个非常有用的资源。

我在研究您的二进制包时,发现其中并未包含动态库版本。在许多情况下,特别是在尝试使用其他编程语言进行开发时,动态库通常会非常有用。因此,我想请求您,如果可能的话,能否在发布的二进制包中包含一个动态库版本?

这样的改进将使得使用其他编程语言的开发者也能方便地使用您的项目。

再次感谢您的贡献,期待您的回复。

QRCode

Why is not included the module to decode the QRCode? It's classic mobile thing

up up up 我遇到一个问题和一个疑问

疑问一:描述
我是用您编译的ubuntu20.04的opencv库,我使用您github描述使用方式是没问题,但是我想要改变您所提供opencv使用库目录话,
比如我的结构如 会报错,
image

所以我需要独立的修改config.make的一些链接路径,但是我想问的是能在CMakelist.txt中修改某些变量让它生效,而不动config.make等一系列文件,自动去定位我要使用的头文件和库目录路径呢?目前我暂且搞成了静态库调用的方式~
问题二:描述
我在rk3399 pro 使用opencv-mobile库,貌似出现问题了 (gcc version 7.5.0 (Ubuntu/Linaro 7.5.0-3ubuntu1~18.04)) 怀疑gcc编译版本不匹配
搜了一圈 需要在我每个代码文件中添加 #define _GLIBCXX_USE_CXX11_ABI 0/1去适应您的库 然而 仍然无法使用 (使用的库为opencv-mobile-4.5.4-armlinux/aarch64-linux-gnu)
image

1638251647665_C4F69FFE-A6E7-4506-9599-FB39A82E2E43

image


cmakelsit.txt文件部分内容(ubuntu20.04 gcc-9.3 &rk3399 pro-18.04-gcc7)

cmake_minimum_required(VERSION 3.10)
project(controlslide)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -fopenmp -w")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -fopenmp -w")
set(CMAKE_CXX_STANDARD 11)

include_directories(${CMAKE_SOURCE_DIR}/include)
include_directories(${CMAKE_SOURCE_DIR}/include/common)
include_directories(${CMAKE_SOURCE_DIR}/include/ncnn)
include_directories(${CMAKE_SOURCE_DIR}/include/opencv4)

if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64") # rk3399
message(${CMAKE_SYSTEM_PROCESSOR})
set(TARGET_ARCH aarch64)
elseif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64") # ubuntu
message(${CMAKE_SYSTEM_PROCESSOR})
set(TARGET_ARCH x86_64)
endif()

add_library(libopencv_core STATIC IMPORTED)
set_target_properties(libopencv_core PROPERTIES IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/lib/libopencv/${TARGET_ARCH}/libopencv_core.a)

add_library(libopencv_features2d STATIC IMPORTED)
set_target_properties(libopencv_features2d PROPERTIES IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/lib/libopencv/${TARGET_ARCH}/libopencv_features2d.a)

add_library(libopencv_highgui STATIC IMPORTED)
set_target_properties(libopencv_highgui PROPERTIES IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/lib/libopencv/${TARGET_ARCH}/libopencv_highgui.a)

add_library(libopencv_imgproc STATIC IMPORTED)
set_target_properties(libopencv_imgproc PROPERTIES IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/lib/libopencv/${TARGET_ARCH}/libopencv_imgproc.a)

add_library(libopencv_photo STATIC IMPORTED)
set_target_properties(libopencv_photo PROPERTIES IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/lib/libopencv/${TARGET_ARCH}/libopencv_photo.a)

add_library(libtengine-lite-static STATIC IMPORTED)
set_target_properties(libtengine-lite-static PROPERTIES IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/lib/libtengine/${TARGET_ARCH}/libtengine-lite-static.a)

add_library(libncnn-static STATIC IMPORTED)
set_target_properties(libncnn-static PROPERTIES IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/lib/libncnn/${TARGET_ARCH}/libncnn.a)

option(DEBUG "Set to switch to build use DEBUG" ON)
if (DEBUG)
add_definitions(-DDEBUG) # 宏定义 USE_SEE
message(STATUS "Use DEBUG")
else()
message(STATUS "Use Nothing")
endif()

add_executable(controlslide main.cpp ControlSlide.cpp)

target_link_libraries(controlslide
libtengine-lite-static
libncnn-static
libopencv_highgui
libopencv_imgproc
libopencv_features2d
libopencv_photo
libopencv_core #务必放在最后sxj731533730
-ldl
)

missing or invalid CFBundleExecutable in Info.plist

Hey! I'm trying to integrate this framework into an iOS project and I made some progress (dropped the framework into the project, made sure the build things are alright...). When I tried to build the app in the simulator, I got an error about a non-existing info.plist, so I created on and put this content to it:
<key>CFBundleExecutable</key> <string>opencv2</string> <key>CFBundleShortVersionString</key> <string>__VERSION__</string> <key>CFBundleVersion</key> <string>__VERSION__</string> <key>CFBundleIdentifier</key> <string>__IDENTIFIER__</string> <key>CFBundleName</key> <string>__NAME__</string>
However now I get this error: ...Frameworks/opencv2.framework has missing or invalid CFBundleExecutable in its Info.plist
I would really appreciated any help and thanks in advance!

${OPENCV_LIBS}是空的!

NDK version: 25.2.9519653
android sdk: compileSdk 33
minSdk 24
targetSdk 33

cmake_minimum_required(VERSION 3.22.1)

project("test_opencv_mobile")

set(OpenCV_DIR ${CMAKE_SOURCE_DIR}/opencv-mobile-4.6.0-android/sdk/native/jni)
find_package(OpenCV REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})

add_library(test_opencv_mobile SHARED
        native-lib.cpp)

target_link_libraries(test_opencv_mobile
        ${OPENCV_LIBS})

结果:一堆undefined symbole

zip warning: name not matched install

While trying to make my own custom package following the instructions and running the last command zip -r -9 opencv-mobile-4.6.0.zip install I get:

zip warning: name not matched: install

zip error: Nothing to do! (try: zip -r -9 opencv-mobile-4.6.0.zip . -i install)

I have not been able to get it to run also trying the suggested command that was in the error.

(the reason I want to make my own custom package is because the iOS opencv.framework does not include the arm64 slice for simulators which I wanted to add myself.)

几个undefined reference to

  1. 使用libopencv_imgproc.a编译时,resize报错:
opencv-mobile-4.5.1-android/sdk/native/staticlibs/arm64-v8a/libopencv_imgproc.a(resize.cpp.o): In function `(anonymous namespace)::interpolationLinear<short>::getCoeffs(int, int*, (anonymous namespace)::fixedpoint32*)':
resize.cpp:(.text._ZN12_GLOBAL__N_119interpolationLinearIsE9getCoeffsEiPiPNS_12fixedpoint32E+0x38): undefined reference to `cv::softdouble::softdouble(int)'
resize.cpp:(.text._ZN12_GLOBAL__N_119interpolationLinearIsE9getCoeffsEiPiPNS_12fixedpoint32E+0x50): undefined reference to `cv::softdouble::operator+(cv::softdouble const&) const'
resize.cpp:(.text._ZN12_GLOBAL__N_119interpolationLinearIsE9getCoeffsEiPiPNS_12fixedpoint32E+0x60): undefined reference to `cv::softdouble::operator*(cv::softdouble const&) const'
resize.cpp:(.text._ZN12_GLOBAL__N_119interpolationLinearIsE9getCoeffsEiPiPNS_12fixedpoint32E+0x74): undefined reference to `cv::softdouble::operator-(cv::softdouble const&) const'
resize.cpp:(.text._ZN12_GLOBAL__N_119interpolationLinearIsE9getCoeffsEiPiPNS_12fixedpoint32E+0x7c): undefined reference to `cvFloor(cv::softdouble const&)'
resize.cpp:(.text._ZN12_GLOBAL__N_119interpolationLinearIsE9getCoeffsEiPiPNS_12fixedpoint32E+0xa8): undefined reference to `cv::softdouble::softdouble(int)'
resize.cpp:(.text._ZN12_GLOBAL__N_119interpolationLinearIsE9getCoeffsEiPiPNS_12fixedpoint32E+0xb8): undefined reference to `cv::softdouble::operator-(cv::softdouble const&) const'
resize.cpp:(.text._ZN12_GLOBAL__N_119interpolationLinearIsE9getCoeffsEiPiPNS_12fixedpoint32E+0xc8): undefined reference to `cv::softdouble::softdouble(int)'
resize.cpp:(.text._ZN12_GLOBAL__N_119interpolationLinearIsE9getCoeffsEiPiPNS_12fixedpoint32E+0xd8): undefined reference to `cv::softdouble::operator*(cv::softdouble const&) const'
resize.cpp:(.text._ZN12_GLOBAL__N_119interpolationLinearIsE9getCoeffsEiPiPNS_12fixedpoint32E+0xe0): undefined reference to `cvRound(cv::softdouble const&)'
/home/arsen/work/MIProjects/inpaint_beblid_opencv/jni/dependency/opencv-mobile-4.5.1-android/sdk/native/staticlibs/arm64-v8a/libopencv_imgproc.a(resize.cpp.o): In function `(anonymous namespace)::interpolationLinear<int>::getCoeffs(int, int*, (anonymous namespace)::fixedpoint64*)':
resize.cpp:(.text._ZN12_GLOBAL__N_119interpolationLinearIiE9getCoeffsEiPiPNS_12fixedpoint64E+0x38): undefined reference to `cv::softdouble::softdouble(int)'
resize.cpp:(.text._ZN12_GLOBAL__N_119interpolationLinearIiE9getCoeffsEiPiPNS_12fixedpoint64E+0x50): undefined reference to `cv::softdouble::operator+(cv::softdouble const&) const'
resize.cpp:(.text._ZN12_GLOBAL__N_119interpolationLinearIiE9getCoeffsEiPiPNS_12fixedpoint64E+0x60): undefined reference to `cv::softdouble::operator*(cv::softdouble const&) const'
resize.cpp:(.text._ZN12_GLOBAL__N_119interpolationLinearIiE9getCoeffsEiPiPNS_12fixedpoint64E+0x74): undefined reference to `cv::softdouble::operator-(cv::softdouble const&) const'
resize.cpp:(.text._ZN12_GLOBAL__N_119interpolationLinearIiE9getCoeffsEiPiPNS_12fixedpoint64E+0x7c): undefined reference to `cvFloor(cv::softdouble const&)'
resize.cpp:(.text._ZN12_GLOBAL__N_119interpolationLinearIiE9getCoeffsEiPiPNS_12fixedpoint64E+0xa8): undefined reference to `cv::softdouble::softdouble(int)'
resize.cpp:(.text._ZN12_GLOBAL__N_119interpolationLinearIiE9getCoeffsEiPiPNS_12fixedpoint64E+0xb8): undefined reference to `cv::softdouble::operator-(cv::softdouble const&) const'
resize.cpp:(.text._ZN12_GLOBAL__N_119interpolationLinearIiE9getCoeffsEiPiPNS_12fixedpoint64E+0xc8): undefined reference to `cv::softdouble::softdouble(long)'
resize.cpp:(.text._ZN12_GLOBAL__N_119interpolationLinearIiE9getCoeffsEiPiPNS_12fixedpoint64E+0xd8): undefined reference to `cv::softdouble::operator*(cv::softdouble const&) const'
resize.cpp:(.text._ZN12_GLOBAL__N_119interpolationLinearIiE9getCoeffsEiPiPNS_12fixedpoint64E+0xe0): undefined reference to `cvRound64(cv::softdouble const&)'
  1. 使用libopencv_core.a编译时,报错:
opencv-mobile-4.5.1-android/sdk/native/staticlibs/arm64-v8a/libopencv_core.a(parallel.cpp.o): In function `.omp_outlined.':
parallel.cpp:(.text..omp_outlined.+0x6c): undefined reference to `__kmpc_dispatch_init_4'
parallel.cpp:(.text..omp_outlined.+0x88): undefined reference to `__kmpc_dispatch_next_4'
parallel.cpp:(.text..omp_outlined.+0xb4): undefined reference to `__kmpc_dispatch_next_4'

opencv-mobile-4.5.1-android/sdk/native/staticlibs/arm64-v8a/libopencv_core.a(system.cpp.o): In function `cv::HWFeatures::initialize()':
system.cpp:(.text._ZN2cv10HWFeatures10initializeEv[_ZN2cv10HWFeatures10initializeEv]+0x2bc): undefined reference to `stderr'
system.cpp:(.text._ZN2cv10HWFeatures10initializeEv[_ZN2cv10HWFeatures10initializeEv]+0x2c0): undefined reference to `stderr'

@nihui

Error occurs in Android Studio Native C++ [Solved]

I'm trying to use the opencv-mobile in Native C++ project, but got this error :

CMake Warning at opencv-mobile-4.6.0-android/sdk/native/jni/abi-arm64-v8a/OpenCVConfig.cmake:105 (message):
  Minimum required by OpenCV API level is android-24
Call Stack (most recent call first):
  opencv-mobile-4.6.0-android/sdk/native/jni/OpenCVConfig.cmake:44 (include)
  CMakeLists.txt:6 (find_package)


CMake Error at CMakeLists.txt:6 (find_package):
  Found package configuration file:

    D:/DAVID/AndroidStudioProjects/MyJNI/app/src/main/jni/opencv-mobile-4.6.0-android/sdk/native/jni/OpenCVConfig.cmake

  but it set OpenCV_FOUND to FALSE so package "OpenCV" is considered to be
  NOT FOUND.

opencv-mobile-4.5.3 在Android jni 里使用 cv::cvtColor(roi, roi, cv::COLOR_BGR2GRAY),app崩溃

E/cv::error(): OpenCV(4.5.3) Error: Requested object was not found (could not open directory: /data/app/com.tencent.ncnnyolox-ZEvyprlUzrPIBsQ8ClaFTw==/base.apk!/lib/arm64-v8a) in glob_rec, file /home/runner/work/opencv-mobile/opencv-mobile/opencv-4.5.3/modules/core/src/glob.cpp, line 273 A/libc: Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0 in tid 10749 (ImageReader-640), pid 10701 (ncent.ncnnyolox)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.