3

After implementing the camera2 API for the inApp camera I noticed that on Samsung devices the images appear blurry. After searching about that I found the Sasmung Camera SDK (http://developer.samsung.com/galaxy#camera). So after implementing the SDK on Samsung Galaxy S7 the images are fine now, but on Galaxy S6 they are still blurry. Someone experienced those kind of issues with Samsung devices?

EDIT: To complement @rcsumners comment. I am setting autofocus by using

mPreviewBuilder.set(SCaptureRequest.CONTROL_AF_TRIGGER, SCaptureRequest.CONTROL_AF_TRIGGER_START);
mSCameraSession.capture(mPreviewBuilder.build(), new SCameraCaptureSession.CaptureCallback() {
            @Override
            public void onCaptureCompleted(SCameraCaptureSession session, SCaptureRequest request, STotalCaptureResult result) {
                isAFTriggered = true;
            }
        }, mBackgroundHandler);

It is a long exposure image where the use has to take an image of a static non moving object. For this I am using the CONTROL_AF_MODE_MACRO

mCaptureBuilder.set(SCaptureRequest.CONTROL_AF_MODE, SCaptureRequest.CONTROL_AF_MODE_MACRO);

and also I am enabling auto flash if it is available

requestBuilder.set(SCaptureRequest.CONTROL_AE_MODE,
                SCaptureRequest.CONTROL_AE_MODE_ON_AUTO_FLASH);

I am not really an expert in this API, I mostly followed the SDK example app.

Tooroop
  • 1,824
  • 1
  • 20
  • 31
  • This is an extremely broad question. What were the conditions of the capture? Was auto-focus allowed to converge? Was it a long exposure with camera or subject motion? Was it low light? It is near impossible to say "Oh yes, the software make it blurry," unless it is a documented bug, which is less likely. – rcsumner Aug 04 '16 at 05:58

2 Answers2

0

There could be a number of issues causing this problem. One prominent one is the dimensions of your output image I ran Camera2 API and the preview is clear, but the output was quite blurry

        val characteristics: CameraCharacteristics? = cameraManager.getCameraCharacteristics(cameraId)
        val size = characteristics?.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP)?.getOutputSizes(ImageFormat.JPEG) // The issue
        val width = imageDimension.width
        val height = imageDimension.height
        if (size != null) {
            width = size[0].width; height = size[0].height
        }
        val imageReader = ImageReader.newInstance(width, height, ImageFormat.JPEG, 5)

The code below was returning a dimension about 245*144 which was way to small to be sent to the image reader. Some how the output was stretching the image making it end up been blurry. Therefore I removed this line below.

val size = characteristics?.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP)?.getOutputSizes(ImageFormat.JPEG) // this was returning a small

Setting the width and height manually resolved the issue.

Onwuka Daniel
  • 105
  • 1
  • 7
0

You're setting the AF trigger for one frame, but then are you waiting for AF to complete? For AF_MODE_MACRO (are you verifying the device lists support for this AF mode?) you need to wait for AF_STATE_FOCUSED_LOCKED before the image is guaranteed to be stable and sharp. (You may also receive NOT_FOCUSED_LOCKED if the AF algorithm can't reach sharp focus, which could be because the object is just too close for the lens, or the scene is too confusing)

On most modern devices, it's recommended to use CONTINUOUS_PICTURE and not worry about AF triggering unless you really want to lock focus for some time period. In that mode, the device will continuously try to focus to the best of its ability. I'm not sure all that many devices support MACRO, to begin with.

Eddy Talvala
  • 17,243
  • 2
  • 42
  • 47