У меня есть код JNI, который использует C++.Ошибка «Не объявлена в этой области» в Android JNI C++
#include <eigenfaces_jni.h>
#include <opencv2/core/core.hpp>
#include <opencv2/contrib/contrib.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <string>
#include <vector>
#include <iostream>
#include <fstream>
#include <sstream>
using namespace std;
using namespace cv;
JNIEXPORT jstring JNICALL Java_com_example_facedetector_FaceTracker_nativeCreateObject
(JNIEnv *env, jclass, jstring JFileDir){
// These vectors hold the images and corresponding labels.
vector<Mat> images;
const char *str = env->GetStringUTFChars(jFileDir, NULL);
const char *buf;
/*Releasing the Java String once you have got the C string
is very important!!!*/
env->ReleaseStringUTFChars(jFileDir, str);
Mat im = imread(jFileDir);
if (im.empty())
{
cout << "Cannot load image!" << endl;
buf = "Can load image";
}
else{
buf = "Cannot load image";
}
return env->NewStringUTF("Hello");
}
Однако, всегда есть ошибка при
const char *str = env->GetStringUTFChars(jFileDir, NULL);
, который гласит, что
- Symbol 'jFileDir' could not be resolved
- 'jFileDir' was not declared in this scope
- Invalid arguments ' Candidates are: const char * GetStringUTFChars(_jstring *, unsigned
char *) '
Пробовал решение в этой связи Type 'std::string' could not be resolved. До сих пор не работает. Любая помощь для решения этой проблемы будет оценена по достоинству. Спасибо.
Owh my .... это глупый вопрос, тогда я потратил часы на поиск этой ошибки по всему Интернету, получается небольшая ошибка ... Большое спасибо. – Jack