【Android Camera1】Camera1 Parameters参数详解(三)—— Zoom,Other

一、摘要

本篇文章将介绍Camera1 Parameters Zoom相关的设置以及剩余的Key

二、相关Parameters Key

Key变量名Key变量值
KEY_EFFECTeffect
KEY_ANTIBANDINGantibanding
KEY_SCENE_MODEscene-mode
KEY_HORIZONTAL_VIEW_ANGLEhorizontal-view-angle
KEY_VERTICAL_VIEW_ANGLEvertical-view-angle
KEY_MAX_ZOOMmax-zoom
KEY_ZOOMzoom
KEY_ZOOM_RATIOSzoom-ratios
KEY_ZOOM_SUPPORTEDzoom-supported
KEY_SMOOTH_ZOOM_SUPPORTEDsmooth-zoom-supported
KEY_VIDEO_SIZEvideo-size
KEY_PREFERRED_PREVIEW_SIZE_FOR_VIDEOpreferred-preview-size-for-video
KEY_MAX_NUM_DETECTED_FACES_HWmax-num-detected-faces-hw
KEY_MAX_NUM_DETECTED_FACES_SWmax-num-detected-faces-sw
KEY_RECORDING_HINTrecording-hint
KEY_VIDEO_SNAPSHOT_SUPPORTEDvideo-snapshot-supported
KEY_VIDEO_STABILIZATIONvideo-stabilization
KEY_VIDEO_STABILIZATION_SUPPORTEDvideo-stabilization-supported

三、Zoom

说明:Zoom相关
相关KEYmax-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);
 }

分析:

  1. 在使用其他zoom相关方法时,先调用上述2个方法判断是否支持
  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);
}

分析:

  1. 更新用户当前的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_AUTOScene mode is off.
SCENE_MODE_ACTIONTake photos of fast moving objects
SCENE_MODE_PORTRAITTake people pictures.
SCENE_MODE_LANDSCAPETake pictures on distant objects.
SCENE_MODE_NIGHTTake photos at night.
SCENE_MODE_ACTIONTake photos of fast moving objects
SCENE_MODE_PORTRAITTake people pictures.
SCENE_MODE_NIGHT_PORTRAITTake people pictures at night.
SCENE_MODE_THEATRETake photos in a theater. Flash light is off.
SCENE_MODE_BEACHTake pictures on the beach.
SCENE_MODE_SNOWTake pictures on the snow.
SCENE_MODE_SUNSETTake sunset photos.
SCENE_MODE_STEADYPHOTOAvoid blurry pictures (for example, due to hand shake).
SCENE_MODE_FIREWORKSFor shooting firework displays.
SCENE_MODE_SPORTSTake photos of fast moving objects. Same as
SCENE_MODE_PARTYTake indoor low-light shot.
SCENE_MODE_CANDLELIGHTCapture the naturally warm color of scenes lit by candles.
SCENE_MODE_BARCODEApplications are looking for a barcode.
SCENE_MODE_HDRCapture 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);
}

分析:

  1. Video stabilization reduces the shaking due to the motion of the camera in both the preview stream and in recorded videos。
  2. 可能影响性能
  3. 实际效果不明显
  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值