Problem with Samsung Galaxy SIII - Camera.onPictureTaken () returns interlaced image instead of correct capture image

We have an application that uses the rear β€œcamera” to capture an image of an element. So far, all the devices that we tested are working correctly in terms of image capture, as it should be, to the Samsung Galaxy SIII (S3).

Only in the Samsung Galaxy SIII do we observe that Camera.onPictureTaken () returns a raw image that is an interlaced image instead of the correct capture image. Debugging each of the parameters of the camera parameters determines that the reason for this is the next parameter installer. If we do not explicitly specify the parameterSize () parameter for the parameter, then it works as expected:

parameters.setPictureSize(targetPictureSize); 

By default, parameters.getPictureSize () returns as [w, h] = [3264, 2448]

"targetPictureSize" is determined by the base on the closest match "Return size from bottom", in this case we used the size [w, h] = [1600, 1200] as "targetPictureSize"

 camera.getParameters().getSupportedPictureSizes(); 

Does anyone know the reason and workaround?

+2
android android-camera galaxy
source share
2 answers

This problem occurs when you call camera.setParameters with a different pictureSize value than the previously configured (or default value) while the preview is active. The solution is to set the image size before starting the preview or stopping the preview, setting parameters and restarting the preview.

 parameters.setPictureSize(1600, 1200); ... camera.stopPreview(); camera.setParameters(parameters); camera.startPreview(); 

Technical Note:

Apparently, the reason for interlacing is that the image returned from the camera is fixed by default (3264x2448), but is marked as the resolution you specified with setPictureSize. As a result, when such an image is displayed, each row of pixels from the captured image is displayed as (default resolution / preset resolution) rows of pixels. At an image size of 1600x1200, this will lead to an interlaced image, and at other resolutions (for example, 640x480), the image will be completely damaged.

+6
source share

I believe there will be no good answer or reason for this. I can only blame Samsung for misusing Camera.getParameters (). SetPictureSize ().

Below is my workaround by checking the name of the S3 model, rather than calling setPictureSize ()

  // Source - http://en.wikipedia.org/wiki/Samsung_Galaxy_S_III String s3ModelNames[] = { "XXXXXXXXXXXXXXXX", // Place holder "SAMSUNG-SGH-I747", // AT&T "SAMSUNG-SGH-T999", // T-Mobile "SAMSUNG-SGH-N064", // Japan "SAMSUNG-SCH-R530", // US Cellular "SAMSUNG-SCH-I535", // Verizon "SAMSUNG-SPH-L710", // Sprint "SAMSUNG-GT-I9300", // International "SGH-I747", // AT&T "SGH-T999", // T-Mobile "SGH-N064", // Japan "SCH-R530", // US Cellular "SCH-I535", // Verizon "SPH-L710", // Sprint "GT-I9300" // International }; List<String> s3ModelList = Arrays.asList(s3ModelNames); if (s3ModelList.contains(deviceModel)) { // DEVICE SPECIFIC WORK AROUND for Samsung Galaxy S3 // SKIP calling parameters.setPictureSize() Samsung Galaxy SIII phone (Confirmed on AT&T, Verizon, Sprint) due the Camera image are interlaced when setPictureSize() are set to other than default. } 
0
source share

All Articles