Android 5.0(棒棒糖)上针对Android的OpenCV存在问题
首先,所有OpenCV示例都不能在Nexus6Android5.0上运行。在OpenCV管理器安装提示后,我得到一个屏幕,显示“未找到项目,重试”。后来我安装了android studio,导入了opencv模块,并编写了一个初始化opencv的基本程序。应用程序崩溃,引发本文中提到的错误:。在遵循这些建议之后,我得到了下载OpenCV管理器的提示,并成功安装了OpenCV管理器。但当我返回应用程序时,我看到它无法获取库路径。logcat反复显示这些消息-Android 5.0(棒棒糖)上针对Android的OpenCV存在问题,android,opencv,android-5.0-lollipop,Android,Opencv,Android 5.0 Lollipop,首先,所有OpenCV示例都不能在Nexus6Android5.0上运行。在OpenCV管理器安装提示后,我得到一个屏幕,显示“未找到项目,重试”。后来我安装了android studio,导入了opencv模块,并编写了一个初始化opencv的基本程序。应用程序崩溃,引发本文中提到的错误:。在遵循这些建议之后,我得到了下载OpenCV管理器的提示,并成功安装了OpenCV管理器。但当我返回应用程序时,我看到它无法获取库路径。logcat反复显示这些消息- W/ContextImpl﹕ Imp
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
我如何克服这个问题并开始在棒棒糖上为Android开发OpenCV?我找到了一个临时解决方案。我调试了“AsyncServiceHelper”类。无法在处获取路径
String path = mEngineService.getLibPathByVersion(mOpenCVersion);
因此,我硬编码了下面的路径字符串,我的Nexus6现在可以运行使用OpenCV的程序了
String path = "/data/data/org.opencv.engine/lib";
我看到的最好的解决方法是在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;
}
}
希望对你有所帮助