Jay
Jay

Reputation: 2946

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

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:

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>

Upvotes: 1

Views: 492

Answers (1)

Alpha Reuel
Alpha Reuel

Reputation: 145

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.

Upvotes: 1

Related Questions