Android device (TV) does not detect external USB web cam in Unity

163 views Asked by At

We are building an Unity App to an android TV unit and attempting to access a usb webcam inside unity.

The device is able to recognise the camera and display its feed within the builtin camera app. However, when running our unity application (after it asks for camera permissions) the list of available camera devices is empty - both at startup and while the app is running.

We are using WebCamTexture.devices to access the available cameras, but this property is returning an empty list.

Running the same software on an Android phone (same target api and everything) and it all works perfectly - although naturally it detects its built in cameras as there isn't a usb port to connect a usb webcam to it.

What could be the cause of this? As far as I was aware Android TV Os was effectively the same as android, and this should work.

Testing code is equivalent to

var devices = WebCamTexture.devices;
Debug.Log( $"Length: {devices.Length}" )
foreach ( var device in devices )
{
    Debug.Log( $"Device: {device.name}" );
}

Output:

Length: 0

Specs if needed:

  • Hardware: DQ08 RK3528 Android TV
  • Target Software: Android TV Os 13 (API level 33) (afaik the same as regular android 13 in terms of compatibility)
  • Building from: Unity 2020, mono .NET standard 2.0

Android Launcher Manifest:

<!--  GENERATED BY UNITY. REMOVE THIS COMMENT TO PREVENT OVERWRITING WHEN EXPORTING AGAIN -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" package="com.unity3d.player" android:installLocation="preferExternal">
<supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:xlargeScreens="true" android:anyDensity="true"/>
<application android:extractNativeLibs="true" android:label="@string/app_name" android:icon="@mipmap/app_icon"/>
</manifest>
1

There are 1 answers

2
Alpha Reuel On

Using Unity Native Camera Plugin which is open-source, you can do exactly what you want. Use the Camera.getCameraInfo() API once you download the plugin from github mentioned earlier.