Reputation: 6472
The comparison is simple: I take a photo with my Custom camera which uses CameraManager. Then I take the same photo with the default Galaxy Note 5 camera. The largest size available for the CameraManager is 3264 by 1836
so I use that and set the Samsung camera to that same resolution as well. The results
Then I try setting the CameraManager photos with
captureBuilder.set(CaptureRequest.JPEG_QUALITY, (byte) 100);
Still no change. Well only one change: the file size of the photo taken with CameraManager becomes 2.3MB (it used to be 0.5MB) while the size of the Samsung photo (remains) 1.6MB. So even with the larger size, the photo taken with CameraManager is still of lower quality. Any ideas how I might fix this problem: How do I make the photo taken with CameraManager have the same quality as the one taken with the default Camera app that comes with the Note 5?
Upvotes: 6
Views: 1991
Reputation: 182
These are some methods when we working on Camer manager,this method may help you.
The Android Camera application encodes the photo in the Intent delivered to onActivityResult() as a small Bitmap in the extras, under the key "data". The following code retrieves this image and displays it in an ImageView.
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == REQUEST_IMAGE_CAPTURE && resultCode == RESULT_OK) {
Bundle extras = data.getExtras();
Bitmap imageBitmap = (Bitmap) extras.get("data");
mImageView.setImageBitmap(imageBitmap);
}
}
private File createImageFile() throws IOException {
// Create an image file name
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
String imageFileName = "JPEG_" + timeStamp + "_";
File storageDir = getExternalFilesDir(Environment.DIRECTORY_PICTURES);
File image = File.createTempFile(
imageFileName, /* prefix */
".jpg", /* suffix */
storageDir /* directory */
);
// Save a file: path for use with ACTION_VIEW intents
mCurrentPhotoPath = "file:" + image.getAbsolutePath();
return image;
}
private void setPic() {
// Get the dimensions of the View
int targetW = mImageView.getWidth();
int targetH = mImageView.getHeight();
// Get the dimensions of the bitmap
BitmapFactory.Options bmOptions = new BitmapFactory.Options();
bmOptions.inJustDecodeBounds = true;
BitmapFactory.decodeFile(mCurrentPhotoPath, bmOptions);
int photoW = bmOptions.outWidth;
int photoH = bmOptions.outHeight;
// Determine how much to scale down the image
int scaleFactor = Math.min(photoW/targetW, photoH/targetH);
// Decode the image file into a Bitmap sized to fill the View
bmOptions.inJustDecodeBounds = false;
bmOptions.inSampleSize = scaleFactor;
bmOptions.inPurgeable = true;
Bitmap bitmap = BitmapFactory.decodeFile(mCurrentPhotoPath, bmOptions);
mImageView.setImageBitmap(bitmap);
}
Upvotes: 1
Reputation: 516
I think the quality is better in Samsung stock camera app because it uses the Samsung Camera SDK. It's an extension of Camera2 API.
The SDK provides useful additional functionalities (e.g Phase-Autofocus). Try also enabling lens optical stabilization.
Upvotes: 0