1.下载opencv-4.7.0-android-sdk.zip,下载地址:https://opencv.org/releases/,解压后,如下图:
2.编辑opecv_android.pri,内容如下(可使用命令行命令-dir *.a/ON/B>v8a.txt):
message('Linux/Andoird is running!')
#data.files += images/*.*
#data.files += dnn/*.prototxt
#data.files += dnn/*.caffemodel
#data.path = /assets/dnn
#INSTALLS += data
# 0.指定应用程序二进制接口(Application Binary Interface)
ANDROID_CPU = arm64-v8a
# 1.定义 OPENCV_ANDROID 目录。
OPENCV_ANDROID = D:/MyProjects/Android/OpenCV/OpenCV-android-sdk/sdk/native
# 2.用来描述构建项目时应该搜索的 include 目录。
INCLUDEPATH += \
$$OPENCV_ANDROID/jni/include \
$$OPENCV_ANDROID/jni/include/opencv2 \
# 3.用来描述项目引用的库文件列表。
LIBS += $$OPENCV_ANDROID/libs/$$ANDROID_CPU/libopencv_java4.so
# OpenCV-android-sdk\sdk\native\staticlibs\$$ANDROID_CPU(15)
NATIVE_STATICLIBS = $$OPENCV_ANDROID/staticlibs/$$ANDROID_CPU
LIBS += \
$$NATIVE_STATICLIBS/libopencv_calib3d.a \
$$NATIVE_STATICLIBS/libopencv_core.a \
$$NATIVE_STATICLIBS/libopencv_dnn.a \
$$NATIVE_STATICLIBS/libopencv_features2d.a \
$$NATIVE_STATICLIBS/libopencv_flann.a \
$$NATIVE_STATICLIBS/libopencv_gapi.a \
$$NATIVE_STATICLIBS/libopencv_highgui.a \
$$NATIVE_STATICLIBS/libopencv_imgcodecs.a \
$$NATIVE_STATICLIBS/libopencv_imgproc.a \
$$NATIVE_STATICLIBS/libopencv_ml.a \
$$NATIVE_STATICLIBS/libopencv_objdetect.a \
$$NATIVE_STATICLIBS/libopencv_photo.a \
$$NATIVE_STATICLIBS/libopencv_stitching.a \
$$NATIVE_STATICLIBS/libopencv_video.a \
$$NATIVE_STATICLIBS/libopencv_videoio.a
# OpenCV-android-sdk\sdk\native\3rdparty\libs\$$ANDROID_CPU(13)
NATIVE_3RDPARTY = $$OPENCV_ANDROID/3rdparty/libs/$$ANDROID_CPU
LIBS += \
$$NATIVE_3RDPARTY/libade.a \
$$NATIVE_3RDPARTY/libcpufeatures.a \
$$NATIVE_3RDPARTY/libIlmImf.a \
$$NATIVE_3RDPARTY/libittnotify.a \
$$NATIVE_3RDPARTY/liblibjpeg-turbo.a \
$$NATIVE_3RDPARTY/liblibopenjp2.a \
$$NATIVE_3RDPARTY/liblibpng.a \
$$NATIVE_3RDPARTY/liblibprotobuf.a \
$$NATIVE_3RDPARTY/liblibtiff.a \
$$NATIVE_3RDPARTY/liblibwebp.a \
$$NATIVE_3RDPARTY/libquirc.a \
$$NATIVE_3RDPARTY/libtbb.a \
$$NATIVE_3RDPARTY/libtegra_hal.a
contains(ANDROID_TARGET_ARCH, $$ANDROID_CPU) {
ANDROID_EXTRA_LIBS = \
$$OPENCV_ANDROID/libs/$$ANDROID_CPU/libopencv_java4.so
}
3.在项目文件.pro中引入.pri文件
#Linux/Andoird操作系统
unix: !mac {
OPENCV = $$(OPENCV_QT)
isEmpty(OPENCV) {
error(OPENCV_QT does not exist!!!)
}
include($$(OPENCV_QT)opencv_android.pri)
}
#macOS操作系统
unix: mac {
message('macOS is running!')
INCLUDEPATH += /path/to/opencv/include/opencv4
LIBS += -L/path/to/opencv/lib -lopencv_world
}
#Windows操作系统(...,win8,win10...)的桌面应用程序
win32 {
OPENCV = $$(OPENCV_QT)
isEmpty(OPENCV) {
error(OPENCV_QT does not exist!!!)
}
include($$(OPENCV_QT)opencv_win32.pri)
}
4.正确配置后,.so库会添加到项目中:
5.参考网址:
http://www.taodudu.cc/news/show-4624975.html
https://blog.csdn.net/cqltbe131421/article/details/125011541
标签:3RDPARTY,Qt,OpenCV4.7,Windows11,libopencv,OPENCV,ANDROID,STATICLIBS,NATIVE From: https://www.cnblogs.com/zdt168/p/17287988.html