一、摘要
本篇文章将介绍Camera1 Parameters Zoom相关的设置以及剩余的Key
二、相关Parameters Key
Key变量名 | Key变量值 |
---|---|
KEY_EFFECT | effect |
KEY_ANTIBANDING | antibanding |
KEY_SCENE_MODE | scene-mode |
KEY_HORIZONTAL_VIEW_ANGLE | horizontal-view-angle |
KEY_VERTICAL_VIEW_ANGLE | vertical-view-angle |
KEY_MAX_ZOOM | max-zoom |
KEY_ZOOM | zoom |
KEY_ZOOM_RATIOS | zoom-ratios |
KEY_ZOOM_SUPPORTED | zoom-supported |
KEY_SMOOTH_ZOOM_SUPPORTED | smooth-zoom-supported |
KEY_VIDEO_SIZE | video-size |
KEY_PREFERRED_PREVIEW_SIZE_FOR_VIDEO | preferred-preview-size-for-video |
KEY_MAX_NUM_DETECTED_FACES_HW | max-num-detected-faces-hw |
KEY_MAX_NUM_DETECTED_FACES_SW | max-num-detected-faces-sw |
KEY_RECORDING_HINT | recording-hint |
KEY_VIDEO_SNAPSHOT_SUPPORTED | video-snapshot-supported |
KEY_VIDEO_STABILIZATION | video-stabilization |
KEY_VIDEO_STABILIZATION_SUPPORTED | video-stabilization-supported |
三、Zoom
说明: | Zoom相关 |
---|---|
相关KEY | max-zoom |
zoom-ratios | |
zoom-supported | |
smooth-zoom-supported | |
zoom | |
方法 | public int getMaxZoom() |
public boolean isZoomSupported() | |
public void setZoom(int value) | |
public int getZoom() | |
public List getZoomRatios() | |
public boolean isSmoothZoomSupported() |
/**
* before using other zoom methods.
*/
public boolean isZoomSupported() {
String str = get(KEY_ZOOM_SUPPORTED);
return TRUE.equals(str);
}
/**
* @return true if smooth zoom is supported.
*/
public boolean isSmoothZoomSupported() {
String str = get(KEY_SMOOTH_ZOOM_SUPPORTED);
return TRUE.equals(str);
}
分析:
- 在使用其他zoom相关方法时,先调用上述2个方法判断是否支持
isSmoothZoomSupported()
基本不存在使用场景
/**
* Gets the zoom ratios of all zoom values.
* @return the zoom ratios in 1/100 increments. Ex: a zoom of 3.2x is
* returned as 320. The number of elements is {@link
* #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 List<Integer> getZoomRatios() {
return splitInt(get(KEY_ZOOM_RATIOS));
}
/**
* Gets the maximum zoom value allowed for snapshot. This is the maximum
* value that applications can set to {@link #setZoom(int)}.
* Applications should call {@link #isZoomSupported} before using this
* method. This value may change in different preview size. Applications
* should call this again after setting preview size.
*
* @return the maximum zoom value supported by the camera.
*/
public int getMaxZoom() {
return getInt(KEY_MAX_ZOOM, 0);
}
分析:在系统源码里,这样获取真实的
maxZoom
//AndroidCameraCapabilities.java
if (p.isZoomSupported()) {
mMaxZoom = p.getZoomRatios().get(p.getMaxZoom()) / 100;
mSupportedFeatures.add(Feature.ZOOM);
}
/**
* Gets current zoom value. This also works when smooth zoom is in
* progress. Applications should check {@link #isZoomSupported} before
* using this method.
*
* @return the current zoom value. The range is 0 to {@link
* #getMaxZoom}. 0 means the camera is not zoomed.
*/
public int getZoom() {
return getInt(KEY_ZOOM, 0);
}
/**
* 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 {@link PictureCallback}. The preview size remains the
* same in zoom. Applications should check {@link #isZoomSupported}
* before using this method.
*
* @param value zoom value. The valid range is 0 to {@link #getMaxZoom}.
*/
public void setZoom(int value) {
set(KEY_ZOOM, value);
}
分析:
- 更新用户当前的zoom Value来调整缩放大小
四、其他
4.1 Effect
/**
* Gets the current color effect setting.
*
* @return current color effect. null if color effect
* setting is not supported.
* @see #EFFECT_NONE
* @see #EFFECT_MONO
* @see #EFFECT_NEGATIVE
* @see #EFFECT_SOLARIZE
* @see #EFFECT_SEPIA
* @see #EFFECT_POSTERIZE
* @see #EFFECT_WHITEBOARD
* @see #EFFECT_BLACKBOARD
* @see #EFFECT_AQUA
*/
public String getColorEffect() {
return get(KEY_EFFECT);
}
/**
* Sets the current color effect setting.
*
* @param value new color effect.
* @see #getColorEffect()
*/
public void setColorEffect(String value) {
set(KEY_EFFECT, value);
}
/**
* Gets the supported color effects.
*
* @return a list of supported color effects. null if color effect
* setting is not supported.
* @see #getColorEffect()
*/
public List<String> getSupportedColorEffects() {
String str = get(KEY_EFFECT + SUPPORTED_VALUES_SUFFIX);
return split(str);
}
实际效果
4.2 scene-mode
/**
* Gets the current scene mode setting.
*
* @return one of SCENE_MODE_XXX string constant. null if scene mode
* setting is not supported.
* @see #SCENE_MODE_AUTO
* @see #SCENE_MODE_ACTION
* @see #SCENE_MODE_PORTRAIT
* @see #SCENE_MODE_LANDSCAPE
* @see #SCENE_MODE_NIGHT
* @see #SCENE_MODE_NIGHT_PORTRAIT
* @see #SCENE_MODE_THEATRE
* @see #SCENE_MODE_BEACH
* @see #SCENE_MODE_SNOW
* @see #SCENE_MODE_SUNSET
* @see #SCENE_MODE_STEADYPHOTO
* @see #SCENE_MODE_FIREWORKS
* @see #SCENE_MODE_SPORTS
* @see #SCENE_MODE_PARTY
* @see #SCENE_MODE_CANDLELIGHT
* @see #SCENE_MODE_BARCODE
*/
public String getSceneMode() {
return get(KEY_SCENE_MODE);
}
/**
* 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.
*
* @param value scene mode.
* @see #getSceneMode()
*/
public void setSceneMode(String value) {
set(KEY_SCENE_MODE, value);
}
/**
* Gets the supported scene modes.
*
* @return a list of supported scene modes. null if scene mode setting
* is not supported.
* @see #getSceneMode()
*/
public List<String> getSupportedSceneModes() {
String str = get(KEY_SCENE_MODE + SUPPORTED_VALUES_SUFFIX);
return split(str);
}
scene-mode | 场景 |
---|---|
SCENE_MODE_AUTO | Scene mode is off. |
SCENE_MODE_ACTION | Take photos of fast moving objects |
SCENE_MODE_PORTRAIT | Take people pictures. |
SCENE_MODE_LANDSCAPE | Take pictures on distant objects. |
SCENE_MODE_NIGHT | Take photos at night. |
SCENE_MODE_ACTION | Take photos of fast moving objects |
SCENE_MODE_PORTRAIT | Take people pictures. |
SCENE_MODE_NIGHT_PORTRAIT | Take people pictures at night. |
SCENE_MODE_THEATRE | Take photos in a theater. Flash light is off. |
SCENE_MODE_BEACH | Take pictures on the beach. |
SCENE_MODE_SNOW | Take pictures on the snow. |
SCENE_MODE_SUNSET | Take sunset photos. |
SCENE_MODE_STEADYPHOTO | Avoid blurry pictures (for example, due to hand shake). |
SCENE_MODE_FIREWORKS | For shooting firework displays. |
SCENE_MODE_SPORTS | Take photos of fast moving objects. Same as |
SCENE_MODE_PARTY | Take indoor low-light shot. |
SCENE_MODE_CANDLELIGHT | Capture the naturally warm color of scenes lit by candles. |
SCENE_MODE_BARCODE | Applications are looking for a barcode. |
SCENE_MODE_HDR | Capture a scene using high dynamic range imaging techniques. |
实际scene-mode应用场景不多
4.3 antibanding
/**
* Gets the current antibanding setting.
*
* @return current antibanding. null if antibanding setting is not
* supported.
* @see #ANTIBANDING_AUTO
* @see #ANTIBANDING_50HZ
* @see #ANTIBANDING_60HZ
* @see #ANTIBANDING_OFF
*/
public String getAntibanding() {
return get(KEY_ANTIBANDING);
}
/**
* Sets the antibanding.
*
* @param antibanding new antibanding value.
* @see #getAntibanding()
*/
public void setAntibanding(String antibanding) {
set(KEY_ANTIBANDING, antibanding);
}
刷新频率用于解决LED或者窗帘一些场景下出现摩尔纹的问题。实际不会用到
4.4 view-angle
/**
* Gets the horizontal angle of view in degrees.
*
* @return horizontal angle of view. Returns -1.0 when the device
* doesn't report view angle information.
*/
public float getHorizontalViewAngle() {
return Float.parseFloat(get(KEY_HORIZONTAL_VIEW_ANGLE));
}
/**
* Gets the vertical angle of view in degrees.
*
* @return vertical angle of view. Returns -1.0 when the device
* doesn't report view angle information.
*/
public float getVerticalViewAngle() {
return Float.parseFloat(get(KEY_VERTICAL_VIEW_ANGLE));
}
用于返回预览过程中水平和竖直的夹角。用于做平衡拍摄使用。
4.5 video-size
参考该系列文章【Android Camera1】Camera1 Parameters参数详解(一)—— Size (preview/picture/thumbnail)
4.6 max-num-detected-faces-hw
/**
* Gets the maximum number of detected faces supported. This is the
* maximum length of the list returned from {@link FaceDetectionListener}.
* If the return value is 0, face detection of the specified type is not
* supported.
*
* @return the maximum number of detected face supported by the camera.
* @see #startFaceDetection()
*/
public int getMaxNumDetectedFaces() {
return getInt(KEY_MAX_NUM_DETECTED_FACES_HW, 0);
}
返回最大人脸检测的个数
4.7 recording-hint
/**
* Sets recording mode hint. This tells the camera that the intent of
* the application is to record videos {@link
* android.media.MediaRecorder#start()}, not to take still pictures
* {@link #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.
*
* @param hint true if the apps intend to record videos using
* {@link android.media.MediaRecorder}.
*/
public void setRecordingHint(boolean hint) {
set(KEY_RECORDING_HINT, hint ? TRUE : FALSE);
}
告诉Camera自己要录视频了。 通常使用在切换到视频TAB上。
4.8 video-snapshot-supported
/**
* <p>Returns true if video snapshot is supported. That is, applications
* can call {@link #takePicture(Camera.ShutterCallback,
* Camera.PictureCallback, Camera.PictureCallback,
* Camera.PictureCallback)} during recording. Applications do not need
* to call {@link #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.
*/
public boolean isVideoSnapshotSupported() {
String str = get(KEY_VIDEO_SNAPSHOT_SUPPORTED);
return TRUE.equals(str);
}
视频在录制视频过程中拍照。常用与录制视频过程中截取其中一个画面
4.9 video-stabilization
/**
* <p>Enables and disables video stabilization. Use
* {@link #isVideoStabilizationSupported} to determine if calling this
* method is valid.</p>
*
* <p>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
* {@link Camera#takePicture takePicture}.</p>
*
* <p>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.</p>
*
* @param toggle Set to true to enable video stabilization, and false to
* disable video stabilization.
* @see #isVideoStabilizationSupported()
* @see #getVideoStabilization()
*/
public void setVideoStabilization(boolean toggle) {
set(KEY_VIDEO_STABILIZATION, toggle ? TRUE : FALSE);
}
/**
* Get the current state of video stabilization. See
* {@link #setVideoStabilization} for details of video stabilization.
*
* @return true if video stabilization is enabled
* @see #isVideoStabilizationSupported()
* @see #setVideoStabilization(boolean)
*/
public boolean getVideoStabilization() {
String str = get(KEY_VIDEO_STABILIZATION);
return TRUE.equals(str);
}
/**
* Returns true if video stabilization is supported. See
* {@link #setVideoStabilization} for details of video stabilization.
*
* @return true if video stabilization is supported
* @see #setVideoStabilization(boolean)
* @see #getVideoStabilization()
*/
public boolean isVideoStabilizationSupported() {
String str = get(KEY_VIDEO_STABILIZATION_SUPPORTED);
return TRUE.equals(str);
}
分析:
- Video stabilization reduces the shaking due to the motion of the camera in both the preview stream and in recorded videos。
- 可能影响性能
- 实际效果不明显