durka/HallMonitor

Add camera control

Closed this issue · 9 comments

I want to implement a basic camera capability for whilst the cover is closed - press a button to get an image preview showing in the windowed area, then press another button to take a photo. I've created a new 'camera' branch for this.

i included your camera stuff to the TestInput repository (read here).

This works well. Except for two things:

  • I'm not sure about stretching the camera preview to fill the available space. It's too distorted. It's going to be really small if we keep the correct aspect ratio, but still... maybe better than distortion.
  • At least on my phone, pictures taken from HM show up at the end of my Gallery, instead of at the beginning where new pictures usually are. It seems to be that HM and Camera use slightly different filename patterns. Did your code for saving the image (the PictureCallback) come from a particular example?

Yep, I agree about the preview window - I think we could get away with sizing it a bit beyond the window space, as it's mainly the centre of the view that you are interested in.

And yep, I just pilfered someone else's code for the saving location (http://stackoverflow.com/questions/9853351/building-my-own-camera-application-automatically-capture-the-image) - we can definitely look to tweak that.

Otherwise, it also isn't saving the images the right way up so that needs addressing, and I introduced a bug with the media player control along the way so that also needs looking into. I should get a chance on the 2nd to have another look, but feel free to sort the above out before then! :0)

Happy New Year!! :0)

Happy new year! I dove in and ended up rearranging more than I meant to -- I put the layout into XML and moved the actual taking of the picture into CameraPreview. I'm still stumped as to how to get the photos showing up at the beginning of the Gallery as if they were new camera photos. For me, they show up at the end of the Gallery since the filename is different.

You're right, there's some weird bug with saving the photo - Android has some strange ideas about the orientation.

Managed to get the photos to the right end of the gallery - needed to add date metadata to them. I've also switched it to a better auto focus mode, and downsized the preview so it has a decent aspect ratio. Pictures are taken the right way up if you have the phone in portrait orientation - I've not managed to get it to work correctly with landscape orientation (yet!).

The problem is that rotation is disabled on DefaultActivity, so orientation changes are not received and getRotation() will always return 0.

Fixed using OrientationEventListener.

Edit: um, except that viewing the resulting image crashes the Gallery... that's a new one...
Edit 2: don't save images with orientation greater than 360!

Gallery bug reported.