0

I wanted to use Open CV in my project and followed below installation process:

http://opencv-java-tutorials.readthedocs.io/en/latest/01-installing-opencv-for-java.html#install-opencv-3-x-under-macos

I was not able to get Java folder in the installed directory. As I was getting below error on my Java code:

"NATIVE_LIBRARY_NAME cannot be resolved"

I tried few things till now -

  1. I did "brew edit opencv" and changed "-DBUILD_opencv_java=OFF" to "ON" and did "brew reinstall opencv --with-java"

  2. I tried adding external jar and tried changing the native library location but no help as there is no java folder available in opencv directory

I am not getting help from any source.

3
  • You need OpenCV in Android project or some Java Application ? Commented Aug 31, 2017 at 11:12
  • I need it in Java project as I am doing some preprocessing over the image. Commented Aug 31, 2017 at 12:14
  • Check the installation guide to be one to one to your platform. May be a difference in the Java wrapper causes it not to be able to resolve NATIVE_LIBRARY_NAME. Commented Sep 4, 2017 at 17:51

2 Answers 2

0

For build OpenCV with java libraries you should make project with parametr

cmake -D BUILD_SHARED_LIBS=OFF

After configure project you should see java in OpenCV modules

--   OpenCV modules:
--     To be built: ... java ...

And

--   Java:
--     ant:                         /usr/bin/ant (ver 1.10.1)
--     JNI:                         /usr/lib/jvm/java/include /usr/lib/jvm/java/include/linux /usr/lib/jvm/java/include
--     Java wrappers:               YES
--     Java tests:                  YES

If you build project with this parametrs, but didn't see java in OpenCV modules then try set JAVA_HOME environment For linux

export JAVA_HOME=<path_to_jdk>

For windows

set JAVA_HOME=<path_to_jdk>

I builded OpenCV project with command below:

cmake -D CMAKE_BUILD_TYPE=RELEASE 
    -D CMAKE_INSTALL_PREFIX=/usr/local 
    -D BUILD_OPENCV_JAVA=ON
    -D BUILD_SHARED_LIBS=OFF
    -D WITH_IPP=ON 
    -D WITH_TBB=ON
    -D IPP_H_PATH=/opt/intel/ipp/include/ ..

Parametrs WITH_IPP and WITH_TBB provide multithreading.

After make install phase you can see jar library in ../bin and /usr/[local/]share/OpenCV

Related resources:

1) Oficial site

2) Man for Linux install process

3) Add OpenCV to Eclipse project

Sign up to request clarification or add additional context in comments.

1 Comment

I am trying to install openCV with java on MACOS exactly following the procedure but everytime there is no JAVA folder! Please help
0

For those who didn't know how to save the change of arg

DBUILD_opencv_java=OFF

to

DBUILD_opencv_java=ON

Such file exist on :

/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/opencv.rb

So open it with any text editor and save it easily.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.