Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between preview size and picture size of android camera

In an app which uses the camera, where I need to show the preview of the camera, I can set the preview size by getting all supported preview sizes and find the best one. Should I also set best picture size for the camera? If so what is the difference between preview size and picture size?

And currently I use the below to find the best preview size

int minDiff = Integer.MAX_VALUE;
for (SizePair sizePair : validPreviewSizes) {
  Size size = sizePair.previewSize();
  int diff =
      Math.abs(size.getWidth() - desiredWidth) + Math.abs(size.getHeight() - desiredHeight);
  if (diff < minDiff) {
    selectedPair = sizePair;
    minDiff = diff;
  }
}

Using this method gives wrong preview sizes in some phones. Can someone suggest a better logic to get best preivew size?

like image 757
arjun Avatar asked Feb 08 '17 05:02

arjun


1 Answers

Picture size This is the size of the image produced when you tell the camera to take a photo. If it is the same aspect ratio as the native resolution then it will be directly scaled from that. If the aspect ratio is different then it will be cropped from the native size. In my experience, the largest size returned by getSupportedPictureSizes is the native resolution of the camera.

Preview size This is the size of the image preview that is shown on-screen. It may be a different aspect ratio than either the native size or the picture size, causing further cropping

To get the closest match between what you see on screen and the image that is produced when you take a photo try to select a preview size with an aspect ratio as close as possible to the aspect ratio of the picture size that you've selected. I generally try to get both as close as possible to the native size.

please also check this link

like image 101
Lalit Jadav Avatar answered Oct 12 '22 14:10

Lalit Jadav