The captured image of the camera looks blurry.

In my application, the image taken from my problem looks blurry when the image that is captured by the camera component of the device looks good - the effect of automatic scaling occurs after the user presses the capture button. can someone help me 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(); } 
+4
source share
1 answer

Well, in your text you are talking about image capture, but I don’t see anything in your shooting code. In any case, if you want to get a focused photo, you need to register AutoFocusCallback to take a picture when the focus is received:

 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); } 

.

+11
source

Source: https://habr.com/ru/post/1390679/


All Articles