繁体   English   中英

编写适用于Android的OpenCV的测试用例

[英]Writing test cases for OpenCV for Android

我将Google的ADT软件包(Eclipse + Android SDK)与适用于Android 2.4.6的OpenCV结合使用。 为了测试来自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)

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

确保.so库已编译为要测试的仿真器/设备的正确CPU体系结构,即,如果在仿真器上运行,请确保将CPU仿真器设置为arm(对于.so为arm编译)或intel (x86)。

如果您使用OpenCV管理器(通过BaseLoaderCallback )加载库,则在测试运行时就不会初始化该库。

您可以使用针对OpenCV的特殊TestRunner。 到目前为止,我仅在源代码中找到了它,而在SDK中却没有找到它。

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM