android.hardware.camera2
API for new
applications.@Deprecated public class Camera.Parameters extends Object
To make camera parameters take effect, applications have to call
Camera.setParameters(Camera.Parameters)
. For example, after
setWhiteBalance(java.lang.String)
is called, white balance is not
actually changed until Camera.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.
Modifier and Type | Field and Description |
---|---|
static String |
ANTIBANDING_50HZ
Deprecated.
|
static String |
ANTIBANDING_60HZ
Deprecated.
|
static String |
ANTIBANDING_AUTO
Deprecated.
|
static String |
ANTIBANDING_OFF
Deprecated.
|
static String |
EFFECT_AQUA
Deprecated.
|
static String |
EFFECT_BLACKBOARD
Deprecated.
|
static String |
EFFECT_MONO
Deprecated.
|
static String |
EFFECT_NEGATIVE
Deprecated.
|
static String |
EFFECT_NONE
Deprecated.
|
static String |
EFFECT_POSTERIZE
Deprecated.
|
static String |
EFFECT_SEPIA
Deprecated.
|
static String |
EFFECT_SOLARIZE
Deprecated.
|
static String |
EFFECT_WHITEBOARD
Deprecated.
|
static String |
FLASH_MODE_AUTO
Deprecated.
Flash will be fired automatically when required.
|
static String |
FLASH_MODE_OFF
Deprecated.
Flash will not be fired.
|
static String |
FLASH_MODE_ON
Deprecated.
Flash will always be fired during snapshot.
|
static String |
FLASH_MODE_RED_EYE
Deprecated.
Flash will be fired in red-eye reduction mode.
|
static String |
FLASH_MODE_TORCH
Deprecated.
Constant emission of light during preview, auto-focus and snapshot.
|
static int |
FOCUS_DISTANCE_FAR_INDEX
Deprecated.
The array index of far focus distance for use with
getFocusDistances(float[]) . |
static int |
FOCUS_DISTANCE_NEAR_INDEX
Deprecated.
The array index of near focus distance for use with
getFocusDistances(float[]) . |
static int |
FOCUS_DISTANCE_OPTIMAL_INDEX
Deprecated.
The array index of optimal focus distance for use with
getFocusDistances(float[]) . |
static String |
FOCUS_MODE_AUTO
Deprecated.
Auto-focus mode.
|
static String |
FOCUS_MODE_CONTINUOUS_PICTURE
Deprecated.
Continuous auto focus mode intended for taking pictures.
|
static String |
FOCUS_MODE_CONTINUOUS_VIDEO
Deprecated.
Continuous auto focus mode intended for video recording.
|
static String |
FOCUS_MODE_EDOF
Deprecated.
Extended depth of field (EDOF).
|
static String |
FOCUS_MODE_FIXED
Deprecated.
Focus is fixed.
|
static String |
FOCUS_MODE_INFINITY
Deprecated.
Focus is set at infinity.
|
static String |
FOCUS_MODE_MACRO
Deprecated.
Macro (close-up) focus mode.
|
static int |
PREVIEW_FPS_MAX_INDEX
Deprecated.
The array index of maximum preview fps for use with
getPreviewFpsRange(int[]) or getSupportedPreviewFpsRange() . |
static int |
PREVIEW_FPS_MIN_INDEX
Deprecated.
The array index of minimum preview fps for use with
getPreviewFpsRange(int[]) or getSupportedPreviewFpsRange() . |
static String |
SCENE_MODE_ACTION
Deprecated.
Take photos of fast moving objects.
|
static String |
SCENE_MODE_AUTO
Deprecated.
Scene mode is off.
|
static String |
SCENE_MODE_BARCODE
Deprecated.
Applications are looking for a barcode.
|
static String |
SCENE_MODE_BEACH
Deprecated.
Take pictures on the beach.
|
static String |
SCENE_MODE_CANDLELIGHT
Deprecated.
Capture the naturally warm color of scenes lit by candles.
|
static String |
SCENE_MODE_FIREWORKS
Deprecated.
For shooting firework displays.
|
static String |
SCENE_MODE_HDR
Deprecated.
Capture a scene using high dynamic range imaging techniques.
|
static String |
SCENE_MODE_LANDSCAPE
Deprecated.
Take pictures on distant objects.
|
static String |
SCENE_MODE_NIGHT
Deprecated.
Take photos at night.
|
static String |
SCENE_MODE_NIGHT_PORTRAIT
Deprecated.
Take people pictures at night.
|
static String |
SCENE_MODE_PARTY
Deprecated.
Take indoor low-light shot.
|
static String |
SCENE_MODE_PORTRAIT
Deprecated.
Take people pictures.
|
static String |
SCENE_MODE_SNOW
Deprecated.
Take pictures on the snow.
|
static String |
SCENE_MODE_SPORTS
Deprecated.
Take photos of fast moving objects.
|
static String |
SCENE_MODE_STEADYPHOTO
Deprecated.
Avoid blurry pictures (for example, due to hand shake).
|
static String |
SCENE_MODE_SUNSET
Deprecated.
Take sunset photos.
|
static String |
SCENE_MODE_THEATRE
Deprecated.
Take photos in a theater.
|
static String |
WHITE_BALANCE_AUTO
Deprecated.
|
static String |
WHITE_BALANCE_CLOUDY_DAYLIGHT
Deprecated.
|
static String |
WHITE_BALANCE_DAYLIGHT
Deprecated.
|
static String |
WHITE_BALANCE_FLUORESCENT
Deprecated.
|
static String |
WHITE_BALANCE_INCANDESCENT
Deprecated.
|
static String |
WHITE_BALANCE_SHADE
Deprecated.
|
static String |
WHITE_BALANCE_TWILIGHT
Deprecated.
|
static String |
WHITE_BALANCE_WARM_FLUORESCENT
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
void |
copyFrom(Camera.Parameters other)
Deprecated.
Overwrite existing parameters with a copy of the ones from
other . |
void |
dump()
Deprecated.
|
String |
flatten()
Deprecated.
Creates a single string with all the parameters set in
this Parameters object.
|
String |
get(String key)
Deprecated.
Returns the value of a String parameter.
|
String |
getAntibanding()
Deprecated.
Gets the current antibanding setting.
|
boolean |
getAutoExposureLock()
Deprecated.
Gets the state of the auto-exposure lock.
|
boolean |
getAutoWhiteBalanceLock()
Deprecated.
Gets the state of the auto-white balance lock.
|
String |
getColorEffect()
Deprecated.
Gets the current color effect setting.
|
int |
getExposureCompensation()
Deprecated.
Gets the current exposure compensation index.
|
float |
getExposureCompensationStep()
Deprecated.
Gets the exposure compensation step.
|
String |
getFlashMode()
Deprecated.
Gets the current flash mode setting.
|
float |
getFocalLength()
Deprecated.
Gets the focal length (in millimeter) of the camera.
|
List<Camera.Area> |
getFocusAreas()
Deprecated.
Gets the current focus areas.
|
void |
getFocusDistances(float[] output)
Deprecated.
Gets the distances from the camera to where an object appears to be
in focus.
|
String |
getFocusMode()
Deprecated.
Gets the current focus mode setting.
|
float |
getHorizontalViewAngle()
Deprecated.
Gets the horizontal angle of view in degrees.
|
int |
getInt(String key)
Deprecated.
Returns the value of an integer parameter.
|
int |
getJpegQuality()
Deprecated.
Returns the quality setting for the JPEG picture.
|
int |
getJpegThumbnailQuality()
Deprecated.
Returns the quality setting for the EXIF thumbnail in Jpeg picture.
|
Camera.Size |
getJpegThumbnailSize()
Deprecated.
Returns the dimensions for EXIF thumbnail in Jpeg picture.
|
int |
getMaxExposureCompensation()
Deprecated.
Gets the maximum exposure compensation index.
|
int |
getMaxNumDetectedFaces()
Deprecated.
Gets the maximum number of detected faces supported.
|
int |
getMaxNumFocusAreas()
Deprecated.
Gets the maximum number of focus areas supported.
|
int |
getMaxNumMeteringAreas()
Deprecated.
Gets the maximum number of metering areas supported.
|
int |
getMaxZoom()
Deprecated.
Gets the maximum zoom value allowed for snapshot.
|
List<Camera.Area> |
getMeteringAreas()
Deprecated.
Gets the current metering areas.
|
int |
getMinExposureCompensation()
Deprecated.
Gets the minimum exposure compensation index.
|
int |
getPictureFormat()
Deprecated.
Returns the image format for pictures.
|
Camera.Size |
getPictureSize()
Deprecated.
Returns the dimension setting for pictures.
|
Camera.Size |
getPreferredPreviewSizeForVideo()
Deprecated.
Returns the preferred or recommended preview size (width and height)
in pixels for video recording.
|
int |
getPreviewFormat()
Deprecated.
Returns the image format for preview frames got from
Camera.PreviewCallback . |
void |
getPreviewFpsRange(int[] range)
Deprecated.
Returns the current minimum and maximum preview fps.
|
int |
getPreviewFrameRate()
Deprecated.
replaced by
getPreviewFpsRange(int[]) |
Camera.Size |
getPreviewSize()
Deprecated.
Returns the dimensions setting for preview pictures.
|
String |
getSceneMode()
Deprecated.
Gets the current scene mode setting.
|
List<String> |
getSupportedAntibanding()
Deprecated.
Gets the supported antibanding values.
|
List<String> |
getSupportedColorEffects()
Deprecated.
Gets the supported color effects.
|
List<String> |
getSupportedFlashModes()
Deprecated.
Gets the supported flash modes.
|
List<String> |
getSupportedFocusModes()
Deprecated.
Gets the supported focus modes.
|
List<Camera.Size> |
getSupportedJpegThumbnailSizes()
Deprecated.
Gets the supported jpeg thumbnail sizes.
|
List<Integer> |
getSupportedPictureFormats()
Deprecated.
Gets the supported picture formats.
|
List<Camera.Size> |
getSupportedPictureSizes()
Deprecated.
Gets the supported picture sizes.
|
List<Integer> |
getSupportedPreviewFormats()
Deprecated.
Gets the supported preview formats.
|
List<int[]> |
getSupportedPreviewFpsRange()
Deprecated.
Gets the supported preview fps (frame-per-second) ranges.
|
List<Integer> |
getSupportedPreviewFrameRates()
Deprecated.
replaced by
getSupportedPreviewFpsRange() |
List<Camera.Size> |
getSupportedPreviewSizes()
Deprecated.
Gets the supported preview sizes.
|
List<String> |
getSupportedSceneModes()
Deprecated.
Gets the supported scene modes.
|
List<Camera.Size> |
getSupportedVideoSizes()
Deprecated.
Gets the supported video frame sizes that can be used by
MediaRecorder.
|
List<String> |
getSupportedWhiteBalance()
Deprecated.
Gets the supported white balance.
|
float |
getVerticalViewAngle()
Deprecated.
Gets the vertical angle of view in degrees.
|
boolean |
getVideoStabilization()
Deprecated.
Get the current state of video stabilization.
|
String |
getWhiteBalance()
Deprecated.
Gets the current white balance setting.
|
int |
getZoom()
Deprecated.
Gets current zoom value.
|
List<Integer> |
getZoomRatios()
Deprecated.
Gets the zoom ratios of all zoom values.
|
boolean |
isAutoExposureLockSupported()
Deprecated.
Returns true if auto-exposure locking is supported.
|
boolean |
isAutoWhiteBalanceLockSupported()
Deprecated.
Returns true if auto-white balance locking is supported.
|
boolean |
isSmoothZoomSupported()
Deprecated.
Returns true if smooth zoom is supported.
|
boolean |
isVideoSnapshotSupported()
Deprecated.
Returns true if video snapshot is supported.
|
boolean |
isVideoStabilizationSupported()
Deprecated.
Returns true if video stabilization is supported.
|
boolean |
isZoomSupported()
Deprecated.
Returns true if zoom is supported.
|
void |
remove(String key)
Deprecated.
|
void |
removeGpsData()
Deprecated.
Removes GPS latitude, longitude, altitude, and timestamp from the
parameters.
|
boolean |
same(Camera.Parameters other)
Deprecated.
Value equality check.
|
void |
set(String key,
int value)
Deprecated.
Sets an integer parameter.
|
void |
set(String key,
String value)
Deprecated.
Sets a String parameter.
|
void |
setAntibanding(String antibanding)
Deprecated.
Sets the antibanding.
|
void |
setAutoExposureLock(boolean toggle)
Deprecated.
Sets the auto-exposure lock state.
|
void |
setAutoWhiteBalanceLock(boolean toggle)
Deprecated.
Sets the auto-white balance lock state.
|
void |
setColorEffect(String value)
Deprecated.
Sets the current color effect setting.
|
void |
setExposureCompensation(int value)
Deprecated.
Sets the exposure compensation index.
|
void |
setFlashMode(String value)
Deprecated.
Sets the flash mode.
|
void |
setFocusAreas(List<Camera.Area> focusAreas)
Deprecated.
Sets focus areas.
|
void |
setFocusMode(String value)
Deprecated.
Sets the focus mode.
|
void |
setGpsAltitude(double altitude)
Deprecated.
Sets GPS altitude.
|
void |
setGpsLatitude(double latitude)
Deprecated.
Sets GPS latitude coordinate.
|
void |
setGpsLongitude(double longitude)
Deprecated.
Sets GPS longitude coordinate.
|
void |
setGpsProcessingMethod(String processing_method)
Deprecated.
Sets GPS processing method.
|
void |
setGpsTimestamp(long timestamp)
Deprecated.
Sets GPS timestamp.
|
void |
setJpegQuality(int quality)
Deprecated.
Sets Jpeg quality of captured picture.
|
void |
setJpegThumbnailQuality(int quality)
Deprecated.
Sets the quality of the EXIF thumbnail in Jpeg picture.
|
void |
setJpegThumbnailSize(int width,
int height)
Deprecated.
Sets the dimensions for EXIF thumbnail in Jpeg picture.
|
void |
setMeteringAreas(List<Camera.Area> meteringAreas)
Deprecated.
Sets metering areas.
|
void |
setPictureFormat(int pixel_format)
Deprecated.
Sets the image format for pictures.
|
void |
setPictureSize(int width,
int height)
Deprecated.
Sets the dimensions for pictures.
|
void |
setPreviewFormat(int pixel_format)
Deprecated.
Sets the image format for preview pictures.
|
void |
setPreviewFpsRange(int min,
int max)
Deprecated.
Sets the minimum and maximum preview fps.
|
void |
setPreviewFrameRate(int fps)
Deprecated.
replaced by
setPreviewFpsRange(int,int) |
void |
setPreviewSize(int width,
int height)
Deprecated.
Sets the dimensions for preview pictures.
|
void |
setRecordingHint(boolean hint)
Deprecated.
Sets recording mode hint.
|
void |
setRotation(int rotation)
Deprecated.
Sets the clockwise rotation angle in degrees relative to the
orientation of the camera.
|
void |
setSceneMode(String value)
Deprecated.
Sets the scene mode.
|
void |
setVideoStabilization(boolean toggle)
Deprecated.
Enables and disables video stabilization.
|
void |
setWhiteBalance(String value)
Deprecated.
Sets the white balance.
|
void |
setZoom(int value)
Deprecated.
Sets current zoom value.
|
void |
unflatten(String flattened)
Deprecated.
Takes a flattened string of parameters and adds each one to
this Parameters object.
|
public static final String WHITE_BALANCE_AUTO
public static final String WHITE_BALANCE_INCANDESCENT
public static final String WHITE_BALANCE_FLUORESCENT
public static final String WHITE_BALANCE_WARM_FLUORESCENT
public static final String WHITE_BALANCE_DAYLIGHT
public static final String WHITE_BALANCE_CLOUDY_DAYLIGHT
public static final String WHITE_BALANCE_TWILIGHT
public static final String WHITE_BALANCE_SHADE
public static final String EFFECT_NONE
public static final String EFFECT_MONO
public static final String EFFECT_NEGATIVE
public static final String EFFECT_SOLARIZE
public static final String EFFECT_SEPIA
public static final String EFFECT_POSTERIZE
public static final String EFFECT_WHITEBOARD
public static final String EFFECT_BLACKBOARD
public static final String EFFECT_AQUA
public static final String ANTIBANDING_AUTO
public static final String ANTIBANDING_50HZ
public static final String ANTIBANDING_60HZ
public static final String ANTIBANDING_OFF
public static final String FLASH_MODE_OFF
public static final String FLASH_MODE_AUTO
public static final String FLASH_MODE_ON
public static final String FLASH_MODE_RED_EYE
public static final String FLASH_MODE_TORCH
public static final String SCENE_MODE_AUTO
public static final String SCENE_MODE_ACTION
SCENE_MODE_SPORTS
.public static final String SCENE_MODE_PORTRAIT
public static final String SCENE_MODE_LANDSCAPE
public static final String SCENE_MODE_NIGHT
public static final String SCENE_MODE_NIGHT_PORTRAIT
public static final String SCENE_MODE_THEATRE
public static final String SCENE_MODE_BEACH
public static final String SCENE_MODE_SNOW
public static final String SCENE_MODE_SUNSET
public static final String SCENE_MODE_STEADYPHOTO
public static final String SCENE_MODE_FIREWORKS
public static final String SCENE_MODE_SPORTS
SCENE_MODE_ACTION
.public static final String SCENE_MODE_PARTY
public static final String SCENE_MODE_CANDLELIGHT
public static final String SCENE_MODE_BARCODE
public static final String SCENE_MODE_HDR
public static final String FOCUS_MODE_AUTO
Camera.autoFocus(AutoFocusCallback)
to start the focus in this mode.public static final String FOCUS_MODE_INFINITY
Camera.autoFocus(AutoFocusCallback)
in this mode.public static final String FOCUS_MODE_MACRO
Camera.autoFocus(AutoFocusCallback)
to start the focus in this
mode.public static final String FOCUS_MODE_FIXED
Camera.autoFocus(AutoFocusCallback)
in this mode.public static final String FOCUS_MODE_EDOF
Camera.autoFocus(AutoFocusCallback)
in this mode.public static final String FOCUS_MODE_CONTINUOUS_VIDEO
Camera.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.
Since API level 14, applications can call Camera.autoFocus(AutoFocusCallback)
in this mode. The focus callback will
immediately return with a boolean that indicates whether the focus is
sharp or not. The focus position is locked after autoFocus call. If
applications want to resume the continuous focus, cancelAutoFocus
must be called. Restarting the preview will not resume the continuous
autofocus. To stop continuous focus, applications should change the
focus mode to other modes.
public static final String FOCUS_MODE_CONTINUOUS_PICTURE
FOCUS_MODE_CONTINUOUS_VIDEO
. Auto focus
starts when the parameter is set.
Applications can call Camera.autoFocus(AutoFocusCallback)
in
this mode. If the autofocus is in the middle of scanning, the focus
callback will return when it completes. If the autofocus is not
scanning, the focus callback will immediately return with a boolean
that indicates whether the focus is sharp or not. The apps can then
decide if they want to take a picture immediately or to change the
focus mode to auto, and run a full autofocus cycle. The focus
position is locked after autoFocus call. If applications want to
resume the continuous focus, cancelAutoFocus must be called.
Restarting the preview will not resume the continuous autofocus. To
stop continuous focus, applications should change the focus mode to
other modes.
FOCUS_MODE_CONTINUOUS_VIDEO
,
Constant Field Valuespublic static final int FOCUS_DISTANCE_NEAR_INDEX
getFocusDistances(float[])
.public static final int FOCUS_DISTANCE_OPTIMAL_INDEX
getFocusDistances(float[])
.public static final int FOCUS_DISTANCE_FAR_INDEX
getFocusDistances(float[])
.public static final int PREVIEW_FPS_MIN_INDEX
getPreviewFpsRange(int[])
or getSupportedPreviewFpsRange()
.public static final int PREVIEW_FPS_MAX_INDEX
getPreviewFpsRange(int[])
or getSupportedPreviewFpsRange()
.public void copyFrom(Camera.Parameters other)
other
.
For use by the legacy shim only.public boolean same(Camera.Parameters other)
@Deprecated public void dump()
public String flatten()
The unflatten(String)
method does the reverse.
public void unflatten(String flattened)
The flatten()
method does the reverse.
flattened
- a String of parameters (key-value paired) that
are semi-colon delimitedpublic void remove(String key)
public void set(String key, String value)
key
- the key name for the parametervalue
- the String value of the parameterpublic void set(String key, int value)
key
- the key name for the parametervalue
- the int value of the parameterpublic String get(String key)
key
- the key name for the parameterpublic int getInt(String key)
key
- the key name for the parameterpublic void setPreviewSize(int width, int height)
width
- the width of the pictures, in pixelsheight
- the height of the pictures, in pixelsCamera.setDisplayOrientation(int)
,
Camera.getCameraInfo(int, CameraInfo)
,
setPictureSize(int, int)
,
setJpegThumbnailSize(int, int)
public Camera.Size getPreviewSize()
public List<Camera.Size> getSupportedPreviewSizes()
public List<Camera.Size> getSupportedVideoSizes()
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.
getPreferredPreviewSizeForVideo()
public Camera.Size getPreferredPreviewSizeForVideo()
getSupportedVideoSizes()
public void setJpegThumbnailSize(int width, int height)
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 pixelsheight
- the height of the thumbnail, in pixelssetPreviewSize(int,int)
public Camera.Size getJpegThumbnailSize()
public List<Camera.Size> getSupportedJpegThumbnailSizes()
public void setJpegThumbnailQuality(int quality)
quality
- the JPEG quality of the EXIF thumbnail. The range is 1
to 100, with 100 being the best.public int getJpegThumbnailQuality()
public void setJpegQuality(int quality)
quality
- the JPEG quality of captured picture. The range is 1
to 100, with 100 being the best.public int getJpegQuality()
@Deprecated public void setPreviewFrameRate(int fps)
setPreviewFpsRange(int,int)
fps
- the frame rate (frames per second)@Deprecated public int getPreviewFrameRate()
getPreviewFpsRange(int[])
@Deprecated public List<Integer> getSupportedPreviewFrameRates()
getSupportedPreviewFpsRange()
public void setPreviewFpsRange(int min, int max)
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.Camera.setPreviewCallbackWithBuffer(Camera.PreviewCallback)
,
getSupportedPreviewFpsRange()
public void getPreviewFpsRange(int[] range)
getSupportedPreviewFpsRange()
.public List<int[]> getSupportedPreviewFpsRange()
PREVIEW_FPS_MIN_INDEX
,
PREVIEW_FPS_MAX_INDEX
public void setPreviewFormat(int pixel_format)
If this is never called, the default format will be
ImageFormat.NV21
, which
uses the NV21 encoding format.
Use getSupportedPreviewFormats()
to get a list of
the available preview formats.
It is strongly recommended that either
ImageFormat.NV21
or
ImageFormat.YV12
is used, since
they are supported by all camera devices.
For YV12, the image buffer that is received is not necessarily
tightly packed, as there may be padding at the end of each row of
pixel data, as described in
ImageFormat.YV12
. For camera callback data,
it can be assumed that the stride of the Y and UV data is the
smallest possible that meets the alignment requirements. That is, if
the preview size is width x height, then the following
equations describe the buffer index for the beginning of row
y for the Y plane and row c for the U and V
planes:
yStride = (int) ceil(width / 16.0) * 16;
uvStride = (int) ceil( (yStride / 2) / 16.0) * 16;
ySize = yStride * height;
uvSize = uvStride * height / 2;
yRowIndex = yStride * y;
uRowIndex = ySize + uvSize + uvStride * c;
vRowIndex = ySize + uvStride * c;
size = ySize + uvSize * 2;
pixel_format
- the desired preview picture format, defined by
one of the ImageFormat
constants. (E.g.,
ImageFormat.NV21 (default), or
ImageFormat.YV12)ImageFormat
,
getSupportedPreviewFormats()
public int getPreviewFormat()
Camera.PreviewCallback
.ImageFormat
,
setPreviewFormat(int)
public List<Integer> getSupportedPreviewFormats()
ImageFormat.NV21
is always supported. ImageFormat.YV12
is always supported since API level 12.ImageFormat
,
setPreviewFormat(int)
public void setPictureSize(int width, int height)
Sets the dimensions for pictures.
Applications need to consider the display orientation. See setPreviewSize(int,int)
for reference.
width
- the width for pictures, in pixelsheight
- the height for pictures, in pixelssetPreviewSize(int,int)
public Camera.Size getPictureSize()
public List<Camera.Size> getSupportedPictureSizes()
public void setPictureFormat(int pixel_format)
pixel_format
- the desired picture format
(ImageFormat.NV21,
ImageFormat.RGB_565, or
ImageFormat.JPEG)ImageFormat
public int getPictureFormat()
ImageFormat
public List<Integer> getSupportedPictureFormats()
ImageFormat
public void setRotation(int rotation)
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 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.OrientationEventListener
,
Camera.getCameraInfo(int, CameraInfo)
public void setGpsLatitude(double latitude)
latitude
- GPS latitude coordinate.public void setGpsLongitude(double longitude)
longitude
- GPS longitude coordinate.public void setGpsAltitude(double altitude)
altitude
- GPS altitude in meters.public void setGpsTimestamp(long timestamp)
timestamp
- GPS timestamp (UTC in seconds since January 1,
1970).public void setGpsProcessingMethod(String processing_method)
processing_method
- The processing method to get this location.public void removeGpsData()
public String getWhiteBalance()
WHITE_BALANCE_AUTO
,
WHITE_BALANCE_INCANDESCENT
,
WHITE_BALANCE_FLUORESCENT
,
WHITE_BALANCE_WARM_FLUORESCENT
,
WHITE_BALANCE_DAYLIGHT
,
WHITE_BALANCE_CLOUDY_DAYLIGHT
,
WHITE_BALANCE_TWILIGHT
,
WHITE_BALANCE_SHADE
public void setWhiteBalance(String value)
value
- new white balance.getWhiteBalance()
,
setAutoWhiteBalanceLock(boolean)
public List<String> getSupportedWhiteBalance()
getWhiteBalance()
public String getColorEffect()
EFFECT_NONE
,
EFFECT_MONO
,
EFFECT_NEGATIVE
,
EFFECT_SOLARIZE
,
EFFECT_SEPIA
,
EFFECT_POSTERIZE
,
EFFECT_WHITEBOARD
,
EFFECT_BLACKBOARD
,
EFFECT_AQUA
public void setColorEffect(String value)
value
- new color effect.getColorEffect()
public List<String> getSupportedColorEffects()
getColorEffect()
public String getAntibanding()
ANTIBANDING_AUTO
,
ANTIBANDING_50HZ
,
ANTIBANDING_60HZ
,
ANTIBANDING_OFF
public void setAntibanding(String antibanding)
antibanding
- new antibanding value.getAntibanding()
public List<String> getSupportedAntibanding()
getAntibanding()
public String getSceneMode()
SCENE_MODE_AUTO
,
SCENE_MODE_ACTION
,
SCENE_MODE_PORTRAIT
,
SCENE_MODE_LANDSCAPE
,
SCENE_MODE_NIGHT
,
SCENE_MODE_NIGHT_PORTRAIT
,
SCENE_MODE_THEATRE
,
SCENE_MODE_BEACH
,
SCENE_MODE_SNOW
,
SCENE_MODE_SUNSET
,
SCENE_MODE_STEADYPHOTO
,
SCENE_MODE_FIREWORKS
,
SCENE_MODE_SPORTS
,
SCENE_MODE_PARTY
,
SCENE_MODE_CANDLELIGHT
,
SCENE_MODE_BARCODE
public void setSceneMode(String value)
value
- scene mode.getSceneMode()
public List<String> getSupportedSceneModes()
getSceneMode()
public String getFlashMode()
FLASH_MODE_OFF
,
FLASH_MODE_AUTO
,
FLASH_MODE_ON
,
FLASH_MODE_RED_EYE
,
FLASH_MODE_TORCH
public void setFlashMode(String value)
value
- flash mode.getFlashMode()
public List<String> getSupportedFlashModes()
getFlashMode()
public String getFocusMode()
Camera.autoFocus(AutoFocusCallback)
to start the focus if focus
mode is FOCUS_MODE_AUTO or FOCUS_MODE_MACRO.FOCUS_MODE_AUTO
,
FOCUS_MODE_INFINITY
,
FOCUS_MODE_MACRO
,
FOCUS_MODE_FIXED
,
FOCUS_MODE_EDOF
,
FOCUS_MODE_CONTINUOUS_VIDEO
public void setFocusMode(String value)
value
- focus mode.getFocusMode()
public List<String> getSupportedFocusModes()
getFocusMode()
public float getFocalLength()
public float getHorizontalViewAngle()
public float getVerticalViewAngle()
public int getExposureCompensation()
getMinExposureCompensation()
to getMaxExposureCompensation()
. 0 means exposure is not
adjusted.public void setExposureCompensation(int value)
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.public int getMaxExposureCompensation()
getMinExposureCompensation()
return 0,
exposure compensation is not supported.public int getMinExposureCompensation()
getMaxExposureCompensation()
return 0,
exposure compensation is not supported.public float getExposureCompensationStep()
public void setAutoExposureLock(boolean toggle)
Sets the auto-exposure lock state. Applications should check
isAutoExposureLockSupported()
before using this method.
If set to true, the camera auto-exposure routine will immediately pause until the lock is set to false. Exposure compensation settings changes will still take effect while auto-exposure is locked.
If auto-exposure is already locked, setting this to true again has no effect (the driver will not recalculate exposure values).
Stopping preview with Camera.stopPreview()
, or triggering still
image capture with Camera.takePicture(Camera.ShutterCallback,
Camera.PictureCallback, Camera.PictureCallback)
, will not change the
lock.
Exposure compensation, auto-exposure lock, and auto-white balance lock can be used to capture an exposure-bracketed burst of images, for example.
Auto-exposure state, including the lock state, will not be
maintained after camera Camera.release()
is called. Locking
auto-exposure after Camera.open()
but before the first call to
Camera.startPreview()
will not allow the auto-exposure routine to
run at all, and may result in severely over- or under-exposed
images.
toggle
- new state of the auto-exposure lock. True means that
auto-exposure is locked, false means that the auto-exposure
routine is free to run normally.getAutoExposureLock()
public boolean getAutoExposureLock()
isAutoExposureLockSupported()
before using this method. See
setAutoExposureLock(boolean)
for details about the lock.setAutoExposureLock(boolean)
public boolean isAutoExposureLockSupported()
setAutoExposureLock(boolean)
for details about the lock.setAutoExposureLock(boolean)
public void setAutoWhiteBalanceLock(boolean toggle)
Sets the auto-white balance lock state. Applications should check
isAutoWhiteBalanceLockSupported()
before using this
method.
If set to true, the camera auto-white balance routine will immediately pause until the lock is set to false.
If auto-white balance is already locked, setting this to true again has no effect (the driver will not recalculate white balance values).
Stopping preview with Camera.stopPreview()
, or triggering still
image capture with Camera.takePicture(Camera.ShutterCallback,
Camera.PictureCallback, Camera.PictureCallback)
, will not change the
the lock.
Changing the white balance mode with setWhiteBalance(java.lang.String)
will release the auto-white balance lock if it is set.
Exposure compensation, AE lock, and AWB lock can be used to
capture an exposure-bracketed burst of images, for example.
Auto-white balance state, including the lock state, will not be
maintained after camera Camera.release()
is called. Locking
auto-white balance after Camera.open()
but before the first call to
Camera.startPreview()
will not allow the auto-white balance routine
to run at all, and may result in severely incorrect color in captured
images.
toggle
- new state of the auto-white balance lock. True means
that auto-white balance is locked, false means that the
auto-white balance routine is free to run normally.getAutoWhiteBalanceLock()
,
setWhiteBalance(String)
public boolean getAutoWhiteBalanceLock()
isAutoWhiteBalanceLockSupported()
before using this
method. See setAutoWhiteBalanceLock(boolean)
for details about the
lock.setAutoWhiteBalanceLock(boolean)
public boolean isAutoWhiteBalanceLockSupported()
setAutoWhiteBalanceLock(boolean)
for details about the lock.setAutoWhiteBalanceLock(boolean)
public int getZoom()
isZoomSupported()
before
using this method.getMaxZoom()
. 0 means the camera is not zoomed.public void setZoom(int value)
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()
.public boolean isZoomSupported()
public int getMaxZoom()
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.public List<Integer> getZoomRatios()
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.public boolean isSmoothZoomSupported()
public void getFocusDistances(float[] output)
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 Camera.autoFocus(AutoFocusCallback)
, Camera.cancelAutoFocus()
, or Camera.startPreview()
. Applications can call Camera.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.FOCUS_DISTANCE_NEAR_INDEX
,
FOCUS_DISTANCE_OPTIMAL_INDEX
,
FOCUS_DISTANCE_FAR_INDEX
public int getMaxNumFocusAreas()
setFocusAreas(List)
and
getFocusAreas()
.getFocusAreas()
public List<Camera.Area> getFocusAreas()
Gets the current focus areas. Camera driver uses the areas to decide focus.
Before using this API or setFocusAreas(List)
, apps should
call getMaxNumFocusAreas()
to know the maximum number of
focus areas first. If the value is 0, focus area is not supported.
Each focus area is a rectangle with specified weight. The direction
is relative to the sensor orientation, that is, what the sensor sees.
The direction is not affected by the rotation or mirroring of
Camera.setDisplayOrientation(int)
. Coordinates of the rectangle
range from -1000 to 1000. (-1000, -1000) is the upper left point.
(1000, 1000) is the lower right point. The width and height of focus
areas cannot be 0 or negative.
The weight must range from 1 to 1000. The weight should be interpreted as a per-pixel weight - all pixels in the area have the specified weight. This means a small area with the same weight as a larger area will have less influence on the focusing than the larger area. Focus areas can partially overlap and the driver will add the weights in the overlap region.
A special case of a null
focus area list means the driver is
free to select focus targets as it wants. For example, the driver may
use more signals to select focus areas and change them
dynamically. Apps can set the focus area list to null
if they
want the driver to completely control focusing.
Focus areas are relative to the current field of view
(getZoom()
). No matter what the zoom level is, (-1000,-1000)
represents the top of the currently visible camera frame. The focus
area cannot be set to be outside the current field of view, even
when using zoom.
Focus area only has effect if the current focus mode is
FOCUS_MODE_AUTO
, FOCUS_MODE_MACRO
,
FOCUS_MODE_CONTINUOUS_VIDEO
, or
FOCUS_MODE_CONTINUOUS_PICTURE
.
public void setFocusAreas(List<Camera.Area> focusAreas)
getFocusAreas()
for documentation.focusAreas
- the focus areasgetFocusAreas()
public int getMaxNumMeteringAreas()
setMeteringAreas(List)
and
getMeteringAreas()
.getMeteringAreas()
public List<Camera.Area> getMeteringAreas()
Gets the current metering areas. Camera driver uses these areas to decide exposure.
Before using this API or setMeteringAreas(List)
, apps should
call getMaxNumMeteringAreas()
to know the maximum number of
metering areas first. If the value is 0, metering area is not
supported.
Each metering area is a rectangle with specified weight. The
direction is relative to the sensor orientation, that is, what the
sensor sees. The direction is not affected by the rotation or
mirroring of Camera.setDisplayOrientation(int)
. Coordinates of the
rectangle range from -1000 to 1000. (-1000, -1000) is the upper left
point. (1000, 1000) is the lower right point. The width and height of
metering areas cannot be 0 or negative.
The weight must range from 1 to 1000, and represents a weight for every pixel in the area. This means that a large metering area with the same weight as a smaller area will have more effect in the metering result. Metering areas can partially overlap and the driver will add the weights in the overlap region.
A special case of a null
metering area list means the driver
is free to meter as it chooses. For example, the driver may use more
signals to select metering areas and change them dynamically. Apps
can set the metering area list to null
if they want the
driver to completely control metering.
Metering areas are relative to the current field of view
(getZoom()
). No matter what the zoom level is, (-1000,-1000)
represents the top of the currently visible camera frame. The
metering area cannot be set to be outside the current field of view,
even when using zoom.
No matter what metering areas are, the final exposure are compensated
by setExposureCompensation(int)
.
public void setMeteringAreas(List<Camera.Area> meteringAreas)
getMeteringAreas()
for
documentation.meteringAreas
- the metering areasgetMeteringAreas()
public int getMaxNumDetectedFaces()
Camera.FaceDetectionListener
.
If the return value is 0, face detection of the specified type is not
supported.Camera.startFaceDetection()
public void setRecordingHint(boolean hint)
MediaRecorder.start()
, not to take still pictures
Camera.takePicture(Camera.ShutterCallback, Camera.PictureCallback,
Camera.PictureCallback, Camera.PictureCallback)
. Using this hint can
allow MediaRecorder.start() to start faster or with fewer glitches on
output. This should be called before starting preview for the best
result, but can be changed while the preview is active. The default
value is false.
The app can still call takePicture() when the hint is true or call
MediaRecorder.start() when the hint is false. But the performance may
be worse.hint
- true if the apps intend to record videos using
MediaRecorder
.public boolean isVideoSnapshotSupported()
Returns true if video snapshot is supported. That is, applications
can call Camera.takePicture(Camera.ShutterCallback,
Camera.PictureCallback, Camera.PictureCallback,
Camera.PictureCallback)
during recording. Applications do not need
to call Camera.startPreview()
after taking a picture. The preview
will be still active. Other than that, taking a picture during
recording is identical to taking a picture normally. All settings and
methods related to takePicture work identically. Ex:
getPictureSize()
, getSupportedPictureSizes()
,
setJpegQuality(int)
, setRotation(int)
, and etc. The
picture will have an EXIF header. FLASH_MODE_AUTO
and
FLASH_MODE_ON
also still work, but the video will record the
flash.
Applications can set shutter callback as null to avoid the shutter sound. It is also recommended to set raw picture and post view callbacks to null to avoid the interrupt of preview display.
Field-of-view of the recorded video may be different from that of the captured pictures. The maximum size of a video snapshot may be smaller than that for regular still captures. If the current picture size is set higher than can be supported by video snapshot, the picture will be captured at the maximum supported size instead.
public void setVideoStabilization(boolean toggle)
Enables and disables video stabilization. Use
isVideoStabilizationSupported()
to determine if calling this
method is valid.
Video stabilization reduces the shaking due to the motion of the
camera in both the preview stream and in recorded videos, including
data received from the preview callback. It does not reduce motion
blur in images captured with
takePicture
.
Video stabilization can be enabled and disabled while preview or recording is active, but toggling it may cause a jump in the video stream that may be undesirable in a recorded video.
toggle
- Set to true to enable video stabilization, and false to
disable video stabilization.isVideoStabilizationSupported()
,
getVideoStabilization()
public boolean getVideoStabilization()
setVideoStabilization(boolean)
for details of video stabilization.isVideoStabilizationSupported()
,
setVideoStabilization(boolean)
public boolean isVideoStabilizationSupported()
setVideoStabilization(boolean)
for details of video stabilization.setVideoStabilization(boolean)
,
getVideoStabilization()