centos操作系统 ,opencv, java调用编译后的opencv动态链接库报错

yanfengben 发布于 2014/10/24 18:11
阅读 2K+
收藏 0

各位大牛好:

    遇到一个棘手问题需要请教各位有opencv经验开发的大牛。

    在centos6.5/opencv2.4.9/jdk1.7/cmake3.0环境下,编译opencv 并支持java模块,编译成功后,通过opencv编译后的build 生成的test jar文件测试。

    cmake命令:cmake -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=RELEASE -DBUILD_FAT_JAVA_LIB=ON ..

    测试语句如下:

    java -cp opencv-test.jar:../../lib/junit-4.11.jar -Djava.ext.dirs=/home/opencv/opencv_test/libs -Djava.library.path=/home/opencv/opencv-2.4.9/lib org.junit.runner.JUnitCore org.opencv.test.objdetect.CascadeClassifierTest 

运行后,始终报异常,异常信息如下:

[root@localhost jar]# java -cp opencv-test.jar:../../lib/junit-4.11.jar -Djava.ext.dirs=/home/opencv/opencv_test/libs -Djava.library.path=/home/opencv/opencv-2.4.9/build2/lib org.junit.runner.JUnitCore org.opencv.test.objdetect.CascadeClassifierTest
JUnit version 4.11
.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E
Time: 0.034
There were 17 failures:
1) testDetectMultiScaleMatListOfRectListOfIntegerListOfDoubleDoubleIntIntSizeSize(org.opencv.test.objdetect.CascadeClassifierTest)
java.lang.UnsatisfiedLinkError: org.opencv.core.Core.setErrorVerbosity_0(Z)V
        at org.opencv.core.Core.setErrorVerbosity_0(Native Method)
        at org.opencv.core.Core.setErrorVerbosity(Core.java:6638)
        at org.opencv.test.OpenCVTestCase.setUp(Unknown Source)
        at org.opencv.test.objdetect.CascadeClassifierTest.setUp(Unknown Source)
        at junit.framework.TestCase.runBare(TestCase.java:139)
        at junit.framework.TestResult$1.protect(TestResult.java:122)
        at junit.framework.TestResult.runProtected(TestResult.java:142)
        at junit.framework.TestResult.run(TestResult.java:125)
        at junit.framework.TestCase.run(TestCase.java:129)
        at junit.framework.TestSuite.runTest(TestSuite.java:255)
        at junit.framework.TestSuite.run(TestSuite.java:250)
        at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:84)
        at org.junit.runners.Suite.runChild(Suite.java:127)
        at org.junit.runners.Suite.runChild(Suite.java:26)
        at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
        at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
        at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
        at org.junit.runner.JUnitCore.run(JUnitCore.java:138)
        at org.junit.runner.JUnitCore.run(JUnitCore.java:117)
        at org.junit.runner.JUnitCore.runMain(JUnitCore.java:96)
        at org.junit.runner.JUnitCore.runMainAndExit(JUnitCore.java:47)
        at org.junit.runner.JUnitCore.main(JUnitCore.java:40)

    并且自己编写代码调用链接库也是报错:

    下面粘出部分代码和报错信息:

    System.out.println("\nRunning DetectFaceDemo");
    // 导入opencv的库
    System.loadLibrary(Core.NATIVE_LIBRARY_NAME);

    System.out.println("opencv version: "+Core.VERSION);

    CascadeClassifier faceDetectorAll = new CascadeClassifier();

    报错信息:

Exception in thread "main" java.lang.UnsatisfiedLinkError: org.opencv.objdetect.CascadeClassifier.CascadeClassifier_0()J
        at org.opencv.objdetect.CascadeClassifier.CascadeClassifier_0(Native Method)
        at org.opencv.objdetect.CascadeClassifier.<init>(CascadeClassifier.java:38)
        at com.tcl.uviewer.features.featuresImpl.Test.detectFace(Test.java:23)
        at com.tcl.uviewer.features.featuresImpl.Test.main(Test.java:51)

以上是请求帮助详细信息,还请各位大牛指点迷津,万分感谢。

加载中
0
yanfengben
yanfengben
自己顶下,哪位大牛遇到过类似的问题吗……求点化
0
赵-猛
赵-猛

opencv的jar包不能放在java.ext.dirs里,只能放在cp下。   

java -cp opencv-test.jar:../../lib/junit-4.11.jar:/home/opencv/opencv_test/libs/xxxopencvxxx.jar -Djava.library.path=/home/opencv/opencv-2.4.9/lib org.junit.runner.JUnitCore org.opencv.test.objdetect.CascadeClassifierTest 

返回顶部
顶部