OpenCV Android 上的静态初始化

2022-01-18 00:00:00 opencv initialization static android java

我正在尝试运行 OpenCV 教程 1 - 使用 这个
我不想安装单独的 OpenCV 管理器应用程序)但我收到 OpenCV 错误:无法为 OpenCV 加载信息库."

我做了以下事情:

  1. 添加了一个 libs 文件夹,其中包含 armeabiarmeabi-v7ax86 文件夹(来自 OpenCV-2.4.2-android-sdk/sdk/native/libs/)

  2. 在私有 Sample1View mView 下方添加了静态 {if (!OpenCVLoader.initDebug())} 代码;

  3. 删除了以下代码

<块引用>

如果 (!OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_2, 这个,mOpenCVCallBack))

似乎是什么问题?

解决方案

你应该添加代码:

mOpenCVCallBack.onManagerConnected(LoaderCallbackInterface.SUCCESS);

之后:

if(!OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_2, this, mOpenCVCallBack))

如果你删除:

if(!OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_2, this, mOpenCVCallBack))

代码块然后没人调用.

希望对你有帮助.

i'm trying to run OpenCV Tutorial 1 - Add OpenCV with static initialization using this
i don't want a separate OpenCV Manager application installed) but i get an "OpenCV error: Cannot load info library for OpenCV."

I did the following things:

  1. added a libs folder with armeabi, armeabi-v7a, and x86 folders inside of it (from OpenCV-2.4.2-android-sdk/sdk/native/libs/)

  2. added the static {if (!OpenCVLoader.initDebug())} code just below private Sample1View mView;

  3. removed the below code

if (!OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_2, this, mOpenCVCallBack))

what seems to be the problem?

解决方案

You should add the code:

mOpenCVCallBack.onManagerConnected(LoaderCallbackInterface.SUCCESS);

after:

if(!OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_2, this, mOpenCVCallBack)) 

If you remove:

if(!OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_2, this, mOpenCVCallBack))  

code block then nobody calls.

Hope it can help you.

相关文章