Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Saving image back to sdcard after processing in Android+OpenCV

I want to save the image after processing it, into the same location in sdcard. Initially I converted the image into 'Mat' for processing and now if I'm writing it directly into the same location but it's saving as a file containing some random values. I'm using the following code for writing.

private void write(String fpath, String fname, Mat image, boolean mode) {
// TODO Auto-generated method stub
try {
    File savefile = new File(fpath, "/"+fname);
    FileOutputStream fout = null;
    try {
        fout = new FileOutputStream(savefile,mode);
    } catch (FileNotFoundException e2) {
        // TODO Auto-generated catch block
        e2.printStackTrace();
    }
    PrintWriter pr = new PrintWriter(fout);
    for (int i = 0; i < image.width(); i++){
        for(int j = 0; j < image.height(); j++)
        {
        pr.print(image+"," );
        //pr.print("\n");
    }
    }

    pr.close();
} catch (Exception e) {
    e.printStackTrace();
}

}