Ask Your Question
0

feature2d_manual.hpp modifications don't take effect

asked 2016-06-22 05:29:32 -0600

Dolpho gravatar image

I am trying to use BRIEF descriptor in OpenCV 3.1 for andoid. In order to achieve that OpenCV has to be built from source with _contrib. So I compiled it without errors and could also see BRIEF.cpp.o beeing built in the command window.

When I try to use it, my android app crashes throwing

OpenCV Error: Bad argument (Specified descriptor extractor type is not supported.) in static cv::javaDescriptorExtractor* cv::javaDescriptorExtractor::create(int), file /home/maksim/workspace/android-pack/opencv/modules/features2d/misc/java/src/cpp/features2d_manual.hpp, line 374

So I checked features2d_manual.hpp. Line 374 is the default expression of a switch case block:

CV_WRAP static javaDescriptorExtractor* create( int extractorType )
{
    //String name;

    if (extractorType > OPPONENTEXTRACTOR)
    {
        //name = "Opponent";
        extractorType -= OPPONENTEXTRACTOR;
    }

    Ptr<DescriptorExtractor> de;
    switch(extractorType)
    {
    //case SIFT:
    //    name = name + "SIFT";
    //    break;
    //case SURF:
    //    name = name + "SURF";
    //    break;
    case ORB:
        de = ORB::create();
        break;
    //case BRIEF:
    //    name = name + "BRIEF";
    //    break;
    case BRISK:
        de = BRISK::create();
        break;
    //case FREAK:
    //    name = name + "FREAK";
    //    break;
    case AKAZE:
        de = AKAZE::create();
        break;
    default: //**this is line 374**
        CV_Error( Error::StsBadArg, "Specified descriptor extractor type is not supported." );
        break;
    }

    return new javaDescriptorExtractor(de);

Clearly the error comes up, because case BRIEF is commented. I modified it like that:

#include "opencv2/xfeatures2d.hpp"

. . .

case BRIEF:
    de = xfeatures2d::BriefDescriptorExtractor::create();
    break;

. . .

default:
            CV_Error( Error::StsBadArg, "---TEST--- Specified descriptor extractor type is not supported." );
            break;
        }

After rebuiling in a fresh directory and using the new build, the exact same error is persistent. Not even "---TEST---" is included with the message.

Now I am wondering why my changes do not have any effect.

I am also wondering why the file path is:

/home/maksim/workspace/android-pack/opencv/modules/features2d/misc/java/src/cpp/features2d_manual.hpp

This dirctory doesn't even exist on my system and googling it showed, that /home/maksim/ is part of a lot of different error messages on android.

The actual path before building is:

C:\Users\JJG-CD\Desktop\Build_Workspace\opencv-3.1.0\modules\features2d\misc\java\src\cpp\features2d_manual.hpp

I hope somebody can explain to me what the problem is and eventually give me a hint how to solve it.

edit retag flag offensive close merge delete

Comments

I am also wondering why the file path is:

/home/maksim/workspace/android-pack/opencv/modules/features2d/misc/java/src/cpp/features2d_manual.hpp

that's because maksim built it, and the filepath to the src got saved in the build.

berak gravatar imageberak ( 2016-07-27 05:10:09 -0600 )edit

2 answers

Sort by ยป oldest newest most voted
2

answered 2016-07-27 04:36:37 -0600

I've encountered the same issue, and here's my solution:

Copy the folder xfeatures2d and file xfeatures2d.hpp from opencv_contrib/modules/xfeatures2d/include/opencv2 to the OpenCV master path : opencv/modules/features2d/include/opencv2.

And modify the features2d_manual.hpp file as you did.

Copy the brief.cpp file located at opencv_contrib/modules/xfeatures2d/src to your project's jni folder and add brief.cpp to LOCAL_SRC_FILES in your Android.mk.

Make sure you set include ... build/OpenCV-android-sdk/sdk/native/jni/OpenCV.mk path correctly in your Android.mk file.

When build is finished, make sure you re-install the new OpenCV Manager (at build/OpenCV-android-sdk/apk) to your device.

edit flag offensive delete link more
0

answered 2016-07-28 12:40:39 -0600

Dolpho gravatar image

Thanks for your answers. I already solved it a while ago. My problem was that i didn't initialize opencv statically, so the build from opencv manager has been used. Adding

static {
    if (!OpenCVLoader.initDebug()) {
        // Handle initialization error
    }
}

solved it for me.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2016-06-22 05:29:32 -0600

Seen: 1,595 times

Last updated: Jul 27 '16