Calling Imgproc.matchTemplate() triggers "exception unknow exception"

I have searched the Internet for a long time without finding the answer, please help me, thank you!

//win10 +  java + opencv_java2413

System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
OpenCV.loadLocally();//must be added otherwise an exception will be reported

Mat source = Imgcodecs.imread(sourcePath, Imgcodecs.IMREAD_COLOR);
Mat template = Imgcodecs.imread(path,Imgcodecs.IMREAD_COLOR);
Mat outputImage = new Mat();

Imgproc.matchTemplate(source, template, outputImage, MACH_METHOD);// unknow exception

seriously outdated, no more maintained,
please use a more recent release (we’re at 4.5.5 now !)

“exception unknow exception"

please add the complete exception txt

what is this ? please explain

also, which match method is used ? (what happens if you change it ?)
are you sure, your images are correctly loaded ? (add checks, please)

First of all, thank you very much for your reply
1、I am maintaining a 5 year old project, so I am not in a position to update the software version immediately.


2、The matchTemplate function only returns the “java.lang.Exception:unknow exception”.

3、

loadLocally is used to solve "Method threw ‘java.lang.UnsatisfiedLinkError’ exception.

4、what’s mean for loadLocally, according to the notes, I understand that it allows the program to load the “dll” file from the “classpath” environment variable

You know, maintaining an old project can be a pain, both in terms of meeting deadlines and understanding the technologies used in the project.

Yes, I’m sure there’s nothing wrong with the images, because I took the code and images from the project to the “demo” project and it works correctly

I use this method “Imgproc.TM_CCOEFF_NORMED”

Guys, I fixed the problem!
The previous programmer referenced the wrong “dll” file!
When generating the “jar” file, remember to use the “build” operation

1 Like