在Android 5.0(棒棒糖)上使用OpenCV for Android的问题

rkd*_*ari 3 android opencv android-5.0-lollipop

首先,没有一个OpenCV示例适用于Nexus 6 Android 5.0.在OpenCV管理器安装提示之后,我得到一个显示"找不到项目,重试"的屏幕.我后来设置了android studio并导入了opencv模块并编写了一个初始化OpenCV的基本程序.该应用程序崩溃抛出了这篇文章中提到的错误:OpenCV Service Intent必须是显式的,Android 5.0 Lolipop.按照建议后,我得到了下载OpenCV管理器的提示并成功安装了OpenCV管理器.但是当我返回应用程序时,我发现它无法获得库路径.logcat反复显示这些消息 -

 W/ContextImpl? Implicit intents with startService are not safe: Intent { act=org.opencv.engine.BIND } android.content.ContextWrapper.bindService:538 org.opencv.android.AsyncServiceHelper.initOpenCV:24 org.opencv.android.OpenCVLoader.initAsync:44
 D/OpenCVManager/Helper? Service connection created
 D/OpenCVManager/Helper? Trying to get library path
 W/ContextImpl? Implicit intents with startService are not safe: Intent { act=org.opencv.engine.BIND } android.content.ContextWrapper.bindService:538 org.opencv.android.AsyncServiceHelper.initOpenCV:24 org.opencv.android.OpenCVLoader.initAsync:44
 D/OpenCVManager/Helper? Service connection created
 D/OpenCVManager/Helper? Trying to get library path
Run Code Online (Sandbox Code Playgroud)

我如何克服这个问题并开始在Lollipop上使用OpenCV for Android?

Pli*_*ira 5

我看到的最好的解决方法是AsyncServiceHelper在他们不提交正式修复时自己更新OpenCV .

你只需要添加一行.这很简单.

查找initOpenCV函数并将其更改为:

public static boolean initOpenCV(String Version, final Context AppContext,
    final LoaderCallbackInterface Callback) {
    AsyncServiceHelper helper = new AsyncServiceHelper(Version, AppContext,
            Callback);
    Intent intent = new Intent("org.opencv.engine.BIND");
    intent.setPackage("org.opencv.engine");
    if (AppContext.bindService(intent, helper.mServiceConnection,
            Context.BIND_AUTO_CREATE)) {
        return true;
    } else {
        AppContext.unbindService(helper.mServiceConnection);
        InstallService(AppContext, Callback);
        return false;
    }
}
Run Code Online (Sandbox Code Playgroud)

希望能有所帮助.