Opencv Java MatOfFloat4 object cannot be created via constructor
I've a class which has the following variable:
private MatOfFloat4 horizonLine = new MatOfFloat4();
which I later on pass into a function as follows:
Imgproc.fitLine(tmpPoints, horizonLine, Imgproc.CV_DIST_L1, 0, 0.01, 0.01);
However, I get an error saying that:
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)
at org.opencv.core.MatOfFloat4.<init>(MatOfFloat4.java:12)
at obstacleDetector.HorizonDetector.<init>(HorizonDetector.java:327)
at obstacleDetector.HorizonDetector.getInstance(HorizonDetector.java:59)
at obstacleDetector.Detector.<clinit>(Detector.java:28)
which directs me to the initialization of the variable. Why can't OpenCV intialize this variable? What is wrong?
P.S: If it matters, the class which I place this variable, is a Singleton class:
public static HorizonDetector getInstance() {
if (_instance == null) {
_instance = new HorizonDetector();
} else {
System.out.println("Same instance of the Horizon Detector-Singleton class already exists.");
}
return _instance;
}
Any thoughts?
java.lang.UnsatisfiedLinkError
-- are you sure, the opencv_java.so is already loaded, when you try to run your code ?The code runs when I comment out the initialization part of the
MatOfFloat4
object. So the problem is not about the library. Additionally, I haveSystem.loadLibrary(Core.NATIVE_LIBRARY_NAME);
as well.