0

我将 Google 的 ADT 包(Eclipse + Android SDK)与 OpenCV for Android 2.4.6 结合使用。为了从 Android 应用程序测试一个类(无活动),我为它编写了一个测试用例。当我运行它时,我得到了这个:

java.lang.UnsatisfiedLinkError: Native method not found: org.opencv.core.Mat.n_eye:(III)J
at org.opencv.core.Mat.n_eye(Native Method)
at org.opencv.core.Mat.eye(Mat.java:1449)
at de.htw_berlin.threed_scan.utils.SceneStitcher.findTransformations(SceneStitcher.java:71)
at de.htw_berlin.threed_scan.utils.SceneStitcher.consolidateCoordinateSystems(SceneStitcher.java:109)
at de.htw_berlin.threed_scan.utils.SceneStitcher.stitchClouds(SceneStitcher.java:192)
at de.htw_berlin.threed_scan.test.SceneStitcherTest.testStitchClouds(SceneStitcherTest.java:86)
at java.lang.reflect.Method.invokeNative(Native Method)
at android.test.InstrumentationTestCase.runMethod(InstrumentationTestCase.java:214)
at android.test.InstrumentationTestCase.runTest(InstrumentationTestCase.java:199)
at android.test.ActivityInstrumentationTestCase2.runTest(ActivityInstrumentationTestCase2.java:192)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:190)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:175)
at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:555)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1614)

虽然要测试的项目运行良好,但测试项目似乎缺少本机二进制文件。有任何想法吗?

4

2 回答 2

0

如果您使用 OpenCV 管理器来加载库(使用BaseLoaderCallback),那么库在测试运行时根本没有初始化。

您可以使用 OpenCV 的特殊 TestRunner。到目前为止,我只在源代码中找到它,而不是在 SDK 中。

https://github.com/Itseez/opencv/blob/master/modules/java/android_test/src/org/opencv/test/OpenCVTestRunner.java

将此文件复制到您的项目中并在 Eclipse 中将其设置为 TestRunner。

于 2014-05-29T16:19:18.177 回答
0

确保将 .so 库编译为您正在测试的模拟器/设备的正确 CPU 架构,即,如果您在模拟器上运行,请确保 CPU 模拟器设置为 arm(对于为 arm 编译的 .so)或 intel (x86)。

于 2013-11-05T08:38:16.850 回答