how can i use openCV in an android studio's project - but i need to use it in other native cpp files and not in java.
all the guides and tutorials i found explain how to use openCV in java files (loadLibrary..) for example this and this
eventually i have all the .so in jniLibs folder or add openCV as a module with a dependency, but what do i "#include .. " ? how can i not get
error: 'cv' is not a namespace-name
for
using namespace cv;
? (and of course other openCV code...)
thanks a lot!
To work with the OpenCV Android library, you have to add it to your app module as a dependency. To easily do this on Android Studio, click on File -> Project Structure. When the project structure dialog opens, click on the app module or any other module that you want to use OpenCV library in.
Basically OpenCV is an open source computer vision and machine learning software library. Based on the documentation this library has more than 2500 optimized algorithm inside of it.
Download and install IP Webcam application on your mobile phone. Then make sure your PC and Phone both are connected to the same network. Open your IP Webcam application on your both, click “Start Server” (usually found at the bottom). This will open a camera on your Phone.
finally i succeeded:
i created my own android.mk file:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
# OpenCV
OPENCV_INSTALL_MODULES:=on
include path/to/OpenCV-2.4.10-android-sdk/sdk/native/jni/OpenCV.mk
LOCAL_MODULE := glucomesdk
LOCAL_CFLAGS := -I/path tp/OpenCV-2.4.10-android-sdk/sdk/native/jni/include -Wall -Werror
LOCAL_SRC_FILES := \ all my cpp files
LOCAL_C_INCLUDES += /path to/src/main/jni
LOCAL_C_INCLUDES += /path to/src/debug/jni
LOCAL_C_INCLUDES += /path to/OpenCV-2.4.10-android-sdk/sdk/native/jni/include
LOCAL_STATIC_LIBRARIES := /path to/OpenCV-2.4.10-android-sdk/sdk/native/libs/armeabi-v7a/libopencv_core.a
LOCAL_LDLIBS += -llog -ldl
include $(BUILD_SHARED_LIBRARY)
then i use this code in terminal to build the shared library (.so)
/path/to/android-ndk/ndk-build NDK_PROJECT_PATH=/path/to/project APP_BUILD_SCRIPT=/path/to/Android.mk NDK_OUT=/path/to/project/module/build/intermediates/ndk/debug/obj NDK_LIBS_OUT=/path/to/project/module/build/intermediates/ndk/debug/lib APP_STL=stlport_static APP_ABI=armeabi-v7a
after that i use gradle's assemble(debug) to create an aar file that contains both java code and the shared library
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With