Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is correct Native Library Path to use OpenCV in eclipse-ubuntu

I have an issue in setting native library path for opencv in eclipse-ubuntu.i am using ubuntu 15.04.installed opencv 3.1.0 following this link http://milq.github.io/install-opencv-ubuntu-debian/ and add new library(OpenCV) in eclipse and set it's jar path as

/home/user/opencv-3.1.0/build/bin/opencv-310.jar

and native library path as

/home/user/opencv-3.1.0/build/lib

lib folder contains .so and .a files. But when i try to use Mat object it gives me error:here is Main Method

System.out.println("Welcome to OpenCV hhhh " + Core.VERSION);
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
Mat img=new Mat();

and here is screenshot of my code and console enter image description here it gives me error:

Exception in thread "main" java.lang.UnsatisfiedLinkError: org.opencv.core.Mat.n_Mat()J
        at org.opencv.core.Mat.n_Mat(Native Method)
        at org.opencv.core.Mat.<init>(Mat.java:24)

if i use mat like this

Mat m1 =Imgcodecs.imread("/home/zed/Desktop/img.png");

then it gives me diff error:

Exception in thread "main" java.lang.UnsatisfiedLinkError: org.opencv.imgcodecs.Imgcodecs.imread_1(Ljava/lang/String;)J
    at org.opencv.imgcodecs.Imgcodecs.imread_1(Native Method)
    at org.opencv.imgcodecs.Imgcodecs.imread(Imgcodecs.java:102)

am i giving right path for native library? If not then what is the right path for Native Library to use Opencv3.1.0 in eclipse-ubuntu

like image 922
Sony Khan Avatar asked Jan 29 '16 08:01

Sony Khan


1 Answers

you should add

System.loadLibrary(Core.NATIVE_LIBRARY_NAME);

Main:

public static void main(String[] args) {

  System.out.println("Welcome to OpenCV hhhh " + Core.VERSION);
  System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
  Mat m1 =Imgcodecs.imread("/home/zed/Desktop/img.png");
  Mat m2=new Mat();
}

Hope this helps!

like image 93
Arijit Avatar answered Sep 21 '22 17:09

Arijit