Issue using OpenCV 4.1.1 and Tracking API in Java
All,
I'm trying to leverage the opencv-contrib's Tracking API in a Java application but am currently seeing an "java.lang.UnsatisfiedLinkError: org.opencv.tracking.TrackerCSRT.create_0()J" exception in my Java program. Here's what I've done to get to that point...realizing that the Tracking API is not included in the pre-built OpenCV releases I successfully built OpenCV 4.1.1 from source along with the opencv-contrib-4.1.1 release (where the Tracking API code resides). I've never built OpenCV before so it was all new to me but I finally got that working (sort of). Here's my environment:
- Windows 7 64-bit
- CMake 3.16.0-rc3
- Microsoft Visual Studio Community 2019 (version 16.3.8)
- OpenCV 4.1.1
I followed the instructions from here: https://cv-tricks.com/how-to/installa...
Initially, I did NOT have the BUILD_opencv_world option selected in CMake and so it was just building all of the *.dll files separately (including the "opencv_tracking411.dll" file) and didn't know how to easily load the necessary native libraries into my Java program (as a comparison, when you download the pre-built release of OpenCV, there's a "opencv-411.jar" file along with a single "opencv_java411.dll" file that I use to load into my Java program). I did not see the "opencv_java411.dll" file in the "build/bin/Release" directory when I originally built OpenCV from source. So I turned on the BUILD_opencv_world option and it generated the "opencv_world411.dll" file. Being a bit confused about what *.dll files I now need, I'm currently only loading the "opencv_world411.dll" file into my Java program. The program runs and loads OpenCV and works until it hits the code that leverages the Tracking API. In particular it throws the following exception when instantiating a Tracker object (I'm assuming that this is because the "opencv_tracking411.dll file isn't actually being loaded):
Caused by: java.lang.UnsatisfiedLinkError: org.opencv.tracking.TrackerCSRT.create_0()J
at org.opencv.tracking.TrackerCSRT.create_0(Native Method)
at org.opencv.tracking.TrackerCSRT.create(TrackerCSRT.java:32)
So at this point I have the following questions:
- What steps in the OpenCV build process do I need to follow to generate the "opencv_java411.dll" file. Is the "opencv_world411.dll" that file just renamed?
- Is the "opencv_tracking411.dll" file linked and included in the "opencv_world411.dll" file? If not, is there a way to configure that in CMake? Or will I need to load the "opencv_tracking411.dll" file in my Java program separate from the "opencv_world411.dll" file?
- If I need to load the "opencv_tracking411.dll" file separately, where can I find the native name that should be used? For reference, to load the core OpenCV library in my Java program I use " System.loadLibrary(Core.NATIVE_LIBRARY_NAME);" which works.
Thanks for any feedback and help.
Dave
after you build OpenCV if you have opencv_tracking411.dll and opencv-411.jar you should have opencv_java411.dll ( search it in build directories)