java.lang.Object | |
↳ | android.hardware.Camera.Parameters |
Camera service settings.
To make camera parameters take effect, applications have to call
setParameters(Camera.Parameters)
. For example, after
setWhiteBalance(String)
is called, white balance is not
actually changed until setParameters(Camera.Parameters)
is called with the changed parameters object.
Different devices may have different camera capabilities, such as
picture size or flash modes. The application should query the camera
capabilities before setting parameters. For example, the application
should call getSupportedColorEffects()
before
calling setColorEffect(String)
. If the
camera does not support color effects,
getSupportedColorEffects()
will return null.
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Creates a single string with all the parameters set in
this Parameters object.
| |||||||||||
Returns the value of a String parameter.
| |||||||||||
Gets the current antibanding setting.
| |||||||||||
Gets the current color effect setting.
| |||||||||||
Gets the current exposure compensation index.
| |||||||||||
Gets the exposure compensation step.
| |||||||||||
Gets the current flash mode setting.
| |||||||||||
Gets the focal length (in millimeter) of the camera.
| |||||||||||
Gets the distances from the camera to where an object appears to be
in focus.
| |||||||||||
Gets the current focus mode setting.
| |||||||||||
Gets the horizontal angle of view in degrees.
| |||||||||||
Returns the value of an integer parameter.
| |||||||||||
Returns the quality setting for the JPEG picture.
| |||||||||||
Returns the quality setting for the EXIF thumbnail in Jpeg picture.
| |||||||||||
Returns the dimensions for EXIF thumbnail in Jpeg picture.
| |||||||||||
Gets the maximum exposure compensation index.
| |||||||||||
Gets the maximum zoom value allowed for snapshot.
| |||||||||||
Gets the minimum exposure compensation index.
| |||||||||||
Returns the image format for pictures.
| |||||||||||
Returns the dimension setting for pictures.
| |||||||||||
Returns the preferred or recommended preview size (width and height)
in pixels for video recording.
| |||||||||||
Returns the image format for preview frames got from
Camera.PreviewCallback . | |||||||||||
Returns the current minimum and maximum preview fps.
| |||||||||||
This method is deprecated.
replaced by
getPreviewFpsRange(int[])
| |||||||||||
Returns the dimensions setting for preview pictures.
| |||||||||||
Gets the current scene mode setting.
| |||||||||||
Gets the supported antibanding values.
| |||||||||||
Gets the supported color effects.
| |||||||||||
Gets the supported flash modes.
| |||||||||||
Gets the supported focus modes.
| |||||||||||
Gets the supported jpeg thumbnail sizes.
| |||||||||||
Gets the supported picture formats.
| |||||||||||
Gets the supported picture sizes.
| |||||||||||
Gets the supported preview formats.
| |||||||||||
Gets the supported preview fps (frame-per-second) ranges.
| |||||||||||
This method is deprecated.
replaced by
getSupportedPreviewFpsRange()
| |||||||||||
Gets the supported preview sizes.
| |||||||||||
Gets the supported scene modes.
| |||||||||||
Gets the supported video frame sizes that can be used by
MediaRecorder.
| |||||||||||
Gets the supported white balance.
| |||||||||||
Gets the vertical angle of view in degrees.
| |||||||||||
Gets the current white balance setting.
| |||||||||||
Gets current zoom value.
| |||||||||||
Gets the zoom ratios of all zoom values.
| |||||||||||
Returns true if smooth zoom is supported.
| |||||||||||
Returns true if zoom is supported.
| |||||||||||
Removes GPS latitude, longitude, altitude, and timestamp from the
parameters.
| |||||||||||
Sets a String parameter.
| |||||||||||
Sets an integer parameter.
| |||||||||||
Sets the antibanding.
| |||||||||||
Sets the current color effect setting.
| |||||||||||
Sets the exposure compensation index.
| |||||||||||
Sets the flash mode.
| |||||||||||
Sets the focus mode.
| |||||||||||
Sets GPS altitude.
| |||||||||||
Sets GPS latitude coordinate.
| |||||||||||
Sets GPS longitude coordinate.
| |||||||||||
Sets GPS processing method.
| |||||||||||
Sets GPS timestamp.
| |||||||||||
Sets Jpeg quality of captured picture.
| |||||||||||
Sets the quality of the EXIF thumbnail in Jpeg picture.
| |||||||||||
Sets the dimensions for EXIF thumbnail in Jpeg picture.
| |||||||||||
Sets the image format for pictures.
| |||||||||||
Sets the dimensions for pictures.
| |||||||||||
Sets the image format for preview pictures.
| |||||||||||
Sets the maximum and maximum preview fps.
| |||||||||||
This method is deprecated.
replaced by
setPreviewFpsRange(int, int)
| |||||||||||
Sets the dimensions for preview pictures.
| |||||||||||
Sets the rotation angle in degrees relative to the orientation of
the camera.
| |||||||||||
Sets the scene mode.
| |||||||||||
Sets the white balance.
| |||||||||||
Sets current zoom value.
| |||||||||||
Takes a flattened string of parameters and adds each one to
this Parameters object.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
Flash will be fired automatically when required. The flash may be fired during preview, auto-focus, or snapshot depending on the driver.
Flash will not be fired.
Flash will always be fired during snapshot. The flash may also be fired during preview or auto-focus depending on the driver.
Flash will be fired in red-eye reduction mode.
Constant emission of light during preview, auto-focus and snapshot. This can also be used for video recording.
The array index of far focus distance for use with
getFocusDistances(float[])
.
The array index of near focus distance for use with
getFocusDistances(float[])
.
The array index of optimal focus distance for use with
getFocusDistances(float[])
.
Auto-focus mode. Applications should call autoFocus(AutoFocusCallback)
to start the focus in this mode.
Continuous auto focus mode intended for video recording. The camera
continuously tries to focus. This is ideal for shooting video.
Applications still can call takePicture(Camera.ShutterCallback, Camera.PictureCallback, Camera.PictureCallback)
in this mode but the subject may not be in
focus. Auto focus starts when the parameter is set. Applications
should not call autoFocus(AutoFocusCallback)
in this mode.
To stop continuous focus, applications should change the focus mode
to other modes.
Extended depth of field (EDOF). Focusing is done digitally and
continuously. Applications should not call autoFocus(AutoFocusCallback)
in this mode.
Focus is fixed. The camera is always in this mode if the focus is not
adjustable. If the camera has auto-focus, this mode can fix the
focus, which is usually at hyperfocal distance. Applications should
not call autoFocus(AutoFocusCallback)
in this mode.
Focus is set at infinity. Applications should not call
autoFocus(AutoFocusCallback)
in this mode.
Macro (close-up) focus mode. Applications should call
autoFocus(AutoFocusCallback)
to start the focus in this
mode.
The array index of maximum preview fps for use with getPreviewFpsRange(int[])
or getSupportedPreviewFpsRange()
.
The array index of minimum preview fps for use with getPreviewFpsRange(int[])
or getSupportedPreviewFpsRange()
.
Take photos of fast moving objects. Same as SCENE_MODE_SPORTS
.
Scene mode is off.
Applications are looking for a barcode. Camera driver will be optimized for barcode reading.
Take pictures on the beach.
Capture the naturally warm color of scenes lit by candles.
For shooting firework displays.
Take pictures on distant objects.
Take photos at night.
Take people pictures at night.
Take indoor low-light shot.
Take people pictures.
Take pictures on the snow.
Take photos of fast moving objects. Same as SCENE_MODE_ACTION
.
Avoid blurry pictures (for example, due to hand shake).
Take sunset photos.
Take photos in a theater. Flash light is off.
Creates a single string with all the parameters set in this Parameters object.
The unflatten(String)
method does the reverse.
Returns the value of a String parameter.
key | the key name for the parameter |
---|
Gets the current antibanding setting.
Gets the current color effect setting.
Gets the current exposure compensation index.
getMinExposureCompensation()
to getMaxExposureCompensation()
. 0 means exposure is not
adjusted.
Gets the exposure compensation step.
Gets the current flash mode setting.
Gets the focal length (in millimeter) of the camera.
Gets the distances from the camera to where an object appears to be
in focus. The object is sharpest at the optimal focus distance. The
depth of field is the far focus distance minus near focus distance.
Focus distances may change after calling autoFocus(AutoFocusCallback)
, cancelAutoFocus()
, or startPreview()
. Applications can call getParameters()
and this method anytime to get the latest focus distances. If the
focus mode is FOCUS_MODE_CONTINUOUS_VIDEO, focus distances may change
from time to time.
This method is intended to estimate the distance between the camera
and the subject. After autofocus, the subject distance may be within
near and far focus distance. However, the precision depends on the
camera hardware, autofocus algorithm, the focus area, and the scene.
The error can be large and it should be only used as a reference.
Far focus distance >= optimal focus distance >= near focus distance.
If the focus distance is infinity, the value will be
Float.POSITIVE_INFINITY.
output | focus distances in meters. output must be a float array with three elements. Near focus distance, optimal focus distance, and far focus distance will be filled in the array. |
---|
Gets the current focus mode setting.
autoFocus(AutoFocusCallback)
to start the focus if focus
mode is FOCUS_MODE_AUTO or FOCUS_MODE_MACRO.Gets the horizontal angle of view in degrees.
Returns the value of an integer parameter.
key | the key name for the parameter |
---|
Returns the quality setting for the JPEG picture.
Returns the quality setting for the EXIF thumbnail in Jpeg picture.
Returns the dimensions for EXIF thumbnail in Jpeg picture.
Gets the maximum exposure compensation index.
getMinExposureCompensation()
return 0,
exposure compensation is not supported.
Gets the maximum zoom value allowed for snapshot. This is the maximum
value that applications can set to setZoom(int)
.
Applications should call isZoomSupported()
before using this
method. This value may change in different preview size. Applications
should call this again after setting preview size.
Gets the minimum exposure compensation index.
getMaxExposureCompensation()
return 0,
exposure compensation is not supported.
Returns the dimension setting for pictures.
Returns the preferred or recommended preview size (width and height) in pixels for video recording. Camcorder applications should set the preview size to a value that is not larger than the preferred preview size. In other words, the product of the width and height of the preview size should not be larger than that of the preferred preview size. In addition, we recommend to choose a preview size that has the same aspect ratio as the resolution of video to be recorded.
Returns the image format for preview frames got from
Camera.PreviewCallback
.
Returns the current minimum and maximum preview fps. The values are
one of the elements returned by getSupportedPreviewFpsRange()
.
This method is deprecated.
replaced by getPreviewFpsRange(int[])
Returns the setting for the rate at which preview frames are received. This is the target frame rate. The actual frame rate depends on the driver.
Returns the dimensions setting for preview pictures.
Gets the current scene mode setting.
Gets the supported antibanding values.
Gets the supported color effects.
Gets the supported flash modes.
Gets the supported focus modes.
Gets the supported jpeg thumbnail sizes.
Gets the supported picture formats.
Gets the supported picture sizes.
Gets the supported preview formats.
Gets the supported preview fps (frame-per-second) ranges. Each range contains a minimum fps and maximum fps. If minimum fps equals to maximum fps, the camera outputs frames in fixed frame rate. If not, the camera outputs frames in auto frame rate. The actual frame rate fluctuates between the minimum and the maximum. The values are multiplied by 1000 and represented in integers. For example, if frame rate is 26.623 frames per second, the value is 26623.
This method is deprecated.
replaced by getSupportedPreviewFpsRange()
Gets the supported preview frame rates.
Gets the supported preview sizes.
Gets the supported scene modes.
Gets the supported video frame sizes that can be used by MediaRecorder. If the returned list is not null, the returned list will contain at least one Size and one of the sizes in the returned list must be passed to MediaRecorder.setVideoSize() for camcorder application if camera is used as the video source. In this case, the size of the preview can be different from the resolution of the recorded video during video recording.
Gets the supported white balance.
Gets the vertical angle of view in degrees.
Gets the current white balance setting.
Gets current zoom value. This also works when smooth zoom is in
progress. Applications should check isZoomSupported()
before
using this method.
getMaxZoom()
. 0 means the camera is not zoomed.
Gets the zoom ratios of all zoom values. Applications should check
isZoomSupported()
before using this method.
getMaxZoom()
+ 1. The list is sorted from small to large. The
first element is always 100. The last element is the zoom
ratio of the maximum zoom value.
Returns true if smooth zoom is supported. Applications should call this before using other smooth zoom methods.
Returns true if zoom is supported. Applications should call this before using other zoom methods.
Removes GPS latitude, longitude, altitude, and timestamp from the parameters.
Sets a String parameter.
key | the key name for the parameter |
---|---|
value | the String value of the parameter |
Sets an integer parameter.
key | the key name for the parameter |
---|---|
value | the int value of the parameter |
Sets the exposure compensation index.
value | exposure compensation index. The valid value range is
from getMinExposureCompensation() (inclusive) to getMaxExposureCompensation() (inclusive). 0 means exposure is
not adjusted. Application should call
getMinExposureCompensation and getMaxExposureCompensation to
know if exposure compensation is supported.
|
---|
Sets GPS altitude. This will be stored in JPEG EXIF header.
altitude | GPS altitude in meters. |
---|
Sets GPS latitude coordinate. This will be stored in JPEG EXIF header.
latitude | GPS latitude coordinate. |
---|
Sets GPS longitude coordinate. This will be stored in JPEG EXIF header.
longitude | GPS longitude coordinate. |
---|
Sets GPS processing method. It will store up to 32 characters in JPEG EXIF header.
processing_method | The processing method to get this location. |
---|
Sets GPS timestamp. This will be stored in JPEG EXIF header.
timestamp | GPS timestamp (UTC in seconds since January 1, 1970). |
---|
Sets Jpeg quality of captured picture.
quality | the JPEG quality of captured picture. The range is 1 to 100, with 100 being the best. |
---|
Sets the quality of the EXIF thumbnail in Jpeg picture.
quality | the JPEG quality of the EXIF thumbnail. The range is 1 to 100, with 100 being the best. |
---|
Sets the dimensions for EXIF thumbnail in Jpeg picture. If
applications set both width and height to 0, EXIF will not contain
thumbnail.
Applications need to consider the display orientation. See setPreviewSize(int, int)
for reference.
width | the width of the thumbnail, in pixels |
---|---|
height | the height of the thumbnail, in pixels |
Sets the image format for pictures.
pixel_format | the desired picture format (ImageFormat.NV21, ImageFormat.RGB_565, or ImageFormat.JPEG) |
---|
Sets the dimensions for pictures.
Applications need to consider the display orientation. See setPreviewSize(int, int)
for reference.
width | the width for pictures, in pixels |
---|---|
height | the height for pictures, in pixels |
Sets the image format for preview pictures.
If this is never called, the default format will be
NV21
, which
uses the NV21 encoding format.
pixel_format | the desired preview picture format, defined
by one of the ImageFormat constants.
(E.g., ImageFormat.NV21 (default),
ImageFormat.RGB_565, or
ImageFormat.JPEG) |
---|
Sets the maximum and maximum preview fps. This controls the rate of
preview frames received in Camera.PreviewCallback
. The minimum and
maximum preview fps must be one of the elements from getSupportedPreviewFpsRange()
.
min | the minimum preview fps (scaled by 1000). |
---|---|
max | the maximum preview fps (scaled by 1000). |
RuntimeException | if fps range is invalid. |
---|
This method is deprecated.
replaced by setPreviewFpsRange(int, int)
Sets the rate at which preview frames are received. This is the target frame rate. The actual frame rate depends on the driver.
fps | the frame rate (frames per second) |
---|
Sets the dimensions for preview pictures. The sides of width and height are based on camera orientation. That is, the preview size is the size before it is rotated by display orientation. So applications need to consider the display orientation while setting preview size. For example, suppose the camera supports both 480x320 and 320x480 preview sizes. The application wants a 3:2 preview ratio. If the display orientation is set to 0 or 180, preview size should be set to 480x320. If the display orientation is set to 90 or 270, preview size should be set to 320x480. The display orientation should also be considered while setting picture size and thumbnail size.
width | the width of the pictures, in pixels |
---|---|
height | the height of the pictures, in pixels |
Sets the rotation angle in degrees relative to the orientation of
the camera. This affects the pictures returned from JPEG Camera.PictureCallback
. The camera driver may set orientation in the
EXIF header without rotating the picture. Or the driver may rotate
the picture and the EXIF thumbnail. If the Jpeg picture is rotated,
the orientation in the EXIF header will be missing or 1 (row #0 is
top and column #0 is left side).
If applications want to rotate the picture to match the orientation
of what users see, apps should use OrientationEventListener
and Camera.CameraInfo
.
The value from OrientationEventListener is relative to the natural
orientation of the device. CameraInfo.orientation is the angle
between camera orientation and natural device orientation. The sum
of the two is the rotation angle for back-facing camera. The
difference of the two is the rotation angle for front-facing camera.
Note that the JPEG pictures of front-facing cameras are not mirrored
as in preview display.
For example, suppose the natural orientation of the device is portrait. The device is rotated 270 degrees clockwise, so the device orientation is 270. Suppose a back-facing camera sensor is mounted in landscape and the top side of the camera sensor is aligned with the right edge of the display in natural orientation. So the camera orientation is 90. The rotation should be set to 0 (270 + 90).
The reference code is as follows.
public void public void onOrientationChanged(int orientation) { if (orientation == ORIENTATION_UNKNOWN) return; android.hardware.Camera.CameraInfo info = new android.hardware.Camera.CameraInfo(); android.hardware.Camera.getCameraInfo(cameraId, info); orientation = (orientation + 45) / 90 * 90; int rotation = 0; if (info.facing == CameraInfo.CAMERA_FACING_FRONT) { rotation = (info.orientation - orientation + 360) % 360; } else { // back-facing camera rotation = (info.orientation + orientation) % 360; } mParameters.setRotation(rotation); }
rotation | The rotation angle in degrees relative to the orientation of the camera. Rotation can only be 0, 90, 180 or 270. |
---|
IllegalArgumentException | if rotation value is invalid. |
---|
Sets the scene mode. Changing scene mode may override other parameters (such as flash mode, focus mode, white balance). For example, suppose originally flash mode is on and supported flash modes are on/off. In night scene mode, both flash mode and supported flash mode may be changed to off. After setting scene mode, applications should call getParameters to know if some parameters are changed.
value | scene mode. |
---|
Sets current zoom value. If the camera is zoomed (value > 0), the
actual picture size may be smaller than picture size setting.
Applications can check the actual picture size after picture is
returned from Camera.PictureCallback
. The preview size remains the
same in zoom. Applications should check isZoomSupported()
before using this method.
value | zoom value. The valid range is 0 to getMaxZoom() .
|
---|
Takes a flattened string of parameters and adds each one to this Parameters object.
The flatten()
method does the reverse.
flattened | a String of parameters (key-value paired) that are semi-colon delimited |
---|