Android平台使用Camera2(5.0+)替代过时的Camera

转自:https://forums.developer.amazon.com/articles/2707/using-camera2-to-replace-deprecated-camera-api.html

From Android 5.0(API Level 21) the new Camera2 API(android.hardware.Camera2) is introduced which now gives full manual control over Android device cameras. With previous Camera API(android.hardware.Camera), manual controls for the camera were only accessible by making changes to OS and existing APIs which wasn't friendly. The old Camera API (android.hardware.Camera) is now deprecated on Android 5.0 and recommended to use Camera2 API for future apps.

Pre-L Camera API - Limited access to streaming image data Limited information about camera state No manual capture control

Camera2 API - Supports 30fps full resolution with burst mode Supports change on manual camera settings between frame capture Supports RAW image capture Supports Zero Shutter Lag & Movie Snapshot Supports setting other manual camera device controls including level of Noise Cancelling

Resolution

Basic usage of camera is divided with 5 main parts(CameraManager,CameraDevice,CameraCaptureSession,CaptureRequest,CaptureResult)

CameraManager - Provides interfaces for iterating, listing and connecting to CameraDevices http://developer.android.com/reference/android/hardware/camera2/CameraManager.html

CameraDevice - Representation of a single camera connected to an Android device http://developer.android.com/reference/android/hardware/camera2/CameraDevice.html

CameraCaptureSession - Provides set of target output surfaces(TextureView,MediaRecorder,MediaCodec,ImageReader,RenderScriptAllocation) http://developer.android.com/reference/android/hardware/camera2/CameraCaptureSession.html

CaptureRequest - Settings and outputs needed to capture a single image from the camera device Create request builder by predefined templates(TEMPLATE_PREVIEW, TEMPLATE_RECORD, TEMPLATE_STILL_CAPTURE, TEMPLATE_VIDEO_SNAPSHOT, TEMPLATE_MANUAL) This requests are given to capture or setRepeatingRequest to capture images from the camera http://developer.android.com/reference/android/hardware/camera2/CaptureRequest.html

CaptureResult - Results of a single image capture from the image sensorhttp://developer.android.com/reference/android/hardware/camera2/CaptureResult.html

For specifics, you should go through the Camera2 Package Summary page. http://developer.android.com/reference/android/hardware/camera2/package-summary.html

Also there is a great introductory video by Google Developer Advocate on YouTube that explains the changes on Camera2 API: DevBytes: Android L Developer Preview - Camera2 API.

https://www.youtube.com/watch?v=Xtp3tH27OFs

You will need to remember that all features on Camera2 API are not always available on Android device cameras. It all depends on the camera device. In order to check that, use CameraCharacteristics to retrieve camera device feature supported information. characteristics.get(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL);

The results will be returned within 3 flavors of camera functionality with the order of FULL > LIMITED > LEGACY:

INFO_SUPPORTED_HARDWARE_LEVEL_FULL - Full hardware level support which allows high resolution capture with support to full manual control. When this is returned, image capture with burst mode and new features will be available.

https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics.html#INFO_SUPPORTED_HARDWARE_LEVEL

INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED - A LIMITED device may have some or none of the FULL characteristics. Some features are not part of any particular hardware level or capability and must be queried separately.

https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics.html#INFO_SUPPORTED_HARDWARE_LEVEL

INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY - Cameras on all devices support at least this level. This is the same level as the old Camera API which got deprecated.

https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics.html#INFO_SUPPORTED_HARDWARE_LEVEL

Although it is recommended to use Camera2 API for future app development, it is only available for usage from Lollipop(API Level 21). It is unlikely that the Camera2 API will backport to the earlier versions of Android, so you will need to keep using the Camera API(android.hardware.Camera) until minSdkVersion rises to 21 or higher. You can make the app distinguish which camera API to use by the following code.

if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {// your code using Camera API here - is between 1-20
} else if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {// your code using Camera2 API here - is api 21 or higher
}

Keywords: Camera, Deprecated methods, Camera2

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/553074.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

RTMP播放器开发填坑之道

