nicolas2k / google-glass-api

Automatically exported from code.google.com/p/google-glass-api
1 stars 0 forks source link

Pictures saved with Camera API not visible to user #308

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Load Camera API Sample from ApiDemos
2. Call takePicture(null, null, mPicture);
3. Save picture to DCIM\Test in onPictureTaken
4. Plug in Glass and browse to location, picture & folder are not visible
5. Turn Glass off & on again (aka "the solution to every problem")
6. Plug in Glass and browse to location, picture & folder are visible now

What is the expected output? What do you see instead?
I expected the image to be visible to the user immediately after being saved in 
onPictureTaken. Instead, the user must power Glass off & on again before they 
can download the saved images. The stock camera app images are visible 
immediately after being taken however.

What version of the product are you using? On what operating system?
GLASS v1 (not yet swapped), XE12, GDK v2

Please provide any additional information below.

<code>
    private PictureCallback mPicture = new PictureCallback() {

          @Override
          public void onPictureTaken(byte[] data, Camera camera) {
              File pictureFile = getDir();
              Bitmap bmp = BitmapFactory.decodeByteArray(data , 0, data.length);

              try {
                  FileOutputStream fos = new FileOutputStream(pictureFile);
                  bmp.compress(Bitmap.CompressFormat.PNG, 100, fos);
                  fos.close();
              } catch (Exception e) {
                  e.printStackTrace();
              }

              mMainService.startUpdate();
              releaseCamera(); 
              finish();
          }

          private File getDir() {
              File mediaStorageDir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM), "Test");
              if (!mediaStorageDir.exists()) {
                  if (!mediaStorageDir.mkdirs()) {
                      Log.d(TAG, "failed to create directory");
                      return null;
                  }
              }
              // Create a media file name
              String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
              File mediaFile;
              mediaFile = new File(mediaStorageDir.getPath() + File.separator + "IMG_" + timeStamp + ".jpg");
              Log.d("Gauss", "Saving to: " + mediaFile.getAbsolutePath());
              return mediaFile;
          }
    };

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
          if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER) {
              mCamera.takePicture(null, null, mPicture);
              return true; 
          } else {
              return super.onKeyDown(keyCode, event);
          }
    }
</code>

Original issue reported on code.google.com by groupwis...@gmail.com on 18 Dec 2013 at 12:35

GoogleCodeExporter commented 8 years ago
Hello,

Have you tried following the steps provided in the CameraManager class:
  https://developers.google.com/glass/develop/gdk/reference/com/google/android/glass/media/CameraManager

This explains how you can use an ACTION_IMAGE_CAPTURE intent to capture an 
image with Glass.

Best,
Alain

Original comment by ala...@google.com on 18 Dec 2013 at 4:55

GoogleCodeExporter commented 8 years ago
Yes, taking a picture by launching the intent works, but it isn't what I need. 
I am building an app that needs to be hands-free and take a burst of images. 
The camera intent requires the user to tap to accept each image.

Original comment by groupwis...@gmail.com on 18 Dec 2013 at 5:26

GoogleCodeExporter commented 8 years ago

Original comment by ala...@google.com on 18 Dec 2013 at 5:50

GoogleCodeExporter commented 8 years ago
Issue 365 has been merged into this issue.

Original comment by ala...@google.com on 15 Jan 2014 at 4:49

GoogleCodeExporter commented 8 years ago
Hi,
Did you manage to take a burst of images without the previewwith the GDK ?

Original comment by guilla...@touchsurgery.com on 23 May 2014 at 11:01

GoogleCodeExporter commented 8 years ago
I also can't "tap to accept" my camera intent, OnActivtyResult doesn't not get 
called

Original comment by Cooler...@gmail.com on 11 Jul 2014 at 3:26

GoogleCodeExporter commented 8 years ago
this might be related to the behaviour whereby taking a picture with the Camera 
Intent will NOT yield a written file observable by a FileObserver the first 
time, while subsequent attempts will be observable by a FileObserver.

Original comment by coreform on 13 Oct 2014 at 11:50

GoogleCodeExporter commented 8 years ago
I ran into the same issue. Here is a solution (only a bit over a year late). 
After saving the new picture, call the following method and give the second 
parameter the filename of the picture: 

public static void scanFile(Context context, String filename)
{
    context.getApplicationContext().sendBroadcast(
            new Intent("android.intent.action.MEDIA_SCANNER_SCAN_FILE",
            Uri.fromFile(new File(filename))));
}

Original comment by andresac...@gmail.com on 7 Mar 2015 at 5:18