当前位置: 首页 > 知识库问答 >
问题:

OpenCV-原生Android集成

柯良骏
2023-03-14
LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)
OPENCV_CAMERA_MODULES:=on
OPENCV_INSTALL_MODULES:=on
include C:/Users/Piotr/Desktop/Android_App/MyApplication/libraries/opencv/native/jni/OpenCV.mk
LOCAL_SRC_FILES  := DetectionAndRecognition.cpp
LOCAL_C_INCLUDES := C:/Users/Piotr/Desktop/Android_App/MyApplication/libraries/opencv/native/jni/include
LOCAL_LDLIBS     += -llog -ldl

LOCAL_MODULE     := detection_and_recognition_lib

include $(BUILD_SHARED_LIBRARY)

问题是,如果我尝试编译项目,Android Studio会说:

错误:(2,33)opencv2/core/core.hpp:没有这样的文件或目录

为什么是?

共有1个答案

高正初
2023-03-14

这也困扰着我,尝试添加以下内容:

// begin
sourceSets.main {
    jni.srcDirs = [] //disable automatic ndk-build call
}
task ndkBuild(type: Exec, description: 'Compile JNI source via NDK') {
    commandLine "/your-library-folder/Android/sdk/ndk-bundle/ndk-build",
            'NDK_PROJECT_PATH=build/intermediates/ndk',
            'NDK_LIBS_OUT=src/main/jniLibs',
            'APP_BUILD_SCRIPT=src/main/jni/Android.mk',
            'NDK_APPLICATION_MK=src/main/jni/Application.mk'
}
tasks.withType(JavaCompile) {
    compileTask -> compileTask.dependsOn ndkBuild
}
//end

进入您的构建。gradle在您的Android Studio项目的app文件夹中

参考:https://github.com/quanhua92/ndk_opencv_androidstudio

 类似资料:
  • 我正在尝试对现有的android项目进行本地集成,但在android studio中构建项目时出现了以下异常。 原因:java.lang.Exception:React Native CLI无法确定Android项目配置。这可能是由于配置错误。配置输出:[root:/Users/muratoner/Desktop/backup/Sabanci.Projects/Mobile/hrweb-ract-

  • OpenCV for Android I've took OpenCV Library and exported it as .aar library. Now you can easily use OpenCV in a Gradle / Android Studio project. Usage Maven Repo I've uploaded the .aar in my maven rep

  • OpenCV Android 是一个将 OpenCV 移到 Android 手机平台的开源项目,该项目使用 OpenCV 最新的一个分支并利用一个改良过的 Android NDK 进行构建。

  • 每次我重新打开项目和模拟器时,我都必须在命令提示符中运行和吗? 谢谢。

  • 我正在尝试生成android apk用于反应原生。通过https://facebook.github.io/react-native/docs/signed-apk-android.html#content给出的文档 1)生成密钥库 2) 设置 gradle 变量 3)将签名配置添加到应用程序的 gradle 配置 # 4) 生成签名 apk 以通过 android studio 发布 (buil