Harshjags
Harshjags

Reputation: 163

What is the best camera parameters for android camera opened in surface view

The below is my Android camera parameter printed using flaten(). I use Surface view and open my camera manually by using camera.open(). I set camera.paramter using setParameter().

-max=30;zoom=0;taking-picture-zoom=0;zoom-supported=true;sharpness-min=0;sharpness=10;contrast=5;whitebalance=auto;jpeg-quality=100;preview-format-values=yuv420sp;jpeg-thumbnail-quality=75;preview-format=yuv420sp;preview-size=576x432;focal-length=4.92;iso=auto;meter-mode=meter-center;front-camera-mode=mirror;flash-mode-values=off,auto,on,torch;preview-frame-rate-values=15;preview-frame-rate=15;focus-mode-values=auto,infinity;jpeg-thumbnail-width=768;jpeg-thumbnail-size-values=768x576,640x480,512x384,0x0;zoom-ratios=100,114,131,151,174,200;saturation-def=5;preview-size-values=1280x720,800x480,768x432,720x480,640x480,576x432,480x320,400x240,384x288,352x288,320x240,272x272,240x240,240x160,176x144;smart-contrast=off;picture-size-values=3264x2448,3264x1952,2592x1952,2592x1552,2048x1536,2048x1216,1600x1200,1280x960,1280x768,1024x768,640x480,640x384,512x384,400x400,272x272;contrast-min=0;min-exposure-compensation=-4;brightness-min=0;antibanding=auto;taking-picture-zoom-min=0;saturation-min=1;contrast-max=10;vertical-view-angle=38;taking-picture-zoom-max=30;contrast-def=5;brightness-max=6;horizontal-view-angle=49.5;brightness=3;jpeg-thumbnail-height=576;cam-mode=0;focus-mode=auto;sharpness-def=10;front-camera-mode-values=mirror,reverse;picture-format-values=jpeg;saturation-max=10;max-exposure-compensation=4;exposure-compensation=0;exposure-compensation-step=0.5;flash-mode=off;effect-values=none,mono,negative,solarize,sepia,posterize,aqua;meter-mode-values=meter-average,meter-center,meter-spot;picture-size=1024x768;max-zoom=5;effect=none;saturation=5;whitebalance-values=auto,incandescent,fluorescent,daylight,cloudy-daylight;picture-format=jpeg;brightness-def=3;iso-values=auto,deblur,100,200,400,800,1250;antibanding-values=off,50hz,60hz,auto**

**

**

Upvotes: 1

Views: 11801

Answers (1)

Mirco Widmer
Mirco Widmer

Reputation: 2149

It has to do with the different preview sizes there are for the different phones.

The following method I used in a camera preview related android project:

Inside the surfaceCreated Method:

Camera camera = Camera.open(CameraInfo.CAMERA_FACING_BACK);
final Camera.Parameters params = camera.getParameters();
final Size size = getOptimalSize();
params.setPreviewSize(size.width, size.height);
camera.setParameters(params);

Inside the same activity:

private Size getOptimalSize() {
    Camera.Size result = null;
    final Camera.Parameters parameters = camera.getParameters();
    Log.i(Preview.class.getSimpleName(), "window width: " + getWidth() + ", height: " + getHeight());
    for (final Camera.Size size : parameters.getSupportedPreviewSizes()) {
        if (size.width <= getWidth() * PREVIEW_SIZE_FACTOR && size.height <= getHeight() * PREVIEW_SIZE_FACTOR) {
            if (result == null) {
                result = size;
            } else {
                final int resultArea = result.width * result.height;
                final int newArea = size.width * size.height;

                if (newArea > resultArea) {
                    result = size;
                }
            }
        }
    }
    if (result == null) {
        result = parameters.getSupportedPreviewSizes().get(0);
    }
    Log.i(Preview.class.getSimpleName(), "Using PreviewSize: " + result.width + " x " + result.height);
    return result;
}

Of course I should add, that the factor we used was: PREVIEW_SIZE_FACTOR = 1.30;

Upvotes: 5

Related Questions