好多开发者提到&#xff0c;在目前开源播放器如此泛滥的情况下&#xff0c;为什么还需要做自研框架的RTMP播放器&#xff0c;自研和开源播放器&#xff0c;到底好在哪些方面&#xff1f;以下大概聊聊我们的一点经验&#xff0c;感兴趣的&#xff0c;可以关注 github&#xff1a…

Win11系统语言修改不了中文怎么办

一些升级了Win11系统的朋友发现升级后发现是英文版的&#xff0c;怎么把英文版的换成中文版的呢?下面为大家带来如何把Win11系统语言从英文变成中文&#xff0c;方法非常简单。 Win11系统语言修改不了中文怎么办 1、首先打开区域和语言设置(搜索)&#xff0c;看看是否有“显…

Vscode —— 解决Vscode终端无法使用npm的命令的问题

在cmd中可以正常执行npm -v等指令,但是在vs code终端中,无法执行npm -v,node -v等指令 出现报错 解决办法&#x1f447; 方法一&#xff1a;【右键单击Vscode】以【管理员身份运行】&#xff0c;【重启Vscode】 方法二&#xff1a;①【用户变量】的【path】添加npm所在路径的…

RTSP播放器开发填坑之道

好多开发者提到&#xff0c;在目前开源播放器如此泛滥的情况下&#xff0c;为什么还需要做自研框架的RTSP播放器&#xff0c;自研和开源播放器&#xff0c;到底好在哪些方面&#xff1f;以下大概聊聊我们的一点经验&#xff0c;感兴趣的&#xff0c;可以关注 github&#xff1a…

ijkplayer、VLC Player、SmartPlayer、ExoPlayer播放器比较

ijkPlayer ijkPlayer是BiliBili公司维护的一个开源工程&#xff0c;基于ffmpeg开发的一个播放器软件&#xff0c;支持Android和iOS平台&#xff0c;整个ijkplayer就是以ffplay为基础&#xff0c;如果只是使用它进行播放&#xff0c;集成也较为简单&#xff0c;使用也和MediaPl…

Win11系统设置绿色护眼模式的方法

随着Win11系统电脑的逐步推广&#xff0c;Win11系统在市场上的用户量也是越来越大&#xff0c;不少电脑办公群体也是很青睐于使用Win11系统&#xff0c;然而&#xff0c;长时间的办公容易造成视觉疲劳&#xff0c;为此&#xff0c;很多人希望把电脑的显示颜色改成”护眼绿“&am…

浏览器播放RTSP视频流几种解决方案

方案一: H5 websocket_rtsp_proxy 实现视频流直播 Streamedian 提供了一种“html5_rtsp_player websock_rtsp_proxy”的技术方案&#xff0c;可以通过html5的video标签直接播放RTSP的视频流。 整个架构如下图所示&#xff0c;分为服务器端和浏览器端两部分&#xff1a; 方案…

技术员联盟Win11 64位官方全新旗舰版镜像V2021.08

技术员联盟Win11 64位官方全新旗舰版镜像V2021.08以微软官方纯净版作为母盘对系统进行了全面优化更新&#xff0c;用户使用更加流畅顺手&#xff0c;轻松体验到系统的优秀性能&#xff0c;适用目前市场最新机型以及老旧机型&#xff0c;多种安装方式供用户选择&#xff0c;且更…

Android播放器之SurfaceView与GLSurfaceView

先看Surface Surface的官方介绍&#xff1a;Handle onto a raw buffer that is being managed by the screen compositor&#xff0c;Surface是一个raw buffer的句柄&#xff0c;通过它在raw buffer上进行绘制&#xff0c;可以通过Surface获得一个Canvas。 Canvas canvas mS…

几款知名RTMP推流模块比较:OBS VS SmartPublisher VS Flash Media Live Encoder

OBS 功能强大&#xff0c;几乎所有你想要的场景它都有&#xff0c;用起来很顺手。可以将桌面、摄像头、程序窗口通过rtmp推送到流媒体服务器上。 当然如果你是开发者&#xff0c;想基于OBS做二次开发&#xff0c;实现二次产品化的化&#xff0c;难度比较大&#xff0c;OBS代码…

中关村Win11 32位微软原版ISO V2021.08

