1

I am trying to write an android applications witch calculates keypoints and descriptors using opencv and store them. However i am getting troubles with cv:FileStorage. I am actually passing the file path throw native methods. The same path (different file ending) is also used to store another file on the javaside.

JNIEXPORT void JNICALL Java_com_..._CalcFeatures(JNIEnv* env, jobject, jlong addrGray, jstring location){
...
const char *nativeString = env->GetStringUTFChars(location, NULL);
string filepath=string(nativeString);
FileStorage fs(filepath, FileStorage::WRITE);
fs<<"frameCount"<<5;
fs.release();
...
}

LogCat output:

Fatal signal 11 (SIGSEGV) at 0x000009f4 (code=19), thread 23789 

I also tryed to hardcode the path (like „/sdcard/test.xml“ or „/storage/emulated/0/text.xml“). If I am using “test.xml” as filepath, I don’t get any errors, but I am not able to find the file on my phone (HTC One).

Any advices?

Thanks for your time.

UPDATE:

this works just fine, so there is a problem with FileStorage. Is there any other way in opencv to parse it to an xml/json format? perhaps with string as result?

FILE* file = fopen(nativeString,"w+");
fputs("hello, world\n", file);
fclose(file);
Reas0
  • 11
  • 3

1 Answers1

0

I've asked similar question here: imread returns empty matrix while ifstream can open and read the same file and I found that even if I can manipulate file from native part, I cant use opencv's FileStorage.

And that's why I'm not able to load matrix,cascade classifier,etc.

I also tried load data from file to memory and create FileStorage from memory, it created for writing, but it does not works (while it works on windows perfectly). I cant access to any node.

Community
  • 1
  • 1
Andrey Smorodov
  • 10,649
  • 2
  • 35
  • 42