1

We know that we will get a lager field of preview at the same distance when camera preview ratio set to 4:3 instead of 16:9, the detail is as follows:

Android Camera API - Weird zoom effect

But I encountered a problem when I worked with android camera preview with opengl, that is the second way mentioned below.

There are 2 ways of implementing camera preview:

  1. Traditional way without opengl, just use Camera.setPreviewTexture(SurfaceTexture texture) or Camera.setPreviewDisplay(SurfaceHolder holder)
  2. The way of ContinuousCaptureActivity using opengl, we render the preview image with API swapBuffers().

The first way is OK, I will find that preview field become larger if preview ratio changed from 16:9 to 4:3.

However,The second way is not OK in some android phones, the preview field stay the same when preview ratio changed and the preview field is smaller than the first way at the ratio 4:3. I insist that this is an error, I want to resolve this problem very much, Who can give me some advices?

Community
  • 1
  • 1
dragonfly
  • 1,151
  • 14
  • 35
  • @fadden Dear, please take a look at this, I expect your comments. – dragonfly Jun 29 '15 at 11:14
  • No, there can be no guarantee that the FOV of wide picture will be a crop of 4:3 picture, even if this is common behavior on many devices. This is handled by HAL, so Camera2 API may be different from Camera API on the same device. – Alex Cohn Jun 29 '15 at 11:43
  • "Continuous capture" is just calling `setPreviewTexture()` as in #1. The method of rendering the preview shouldn't have any effect on the output from the camera -- Camera is just sending each frame to a Surface. Whether the Surface is attached to a SurfaceView or SurfaceTexture doesn't matter. It'll look different if the Surface is *displayed* differently, i.e. the aspect ratio is off or the layout puts the Surface partly off-screen, but the resolution and aspect ratio are chosen by Camera and shouldn't be affected by how the Surface is used. – fadden Jun 29 '15 at 15:47
  • @fadden But #2 works OK on some devices such as nexus 6, this is true. So I assume there may be some other reasons. – dragonfly Jun 30 '15 at 01:39
  • @fadden Take a look at the answer, I have found the reason! – dragonfly Jun 30 '15 at 07:04
  • @AlexCohn Take a look at the answer, I have found the reason! – dragonfly Jun 30 '15 at 07:04

1 Answers1

4

After a struggle, I finally found out the exact reason, it is the API Camera.Parameters.setRecordingHint(true)

When I removed this clause in my source code, the field of preview became normal.

In one word, the API Camera.Parameters.setRecordingHint(true) is a bug in some android devices.

For some devices, if preview ratio is set to 4:3(use API Camera.Parameters.setPreviewSize(int, int)), calling API setRecordingHint(true) will cause the field of camera preview to be smaller.

dragonfly
  • 1,151
  • 14
  • 35
  • Please clarify. Does `setRecordingHint()` cause the frame size to change? Or the the aspect ratio to change? Or zoom? – Alex Cohn Jun 30 '15 at 09:15
  • @AlexCohn For some devices, if preview ratio set to 4:3, calling API setRecordingHint(true) will cause the field of camera preview to become smaller. – dragonfly Jun 30 '15 at 10:05
  • Thanks, nice to know. But seriously, this is not a bug by any definition I can imagine. There is no requirement that camera focus distance be constant when changing the parameters: `setRecordingHint()`, autoFocus, scene, or other. – Alex Cohn Jun 30 '15 at 10:16