Alright, you may say "use google search for this, there are millions of them". However, I almost spent all day just to run following code but every since I tried I got java.lang.UnsatisfiedLinkError: C:\Users\hp\AppData\Local\Temp\jniopencv_core2477828805078034839.dll: Can't find dependent libraries error which drives me mad.
I found javacv-bin folder which includes javacpp.jar, javacv.jar, javacv-windows-x86.jar, javacv-windows-x86_64.jar.
In Netbeans, I opened project properties and I added them into the libraries
I found 开发者_如何学PythonOpenCV2.3 folder, copied and pasted it into C:\ directory.
I added C:\OpenCV2.3\build\bin; C:\OpenCV2.3\build\x86\vc10\bin; C:\OpenCV2.3\build\x64\vc10\bin; in the PATH.
And I believe nothing to do left. However, every since I tried I got the same error. I'm exhausted please someone help me.
And last to say, I have both 32-bit and 64-bit JDKs so I tried both compilers but it's no use.
import static com.googlecode.javacv.cpp.opencv_core.*;
import static com.googlecode.javacv.cpp.opencv_imgproc.*;
import static com.googlecode.javacv.cpp.opencv_highgui.*;
public class Smoother {
public static void main(String[] args) {
smooth("filename0.png");
}
public static void smooth(String filename) {
System.out.println("java.library.path="+System.getProperty("java.library.path"));
IplImage image = cvLoadImage(filename);
if (image != null) {
cvSmooth(image, image, CV_GAUSSIAN, 3);
cvSaveImage(filename, image);
cvReleaseImage(image);
}
}
}
I had the same problem as you did. Assuming your openCV folder location is C:\OpenCV2.3
, here is what to do.
Create path and classpath variables under both user AND system environment variables.
Append this to all four variables(Assuming you have the latest version of openCV2.3):
C:\OpenCV2.3\build\bin;C:\OpenCV2.3\build\x64\mingw\bin;C:\OpenCV2.3\build\x64\vc9\bin;C:\OpenCV2.3\build\x64\vc10\bin;C:\OpenCV2.3\build\x86\mingw\bin;C:\OpenCV2.3\build\x86\vc9\bin;C:\OpenCV2.3\build\x86\vc10\bin;
Hope it helps! Aravind
Two Tips:
- You can't mix 64 and x86 libraries in the pathes!
- restart Eclipse
I have never worked with OpenCV ,but somehow I made my JNI code work.Have you generated the .dll or it comes with the package? And check this post ,it may Ohelp JNI error while calling a C subroutine ... One more suggestion try putting your dll in system32 folder and then load it manually using System.load(path/to/dll) method...Happy coding
If anybody have this problem and updating system path and class path didn't solve, rename your OpenCv2.3.1 directory to "opencv". It did solve my problem.
精彩评论