我们可以在android JUnit测试中使用OpenCV吗?

问题描述 投票:0回答:1

我现在正在“app / src / androidTest”下编写一个测试用例,需要涉及OpenCV lib。我试过了 : 1.将OpenCV 3.2.0导入为模块。 2.按照建议导入OpenCV lib,Here is the link。 但无论如何导入似乎失败了, ```

static {
    if (!OpenCVLoader.initDebug()){
        Log.w(TAG, "static initializer: Load opencv failed !!!");
    } else {
        Log.i(TAG, "static initializer: Load opencv succeed .");
    }
}

``` 任何评论都会有所帮助。

android opencv junit
1个回答
0
投票

我有同样的问题。

加载OpenCV for android test(在Windows上)

下载适用于Windows的OpenCV版本并解压缩。

在android项目中复制以下文件(我把它放在/ app / src / main / jniLibs / win /中):

“yourunzipath”+ opencv \ build \ java \ x64 \ opencv_java331.dll

然后,在Android测试文件夹中,创建以下类:

public class OpenCVTestInitializer {

    @Before
    public void initOpenCV() {
        String projectPath = System.getProperty("user.dir");
        String opencvpath = projectPath + "/app/src/main/jniLibs/win/";
        System.load(opencvpath + Core.NATIVE_LIBRARY_NAME + ".dll");
    }

}

要完成,要与OpenCV一起使用的每个测试类必须扩展前一个类。

© www.soinside.com 2019 - 2024. All rights reserved.