sakshi sakshi - 4 months ago 19x
Android Question

Captured camera image is looking blurry

My issue captured image is looking blurry in my application where as the image that is captured with the device camera component is looking good - something auto zoom effect is going once user click on capture button. can some one help me to achieve this scenario how and where should i apply.

here is the code:

public void surfaceChanged(SurfaceHolder holder, int format, int width,int height) {
// Now that the size is known, set up the camera parameters and begin
// the preview.
Camera.Parameters parameters = camera.getParameters();
Integer version = Integer.parseInt(Build.VERSION.SDK);
if(version > Build.VERSION_CODES.ECLAIR_MR1)
Log.d(TAG, "------> version greater than eclari 2.1");
List<Size> sizes = parameters.getSupportedPreviewSizes();
Size optimalSize = getOptimalPreviewSize(sizes, width, height);
parameters.setPreviewSize(optimalSize.width, optimalSize.height);
Log.d(TAG, "------> version less than eclari 2.1");

List<String> focusModes = parameters.getSupportedFocusModes();
if (focusModes.contains(Camera.Parameters.FOCUS_MODE_AUTO))



Well, on your text you talk about capturing a image, but I don't see anything in your code about taking a picture, Anyway, if you want to obtain a focused photo, what you have to do is register a AutoFocusCallback to take a picture when focus is obtained:

Camera.AutoFocusCallback mAutoFocusCallback = new Camera.AutoFocusCallback() {
    public void onAutoFocus(boolean success, Camera camera) {
        camera.takePicture(null, null, mPictureCallbackRaw);

Camera.PictureCallback mPictureCallbackRaw = new Camera.PictureCallback() {  
    public void onPictureTaken(byte[] data, Camera c) { 
        // (...)            

public void takeFocusedPicture() {