views:

1842

answers:

2

I am assuming that using the OpenCV code here: http://github.com/billmccord/OpenCV-Android#readme is the best way to use OpenCV on Android, with the NDK.

I am still stuck as to how i get from the C definitions of functions to the ones i declare in OpenCV.java in my Android project (example: cvFindContours( void* img, CvMemStorage* storage, CvSeq** firstContour, int cntHeaderSize, int mode, int method, CvPoint offset ) --> findContours(int[] data, int w, int h) )

any help/pointers appreciated, even where to start to figure this out. i currently want to use cvHoughCircles, cvHoughCircles(CvArr* image, void* circle_storage, int method, double dp, double min_dist, double param1 = 100, double param2 = 300, int min_radius = 0, int max_radius = 0};

how do i write this in java with ndk for android?? thank you!

+1  A: 

Look at the Android samples within the ndk (hello-jni). They are in the apps directory of the NDK. They show how to import the library and call native methods. On C side of things you have to give your methods the proper jni naming conventions Java_...fully qualified java class name, make methods external and also include to make them accessable.

Also the docs directory of the NDK has all the documentation on building and running native code.

sadboy
I know how to import the library and call native methods. The only part I'm confused about is on the C side of things, wondering if there's a good place to read up on that. I have no idea how to get from the c definition of functions to the JNI definitions.
cjayant
sadboy
+2  A: 

Does your app require the C interface? OpenCV actually considers it deprecated / done with, the new API is C++. A port of this interface and sample calibration app are here: http://code.google.com/p/android-opencv/

It took me a while to get sold on the new C++, but I had to admit it was nice to not have to do cvReleaseMat() and go back and forth between IplImage and CvMat all the time. Opencv 2.1 doc: http://opencv.willowgarage.com/documentation/cpp/index.html

peter karasev