Ask Your Question

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;
    //case SIFT:
    //    name = name + "SIFT";
    //    break;
    //case SURF:
    //    name = name + "SURF";
    //    break;
    case ORB:
        de = ORB::create();
    //case BRIEF:
    //    name = name + "BRIEF";
    //    break;
    case BRISK:
        de = BRISK::create();
    //case FREAK:
    //    name = name + "FREAK";
    //    break;
    case AKAZE:
        de = AKAZE::create();
    default: //**this is line 374**
        CV_Error( Error::StsBadArg, "Specified descriptor extractor type is not supported." );

    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();

. . .

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

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:


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:


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


I am also wondering why the file path is:


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

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

Make sure you set include ... build/OpenCV-android-sdk/sdk/native/jni/ path correctly in your 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

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
Login/Signup to Answer

Question Tools

1 follower


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

Seen: 473 times

Last updated: Jul 27 '16