Ask Your Question

Torcellite's profile - activity

2019-09-25 02:20:07 -0600 received badge  Famous Question (source)
2017-07-25 03:57:15 -0600 received badge  Notable Question (source)
2016-05-22 05:07:51 -0600 received badge  Popular Question (source)
2013-12-29 21:49:10 -0600 asked a question OpenCV .so library for Android

How do I build a custom. so file for all architectures for only a select few opencv header files and class files? Is this possible?

2013-07-02 13:38:24 -0600 answered a question Using default BaseLoaderCallback in an android service

Well, I seem to have figured it out.

You need to call initAsync in onStartCommand

if(OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_4, getApplicationContext(), mLoaderCallback)) {
        Log.i(TAG, "Loaded OpenCV");
    }
    else
        Log.i(TAG, "Couldn't load OpenCV");

Wait about 1.5 seconds before you use OpenCV libraries for them to be loaded. You could use a delayed runnable.

Also make sure you override the finish() function of the BaseLoaderCallback.

BaseLoaderCallback mLoaderCallback = new BaseLoaderCallback(
        WDMRService.this) {
    @Override
    public void onManagerConnected(int status) {
        switch (status) {
        case LoaderCallbackInterface.SUCCESS: {
            Log.i("", "OpenCV loaded successfully");
        }
            break;
        default: {
            super.onManagerConnected(status);
        }
            break;
        }
    }

    @Override
    public void finish() {
        // implementing own finish method since openCV treats context as
        // activity
    }
};

If you're not going to use OpenCV once the service is destroyed, you should unbind the OpenCV service in finish(). It will work even if you don't, but it is better if you do. I don't because I require OpenCV after the service is destroyed too.

2013-07-02 11:46:51 -0600 commented question Using default BaseLoaderCallback in an android service

@variablexxx - Did you figure out how to do this?

2013-07-02 11:46:32 -0600 received badge  Supporter (source)
2013-04-16 09:07:14 -0600 answered a question Async Initialization of OpenCV on Android using OpenCVManager

I finally solved it! Apparently OpenCV crashes every time it's functions are called in the UI, so I did..

Something like this :

 public class Face extends Activity {
 private Bitmap bitmap;
 private int f = Crop.k;
 private ImageView tv;
 Mat m;
 private static final String    TAG                 = "OCVSample::Activity";

  private BaseLoaderCallback mLoaderCallback = new BaseLoaderCallback(this) {
@Override
public void onManagerConnected(int status) {
    switch (status) {
        case LoaderCallbackInterface.SUCCESS:
        {
            Log.i(TAG, "OpenCV loaded successfully");
            m=new Mat();
        } break;
        default:
        {
            super.onManagerConnected(status);
        } break;
    }
}
};

I would suggest you execute whatever function you're trying in an AsyncTask like in my project. Mat functions however can be declared without the risk of the UnsatisfiedLinkError exception in OpenCV functions. Functions called in the UI however experience this. At least this is what I've seen.

2013-03-27 10:50:56 -0600 received badge  Editor (source)
2013-03-27 10:07:43 -0600 commented answer Async Initialization of OpenCV on Android using OpenCVManager

I do not want to open camera view. Just compare images. What should my baseloader contain?

2013-03-27 07:50:30 -0600 commented answer Async Initialization of OpenCV on Android using OpenCVManager

I would like to read an already existing image. So I'm reading it onto a Mat using Highui. What do I for that?

I've already checked the samples out. They don't help me.

2013-03-27 03:22:53 -0600 received badge  Student (source)
2013-03-27 02:07:26 -0600 asked a question Async Initialization of OpenCV on Android using OpenCVManager

My understanding on the OpenCV structure for Android is limited to whatever was on the site's content. So far, I know how to check for the OpenCV library on a device. What is currently stumping me is it's initialization.

This is my previous code :

private BaseLoaderCallback mLoaderCallback = new BaseLoaderCallback(this) {
    @Override
    public void onManagerConnected(int status) {
        switch (status) {
        case LoaderCallbackInterface.SUCCESS: {
            Log.i(TAG, "OpenCV loaded successfully");
                            compare();
        }
            break;
        default: {
            super.onManagerConnected(status);
        }
            break;
        }
    }
};

Where compare() is a function dealing with OpenCV functions such as keypoint detection, descriptor extraction, etc.

Now if I don't call compare() from within the BaseLoader but from the onCreate() function and use OpenCVLoader.init(<params>) within compare() itself, the app crashes with the Unsatisfied Link Error. Could someone point out the correct method of initialization WITH code, please?

The error: 03-27 21:18:20.968: W/dalvikvm(1575): No implementation found for native Lorg/opencv/highgui/Highgui;.imread_1 (Ljava/lang/String;)J