Skip devices with harwarde level LEGACY

This commit is contained in:
Marc Rousavy 2021-02-25 10:20:23 +01:00
parent a8424cc3e5
commit edbd850b4c
2 changed files with 10 additions and 5 deletions

View File

@ -123,14 +123,16 @@ class CameraViewModule(reactContext: ReactApplicationContext) : ReactContextBase
val imageCaptureBuilder = ImageCapture.Builder() val imageCaptureBuilder = ImageCapture.Builder()
val characteristics = manager.getCameraCharacteristics(id) val characteristics = manager.getCameraCharacteristics(id)
val capabilities = characteristics.get(CameraCharacteristics.REQUEST_AVAILABLE_CAPABILITIES)!! val hardwareLevel = characteristics.get(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL)!!
// Check if the device is actually a "basic camera" (i.e. filter out depth-only sensors) // Filters out cameras that are LEGACY hardware level. Those don't support Preview + Photo Capture + Video Capture at the same time.
if (!capabilities.contains(CameraCharacteristics.REQUEST_AVAILABLE_CAPABILITIES_BACKWARD_COMPATIBLE)) { if (hardwareLevel == CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY) {
Log.d(REACT_CLASS, "Skipping Camera #${id} because it does not support backward compatible capabilities..") Log.i(REACT_CLASS, "Skipping Camera #${id} because it does not meet the minimum requirements for react-native-vision-camera. " +
"See the tables at https://developer.android.com/reference/android/hardware/camera2/CameraDevice#regular-capture for more information.")
return@loop return@loop
} }
val capabilities = characteristics.get(CameraCharacteristics.REQUEST_AVAILABLE_CAPABILITIES)!!
val isMultiCam = Build.VERSION.SDK_INT >= Build.VERSION_CODES.P && val isMultiCam = Build.VERSION.SDK_INT >= Build.VERSION_CODES.P &&
capabilities.contains(CameraCharacteristics.REQUEST_AVAILABLE_CAPABILITIES_LOGICAL_MULTI_CAMERA) capabilities.contains(CameraCharacteristics.REQUEST_AVAILABLE_CAPABILITIES_LOGICAL_MULTI_CAMERA)
val deviceTypes = characteristics.getDeviceTypes() val deviceTypes = characteristics.getDeviceTypes()

View File

@ -18,10 +18,13 @@ Before opening an issue, make sure you try the following:
3. Check your Swift version. react-native-vision-camera requires a minimum Swift version of **5.2**. 3. Check your Swift version. react-native-vision-camera requires a minimum Swift version of **5.2**.
4. Make sure you have created a Swift bridging header in your project. 4. Make sure you have created a Swift bridging header in your project.
1. Open your project with Xcode (`Example.xcworkspace`) 1. Open your project with Xcode (`Example.xcworkspace`)
2. In the menu-bar, press **File** > **New** > **File** (<kbd></kbd><kbd>N</kbd>) 2. In the menu-bar, press **File** > **New** > **File** (<kbd></kbd> + <kbd>N</kbd>)
4. Use whatever name you prefer, e.g. `File.swift`, and press **Create** 4. Use whatever name you prefer, e.g. `File.swift`, and press **Create**
5. Press **Create Bridging Header** when promted. 5. Press **Create Bridging Header** when promted.
5. If you're experiencing weird behaviour, check the logs in Xcode to find out more.
## Android ## Android
1. Since the Android implementation uses the not-yet fully stable **CameraX** API, make sure you've browsed the [CameraX issue tracker](https://issuetracker.google.com/issues?q=componentid:618491%20status:open) to find out if your issue is a limitation by the **CameraX** library even I cannot get around. 1. Since the Android implementation uses the not-yet fully stable **CameraX** API, make sure you've browsed the [CameraX issue tracker](https://issuetracker.google.com/issues?q=componentid:618491%20status:open) to find out if your issue is a limitation by the **CameraX** library even I cannot get around.
2. If you're experiencing weird behaviour, check the logs in Android Studio/Logcat (<kbd></kbd> + <kbd>6</kbd>) to find out more.
3. If a camera device is not being returned by `getAvailableCameraDevices()`, make sure it meets the minimum requirements - that is minum supported harwdware level of `LIMITED` and above. See [this section in the Android docs](https://developer.android.com/reference/android/hardware/camera2/CameraDevice) for more information.