Recently I'm doing some stuff on Android using JNI and C++
I want to write the result to the android file system with cv::imwrite() to check if I'm doing right, however, there is no file written into it. I also tried to write text file, failed again.
Here is part of my code. Is there anything I'm doing wrong? Thanks for your help!
JNIEXPORT void JNICALL Java_com_project_NativeLibs_test(JNIEnv *env, jclass clazz
{
LOGV("test CALLED");
std::string file1, file2, outFile;
file1 = "/sdcard/test_data/images/box.pgm";
file2 = "/sdcard/test_data/images/scene.pgm";
outFile = "/sdcard/output_data/JNI_after.png";
cv::Mat objectImg = cv::imread(file1, cv::IMREAD_GRAYSCALE);
cv::Mat sceneImg = cv::imread(file2, cv::IMREAD_GRAYSCALE);
cv::Mat out;
// ... some Mat process get output to Mat out
cv::imwrite(outFile, out);
std::ofstream filetest;
filetest.open("test.txt");
filetest<<"writing from JNI";
filetest.close();
LOGV("Done Finally");
}