繁体   English   中英

使用OpenCV4Android时无法解决字段“距离”

[英]Field 'distance' could not be resolved when using OpenCV4Android

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

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

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

编辑变化4.x4.4.3在$ {} NDKROOT /来源/ CXX-STL / GNU-的libstdc ++ / 4.x的....

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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