Ask Your Question
0

OpenCV Run on Tomcat

asked 2015-09-16 11:34:01 -0600

Rafalsonn gravatar image

Hello, I've made an application which uses OpenCV, and now I want to run it on Tomcat. I'm now trying to set Tomcat to Work, this is the simple code to check is it working on tomcat:

String libopencv_java = "C:\\eclipse\\workspace\\tomcat_try\\opencv_java300.dll";
        System.load(libopencv_java); 
        LOG.debug("OpenCV Loaded");

        System.out.println("Welcome to OpenCV " + Core.VERSION);
        Mat m = new Mat(5, 10, CvType.CV_8UC1, new Scalar(0));
        System.out.println("OpenCV Mat: " + m);
        Mat mr1 = m.row(1);
        mr1.setTo(new Scalar(1));
        Mat mc5 = m.col(5);
        mc5.setTo(new Scalar(5));
        System.out.println("OpenCV Mat data:\n" + m.dump());

When I'm executing the code on tomcat the result is:

Caused by: java.lang.UnsatisfiedLinkError: org.opencv.core.Mat.n_Mat(IIIDDDD)J at org.opencv.core.Mat.n_Mat(Native Method) at org.opencv.core.Mat.<init>(Mat.java:63)

Can somebody help me? I've added the opencv300.jar file to the build path,

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2015-09-20 10:31:20 -0600

RolandC gravatar image

updated 2015-09-21 01:12:18 -0600

My guess is that the OpenCV library isn't loaded. If you'd like to do it with loadLibrary you must specify a library path when you start the VM:

-Djava.library.path=C:\\eclipse\\workspace\\tomcat_try

Also, the libary must be without the ".dll" extension.

In other words:

OpenCV's Core.java looks like this:

public static final String NATIVE_LIBRARY_NAME = getNativeLibraryName();
private static String getNativeLibraryName() { return "opencv_java300"; }

Then you load the library like this:

System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-09-16 11:34:01 -0600

Seen: 1,851 times

Last updated: Sep 21 '15