Opencv is an open source library for computer vision, Now i am going to show you how to install it on Mac OS X.
Steps:
- Download a fresh copy of opencv-2.4.6.1 from here.
- Extract it to some location in your Mac.
- now open terminal go inside the extracted folder opencv-2.4.6.1.
- Type following commands
- mkdir build
- cd build
- Make sure your JAVA_HOME environment variable is set or explicitly type export JAVA_HOME=<location of java home folder>
- cmake -G "Unix Makefiles" -D CMAKE_CXX_COMPILER=/usr/bin/g++ -D CMAKE_C_COMPILER=/usr/bin/gcc -D WITH_CUDA=ON ..
- make -j4 // here number 4 means the number of cores in your processor
- make install
Configuring Eclipse with opencv
- Open eclipse
- Click on File-> New Project-> Java Project
- Give an appropriate Project Name
- Now right click on Project and choose Properties.
- Select Java Build Path and then select Libraries.
- Click on Add Library.
- Choose User Library.
- Click on User Libraries, then Select New and give a name to your library.
- Now Select your library and click on Add External JARs, go to your build folder and then open bin folder, there you will find opencv-246.jar, Select this file.
- If you are not able to find .jar then make sure your JAVA_HOME variable is set in the environment variables at the time of build.
- Now Select Native Library Location and click on Edit.
- Insert the path of your cv.so file, mine is in /build/lib.
- Click on Finish, Now your project is configured with openCV library.
This post was so helpful! Thanks for sharing!
ReplyDeleteThank you Jadisha
DeleteHello Sumit, I'm facing problems when I try to run a .jar of my application, that I generated with Eclipse. It throws the following error:
DeleteException in thread "main" java.lang.UnsatisfiedLinkError: no opencv_java246 in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1878)
at java.lang.Runtime.loadLibrary0(Runtime.java:849)
at java.lang.System.loadLibrary(System.java:1087)
at Main.main(Main.java:11)
I need that the .jar runs in any computer. I would appreciate your help a lot!
Thank you very much!
Go to File ---> Export ---> Chooose-> Java Runnable Jar
DeleteThen choose ->Copy required libraries into a subfolder next to the generated jar
You can also save it as ANT script.
Hi, thanks you for your help. However, I tried that and I still have the same exception when I run a .jar generated...
DeleteHi Sumit, maybe the problem is how I load the library of OpenCV in the program... Because, I generated the jar as you mentioned... How do you load the library of OpenCV? Thank you so much for your help.
DeleteI am using this method to load libraries
DeleteSystem.loadLibrary(Core.NATIVE_LIBRARY_NAME);
Hi
DeleteI have the same problem. In Eclipse everything works fine but no exporting option works.
I'm using as well System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
and did everything like you said.
Do you have any more hints for me where to search?
Solved it like this:
Deletehttps://stackoverflow.com/questions/32192866/executable-jar-with-opencv-lib-eclipse-mac/32255233#32255233
This comment has been removed by the author.
ReplyDeleteThanks a tonnnn!!!!! :-)
ReplyDeletehi,
ReplyDeletei follow the command above, but i cannot find my opencv-247.jar,
do u know where is the build path ?
thanks : )
Hi,
ReplyDeleteI cannot find the .jar file as well. All I found is a bunch of unix executable files inside the bin folder of build.
Any idea why this happens?
Thanks~
i again build it with the same instructions and it is successfully generating the .jar files in the build/bin directory
DeleteThis comment has been removed by the author.
ReplyDeleteokay - for all the people who don't find their .jar file in the build/bin folder, you need to install ant first. i just had the same problem and it all worked afterwards.
ReplyDeleteant is easily installed via the terminal command "brew install ant". for this to work you need to install the package manager hombrew first. you can find the instructions here: http://brew.sh
Thanks for the detailed instructions and comments
ReplyDeleteHi, I follow the steps, but when I run my project, this says:
ReplyDeleteException in thread "main" java.lang.UnsatisfiedLinkError: no opencv_java249 in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1764)
at java.lang.Runtime.loadLibrary0(Runtime.java:823)
at java.lang.System.loadLibrary(System.java:1044)
at visionporcomputadora.main.main(main.java:46)
the line 46 says: System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
I have a macbook. hope you can help me, sorry for my english. thanks!
Take a look at this link, if System.loadLibrary(Core.NATIVE_LIBRARY_NAME) doesn't work
Deletehttps://stackoverflow.com/questions/32192866/executable-jar-with-opencv-lib-eclipse-mac/32255233#32255233