Ask Your Question

Revision history [back]

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

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.

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

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

1803

Followed by

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

(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.