Re: Mat doesn't get written to SDCard file

57 views
Skip to first unread message

VT

unread,
Jul 1, 2012, 10:46:21 PM7/1/12
to android...@googlegroups.com

Do you have a debugger attached to the phone when you run your program? If so, can you unplug the USB cable and then test?

On Thursday, June 28, 2012 3:32:12 AM UTC-7, Rangitha wrote:
I'm performing a simple grayscale conversion to a JPEG file from the SDcard. The result is also saved in the SDcard after conversion.
The code executes without error, but the converted file does not appear either in the Gallery or in any other file explorer.
I've added the write permission to the manifest plus tested while the phone is not connected via USB. Here's my code;
(I'm using the latest OpenCV binary release for Android - 2.4.1)

<manifest...
    <users-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> 
</manifest>

        public void processClick(View view)
{
Mat m;

m = loadImage();
        convertGrayscale(m);
}

public Mat loadImage()
{
Mat m = Highgui.imread("/mnt/sdcard/image2.jpg", 1);

Context context = getApplicationContext();  //show toast
CharSequence text = "Image loaded.";
int duration = Toast.LENGTH_SHORT;
Toast.makeText(context, text, duration).show();

return m;
}
private void convertGrayscale(Mat mIn)
{
Mat mOut = new Mat();

Imgproc.cvtColor(mIn, mOut, Imgproc.COLOR_RGB2GRAY);
Highgui.imwrite("/mnt/sdcard/DCIM/gray.jpg", mOut);

Context context = getApplicationContext(); //show toast
CharSequence text = "Image converted to grayscale.";
int duration = Toast.LENGTH_SHORT;
Toast.makeText(context, text, duration).show();
return mOut;
}

Andrey Pavlenko

unread,
Jul 2, 2012, 1:00:57 PM7/2/12
to android...@googlegroups.com
Can you successfully write files to the same location without OpenCV via Android Java API?
Reply all
Reply to author
Forward
0 new messages