OpenCV进行示值误差的Andr​​oid示例程序误差、示例、程序、OpenCV

2023-09-05 11:11:40 作者:烧尽相思

我已经下载了OpenCV的项目为来到捆绑它包含几个错误,Android和样本项目.... 只包含NDK code中的项目有错误.... 问题是,C ++ code显示许多错误... 喜欢的jstring关键字无法识别.. 请帮我解决这个问题? 感谢你提前为您的宝贵时间。

 的#include< jni.h>
#包括< opencv2 /核心/ core.hpp>
#包括< opencv2 / imgproc / imgproc.hpp>
#包括< opencv2 / features2d / features2d.hpp>
#包括<载体>

使用名字空间std;
使用命名空间的简历;

为externC{
JNIEXPORT无效JNICALL Java_org_opencv_samples_tutorial3_Sample3View_FindFeatures(JNIEnv的* ENV,jobject,jint宽度,jint高度,jbyteArray YUV,jintArray BGRA)
{
    jbyte * _yuv = ENV-> GetByteArrayElements(YUV,0);
    jint * _bgra = ENV-> GetIntArrayElements(BGRA,0);

    垫myuv(高+高/ 2,宽度,CV_8UC1,(无符号字符*)_ YUV);
    垫mbgra(高度,宽度,CV_8UC4,(无符号字符*)_ BGRA);
    垫mgray(高度,宽度,CV_8UC1,(无符号字符*)_ YUV);

    //请注意有关BGRA字节顺序
    // ARGB存储在Java作为int数组变为BGRA在本地水平
    cvtColor(myuv,mbgra,CV_YUV420sp2BGR,4);

    矢量<关键点>伏;

    FastFeatureDetector检测器(50);
    detector.detect(mgray,V);
    用于(为size_t I = 0; I< v.size();我++)
        圆(mbgra,点(V [I] .pt.x,V [I] .pt.y),10,标量(0,0,255,255));

    ENV-> ReleaseIntArrayElements(BGRA,_bgra,0);
    ENV-> ReleaseByteArrayElements(YUV,_yuv,0);
}

}
 

错误..

 未解决的包容:其中,载体GT;
符号性病无法解析
 

解决方案

@诺兰的回答跟@迈克尔的意见解决了这个问题对我来说。下面是合并的步骤:

在Eclipse中,右键点击你的项目并选择属性(这是在Mac上的BTW) 在展开的 C / C ++通用 选择路径和符号 在语言选择 GNU C ++

以下包括应在规定的包含目录

  $ {NDKROOT} /平台/ Android的9 /弓臂/ usr / include目录
$ {ProjDirPath} /../../ SDK /本地/ JNI /包括
$ {NDKROOT} /来源/ CXX-STL / GNU-的libstdc ++ / 4.4.3 /库/ armeabi-V7A /包括
$ {NDKROOT} /来源/ CXX-STL / GNU-的libstdc ++ / 4.4.3 /包括
 

确认$ {NDKROOT}被定义为环境变量。如果它不继续前进,在添加它的 C / C ++编译 - 环境

现在,继续前进,重建索引通过右键点击你的项目,并选择索引 - 重建

干杯。

I have downloaded OpenCV project for android and the sample projects that came bundled with it contains several errors.... Only the projects that contain the NDK code has the errors.... The problem is that the C++ code shows many errors... The keywords like jstring are not recognised.. Kindly help me resolve this issue... Thanking you in advance for your valuable time

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

using namespace std;
using namespace cv;

extern "C" {
JNIEXPORT void JNICALL Java_org_opencv_samples_tutorial3_Sample3View_FindFeatures(JNIEnv* env, jobject, jint width, jint height, jbyteArray yuv, jintArray bgra)
{
    jbyte* _yuv  = env->GetByteArrayElements(yuv, 0);
    jint*  _bgra = env->GetIntArrayElements(bgra, 0);

    Mat myuv(height + height/2, width, CV_8UC1, (unsigned char *)_yuv);
    Mat mbgra(height, width, CV_8UC4, (unsigned char *)_bgra);
    Mat mgray(height, width, CV_8UC1, (unsigned char *)_yuv);

    //Please make attention about BGRA byte order
    //ARGB stored in java as int array becomes BGRA at native level
    cvtColor(myuv, mbgra, CV_YUV420sp2BGR, 4);

    vector<KeyPoint> v;

    FastFeatureDetector detector(50);
    detector.detect(mgray, v);
    for( size_t i = 0; i < v.size(); i++ )
        circle(mbgra, Point(v[i].pt.x, v[i].pt.y), 10, Scalar(0,0,255,255));

    env->ReleaseIntArrayElements(bgra, _bgra, 0);
    env->ReleaseByteArrayElements(yuv, _yuv, 0);
}

}

errors..

Unresolved inclusion: <vector>
Symbol 'std' could not be resolved

解决方案

@Nolan's answer followed by @Michael's comment solved it for me. Here are the combined steps:

In Eclipse, right click on your project and select properties (This is on a mac btw) Expand C/C++ General Select Paths and Symbols Under Languages select GNU C++

The following includes should be defined under Include directories

${NDKROOT}/platforms/android-9/arch-arm/usr/include
${ProjDirPath}/../../sdk/native/jni/include
${NDKROOT}/sources/cxx-stl/gnu-libstdc++/4.4.3/libs/armeabi-v7a/include
${NDKROOT}/sources/cxx-stl/gnu-libstdc++/4.4.3/include

Make sure ${NDKROOT} is defined as an environment variable. If it's not go ahead and add it under C/C++ Build - Environment

Now go ahead and rebuild the index by right clicking on your project and select Index - Rebuild

Cheers.