0

I searched for past two days and i was not successful yet .

I my case , i want to check the camera pixel resolution/Megapixels . If the camera's Mp is more than 4 then i need to re-size and upload .

Here is my code :

//to check the resolution

Camera mcamera ;

mcamera = Camera.open(Camera.CameraInfo.CAMERA_FACING_BACK);

Camera.Parameters param = mcamera.getParameters();
Camera.Size size = param.getPictureSize();

cam_height = size.height ;
cam_width = size.width ;

mcamera.release();

// my functionality

BitmapFactory.Options resample = new BitmapFactory.Options();
if(cam_height > pict_height || cam_width > pict_width )
    resample.inSampleSize = 2;  // whatever number seems appropriate 2 means 1/2 of the original
else
    resample.inSampleSize = 1;

capturedimg = BitmapFactory.decodeFile(fileUri.getPath() , resample);
resized_uri = bitmaptouri(capturedimg);

but this returns only the picture resolution which is the same as the Screen resolution of the mobile but i want the Mobile camera's resolution .

Any related answers are welcomed , Thanks in advance .

VIGNESH
  • 2,023
  • 8
  • 31
  • 46
  • check http://stackoverflow.com/questions/6952469/determining-camera-resolution-i-e-megapixels-programatically-in-android –  Jun 20 '13 at 04:42
  • I tried them , i have posted the code also . It didnt work . – VIGNESH Jun 20 '13 at 04:44
  • you mean mega pixels.?? – Sagar Maiyad Jun 20 '13 at 04:46
  • Can't you get the number of pixels in the image and resize based on that? – joshuahealy Jun 20 '13 at 04:46
  • @segi : either mega pixel or resolution , but i want the camera's not the mobile screen's . – VIGNESH Jun 20 '13 at 04:47
  • @appclay : bro. i want to get the camera's resolution , if get the resolution of the image , after capturing it will be the screen's resolution not the camera's resolution . – VIGNESH Jun 20 '13 at 04:50
  • You can use Parameters.getSupportedPictureSizes() to get all actual supported picture sizes, find the one that is the largest and do whatever you desire to do with it. – Milan Jun 20 '13 at 04:52

4 Answers4

1

How about getSupportedPictureSizes()?

Jonathon Reinhart
  • 132,704
  • 33
  • 254
  • 328
1

First find height and width like below:

android.hardware.Camera.Parameters parameters = camera.getParameters();
android.hardware.Camera.Size size = parameters.getPictureSize();


int height = size.height;
int width = size.width;

then get mega pixel using below equation:

int mg = height * width / 1024000;

where mg is your mega pixels.

Sagar Maiyad
  • 12,655
  • 9
  • 63
  • 99
0

First check the supported picture sizes available for the Camera using Camera.Parameters. There is a function called getSupportedPictureSizes() in Camera Parameters.

For e.g:

List<Camera.Size> mList    =    mParams.getSupportedPictureSizes();
Camera.Size mSize          =    mList.get(mList.size() - 1);

From the mList you get all the supported Picture Sizes. The final one in the list will be the largest possible resolution.

Renjith
  • 5,783
  • 9
  • 31
  • 42
0

Try the code from here. It returns resolution in mp for back camera. You should use getSupportedPictureSize instead of getPictureSize

https://stackoverflow.com/a/27000029/1554031

Community
  • 1
  • 1
Satish
  • 320
  • 2
  • 9