Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using OpenCV Android porting

I want to use the OpenCV Android porting, that you can find HERE, to make some image transformations for an Augmented Reality application. I've found no problem configuring and building the library, I receive no error and I succed put it within my Android application throght JNI process: the library libopencv.so is in the correct directory "\libs\armeabi\" under my project's directory. And now the problems:

1) First I want to understand what version of the original openCV library this porting derive from. Is important for me know if it derive from version 1.5, 2.0 or 2.1 because same functions are very different and others are absent.

2) Before starting with real time video manipulation, I'd try make some simple operations on a single image or saved video:


JNIEXPORT
jstring
JNICALL
Java_org_examples_testOpenCV_OpenCV_LoadImage(JNIEnv* env, jobject thiz)
{
    IplImage* imgIn = cvLoadImage("/sdcard/testimage.jpg", -1);

if (!imgIn) return env->NewStringUTF("Error");

cvReleaseImage( &imgIn );

return env->NewStringUTF("Ok");

}


JNIEXPORT
jstring
JNICALL
Java_balmas_examples_testOpenCV_OpenCV_manageVideo(JNIEnv* env, jobject thiz)
{
     CvCapture* capture = cvCaptureFromFile("/sdcard/video_galaxyspica_352x288_15fps.3gp");

    if (!capture) return env->NewStringUTF("Error");

    return env->NewStringUTF("Ok");

}

In both cases I receive "Error". There are no problems with files on the sdcard becouse I try to make this:


FILE* file = fopen("/sdcard/video_galaxyspica_352x288_15fps.3gp","w+");

//FILE* file = fopen("/sdcard/testimage.jpg","w+");

if (!file) return env->NewStringUTF("Error");
else {
    fflush(file);
    fclose(file);
    return env->NewStringUTF("OK");
}

and I receive "OK". I realize that there is some problem within highgui library but I don't understand what and wath I should make to avoid the problem. Some suggestions!!!

Thank you everyone

like image 879
Native_Code Avatar asked Sep 10 '26 18:09

Native_Code


1 Answers

guys- you may want to try this link, it ports the C++ 'modern' interface to opencv. The IplImage stuff is deprecated, but new versions leave wrappers if you need to support legacy code.

http://code.google.com/p/android-opencv/

There's a sample camera-calibration app, you click snap a few times and it will solve for the K matrix.

Note: you'll need the crystax ndk for STL classes, http://www.crystax.net/android/ndk-r4.php

like image 198
peter karasev Avatar answered Sep 12 '26 06:09

peter karasev



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!