Trouble building opencv3.2.0 using cmake on mac os

Viewed 33

I am new to this...I am trying to use a video monitoring program that was previously published in a scientific article. There are several different blogposts from the developers-some older than others on how to set it up. I used this one:http://javagrinders-arc.blogspot.com/

these are my computer settings:

1)I am using a mac Monterey version 12.4

2)The program requires eclipse my version is IDE Version: 2022-03 (4.23.0)

3)I have the latest version of java:

java version "18.0.1.1" 2022-04-22
Java(TM) SE Runtime Environment (build 18.0.1.1+2-6)
Java HotSpot(TM) 64-Bit Server VM (build 18.0.1.1+2-6, mixed mode, sharing)
  1. All I needed it seems was to have an Opencv .jar file with dependencies installed.

To do this I have followed the instructions and successfully built the latest version of OpenCV (4.6) according to this blog: https://udallascs.wordpress.com/2014/03/30/adding-opencv-and-configuring-to-work-with-eclipse-and-java/.

everything worked well and I was able to get the .jar files and dependencies.

This was stored in my

/user/local/Cellar/opencv/4.6.0/share/opencv4

I then added the opencv-460.jar into eclipse as an external library, then I set the native library path to the one above.

then i added

System.loadLibrary(Core.NATIVE_LIBRARY_NAME)

then I made sure to include the

import org.opencv.core.Core

at the top of the program with the other import commands.

when I ran the program I got this error:

Exception in thread "main" java.lang.UnsatisfiedLinkError: no opencv_java320 in java.library.path: /usr/local/Cellar/opencv/4.6.0/share/java/opencv4
at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2434)
at java.base/java.lang.Runtime.loadLibrary0(Runtime.java:848)
at java.base/java.lang.System.loadLibrary(System.java:2015)
at _ARC.ARCController.main(ARCController.java:191)

_ARC.ARCController is the name of the program I am trying to get to work. I contacted the developer and he told me to try and install open.cv 3.2.0 instead.

So, I unistalled that version of opencv using brew.

Then I tried to install and build opencv3.2.0 using cmake:

a) I downloaded version 3.2.0 to my documents folder:

wget -O opencv.zip https://github.com/opencv/opencv/archive/3.2.0.zip

unzip opencv.zip

b) Then I created the build file within the unzipped opencv folder:

cd opencv-3.2.0mkdir build && cd build

c) Now I was ready to build Opencv with Cmake

cmake -DCMAKE_SYSTEM_PROCESSOR=arm64 \
-DCMAKE_OSX_ARCHITECTURES=arm64 \
-DWITH_OPENJPEG=OFF \
-DWITH_IPP=OFF \
-D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local/opencv \
-D JAVA_INCLUDE_PATH=$JAVA_HOME/include \
-D JAVA_AWT_LIBRARY=$JAVA_HOME/jre/lib/amd64/libawt.so \
-D JAVA_JVM_LIBRARY=$JAVA_HOME/jre/lib/arm/server/libjvm.so \
-D BUILD_opencv_python2=OFF \
-D BUILD_opencv_java=ON \
-D INSTALL_PYTHON_EXAMPLES=OFF \
-D INSTALL_C_EXAMPLES=OFF \
-D OPENCV_ENABLE_NONFREE=OFF \
-D BUILD_EXAMPLES=ON ..

Then I still got this lengthy error.

CMake Deprecation Warning at CMakeLists.txt:22 (cmake_minimum_required):

  Compatibility with CMake < 2.8.12 will be removed from a future version of

  CMake.

 

  Update the VERSION argument <min> value or use a ...<max> suffix to tell

  CMake that the project does not need compatibility with older versions.

 

 

CMake Deprecation Warning at CMakeLists.txt:72 (cmake_policy):

  The OLD behavior for policy CMP0020 will be removed from a future version

  of CMake.

 

  The cmake-policies(7) manual explains that the OLD behaviors of all

  policies are deprecated and that a policy should be set to OLD only under

  specific short-term circumstances.  Projects should be ported to the NEW

  behavior and not rely on setting a policy to OLD.

 

 

CMake Deprecation Warning at CMakeLists.txt:76 (cmake_policy):

  The OLD behavior for policy CMP0022 will be removed from a future version

  of CMake.

 

  The cmake-policies(7) manual explains that the OLD behaviors of all

  policies are deprecated and that a policy should be set to OLD only under

  specific short-term circumstances.  Projects should be ported to the NEW

  behavior and not rely on setting a policy to OLD.

 

 

CMake Deprecation Warning at CMakeLists.txt:81 (cmake_policy):

  The OLD behavior for policy CMP0026 will be removed from a future version

  of CMake.

 

  The cmake-policies(7) manual explains that the OLD behaviors of all

  policies are deprecated and that a policy should be set to OLD only under

  specific short-term circumstances.  Projects should be ported to the NEW

  behavior and not rely on setting a policy to OLD.

 

 

-- The CXX compiler identification is AppleClang 13.1.6.13160021

-- The C compiler identification is AppleClang 13.1.6.13160021

-- Detecting CXX compiler ABI info

-- Detecting CXX compiler ABI info - done

-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ - skipped

-- Detecting CXX compile features

-- Detecting CXX compile features - done

-- Detecting C compiler ABI info

-- Detecting C compiler ABI info - done

-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc - skipped

-- Detecting C compile features

-- Detecting C compile features - done

CMake Error at cmake/OpenCVCompilerOptions.cmake:21 (else):

  Flow control statements are not properly nested.

Call Stack (most recent call first):

  CMakeLists.txt:495 (include)


-- Configuring incomplete, errors occurred!

See also "/Users/dena/Documents/opencv-3.2.0/build/CMakeFiles/CMakeOutput.log".

See also "/Users/dena/Documents/opencv-3.2.0/build/CMakeFiles/CMakeError.log".

sorry for the long message, but I am just wondering if someone could suggest a solution.

  1. I don't know why the ARC.controller script is set at only using the opencv3.2.0 and how to go in and make it compatible with the newer opencv.
  2. or how to successfully be able to build opencv3.2.0 on my computer. I have installed the latest xcode and my command line tools are up to date.

Thanks!

0 Answers
Related