2

I am new to opencv in android. I imported the opencv module 3.4.2 successfully. In application.mk

APP_STL:=gnustl_static

When I tried to build the application, I got NDK build error that 'gnustl_static' is no longer supported. I changed the above line in application.mk to

APP_STL:=c++_static as suggested by android studio.

The build was successful and I ran the project successfully. Now I tried to implement the face detection with opencv as like as opencv samples 'face-detection'. I got the error this time :

E:/MyOpenDetections/app/src/main/jni/com_sar_pahc_DetectionBasedTracker.cpp:37: error: undefined reference to 'cv::CascadeClassifier::detectMultiScale(cv::_InputArray const&, std::__ndk1::vector<cv::Rect_<int>, std::__ndk1::allocator<cv::Rect_<int> > >&, double, int, int, cv::Size_<int>, cv::Size_<int>)'

I searched about this and got some suggestions that I have to change the APP_STL to 'gnustl_static' from 'c++_static' but when I do this the NDK stops the build and shows that it is not supported now.

I got some hint from Alex Cohn that I have to rebuild the Opencv with c++_static OpenCV - undefined reference to 'cv::CascadeClassifier::detectMultiScale() after NDK update

But I have no idea of doing that. Please help

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Sar
  • 550
  • 4
  • 18
  • Another solution here would be to [download an older version of the NDK and associate it with your project](https://stackoverflow.com/a/52504296/5132744). – Jk Jensen Dec 17 '18 at 06:49

1 Answers1

1

You can try solution from opencv bugtracker (source):

cmake -GNinja -DINSTALL_ANDROID_EXAMPLES=ON -DANDROID_EXAMPLES_WITH_LIBS=ON -DBUILD_EXAMPLES=ON -DBUILD_DOCS=OFF -DWITH_OPENCL=OFF -DWITH_IPP=ON -DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK}/build/cmake/android.toolchain.cmake -DANDROID_TOOLCHAIN=clang "-DANDROID_STL=c++_static" -DANDROID_ABI=x86 -DANDROID_SDK_TARGET=18 ../opencv

Followed by

make && make install

Dmitrii Z.
  • 2,287
  • 3
  • 19
  • 29
  • in windows > inside opencv sdk folder > ran the above command > CMake Error: The source directory "E:/OpenCV-android-sdk" does not appear to contain CMakeLists.txt. – Sar Oct 19 '18 at 06:43
  • 1
    OpenCV-android-sdk is the output of this command. You need to run the script using opencv source code https://github.com/opencv/opencv – Dmitrii Z. Oct 19 '18 at 07:29