1

I wanted to save the OpenCV resultant Images into my Android gallery automatically but in my case the Images are not being saved in my gallery.

Here's my code for saving the Images.

String Folder = Environment.getExternalStorageDirectory().getPath()+"/Gallery";
String timestamp = new SimpleDateFormat("yyyyMMdd_HHmmss").Format(new Date());
Highgui.imwrite(Folder + "/" + "Name_" + timestamp + ".png", outputImage);

I had a look into my Android Manifest file too and I had permissions to write the Images into storage card.

WhoAmI
  • 257
  • 1
  • 15
  • OpenCV is silent if you pass a nonexistent folder to save the file. You make sure that `Environment.getExternalStorageDirectory().getPath()+"/Gallery"` Actually exists. You may use `file.exists();`. – ZdaR Sep 09 '16 at 12:18

1 Answers1

1

To save images to the user gallery, simply use this piece of code:

MediaStore.Images.Media.insertImage(getContentResolver(), yourBitmap, yourTitle , yourDescription);

From https://stackoverflow.com/a/8722494/2707325

Community
  • 1
  • 1
Mehmet K
  • 2,805
  • 1
  • 23
  • 35