Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Android 4.2 OpenCV 2.4.4 Highgui.imwrite fails

Hi

This code used to work but on Android 4.2 and OpenCV 2.4.4 it fails, but I don't know why. Can anyone shed any light on it for me?

Thanks for any help.

Baz

public void SaveImage (Mat mat) {
    Mat mIntermediateMat = new Mat();

    Imgproc.cvtColor(mRgba, mIntermediateMat, Imgproc.COLOR_RGBA2BGR, 3);

    File path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
    String filename = "barry.png";
    File file = new File(path, filename);

    Boolean bool = null;
    filename = file.toString();
    bool = Highgui.imwrite(filename, mIntermediateMat);

    if (bool == true)
        Log.d(TAG, "SUCCESS writing image to external storage");
    else
        Log.d(TAG, "Fail writing image to external storage");
    }

bool comes back false every time. The file path/name is as it should be ("storage/emulated/0/Pictures/barry.png") for User #0 and the directory Pictures is there.

What can make imwrite return false?

Many thanks

Baz