【问题标题】:Issue with OpenCV for Android on Android 5.0 (lollipop)Android 5.0 上的 OpenCV for Android 问题(棒棒糖)
【发布时间】:2015-03-07 00:13:20
【问题描述】:

首先,OpenCV 示例都不能在 Nexus 6 Android 5.0 上运行。在 OpenCV 管理器安装提示后,我看到一个屏幕显示“未找到项目,重试”。后来我设置了android studio并导入了opencv模块并编写了一个初始化OpenCV的基本程序。该应用程序崩溃并抛出这篇文章中提到的错误:OpenCV Service Intent must be explicit, 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

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

【问题讨论】:

    标签: android opencv android-5.0-lollipop


    【解决方案1】:

    我看到的最好的解决方法是自己更新 OpenCV 的 AsyncServiceHelper,而他们没有提交官方修复。

    您只需添加一行。很简单。

    寻找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;
        }
    }
    

    希望能提供帮助。

    【讨论】:

      【解决方案2】:

      我找到了一个临时解决方案。我调试了“AsyncServiceHelper”类。无法在

      处获取路径
      String path = mEngineService.getLibPathByVersion(mOpenCVersion); 
      

      所以,我像下面这样硬编码了路径字符串,我的 Nexus 6 现在可以运行我使用 OpenCV 的程序了

      String path = "/data/data/org.opencv.engine/lib";
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2016-11-22
        • 2015-06-21
        • 1970-01-01
        • 2015-02-21
        • 2016-02-28
        • 2016-02-11
        • 1970-01-01
        相关资源
        最近更新 更多