2016-10-25 55 views
6

比较很简单:我使用使用CameraManager的自定义相机拍摄照片。然后我使用默认的Galaxy Note 5相机拍摄相同的照片。 CameraManager可用的最大尺寸为3264 by 1836,所以我使用它并将三星相机设置为相同的分辨率。结果如何增加使用CameraManager拍摄的照片的质量

  • 注5:我可以看到细节照片
  • CameraManager:我无法看到的细节。图像质量不高。

然后我试着用

captureBuilder.set(CaptureRequest.JPEG_QUALITY, (byte) 100); 

仍然没有改变设置CameraManager照片。那么只有一个变化:使用CameraManager拍摄的照片的文件大小变为2.3MB(它曾经是0.5MB),而三星照片的大小(保留)为1.6MB。因此,即使尺寸较大,使用CameraManager拍摄的照片质量仍然较差。任何想法我可以解决这个问题:我如何使CameraManager拍摄的照片具有与Note 5附带的默认Camera应用程序拍摄的照片相同的质量?

+0

另外那为什么三星相机可以达到'5312x2088'而CameraManager通过1836'报告的'3264一个最大? –

+0

你使用普通的'android.hardware.Camera'类吗? – nandsito

+0

抱歉延迟。我正在使用'android.hardware.camera2' –

回答

0

我认为质量在三星相机应用程序更好,因为它使用Samsung Camera SDK。它是Camera2 API的扩展。

SDK提供了有用的附加功能(例如相位自动对焦)。尝试启用镜头光学稳定。

1

这些是我们在Camer管理器上工作时的一些方法,这种方法 可能会对您有所帮助。

Android相机应用编码在Intent 照片作为额外小的位图传递到onActivityResult(), 下键“数据”。以下代码检索此图像并在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); 
}