0

我试图在 Android 应用程序中使用 ORB 功能,并创建一个项目。当我使用 BruteForceMatcher 并编写代码:dist=matches[i].distance,我的 IDE 通知我“无法解析字段'距离'”。为什么会这样?

#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;
}
}
4

1 回答 1

0

转到项目属性 -> C/C++ 常规 -> GNU C++ ->

在 ${NDKROOT}/sources/cxx-stl/gnu-libstdc++/4.x.. 中编辑更改4.x4.4.3 。

于 2014-04-01T13:31:47.673 回答