Ask Your Question
1

matching causes assertion error (Features2d + Homography example) Android jni

asked 2012-11-22 11:25:14 -0600

thereisaspoon gravatar image

updated 2013-04-16 12:44:18 -0600

Hi all,

I'm new to using Android and openCV so treat me like an idiot :).

I have taken the Features2d + Homography example and tried to use some of it for my needs in my Android application, I've ran into a problem though and tracked it down to when I try to do some matching.

Here is my code:

JNIEXPORT void JNICALL Java_com_example_basicsstarter_FastBitmapTest2_FindFeatures(JNIEnv*, jobject, jlong addrGray, jlong addrRgba, jlong addrFish)
{

     cv::Mat* pMatG=(Mat*)addrGray;
     cv::Mat* pMatRg=(Mat*)addrRgba;
     cv::Mat* pFis=(Mat*)addrFish;

    std::vector<cv::KeyPoint> vs;
    std::vector<cv::KeyPoint> vo;

    cv::ORB detector(40);
    detector.detect(*pFis, vo);
    detector.detect(*pMatG, vs);

      cv::Mat descriptors_object;
      cv::Mat descriptors_scene;

      detector.compute(*pFis, vo, descriptors_object);
      detector.compute(*pMatG, vs, descriptors_scene);


        std::vector< cv::DMatch > matches;
        BFMatcher matcher(NORM_HAMMING, false);

        matcher.match(descriptors_object, descriptors_scene, matches);
}

When trying to run matcher.match(descriptors_object, descriptors_scene, matches); I get the following error:

11-22 17:49:05.950: E/cv::error()(19616): OpenCV Error: Assertion failed (type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type == CV_8U)) in void cv::batchDistance(cv::InputArray, cv::InputArray, cv::OutputArray, int, cv::OutputArray, int, int, cv::InputArray, int, bool), file /home/alexander/Projects/OpenCV_asmorkalov/opencv/modules/core/src/stat.cpp, line 1803

Followed by

A/libc(19653): Fatal signal 11 (SIGSEGV) at 0xdeadbaad (code=1)

I have tried all sorts of fixes such as using a different combinations of detectors and extractors (such as Fast and FREAK). I've tried changing the Mat type (it is currently CV_8U). I've tried changing the detectors parameters. I just can't figure out why when I try to run the match this is happening. I know the Mat sizes are the same as are the types.

Any help is much appreciated, I've spent far too long trying to figure this out by myself, it's driving me a bit crazy!

Thanks.

edit retag flag offensive close merge delete

Comments

Hi, have you figured it out? I have the same problem with you.

wowoo gravatar imagewowoo ( 2013-02-18 19:56:12 -0600 )edit

@wowoo can you post your code, like that i can't help you

Marwen Z gravatar imageMarwen Z ( 2013-03-18 06:22:40 -0600 )edit

Hi, Same problem here.

void FindPatent(Mat* imgFrame, Mat* imgPatent)
{
    vector&lt;KeyPoint&gt; keyPoints_1, keyPoints_2;
    Mat descriptors_1, descriptors_2;
    ORB orb;

    orb(*imgPatent, Mat(), keyPoints_1, descriptors_1);
    orb(*imgFrame, Mat(), keyPoints_2, descriptors_2);

    BFMatcher matcher(2);
    vector&lt;DMatch&gt; matches;
    matcher.match(descriptors_1, descriptors_2, matches);
...
...

I got same error when matcher.match(...)

Thanks, Neo

neo gravatar imageneo ( 2013-04-16 10:40:17 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2013-04-16 12:46:39 -0600

Basically the input and output matrix do not match. Thats the explicit error. Are you using the same input image for testing this code? It is known that matcher does not work if object and source image are equal for testing purposes.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2012-11-22 11:25:14 -0600

Seen: 2,460 times

Last updated: Apr 16 '13