Ask Your Question

seba1986's profile - activity

2016-01-08 08:24:18 -0600 answered a question initAsync not applicable for the arguments

Wow, old question and no answer...

I would guess that your class is not a context. I has to be a subclass of context. You could for example declarate your class like this:

   public class PFC_AVR extends Activity {
          ...
    }

Maybe this can help someone... probably the author of this question not anymore. :(

2016-01-06 10:47:33 -0600 asked a question initasync Nullpointer Exception

Hi all,

I have the following question:

I have several ideas for different apps using one and the key feature. Therefore I want to implement that feature as a library project. I created one, referenced the OpenCV Library project and also created a project for Android JUnit test.

In the library project I have a class that extends activity in which call the constructor and initialize opencv in async mode like this:

public class Abc extends Activity implements IAbc  {

final String TAG = "Hello World";

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

           } break;
           default:
           {
          super.onManagerConnected(status);
           } break;
       }
        }
    };

public Abc(){
    super();

    Log.i(TAG, "Trying to load OpenCV library");
    if (!OpenCVLoader.initDebug()) {
        Log.d(TAG, "Internal OpenCV library not found. Using OpenCV Manager for initialization");
        OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_3_0_0, this, mOpenCVCallBack);
    } else {
        Log.d(TAG, "OpenCV library found inside package. Using it!");
        mOpenCVCallBack.onManagerConnected(LoaderCallbackInterface.SUCCESS);
    }
}

So I basically made things like in the examples ( at least I think I did). I now create an instance of Abc class in my Android test. The test starts and fails with a NullPointerException that is being triggered by

 OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_3_0_0, this, mOpenCVCallBack);

I can follow it back to ContentWrapper.bindService (but can't look at the source code of this method). Whole exception looks like this:

java.lang.NullPointerException
at android.content.ContextWrapper.bindService(ContextWrapper.java:517)
at org.opencv.android.AsyncServiceHelper.initOpenCV(AsyncServiceHelper.java:26)
at org.opencv.android.OpenCVLoader.initAsync(OpenCVLoader.java:95)
at de.spospiech.gazetracker.Abc.estimateGazeDirection(Starburst.java:54)
at de.spospiech.gazetracker.AbcTest.testStarburst(StarburstTest.java:33)
at java.lang.reflect.Method.invokeNative(Native Method)
at android.test.InstrumentationTestCase.runMethod(InstrumentationTestCase.java:214)
at android.test.InstrumentationTestCase.runTest(InstrumentationTestCase.java:199)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:191)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:176)
at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:554)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1701)

Of course I do have OpenCV Manager 3.0.0 installed on my device. Examples do work fine.

Any idea what I do wrong?

Thanks and greetings, Sebastian

2015-06-07 11:59:52 -0600 asked a question JavaCV 0.11 VideoInputLib Android UnsatisfiedLinkError

Hi all,

I currently have to face the following problem, that I already googled a lot about, but still did not find a working solution:

I implemented a small javacv example for windows, which is working well. The example's purpose is simply to print out available video hardware, like my webcam.

Now I want to run this example on an Android device. So I created a new Android app project, created a button and a text field. When clicking the button, the text field has to be filled with the information about the video hardware.

I added javacv.jar, javacpp.jar and videoinput.jar to the "libs" folder of the android project. In Eclipse I added those jars to the build path. Additionally I checked the jars to be exported in the build path configuration.

Then I extracted the .so files from ffmpeg-android-arm.jar and opencv-android-arm.jar into the libs/armeabi folder.

The code I try to run is free from errors as far as Eclipse tells me and is being build without errors. The app launches on the device (Nexus 5), but when I try to press the button to detect the video devices it crashes with the folowing exceptions:

06-07 16:56:04.618: E/AndroidRuntime(8232): Caused by: java.lang.ClassNotFoundException: org.bytedeco.javacpp.videoInputLib

06-07 16:56:04.618: E/AndroidRuntime(8232): Caused by: java.lang.UnsatisfiedLinkError: Couldn't load jnivideoInputLib from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/de.s.pospiech.sebastianstest-1.apk"],nativeLibraryDirectories=[/data/app-lib/de.s.pospiech.sebastianstest-1, /vendor/lib, /system/lib]]]: findLibrary returned null

This is the part of code that is not working:

 answerButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {

            int numDevs = videoInput.listDevices();
            StringBuffer resultText = new StringBuffer();
            for (int i = 0; i < numDevs; i++){
                resultText.append(" " + i + ": " + videoInput.getDeviceName(i) + "\n");
            }
            answerLabel.setText(resultText);

        }
    });

The exception occurs on the line videoInput.listDevices();

The videoInput class is of course importet in the class file:

import org.bytedeco.javacpp.videoInputLib.videoInput;

I've used this tutorial: http://javacv4android.blogspot.de/201...

But I did not use JavaCV / CPP 0.7, I used 0.11. In 0.11 there is no javacv-android-arm.jar file, I could have extracted some .so files out, so I left that step out. Maybe there is still missing something in my configuration?

I also tried with 0.7 later on, but 0.7 is missing "videolib.jar" so I can not even compile the code example using those older libraries.

Any suggestions / experience ?

Thanks a lot in advance!!!

Sebastian