android 拍照 Camera类 使用照相机进行拍照 翻译

  次阅读 来源:互联网(转载协议) 2015-09-29 10:11 我要评论(0)

android.hardware.Camera

The Camera class is used to set image capture settings, start/stop preview, snap pictures, and retrieve frames for encoding for video. This class is a client for the Camera service, which manages the actual camera hardware.

权限AndroidManifest.xml:

下面写上:

如果涉及到存储,则还应当添加:

To take pictures with this class, use the following steps:

获取个Camera实例 open(int).获取已经存在(默认)的设置 getParameters().如果必要,可以修改返回的 Camera.Parameters 对象 and 调用setParameters(Camera.Parameters).如果需要,也可以调用 setDisplayOrientation(int).重要: 传递一个完全初始化后的 SurfaceHolder 到setPreviewDisplay(SurfaceHolder). Without a surface, the camera will be unable to start the preview.重要: 调用startPreview() 更新预览界面,预览必须在你拍照之前启动。 当你想要的时候,调用takePicture(Camera.ShutterCallback, Camera.PictureCallback, Camera.PictureCallback, Camera.PictureCallback) 来捕获一张照片.等待 回调函数提供实际的图像数据。 照完之后,预览显示将会停止。如果想照更多的照片,请再次调用 startPreview() .调用 stopPreview() 来通知更新预览界面。重要: 调用release() 来释放相机,让其他应用程序使用. 应用程序应该用onPause() (and re-open() it inonResume())来立即释放相机.

To quickly switch to video recording mode, use these steps:

Obtain and initialize a Camera and start preview as described above. Call unlock() to allow the media process to access the camera.Pass the camera to setCamera(Camera). SeeMediaRecorder information about video recording.When finished recording, call reconnect() to re-acquire and re-lock the camera.If desired, restart preview and take more photos or videos. Call stopPreview() andrelease() as described above.

This class is not thread-safe, and is meant for use from one event thread. Most long-running operations (preview, focus, photo capture, etc) happen asynchronously and invoke callbacks as necessary. Callbacks will be invoked on the event thread open(int) was called from. This class's methods must never be called from multiple threads at once.

这个类不是线程安全的,并且是供一个事件线程使用。最长时间运行的操作(预览,对焦,照片拍摄等)发生 异步调用的回调是必要的。回调将在事件线程open(int)被调用后被调用。这个类的方法,绝不能从多个线程立即调用。

Caution: Different Android-powered devices may have different hardware specifications, such as megapixel ratings and auto-focus capabilities. In order for your application to be compatible with more devices, you should not make assumptions about the device camera specifications.

注意:不同版本的Android手机可能有不同的硬件规格,如像素的分级和自动对焦功能。为了让您的应用程序能与更多的设备兼容,你不应该做出有关该设备的摄像头规格的假设。

Public Methods公共

final void

addCallbackBuffer(byte[] callbackBuffer) Adds a pre-allocated buffer to the preview callback buffer queue.

final void

autoFocus(Camera.AutoFocusCallback cb) Starts camera auto-focus and registers a callback function to run when the camera is focused.

final void

cancelAutoFocus() Cancels any auto-focus function in progress.

final boolean

enableShutterSound(boolean enabled)

Enable or disable the default shutter sound when taking a picture.拍摄时启用或禁用默认的快门声。

static void

getCameraInfo(int cameraId, Camera.CameraInfo cameraInfo) Returns the information about a particular camera.

static int

getNumberOfCameras() Returns the number of physical cameras available on this device.返回物理相机在此设备上可用的数目

Camera.Parameters

getParameters() Returns the current settings for this Camera service.

本站部分文章来源于网络以及网友投稿,本站只负责对文章进行整理、排版、编辑,是出于传递更多信息之目的,并不意味着赞同其观点或证实其内容的真实性。如果您有什么意见或建议,请联系QQ28-1688-302!

人工智能实验室
相关文章相关文章
  • teamLab创始人猪子寿之: 抛去衣食住行,我还剩下什么?

    teamLab创始人猪子寿之: 抛去衣食住行,我还剩下什么?

  • 2018深圳国际人工智能展览会 2018 shenzhen International Artif

    2018深圳国际人工智能展览会 2018 shenzhen International Artif

  • Oculus公布原型机,大幅度提升可视角,能实现140°的视场水平

    Oculus公布原型机,大幅度提升可视角,能实现140°的视场水平

  • Michael I. Jordan带你解读百万奖金ATEC蚂蚁人工智能大赛

    Michael I. Jordan带你解读百万奖金ATEC蚂蚁人工智能大赛

网友点评网友点评
阅读推荐阅读推荐

据外媒报道,STEER打造了首款完全自动驾驶停车技术,旨在使常规车辆转变为无人驾驶车辆。STEER的首款技术应用是4级自动驾驶及网络安全停车...

近日,美国软性机器抓手制造商 Soft Robotics 宣布,获得 2000 万美元的融资,本轮投资者包括 Scale Venture Partners,Calibrate Ventures...

据外媒报道,加州车管局发布了《2017自动驾驶脱离报告(California Autonomous Vehicle Disengagement Reports)》,其中谈及了脱离的具体...

用人机语音交互,来解决智能家居适老的问题;通过家庭门禁与安防套件、空气净化套件、可燃气体与有害气体监控套件等相互联动,在不同生活情...