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);
}
else
{
Log.d(TAG, "------> version less than eclari 2.1");
parameters.setPreviewSize(ApplicationInitiator.screenW,ApplicationInitiator.screenH);
}
List<String> focusModes = parameters.getSupportedFocusModes();
if (focusModes.contains(Camera.Parameters.FOCUS_MODE_AUTO))
{
parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_AUTO);
}
parameters.setJpegQuality(100);
camera.setParameters(parameters);
camera.startPreview();
}
Check to see if you can focus the lens manually to make sure the focus mechanism is not jammed. Also, check to see if the lens has a focus limiting switch. Some macro lenses and some of the longer zoom lenses have a switch that limits the range of focus.
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() {
@Override
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() {
mCamera.autoFocus(mAutoFocusCallback);
}
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With