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?
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;
}