1

I am using the android camera API for a project I am working on at the moment and I came across a rather strange behavior. When I change the preview size to go to a higher resolution, I indeed get a much better quality preview but there is also this annoying zoom effect that occurs: Say I am holding my device at 5 cm from a object in 1024x512, I can see it entirely. But if I change to 1920x1080, It's like I've zoomed into the object and I need to go further away to capture it entirely. Now that's a bit disappointing as I want a higher resolution to get more details of my object but if I have to go further away from it then the sensor is not sensible enough to get those details. Is there something I misunderstood with the Camera API maybe?

Jérémy Riviere
  • 173
  • 1
  • 10
  • How are you rendering the Camera preview frame? (I'm wondering if it's not getting scaled to the window on the screen.) – fadden Dec 18 '13 at 18:50
  • Using a SurfaceView. I figured the API would set the SurfaceView's resolution according to the preview's resolution. Maybe not. Did not look into the options of the SurfaceView ... – Jérémy Riviere Dec 18 '13 at 19:31
  • TextureView will scale and generally behave like a View. SurfaceView is just a transparent rectangle that sits on top of a layer handled directly by the surface compositor. The TextureView doc (http://developer.android.com/reference/android/view/TextureView.html) has an example of routing the camera preview to the View. – fadden Dec 18 '13 at 20:24
  • Hey sorry I wasn't around during the Xmas break. Thanks fadden for your answer. I went with a TextureView and I have no scaling effect anymore when I change the preview resolution – Jérémy Riviere Jan 02 '14 at 17:52

1 Answers1

1

This could be a bug on your side, or a bug (or a feature, if you like) of the camera on your device. To check, register for preview callback (setOneShotPreviewCallback()), save the buffers that you receive in same position for different resolutions, and compare the images.

From my personal experience, going from 4:3 to 16:9 resolution often reduces the field of view. But in your example, both settings keep same aspect ratio.

Alex Cohn
  • 56,089
  • 9
  • 113
  • 307
  • 1
    I've tried playing with different aspect ratios and turns out you were right. This is the reason to the effect I had noticed. Thanks – Jérémy Riviere Jan 03 '14 at 11:06
  • Hello, I also noticed this effect when I play the android system camera app. 4:3 ratio has a larger field than 16:9 at the same distance. But I encounter a problem, I need this effect in my own app, but when I change the previewsize with API Camera.Parameters.setPreviewSize(int ,int), the field of preview do not change. How do you implement this effect? Did I use the wrong method? – dragonfly Jun 29 '15 at 08:01
  • @dragonfly: I don't quite understand your question. There is no *contract* that controls the field of view for camera when its preview size changes. Please give more details. It will not cost you money to open a new question if you expect something beyond a one-liner reply. – Alex Cohn Jun 29 '15 at 10:54
  • @AlexCohn Dear, please take a look at this: http://stackoverflow.com/questions/31114191/field-of-camera-preview-is-smaller-if-i-use-the-way-of-preview-in-grifikas-cont – dragonfly Jun 29 '15 at 11:13