Java中的OpenCV,Junit 4测试用例使用Mat()对象失败

Java中的OpenCV,Junit 4测试用例使用Mat()对象失败,java,c++,eclipse,opencv,junit,Java,C++,Eclipse,Opencv,Junit,我正在用Java开发一个应用程序,到目前为止进展顺利。我刚开始编写测试用例,在Eclipse和JUnit4以及openCV中遇到了一些问题 尤其是Mat()对象 基本上,这里是我的测试函数,用于测试对象的构造函数: //expectedColor is a String value for the color name @Test public void test_Constructor(){ System.out.println("Testing Sign Co

我正在用Java开发一个应用程序,到目前为止进展顺利。我刚开始编写测试用例,在Eclipse和JUnit4以及openCV中遇到了一些问题

尤其是Mat()对象

基本上,这里是我的测试函数,用于测试对象的构造函数:

//expectedColor is a String value for the color name
    @Test
    public void test_Constructor(){
        System.out.println("Testing Sign Constructor");
        Sign test = new Sign();
        assertEquals(expectedColor,test.getColor());
    }
以下是默认的符号构造函数:

Sign() {
    roiSrc = new Mat();
    signText = "stop";
}
我有另一个默认构造函数来测试图像的加载

Sign() {
    roiSrc = Imgproc.imread(Sign.class.getResource("coolduck.jpg").getPath());
    signText = "stop";
}
这里的问题是,如果我用java编写任意程序,这两个函数都可以正常工作。然而,当我开始创建和运行Junit测试时,它们会返回错误(请注意,没有失败)

以下是我的失败记录:

java.lang.UnsatisfiedLinkError: org.opencv.highgui.Highgui.imread_1(Ljava/lang/String;)J
    at org.opencv.highgui.Highgui.imread_1(Native Method)
    at org.opencv.highgui.Highgui.imread(Highgui.java:362)
    at com.add123.japr.Plate.<init>(Plate.java:48)
    at com.add123.japr.TestPlate.test_Constructor(TestPlate.java:15)
java.lang.UnsatisfiedLinkError:org.opencv.highgui.highgui.imread_1(Ljava/lang/String;)J
位于org.opencv.highgui.highgui.imread_1(本机方法)
位于org.opencv.highgui.highgui.imread(highgui.java:362)
在com.add123.japr.Plate.(Plate.java:48)
位于com.add123.japr.TestPlate.test_构造函数(TestPlate.java:15)
如果要删除构造函数中初始化mat对象的行,它运行良好: 符号(){ //roiSrc=Imgproc.imread(Sign.class.getResource(“coolduck.jpg”).getPath()); signText=“停止”; }


以前有人碰到过这个问题并解决了吗

弄明白了,我忘了包括:

System.lostLibrary(Core.NATIVE_LIBRARY_NAME);

在我的测试套件中。

也许junit测试的运行配置与其他程序不同?您是否忘记在junit测试中加载共享库?你是怎么解决DLL或.sos的?嘿,HughB,我刚弄明白。忘记加载测试套件的本机lib,但已将它们加载到我编写的草稿程序中。应为loadLibrary:)
System.lostLibrary(Core.NATIVE_LIBRARY_NAME);