1

does anyone know how to make absdiff work in opencv. following code gives error:

@Override
    public void onManagerConnected(int status) {
        if (status == LoaderCallbackInterface.SUCCESS ) {
            // now we can call opencv code !
            //helloworld();

            Log.i(TAG, "OpenCV is ready");
            Mat m1 = Mat.zeros(100,100, CvType.CV_8UC1);
            Mat m2 = Mat.zeros(100,100, CvType.CV_8UC1);
            Mat m3 = Mat.zeros(100,100, CvType.CV_8UC1);
            Core.absdiff(m1,m2,m3);

        } else {
            super.onManagerConnected(status);
        }
    }

Fatal signal 11 (SIGSEGV), code 1, fault addr 0x16 in tid 5110

Tryed to move to previos version of opencv 2.4.11 but it has problems on initialization.

java.lang.RuntimeException: Unable to resume activity ...: java.lang.IllegalArgumentException: Service Intent must be explicit: Intent { act=org.opencv.engine.BIND } at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2956) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2987) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2370)

But back to opencv 3.1.0 the problem is Core functions substract,add,absdiff give error

Fatal signal 11 (SIGSEGV), code 1, fault addr 0x16 in tid 5110

Did anyone meet this problem? or have an idea is it something wrong with library or usage?

thanks in advance for any help.

1
  • Have you tried with Mat m1 = new Mat.zeros(100,100, CvType.CV_8UC1); etc... ?
    – Miki
    Mar 7, 2016 at 12:51

3 Answers 3

7

Update: OpenCV 3.2 is not affected.


It seems that it is a problem of OpenCV Manager version distributed on Play Store (updated 21/09/15).

The version distributed with Android SDK works just fine (OpenCV-android-sdk/apk/OpenCV_3.1.0_Manager_3.10_{platform}.apk). You can download it from OpenCV website.

To install the apk from adb:

    adb install OpenCV-android-sdk/apk/OpenCV_3.1.0_Manager_3.10_{platform}.apk

Related issues: #5722, #6247 and #6488.

2
  • Worked for me too!!
    – Nullpoet
    Jun 30, 2017 at 7:30
  • Had a similar issue (not quite the same), but this solution helped me. Thanks
    – noamgot
    Jan 18, 2018 at 20:57
0

I had the same problem.I moved to previous version of opencv 3.0.0 and the problem has been solved.

0

Something like this could help you. But it is really slow. I really recommend use absdiff from 3.0 version of Android SDK instead of 3.1 and wait for the fix to upgrade to 3.1.

Android SDK absdiff can late 1 [ms] and this section of code 2700 [ms] increasing hardly if the size of Mats increase.

    // OriginalImage is RGBColor, CurrentImage is GrayScale, you could change this with minor adjusts.

    Mat dest = OriginalImage.clone();
    byte[] b = new byte[4];
    for (int j= 0; j<OriginalImage.cols(); ++j)
    {
        for (int i=0; i<OriginalImage.rows(); ++i)
        {
            b[0] = (byte)Math.abs(OriginalImage.get(i,j)[0] - CurrentImage.get(i,j)[0]);
            //b[1] = valor;
            //b[2] = valor;
            //b[3] = (byte)(255 & 0xFF);
            dest.put(i,j, b);
        }
    }
    CurrentImage = dest;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.