您好,登錄后才能下訂單哦!
如何在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 判斷相機是否可用問題的解答就分享到這里了,希望以上內容可以對大家有一定的幫助,如果你還有很多疑惑沒有解開,可以關注億速云行業資訊頻道了解更多相關知識。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。