I have implemented a C++ OpenCV program that extracts characters from images. I want to integrate this program into an android app that takes picture and extracts the characters. For this I have tried cross-compiling C code into arm. I have been able to pass some string arguments and successfully print them inside the executable. Now I am trying to pass path references to a file and try to open the file inside the executable. Here is the code involved for the C file that is turned into an executable:
#include <stdio.h>
int main (int argc, char** argv )
{
char* filename_image;
char* filename_output;
FILE *fp;
if(argc >= 2 )
{
filename_image = argv[1];
filename_output = argv[2];
printf("This is testing...\n");
fp = fopen(filename_output,"r");
if( fp == NULL )
{
printf("file cannot open...\n");
perror("Error while opening the file.\n");
return;
// exit(EXIT_FAILURE);
}
fprintf(fp, "This is testing...\n");
printf("testing done...\n");
fclose(fp);
return;
}
}
and From android I call:
Process process = new ProcessBuilder(executableFilePath,"/sdcard/Pictures/MyCameraApp"+"/param2.txt").start()
Note: /sdcard/Pictures/MyCameraApp/param1.txt and /sdcard/Pictures/MyCameraApp/param2.txt are the paths to files i have created on my device. The output in the LogCat window is: The message file cannot open... Error while opening the file
Any help will be greatly appreciated.