Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect Value for "Core.NATIVE_LIBRARY_NAME" #24

Closed
aji4032 opened this issue Sep 14, 2017 · 4 comments
Closed

Incorrect Value for "Core.NATIVE_LIBRARY_NAME" #24

aji4032 opened this issue Sep 14, 2017 · 4 comments

Comments

@aji4032
Copy link

aji4032 commented Sep 14, 2017

Hi,

I was facing the below error while trying to use Highgui.imread(String) function:
"java.lang.UnsatisfiedLinkError: org.opencv.highgui.Highgui.imread_1".

On searching, I found out that I might have to use "System.loadLibrary(Core.NATIVE_LIBRARY_NAME);" to load the library. But now, it gives the below error:
"java.lang.UnsatisfiedLinkError: no opencv_java248 in java.library.path"

The jar file contains opencv_java320.dll for 64bit windows machine but the value for Core.NATIVE_LIBRARY_NAME is "opencv_java320". Is this the reason why I am getting this error? Also, can you help me on how to resolve this above error also I'm receiving?

Issue Found in below Maven Dependency:

org.openpnp
opencv
3.2.0-1

@vonnieda
Copy link
Member

Hi @aji4032,

Did you call loadShared() first? Typically you should load this library like this:

    static {
        nu.pattern.OpenCV.loadShared();
        System.loadLibrary(org.opencv.core.Core.NATIVE_LIBRARY_NAME);
    }

Try that and let me know if you are still having problems.

In addition, unless you actually need features from 3.x, I recommend using 2.4.13 instead. The Java bindings for 3.x are pretty buggy.

@aji4032
Copy link
Author

aji4032 commented Sep 15, 2017

Hi @vonnieda ,
I tried adding the static block and downgraded it to 2.4.13 as you said. Still receiving below error :(.
java.lang.UnsatisfiedLinkError: no opencv_java248 in java.library.path on trying to execute loadShared();

public class TemplateMatching {
static {
nu.pattern.OpenCV.loadShared();
System.loadLibrary("opencv_java2413");
}
public static void run() {
String templateFileName = "C:\Users\aji4032\Desktop\outfile.png";
Mat img = Highgui.imread(templateFileName);
}
}

@vonnieda
Copy link
Member

Hi @aji4032,

A few things:

This works for me:

package org.openpnp;

import org.opencv.core.Mat;
import org.opencv.highgui.Highgui;

public class OpenCvTest {
    static {
        nu.pattern.OpenCV.loadShared();
        System.loadLibrary(org.opencv.core.Core.NATIVE_LIBRARY_NAME);
    }
    
    public static void main(String[] args) {
        String filename = "/Users/jason/Desktop/Screen Shot 2017-09-15 at 8.57.47 AM.png";
        Mat mat = Highgui.imread(filename);
    }
}

using this Maven dependency:

		<dependency>
			<groupId>org.openpnp</groupId>
			<artifactId>opencv</artifactId>
			<version>2.4.11-2</version>
		</dependency>

I'm not sure why you are getting an error that opencv_java248 is not available when you are calling for opencv_java2413. It makes me think you either have a broken Maven dependency or are using non-Maven version of the library.

If you are using Maven, can you please just zip up your entire test project and send it over to me? I can test it locally and see if I get the same error.

I don't believe this is an error with the library, it looks environmental to me.

@vonnieda
Copy link
Member

vonnieda commented Oct 1, 2017

Closing as this doesn't seem like a library issue. Feel free to reopen if you still are having trouble.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants