简体   繁体   中英

Field 'distance' could not be resolved when using OpenCV4Android

I was tring to use ORB feature in Android apps,and create a project.When I use BruteForceMatcher and write the code:dist=matches[i].distance, My IDE notice me that "Field 'distance' could not be resolved". Why this happened?

#include <jni.h>
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/features2d/features2d.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/legacy/legacy.hpp>
#include <iostream>
#include <vector>

using namespace std;
using namespace cv;

extern "C" {

JNIEXPORT int JNICALL Java_org_opencv_samples_tutorial2_Tuturial2Activity_CompareFeatures(JNIEnv*, jobject, jlong addrGray, jlong addrRgba);

JNIEXPORT int JNICALL Java_org_opencv_samples_tutorial2_Tuturial2Activity_CompareFeatures(JNIEnv*, jobject, jlong addrGray, jlong addrRgba)
{
    char img_filename1[]="/sdcard/src.jpg";
    char img_filename2[]="/sdcard/demo.jpg";
    Mat src1,src2;

    src1=imread(img_filename1,CV_LOAD_IMAGE_GRAYSCALE);
    src2=imread(img_filename2,CV_LOAD_IMAGE_GRAYSCALE);

    ORB orb;
    vector<KeyPoint> keys1,keys2;
    Mat descriptors1,descriptors2;
    orb(src1,Mat(),keys1,descriptors1);
    orb(src2,Mat(),keys2,descriptors2);

    BruteForceMatcher<HammingLUT> matcher;
    vector<DMatch> matches;
    matcher.match(descriptors1,descriptors2,matches);

    double max_dist=0; double min_dist=255;
    //--Quick calculation of max and min distances between keypoints

    for (int i=0;i<descriptors1.rows;i++)
    {
        double dist=matches[i].distance;

    }
    return 0;
}
}

Goto Project Properties -> C/C++ General -> GNU C++ ->

Edit change 4.x to 4.4.3 in ${NDKROOT}/sources/cxx-stl/gnu-libstdc++/4.x....

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM