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:
- Traditional way without opengl, just use
Camera.setPreviewTexture(SurfaceTexture texture)
orCamera.setPreviewDisplay(SurfaceHolder holder)
- The way of
ContinuousCaptureActivity
using opengl, we render the preview image with APIswapBuffers()
.
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?
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.