Search code examples
macosopencvhomebrew

Installing OpenCV 3 on mac won't install jar


I am trying to install OpenCV3 on mac using:

brew tap homebrew/science
brew install opencv3 --HEAD --with-java

I would expect a jar lib in:

/usr/local/Cellar/opencv/3.3.0_3/share/OpenCV

But there in no jar in the whole project.

(I also added -DBUILD_opencv_java=ON flag via brew edit opencv3)


Solution

  • I had the very same issue with the v3.3.0. I was following the documentation that says basically the following:

    • brew edit opencv
    • change -DBUILD_opencv_java=ON
    • brew install --build-from-source opencv

    However, the java folder was missing in usr/local/Cellar/opencv/3.3.0_3/share/OpenCV, although there was no error report.

    Fortunately, I figured what was the issue: the OpenCV requires ant to be installed! It is used to build a jar after all the java sources are generated. So, the solution in my case was:

    brew install ant
    

    and then repeating the above procedure. Note that --build-from-source is required in order to get the jar.