Access external USB camera in Android application

1.6k views Asked by At

Is there any official android library to access external USB camera in android?

I have gone through all the android/camera-samples. The issue is external USB camera can not be detected/listed in the below code.

val cameraIds2 = cameraManager.cameraIdList
cameraIds2.forEach {
    println("cameraId =  $it")
}

I also checked the other libraries like saki4510t/UVCCamera and jiangdongguo/AndroidUSBCamera. But they do not work or outdated. This S.O. question is also outdated.

Android official document External USB Cameras does not provide proper way to implement it in Kotlin or Java.

I can't find the latest document related this.

1

There are 1 answers

2
Kimberly McCarty On

Android devices' kernel and system image need to support an external usb camera for camera2 to find them. See this documentation from the Android AOSP for context. Please note this is for building an Android system image, not for an application.

To check if your specific device has that module, you can use ADB to look for FEATURE_CAMERA_EXTERNAL. Run adb shell pm list features | grep "android.hardware.camera.external". If it finds a line, the issue is something else, but I suspect it won't find anything.

One option would be to use the camera2 module on devices that support it (you can use the PackageManager class to check for FEATURE_CAMERA_EXTERNAL) and fallback to a userspace implementation of UVC/webcam support. Unfortunately, I was going to recommend jiangdongguo/AndroidUSBCamera, but it seems it didn't work for you. Maybe the best approach would be to file an issue on that repo's github page?