解决办法:java.lang.UnsatisfiedLinkError: org.opencv.core.Mat.n_eye(III)J

简介: 解决办法:java.lang.UnsatisfiedLinkError: org.opencv.core.Mat.n_eye(III)J
  • 具体错误
java.lang.UnsatisfiedLinkError: 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:402)
  • 解决办法

使用System.load()手动加载本地(dll/so/dylib)库。

如果使用System.loadLibrary(),则要保证java.library.path中要有包含本地库的目录。

package taishan;
import java.io.File;
import org.opencv.core.Core;
import org.opencv.core.CvType;
import org.opencv.core.Mat;
public class OpenCVTest
{
  private final static String KEY_LIB_PATH = "java.library.path";
  private final static String NATIVE_DIR="D:\\OpenCVTest\\lib";
    static
    {
      System.out.println(System.getProperty(KEY_LIB_PATH));
        String fileName = NATIVE_DIR+"\\"+Core.NATIVE_LIBRARY_NAME+".dll";
        File dll = new File(fileName);
        System.out.println(Core.NATIVE_LIBRARY_NAME+" exist ? "+dll.exists());
        if (dll.exists())
        {
          System.load(fileName);
            //System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
        }
    }
    public static void main(String[] args)
    {
        Mat mat = Mat.eye(3, 3, CvType.CV_8UC1);
        System.out.println("mat = "+mat.dump());
    }
}
  • 输出结果:
D:\Office-3.5-project\Office-3.5\tsjdk8-bin;.
opencv_java420 exist ? true
mat = [  1,   0,   0;
   0,   1,   0;
   0,   0,   1]
  • 分析结果很奇怪

出错是在modules/core/misc/java/src/java/core+Mat.java。

搜索n_eye,确实没有这个函数

实际上结果确实是对的。

目录
相关文章
|
3月前
|
Java
flyway报错Caused by: java.lang.NoSuchMethodError: org.flywaydb.core.api.configuration.FluentConfigurat
flyway报错Caused by: java.lang.NoSuchMethodError: org.flywaydb.core.api.configuration.FluentConfigurat
43 2
|
5月前
|
easyexcel Java Apache
EasyExcel导入的时候报错Caused by: java.lang.NoClassDefFoundError: org/apache/poi/poifs/filesystem/File
EasyExcel导入的时候报错Caused by: java.lang.NoClassDefFoundError: org/apache/poi/poifs/filesystem/File
389 0
|
Java
【Java异常】Error:(30, 62) java: 程序包com.sun.org.apache.xerces.internal.impl.dv.util不存在
【Java异常】Error:(30, 62) java: 程序包com.sun.org.apache.xerces.internal.impl.dv.util不存在
1297 0
|
Java Maven
java.lang.UnsatisfiedLinkError: org.opencv.core.Mat.n_Mat(IIILjava/nio/ByteBuffer;)J [duplicate]
java.lang.UnsatisfiedLinkError: org.opencv.core.Mat.n_Mat(IIILjava/nio/ByteBuffer;)J [duplicate]
|
Java 应用服务中间件 Maven
org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1188) - Java
org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1188) - Java
|
Java
解决办法:java.lang.UnsatisfiedLinkError: org.opencv.core.Mat.n_eye(III)J
解决办法:java.lang.UnsatisfiedLinkError: org.opencv.core.Mat.n_eye(III)J
161 0
|
Java 计算机视觉
java调用opencv库出错:java.lang.UnsatisfiedLinkError: org.opencv.core.Mat.n_eye(III)J
java调用opencv库出错:java.lang.UnsatisfiedLinkError: org.opencv.core.Mat.n_eye(III)J
708 0
|
Java
java.lang.UnsatisfiedLinkError: JNA support (com/sun/jna/android-arm/libjnidispatch.so) not found
java.lang.UnsatisfiedLinkError: JNA support (com/sun/jna/android-arm/libjnidispatch.so) not found
211 0
|
Java
Caused by: java.lang.IncompatibleClassChangeError: class net.sf.cglib.core.DebuggingClassWriter has
Caused by: java.lang.IncompatibleClassChangeError: class net.sf.cglib.core.DebuggingClassWriter has
291 0
Caused by: java.lang.IncompatibleClassChangeError: class net.sf.cglib.core.DebuggingClassWriter has