Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to include opencv in visp build #1354

Open
saiakash opened this issue Mar 22, 2024 · 3 comments
Open

Unable to include opencv in visp build #1354

saiakash opened this issue Mar 22, 2024 · 3 comments

Comments

@saiakash
Copy link

saiakash commented Mar 22, 2024

hi, i want to integrate visp with opencv for advanced task for Android studio. so i installed opencv and visp using this tutrial: https://visp-doc.inria.fr/doxygen/visp-daily/tutorial-install-win11-msvc17.html#install_win11_msvc17_advanced .
But, when i run sdk build using the command
python3 [build_sdk.py](http://build_sdk.py/) --config [ndk-23.config.py](http://ndk-23.config.py/) --sdk_path c:\Users\TD02\AppData\Local\Android\Sdk --ndk_path C:\Users\TD02\AppData\Local\Android\Sdk\ndk-bundle c:\Users\TD02\visp-ws\visp-build-android-sdk c:\Users\TD02\visp-ws\visp --debug
visp unable to find opencv .
visp build without opencv setup.
Can you anyone guide me to include opencv in visp.

Below is my log file:

sdkbuild.log

-- ANDROID_PLATFORM not set. Defaulting to minimum supported version
16.
-- The C compiler identification is Clang 11.0.5
-- The CXX compiler identification is Clang 11.0.5
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Users/TD02/AppData/Local/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Users/TD02/AppData/Local/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done

-- ==========================================================
-- General configuration information for ViSP 3.6.1
-- 
--   Version control:               unknown
-- 
--   Platform:
--     Timestamp:                   2024-03-22T05:57:01Z
--     Host:                        Windows 10.0.22621 AMD64
--     Target:                      Android 1 aarch64
--     CMake:                       3.28.1
--     CMake generator:             Ninja
--     CMake build tool:            C:/Users/TD02/Downloads/ninja-win/ninja.exe
--     Configuration:               Debug
-- 
--   System information:
--     Number of CPU logical cores: 12
--     Number of CPU physical cores: 6
--     Total physical memory (in MiB): 16110
--     OS name:                     Windows
--     OS release:                  Personal
--     OS version:                  (Build 22621)
--     OS platform:                 AMD64
--     CPU name:                    Unknown P6 family
--     Is the CPU 64-bit?           yes
--     Does the CPU have FPU?       yes
--     CPU optimization:            NEON
-- 
--   C/C++:
--     Built as dynamic libs?:      no
--     C++ Compiler:                C:/Users/TD02/AppData/Local/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++.exe  (ver 11.0.5)
--     C++ flags (Release):         -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security    -Wall -Wextra -fopenmp=libomp -pthread -std=c++17 -fvisibility=hidden -fPIC -O2 -DNDEBUG 
--     C++ flags (Debug):           -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security    -Wall -Wextra -fopenmp=libomp -pthread -std=c++17 -fvisibility=hidden -fPIC -O0 -fno-limit-debug-info 
--     C Compiler:                  C:/Users/TD02/AppData/Local/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe
--     C flags (Release):           -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security   -Wall -Wextra -fopenmp=libomp -pthread -std=c++17 -fvisibility=hidden -fPIC -O2 -DNDEBUG 
--     C flags (Debug):             -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security   -Wall -Wextra -fopenmp=libomp -pthread -std=c++17 -fvisibility=hidden -fPIC -O0 -fno-limit-debug-info 
--     Linker flags (Release):      -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libgcc_real.a -Wl,--exclude-libs,libatomic.a -Wl,--build-id=sha1 -Wl,--no-rosegment -Wl,--fatal-warnings -Wl,--no-undefined -Qunused-arguments 
--     Linker flags (Debug):        -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libgcc_real.a -Wl,--exclude-libs,libatomic.a -Wl,--build-id=sha1 -Wl,--no-rosegment -Wl,--fatal-warnings -Wl,--no-undefined -Qunused-arguments 
--     Use cxx standard:            17
-- 
--   ViSP modules:
--     To be built:                 core gui imgproc io java_bindings_generator klt me sensor ar blob robot visual_features vs vision detection mbt tt tt_mi java
--     Disabled:                    -
--     Disabled by dependency:      -
--     Unavailable:                 -
-- 
--   Android NDK:                   C:/Users/TD02/AppData/Local/Android/Sdk/ndk-bundle (ver 22.1.7171670)
--     Android ABI:                 arm64-v8a
--     NDK toolchain:               aarch64-linux-android-clang
--     STL type:                    c++_shared
--     Native API level:            21
--   Android SDK:                   c:/Users/TD02/AppData/Local/Android/Sdk (tools: 26.1.1 build tools: 34.0.0)
-- 
--   Python 3:
--     Interpreter:                 C:/Users/TD02/AppData/Local/Microsoft/WindowsApps/python.exe (ver 3.11.8)
-- 
--   Java:                          export all functions
--     ant:                         no
-- 
--   Python3 bindings:              no
-- 
--   Build options: 
--     Build deprecated:            yes
--     Build with moment combine:   no
-- 
--   OpenCV: 
--     Version:                     n/a
-- 
--   Mathematics: 
--     Blas/Lapack:                 yes
--     \- Use MKL:                  no
--     \- Use OpenBLAS:             no
--     \- Use Atlas:                no
--     \- Use Netlib:               no
--     \- Use GSL:                  no
--     \- Use Lapack (built-in):    yes (ver 3.2.1)
--     Use Eigen3:                  no
--     Use OpenCV:                  no
-- 
--   Simulator: 
--     Ogre simulator: 
--     \- Use Ogre3D:               no
--     \- Use OIS:                  no
--     Coin simulator: 
--     \- Use Coin3D:               no
--     \- Use SoWin:                no
--     \- Use SoXt:                 no
--     \- Use SoQt:                 no
--     \- Use Qt5:                  no
--     \- Use Qt4:                  no
--     \- Use Qt3:                  no
-- 
--   Media I/O: 
--     Use JPEG:                    no
--     Use PNG:                     no
--     \- Use ZLIB:                 yes (ver 1.2.11)
--     Use OpenCV:                  no
--     Use stb_image (built-in):    yes (ver 2.27.0)
--     Use TinyEXR (built-in):      yes (ver 1.0.2)
--     Use simdlib (built-in):      yes
-- 
--   Real robots: 
--     Use Afma4:                   no
--     Use Afma6:                   no
--     Use Franka:                  no
--     Use Viper650:                no
--     Use Viper850:                no
--     Use ur_rtde:                 no
--     Use Kinova Jaco:             no
--     Use aria (Pioneer):          no
--     Use PTU46:                   no
--     Use Biclops PTU:             no
--     Use Flir PTU SDK:            no
--     Use MAVSDK:                  no
--     Use Parrot ARSDK:            no
--     \-Use ffmpeg:                no
--     Use Virtuose:                no
--     Use qbdevice (built-in):     yes (ver 2.6.0)
--     Use takktile2 (built-in):    no
--     Use pololu (built-in):       no
-- 
--   GUI: 
--     Use X11:                     no
--     Use GTK:                     no
--     Use OpenCV:                  no
--     Use GDI:                     no
--     Use Direct3D:                no
-- 
--   Cameras: 
--     Use DC1394-2.x:              no
--     Use CMU 1394:                no
--     Use V4L2:                    no
--     Use directshow:              no
--     Use OpenCV:                  no
--     Use FLIR Flycapture:         no
--     Use Basler Pylon:            no
--     Use IDS uEye:                no
-- 
--   RGB-D sensors: 
--     Use Realsense:               no
--     Use Realsense2:              no
--     Use Occipital Structure:     no
--     Use Kinect:                  no
--     \- Use libfreenect:          no
--     \- Use libusb-1:             no
--     \- Use std::thread:          yes
--     Use PCL:                     no
--     \- Use VTK:                  no
-- 
--   F/T sensors: 
--     Use atidaq (built-in):       no
--     Use comedi:                  no
--     Use IIT SDK:                 no
-- 
--   Mocap: 
--     Use Qualisys:                no
--     Use Vicon:                   no
-- 
--   Detection: 
--     Use zbar:                    no
--     Use dmtx:                    no
--     Use AprilTag (built-in):     yes (ver 3.1.1)
--     \- Use AprilTag big family:  no
-- 
--   Misc: 
--     Use Clipper (built-in):      no
--     Use pugixml (built-in):      yes (ver 1.9.0)
--     Use libxml2:                 no
--     Use json (nlohmann):         no
-- 
--   Optimization: 
--     Use OpenMP:                  yes
--     Use std::thread:             yes
--     Use pthread:                 no
--     Use pthread (built-in):      no
--     Use simdlib (built-in):      yes
-- 
--   DNN: 
--     Use CUDA Toolkit:            no
--     Use TensorRT:                no
-- 
--   Documentation: 
--     Use doxygen:                 no
--     \- Use mathjax:              no
-- 
--   Tests and samples:
--     Use catch2 (built-in):       yes (ver 2.13.7)
--     Tests:                       no
--     Apps:                        no
--     Demos:                       no
--     Examples:                    no
--     Tutorials:                   no
--     Dataset found:               no
-- 
--   Library dirs:
-- 
--   Install path:                  C:/Users/TD02/visp-ws/visp-build-android-sdk/o4a/install
-- 
-- ==========================================================
-- Configuring done (47.2s)
-- Generating done (0.2s)
-- Build files have been written to: C:/Users/TD02/visp-ws/visp-build-android-sdk/o4a


BUILD SUCCESSFUL in 14s

51 actionable tasks: 51 executed

Watched directory hierarchies: [C:\Users\TD02\visp-ws\visp-build-android-sdk\o4a\visp_android]

[10/11] Install the project...
Package configuration:
================================================================================
ABIs = [
#    ABI("2", "armeabi-v7a", None, cmake_vars=dict(ANDROID_ABI='armeabi-v7a with NEON', ANDROID_GRADLE_PLUGIN_VERSION='4.1.2', GRADLE_VERSION='7.0')),
    ABI("3", "arm64-v8a",   None, cmake_vars=dict(ANDROID_GRADLE_PLUGIN_VERSION='4.1.2', GRADLE_VERSION='7.0')),
 #  ABI("5", "x86_64",      None, cmake_vars=dict(ANDROID_GRADLE_PLUGIN_VERSION='4.1.2', GRADLE_VERSION='7.0')),
  #  ABI("4", "x86",         None, cmake_vars=dict(ANDROID_GRADLE_PLUGIN_VERSION='4.1.2', GRADLE_VERSION='7.0')),
]
================================================================================


@karthiTD
Copy link

https://visp-doc.inria.fr/doxygen/visp-daily/tutorial-create-android-sdk.html . i follow the link for install visp android sdk the build was succesfull but there is no opencv how to add it

@fspindle
Copy link
Contributor

Never done. Did you first build OpenCV android sdk and then during ViSP configuration set OpenCV_DIR cmake var to its location ?

@saiakash
Copy link
Author

To resolve an issue, I made adjustments in both the build_sdk.py and CMakelist.txt files.

In the build_sdk.py file, I incorporated additional CMake parameters within the build_library function. These parameters were essential for configuring the build process properly. The added parameters include:

 def build_library(self, abi, do_install):
        cmd = [self.cmake_path, "-GNinja"]
        cmake_vars = dict(
            CMAKE_TOOLCHAIN_FILE=self.get_toolchain_file(),
            BUILD_EXAMPLES="OFF",
            BUILD_TESTS="OFF",
            BUILD_TUTORIALS="OFF",
            BUILD_DEMOS="OFF",
            BUILD_ANDROID_EXAMPLES="ON",
            INSTALL_ANDROID_EXAMPLES="ON",
            OpenCV_DIR="C:\\Users\\TD02\\Downloads\\opencv-4.9.0-android-sdk\\OpenCV-android-sdk\\sdk\\native\\jni",
            USE_OPENCV="TRUE",
            OpenCV_FOUND="ON",
            OpenCV_VERSION="4.9.0"
        )

These parameters ensure that the correct OpenCV directory is referenced and that OpenCV is properly utilized in the build process.

Furthermore, I made adjustments to the logic in the CMakelist.txt file to ensure proper handling of OpenCV support for Android.

if(NOT CMAKE_TOOLCHAIN_FILE)
  # Find opencv2.framework for ios and naoqi
  VP_OPTION(USE_OPENCV      "MyOpenCV" QUIET "Include OpenCV support" "OpenCV_DIR;OpenCV_FOUND;OPENCV_FOUND" ON)
  message("Include OpenCV support --------------648---------------------${OpenCV_DIR} ${OpenCV_FOUND} ${OPENCV_FOUND}")
else()
  message("Include OpenCV support ------------------650-------else----------${USE_OPENCV}")
  VP_OPTION(USE_OPENCV      "OpenCV;MyOpenCV" QUIET "Include OpenCV support" "OpenCV_DIR;OpenCV_FOUND;OPENCV_FOUND" ON)
  message("Include OpenCV support ------------------652-------else----------${USE_OPENCV}")
endif()

Hopefully, these modifications prove beneficial to others facing similar challenges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants