get Camera Instance and set rotation and Orientation - Android Camera

Android examples for Camera:Camera Orientation

Description

get Camera Instance and set rotation and Orientation

Demo Code


//package com.java2s;
import android.hardware.Camera;
import android.util.Log;

public class Main {
    private static final String TAG = "CameraHelper";

    public static Camera getCameraInstance() {
        Camera camera = null;/* www  . ja v  a 2  s  . co m*/
        try {
            camera = Camera.open();
            Camera.Parameters parameters = camera.getParameters();
            camera.setDisplayOrientation(90);
            parameters.setRotation(90);
            camera.setParameters(parameters);
        } catch (Exception e) {
            // Camera is not available or doesn't exist
            //            com.example.lightsoo.mycustomcamera.Util.Log
            Log.d(TAG, "getCamera failed");
        }
        return camera;
    }
}

Related Tutorials