我们如何分叉 opencv-android 存储库并在自己的项目中使用它?

huangapple go评论81阅读模式
英文:

How can we fork opencv-android repo and use it in own project?

问题

我曾经在这个仓库 https://github.com/quickbirdstudios/opencv-android 使用过OpenCV用于安卓。它能够正常工作,并且相机也能运行。但是在这个仓库中存在有关相机方向的问题。所以我只是分叉了这个仓库,并且使用 https://jitpack.io/ 进行了发布,没有做任何更改(只是为了检查它是否能工作)。

build.gradle:

dependencies {
  implementation 'com.quickbirdstudios:opencv:3.4.1' 
}

在使用 jitpack 进行发布并且更改了我的依赖之后:

dependencies {
    implementation 'com.github.Balasnest:opencv-android:0.1.1' // 这里 gradle 构建成功了
}

但是问题是在执行以下代码时出现错误,错误消息为 OpenCV error: Cannot load info library for OpenCV

public class MainActivity extends Activity {
    static {
        if (!OpenCVLoader.initDebug()) // 无法加载 OpenCV
            Log.d("ERROR", "Unable to load OpenCV");
        else
            Log.d("SUCCESS", "OpenCV loaded");
    }
...
}

错误日志:

D/OpenCV/StaticHelper: Trying to get library list
09-17 00:15:04.423 14150-14150/com.app E/OpenCV/StaticHelper: OpenCV error: Cannot load info library for OpenCV
09-17 00:15:04.423 14150-14150/com.app D/OpenCV/StaticHelper: Library list: ""
09-17 00:15:04.423 14150-14150/com.app D/OpenCV/StaticHelper: First attempt to load libs
09-17 00:15:04.423 14150-14150/com.app D/OpenCV/StaticHelper: Trying to init OpenCV libs
09-17 00:15:04.423 14150-14150/com.app D/OpenCV/StaticHelper: Trying to load library opencv_java3
09-17 00:15:04.424 14150-14150/com.app D/OpenCV/StaticHelper: Cannot load library "opencv_java3"
09-17 00:15:04.424 14150-14150/com.app W/System.err: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.app-1/base.apk"],nativeLibraryDirectories=[/data/app/com.app-1/lib/arm, /data/app/com.app-1/base.apk!/lib/armeabi-v7a, /vendor/lib, /system/lib]]] couldn't find "libopencv_java3.so"
09-17 00:15:04.439 14150-14150/com.app W/System.err:     at java.lang.Runtime.loadLibrary(Runtime.java:367)
09-17 00:15:04.439 14150-14150/com.app W/System.err:     at java.lang.System.loadLibrary(System.java:1076)
09-17 00:15:04.439 14150-14150/com.app W/System.err:     at org.opencv.android.StaticHelper.loadLibrary(StaticHelper.java:67)
09-17 00:15:04.439 14150-14150/com.app W/System.err:     at org.opencv.android.StaticHelper.initOpenCVLibs(StaticHelper.java:98)
09-17 00:15:04.439 14150-14150/com.app W/System.err:     at org.opencv.android.StaticHelper.initOpenCV(StaticHelper.java:42)
09-17 00:15:04.439 14150-14150/com.app W/System.err:     at org.opencv.android.OpenCVLoader.initDebug(OpenCVLoader.java:107)

请告诉我如何分叉 opencv-android 库,进行修改并在我们的项目中使用它?为什么无法从我的分叉仓库加载 OpenCV 库?

英文:

I had used openCV for android from this repo https://github.com/quickbirdstudios/opencv-android. its worked and also camera was running. But there is a issue with camera orientation in this repo. So I just forked and published mine using https://jitpack.io/ without any changes (just to check if its working).

build.gradle:

dependencies {
  implementation 'com.quickbirdstudios:opencv:3.4.1' 
}

After published with jitpack and changed my dependencies:

dependencies {
    implementation 'com.github.Balasnest:opencv-android:0.1.1' // gradle build success here
}

But problem is getting error saying OpenCV error: Cannot load info library for OpenCV when below code is executed.

public class MainActivity extends Activity {
    static {
        if (!OpenCVLoader.initDebug()) // Failed to load OpenCV
            Log.d("ERROR", "Unable to load OpenCV");
        else
            Log.d("SUCCESS", "OpenCV loaded");
    }
...
}

Error Logs:

D/OpenCV/StaticHelper: Trying to get library list
09-17 00:15:04.423 14150-14150/com.app E/OpenCV/StaticHelper: OpenCV error: Cannot load info library for OpenCV
09-17 00:15:04.423 14150-14150/com.app D/OpenCV/StaticHelper: Library list: ""
09-17 00:15:04.423 14150-14150/com.app D/OpenCV/StaticHelper: First attempt to load libs
09-17 00:15:04.423 14150-14150/com.app D/OpenCV/StaticHelper: Trying to init OpenCV libs
09-17 00:15:04.423 14150-14150/com.app D/OpenCV/StaticHelper: Trying to load library opencv_java3
09-17 00:15:04.424 14150-14150/com.app D/OpenCV/StaticHelper: Cannot load library "opencv_java3"
09-17 00:15:04.424 14150-14150/com.app W/System.err: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.app-1/base.apk"],nativeLibraryDirectories=[/data/app/com.app-1/lib/arm, /data/app/com.app-1/base.apk!/lib/armeabi-v7a, /vendor/lib, /system/lib]]] couldn't find "libopencv_java3.so"
09-17 00:15:04.439 14150-14150/com.app W/System.err:     at java.lang.Runtime.loadLibrary(Runtime.java:367)
09-17 00:15:04.439 14150-14150/com.app W/System.err:     at java.lang.System.loadLibrary(System.java:1076)
09-17 00:15:04.439 14150-14150/com.app W/System.err:     at org.opencv.android.StaticHelper.loadLibrary(StaticHelper.java:67)
09-17 00:15:04.439 14150-14150/com.app W/System.err:     at org.opencv.android.StaticHelper.initOpenCVLibs(StaticHelper.java:98)
09-17 00:15:04.439 14150-14150/com.app W/System.err:     at org.opencv.android.StaticHelper.initOpenCV(StaticHelper.java:42)
09-17 00:15:04.439 14150-14150/com.app W/System.err:     at org.opencv.android.OpenCVLoader.initDebug(OpenCVLoader.java:107)

Let me know how can we fork opencv-android lib, modify and use it in our project? Why OpenCV lib not loaded from my forked repo?

答案1

得分: 1

我已经从不同的OpenCV repo 进行了fork,并且它起作用了。但是不确定为什么它与this一起使用时没有起作用。

英文:

I have forked from diff OpenCV repo and it worked. but not sure why it didn't work with this.

huangapple
  • 本文由 发表于 2020年9月17日 02:53:22
  • 转载请务必保留本文链接:https://go.coder-hub.com/63926310.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定