I am using OpenCV 2.4.4 with Eclipse Juno on Ubuntu. My problem is similar to this OpenCV for android sample programs showing error
But now it drives me out. I spent most of my weekend trying to get the ndk and opencv library to play well, and yet I can't get it to work. I have in my C ++ cpp test file with the following inclusion -
#include <jni.h> #include <opencv2/core/core.hpp> #include <opencv2/imgproc/imgproc.hpp> #include <cstdlib> using namespace cv; //this is a problem ... ...
And he tells me when I try to build that "the cv namespace cannot be found." Oh well, I must have written the wrong path or not using the right library, right? Wrong. In the terminal, ndk-build builds .so files without any errors. I see them just like a day in the project folder. But if I try to build in eclipse, i.e. build apk for tesitng on a virtual device or on a real device, then I will get a cv namespace error and the assembly will fail, and then in the cpp cv file will be underlined in red and there will be a file in eclipse is marked in red, and I canβt even try to build until this file is fixed.
Itβs clear that I am doing something wrong. But if I close the eclipse project and then close it again, the cpp file will no longer be marked in red, and I will be able to build apk. If I try to open the cpp file, red will be returned and no more assemblies will happen until I go through the close / open rigmarole project.
I honestly donβt know what is the cause of the problem. Any help would be greatly appreciated.
My android.mk file:
include $(CLEAR_VARS) OPENCV_CAMERA_MODULES:=off OPENCV_INSTALL_MODULES:=on OPENCV_LIB_TYPE:=STATIC include /the/correct/path/tp/opencv/sdk/native/jni/OpenCV.mk LOCAL_MODULE := mylib LOCAL_SRC_FILES := mylib.cpp include $(BUILD_SHARED_LIBRARY)
Application.mk
APP_STL := gnustl_static APP_CPPFLAGS := -frtti -fexceptions APP_ABI := all
I did not think it would be difficult. I should add that I successfully used opencv with Android in anothe rproject, which I built on WIndows with Eclipse 3.5 (I think) and OpenCV 2.4.2
EDIT I ββalso want to say that I just did a quick dirty dirty opencv test operation. I wrote a quick Sobel function and named it as a native function in a Java file and successfully processed the bitmap. Of course, I still had to close / open my project in order to do this.