中关村Win11 32位微软原版ISO V2021.08以微软官方原版作为母盘对系统进行了全面优化更新&#xff0c;支持一键化智能安装&#xff0c;在操作舒适性和便捷性方面进行了优化设计&#xff0c;流畅稳定&#xff0c;系统进行了全面优化&#xff0c;大大降低了发生蓝屏和黑屏的可能&a…

如何用轻量级RTSP服务本地生成RTSP测试URL

最近发现好多开发者都在搜索可用的RTSP测试URL&#xff0c;目前公网实际可测试的RTSP URL非常少&#xff0c;即便是可用&#xff0c;分辨率和网络也非常差&#xff0c;不适合长期测试。 针对此&#xff0c;我们的建议是最好直接网上买个海康或大华的摄像头&#xff0c;一般来说…

Windows平台RTSP|RTMP播放端SDK集成说明

2.1 demo说明 大牛直播SDK提供C/C#两套接口&#xff0c;对外提供32/64位debug/release库&#xff0c;C和C#接口一一对应&#xff0c;C#接口比C接口增加前缀NT_PB_&#xff1b;WIN-PlayerSDK-CPP-Demo&#xff1a;播放端SDK对应的C接口的demo&#xff1b;WIN-PlayerSDK-CSharp-…

微软为Win11用户更新了剪贴工具、计算器以及邮件和日历应用

微软今天宣布为Windows 11的几个预装应用程序推出第一次更新&#xff0c;以下应用程序的更新正在向开发渠道的Windows Insiders推出。微软正在将经典的Snipping Tool和Snip & Sketch合并为一个截屏应用程序&#xff0c;而计算器、邮件和日历都将以新的视觉风格以配合Window…

Windows平台RTMP直播推送集成简要说明

好多开发者在集成大牛直播SDK &#xff08;官方&#xff09;的Windows平台RTMP推送模块时吓一跳&#xff0c;怎么这么多接口&#xff1f;本文做个简单的拆分&#xff1a; 初始化 初始化之前&#xff0c;如需设置日志路径&#xff0c;调用NTSmartLog.NT_SL_SetPath(log_path);…

如何实现Android端获取RTSP|RTMP流转推RTMP

技术背景 最近不少开发者找到我们&#xff0c;他们在做智能家居等传统行业时&#xff0c;希望实现在Android板件拉取本地的RTSP或RTMP流&#xff0c;然后对外推送RTMP出去&#xff0c;亦或内部启个轻量级RTSP服务&#xff0c;提供个对外对接的媒介URL&#xff0c;简单来说&…

foxmail地址簿怎么添加分组 foxmail地址簿新建分组的教程

foxmail有很多联系人&#xff0c;想要合理管理联系人&#xff0c;该怎么创建分组呢?下面我们就来看看详细的教程。 1、在进行打开地址簿之后&#xff0c;进行点击选中一个文件夹&#xff0c;然后进行点击"新建组" foxmail地址簿怎么添加分组? foxmail地址簿新建分…

Android平台RTSP轻量级服务|RTMP推送摄像头或屏幕之音频接口设计

好多开发者在做Android平台录像或者RTSP轻量级服务、RTMP推送相关模块时&#xff0c;对需要设计哪些常用接口会心存疑惑&#xff0c;本文主要以大牛直播SDK&#xff08;官方&#xff09;为例&#xff0c;简单介绍下Android平台直播推送SDK所有音频相关的接口&#xff0c;感兴趣…

Win7系统更换软件图标的详细方法

Win7系统怎么更换软件图标?相信许多用户会安装很多软件或游戏&#xff0c;并且安装这些软件会在桌面上生成图标&#xff0c;但是一些用户认为某些软件图标不好&#xff0c;因此他们想替换这些图标&#xff0c;但他们不知道怎样做&#xff0c;这里小编就和大家分享Win7系统更换…

QT实现低延迟的RTSP、RTMP播放器

好多开发者在QT环境下实现RTMP或RTSP播放时&#xff0c;首先考虑到的是集成VLC&#xff0c;集成后&#xff0c;却发现VLC在延迟、断网重连、稳定性等各个方面不尽人意&#xff0c;无法满足上线环境需求。本文以调用大牛直播SDK&#xff08;官方&#xff09;的Windows平台播放端…