同事老是抱怨跑不起来,于是吾抄了个范例:
package taishan; import java.io.File; import org.opencv.core.CvType; import org.opencv.core.Mat; @SuppressWarnings("serial") public class OpenCVTest { public static void main(String[] args) { System.out.println(System.getenv("java.library.path")); //System.loadLibrary("opencv_java422"); String fileName = "/home/tsit/eclipse-workspace/FontTest/lib/libopencv_java420.so"; System.out.println(new File(fileName).exists()); //如果是多个分包的形式,要各自加载 System.load(fileName); Mat m = Mat.eye(3, 3, CvType.CV_8UC1); System.out.println("m = " + m.dump()); } }
关键的一句就是要正确找到so包。