Forum Discussion

RealJavaScript's avatar
RealJavaScript
New Contributor
6 years ago

How can I use OpenCV 3.4.1 with Java-Bridge to load a pictures with imread()?

I allways get errors when using OpenCV 3.4.1 with Java-Bridge to load a pictures with imread().

 

Therefore I use the Java-Bridge C:\Program Files\Java\jre1.8.0_171\bin\server\jvm.dll
(This Java-Bridge works fine with other *.jar-Files like ..\..\..\..\..\Java\pdfbox-app-2.0.9.jar)

 

I use the following Java Classes in TestComplete:
- org.opencv.imgcodecs.Imgcodecs
- org.opencv.core.Core
- org.opencv.core.CvType
- org.opencv.core.Mat

and Add Drectory ..\..\..\..\..\opencv\build\java\x64
and Add Jar-Files ..\..\..\..\..\opencv\build\java\opencv-331.jar

 

There are two methods in class org.opencv.imgcodecs.Imgcodecs "imread()" that are also shown in the object inspector of TestComplete
- imread() with one Parameter for the PNG-Filename
- imread_2() with two Parameters

 

Example 1 leads to an error:

function abc1() {
aFullFileName = 'C:\\Testing\\TC.png';
aObj = JavaClasses.org_opencv_imgcodecs.Imgcodecs.newInstance();
aMat = aObj.imread(aFullFileName);
}
leads to java.lang.UnsatisfiedLinkError: org.opencv.imgcodecs.Imgcodecs.imread_1(LJava/lang/String; )J :smileyfrustrated:

 

Example 2 leads also to an error:

function abc2() {
aFullFileName = 'C:\\Testing\\TC.png';
aObj = JavaClasses.org_opencv_imgcodecs.Imgcodecs.newInstance();
aMat = aObj.imread_2(aFullFileName, 1);
}
leads to java.lang.UnsatisfiedLinkError: org.opencv.imgcodecs.Imgcodecs.imread_0(Ljava/lang/String;I)J :smileyfrustrated:

 

If I look at these methods from OpenCV directly with Java in Eclipse it works fine but how can I fix this within TestComplete?