如何在Android中使用camera2 判断相机是否可用

发布时间:2020-11-26 17:23:39 作者:Leah
来源:亿速云 阅读:838

如何在Android中使用camera2 判断相机是否可用?针对这个问题,这篇文章详细介绍了相对应的分析和解答,希望可以帮助更多想解决这个问题的小伙伴找到更简单易行的方法。

首先获取到设备等级:

Float hardwareLevel = mCameraCharacteristics.get(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL);

LEGACY < LIMITED < FULL < LEVEL_3. 越靠右边权限越大

•INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY = 2
•INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED = 0
•INFO_SUPPORTED_HARDWARE_LEVEL_FULL = 1
•INFO_SUPPORTED_HARDWARE_LEVEL_3 = 3

在相应的等级下面会有各自支持的功能,LEGACY为最低权限

在LIMITED中

Additional capabilities may optionally be supported by a LIMITED-level device, and can be checked for in *android.request.availableCapabilities*.

android.request.availableCapabilities

介绍:List of capabilities that this camera device advertises as fully supporting.

int[] ints = mCameraCharacteristics.get(CameraCharacteristics.REQUEST_AVAILABLE_CAPABILITIES);

Possible values:

•BACKWARD_COMPATIBLE
•MANUAL_SENSOR
•MANUAL_POST_PROCESSING
•RAW
•PRIVATE_REPROCESSING
•READ_SENSOR_SETTINGS
•BURST_CAPTURE
•YUV_REPROCESSING
•DEPTH_OUTPUT
•CONSTRAINED_HIGH_SPEED_VIDEO

For example manual_semsor:REQUEST_AVAILABLE_CAPABILITIES_MANUAL_SENSOR 
The camera device can be manually controlled (3A algorithms such as auto-exposure, and auto-focus can be bypassed). The camera device supports basic manual control of the sensor image acquisition related stages. This means the following controls are guaranteed to be supported: 
Manual frame duration control 
- android.sensor.frameDuration 
- android.sensor.info.maxFrameDuration 
Manual exposure control 
- android.sensor.exposureTime 
- android.sensor.info.exposureTimeRange 
Manual sensitivity control 
- android.sensor.sensitivity 
- android.sensor.info.sensitivityRange 
Manual lens control (if the lens is adjustable) 
- android.lens.* 
Manual flash control (if a flash unit is present) 
- android.flash.* 
Manual black level locking 
- android.blackLevel.lock 
Auto exposure lock 
- android.control.aeLock

这些值对应的特征值举例:

final String name3 = CaptureRequest.SENSOR_FRAME_DURATION.getName();
name3 -》android.sensor.frameDuration

列出这个的意思是,如果想知道该设备是否支持此功能,可以通过getName()获取其包名,然后在

mCameraCharacteristics.getAvailableCaptureRequestKeys();生成的队列中寻找。

如果有匹配则是可控;

CaptureRequest.LENS_FOCUS_DISTANCE;调节焦距
CaptureRequest.CONTROL_AF_MODE;自动对焦模式
CaptureRequest.SENSOR_SENSITIVITY 调节iso
CaptureRequest.CONTROL_AE_MODE 自动曝光模式

关于如何在Android中使用camera2 判断相机是否可用问题的解答就分享到这里了,希望以上内容可以对大家有一定的帮助,如果你还有很多疑惑没有解开,可以关注亿速云行业资讯频道了解更多相关知识。

推荐阅读:
  1. Android Camera2 预览功能实现
  2. android 6.0 系统获取权限

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

android camera2 roi

上一篇:android应用中如何判断设备是否有相机

下一篇:怎么在android中利用recyclerview制作一个聊天界面

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》