user1868607
user1868607

Reputation: 2600

UnsatisfiedLinkError using opencv for processing

I'm calling:

Mat opencv_K= new Mat(3, 3, CvType.CV_32F);

in a Processing sketch and I'm getting the following error:

java.lang.UnsatisfiedLinkError: org.opencv.core.Mat.n_Mat(III)J
    at processing.opengl.PSurfaceJOGL$2.run(PSurfaceJOGL.java:480)
    at java.lang.Thread.run(Thread.java:745)
UnsatisfiedLinkError: org.opencv.core.Mat.n_Mat(III)J
A library relies on native code that's not available.
Or only works properly when the sketch is run as a 32-bit application.

This error seems to me different from the one reported here.

A minimal example is:

import processing.core.PVector;
import org.opencv.core.Mat;
import org.opencv.core.CvType; 
import org.opencv.core.Core;
Mat opencv_K= new Mat(3, 3, CvType.CV_32F); 

And the error in this case is somewhat similar:

UnsatisfiedLinkError: org.opencv.core.Mat.n_Mat(III)J
A library relies on native code that's not available.
Or only works properly when the sketch is run as a 32-bit application.

I'm using Processing 3 in an Ubuntu platform.

Upvotes: 2

Views: 428

Answers (3)

Imroze Aslam
Imroze Aslam

Reputation: 103

For me it worked by simply initializing OpenCV object in the start which I was not doing already before using Mat e.g.opencv = new OpenCV(this,500,500);

Upvotes: 0

George Profenza
George Profenza

Reputation: 51837

I recommend trying Greg's OpenCV for Processing library:

import gab.opencv.*;

import processing.core.PVector;
import org.opencv.core.Mat;
import org.opencv.core.CvType; 
import org.opencv.core.Core;
Mat opencv_K; 

OpenCV opencv;

void setup(){
  opencv = new OpenCV(this,640,480);
  opencv_K = new Mat(3, 3, CvType.CV_32F);
  println(opencv_K);
}

Console output:

OpenCV for Processing 0.5.2 by Greg Borenstein http://gregborenstein.com
Using Java OpenCV 2.4.5.0
Mat [ 3*3*CV_32FC1, isCont=true, isSubmat=false, nativeObj=0x7fb86157f080, dataAddr=0x7fb861589e90 ]

Upvotes: 1

user1868607
user1868607

Reputation: 2600

Solution:

Just add System.loadLibrary(Core.NATIVE_LIBRARY_NAME); before the relevant code

Upvotes: 2

Related Questions