UVC4UnityAndroid icon indicating copy to clipboard operation
UVC4UnityAndroid copied to clipboard

Black Screen Issue when Displaying Multiple UVC Cameras Simultaneously

Open kchanyou opened this issue 1 year ago • 2 comments

Hello. I'm experiencing difficulties getting two UVC cameras to display simultaneously in Unity. Currently, one camera displays correctly, while the other shows only a black screen( = If I turn off one of the two cameras, the other one displays normally )

Problem:

  • I'm trying to connect two UVC cameras in Unity and display each on separate RawImage components.
  • The first camera displays correctly, but the second camera only shows a black screen.
  • The CameraInfo objects are created correctly for both cameras, and the previewTexture property has the correct size and format.
  • Adding delays to allow enough time for the texture to be ready has not resolved the issue.

Question

  1. Does the native plugin support multiple UVC cameras simultaneously?
    (It seems like the ReadMe says it's supported.)
  2. Are there any additional settings or code required to display multiple UVC cameras at the same time?

Environment: Unity version: 2021.3.25f1 Plugin version: r0.2.0 Android version: 13

Logcat

3210 3351 Info Unity [QUVC]OnDeviceChanged#CameraID : 477407871 3210 3351 Info Unity [QUVC]OnDeviceChanged#device: Serenegiant.UVC.UVCDevice(id=477407871,vid=3141,pid=25446,name=/dev/bus/usb/002/003,deviceClass=239,deviceSubClass=2,deviceProtocol=1) 3210 3351 Info Unity [QUVC]HandleOnAttachEvent#device : Serenegiant.UVC.UVCDevice(id=477407871,vid=3141,pid=25446,name=/dev/bus/usb/002/003,deviceClass=239,deviceSubClass=2,deviceProtocol=1) 3210 3351 Info Unity [QUVC] OnDeviceChanged: Mapping camera ID 477407871 to UVCDrawer 3210 3351 Info Unity [QUVC] OnDeviceChanged: attachedDevices.Count : 0 3210 3351 Info Unity [QUVC] PERMISSION IN 3210 3351 Info Unity [QUVC] Camera permission already granted for device: 477407871 3210 3351 Info Unity ---------[QUVC]StartPreview 3210 3240 Info Unity [QUVC] previewTexture: (UnityEngine.Texture2D), width: 1280, height: 720, format: RGBA32 3210 3240 Info Unity [QUVC] StartPreview#nativeTexPtr : 29 3210 3240 Info Unity [QUVC] StartPreview#deviceId : 477407871 3210 3240 Info Unity --------[QUVC] OnPreviewTextureReady: device: 477407871 3210 3240 Info Unity [QUVC]device: 477407871 3210 3240 Info Unity --------[QUVC]HandleOnStartPreviewEvent#info : Serenegiant.UVC.UVCManager+CameraInfo(1280x720,id=477407871,activeId=477407871,IsPreviewing=True) 3210 3240 Info Unity [QUVC]info.deviceSerenegiant.UVC.UVCDevice(id=477407871,vid=3141,pid=25446,name=/dev/bus/usb/002/003,deviceClass=239,deviceSubClass=2,deviceProtocol=1) 3210 3240 Info Unity [QUVC]previewTexture (UnityEngine.Texture2D) 3210 3240 Info Unity [QUVC] OnUVCStartEvent: Device ID = 477407871, Texture = (UnityEngine.Texture2D) 3210 3240 Info Unity [QUVC] Drawing on RawImage for Camera ID: 477407871, RawImage Name: RawImage_L 3210 3351 Info Unity [QUVC]OnDeviceChanged#CameraID : -215317999 3210 3351 Info Unity [QUVC]OnDeviceChanged#device: Serenegiant.UVC.UVCDevice(id=-215317999,vid=3141,pid=25446,name=/dev/bus/usb/002/006,deviceClass=239,deviceSubClass=2,deviceProtocol=1) 3210 3351 Info Unity [QUVC]HandleOnAttachEvent#device : Serenegiant.UVC.UVCDevice(id=-215317999,vid=3141,pid=25446,name=/dev/bus/usb/002/006,deviceClass=239,deviceSubClass=2,deviceProtocol=1) 3210 3351 Info Unity [QUVC] OnDeviceChanged: Mapping camera ID -215317999 to UVCDrawer 3210 3351 Info Unity [QUVC] OnDeviceChanged: attachedDevices.Count : 1 3210 3351 Info Unity [QUVC] PERMISSION IN 3210 3351 Info Unity [QUVC] Camera permission already granted for device: -215317999 3210 3351 Info Unity ---------[QUVC]StartPreview 3210 3240 Info Unity [QUVC] previewTexture: (UnityEngine.Texture2D), width: 1280, height: 720, format: RGBA32 3210 3240 Info Unity [QUVC] StartPreview#nativeTexPtr : 30 3210 3240 Info Unity [QUVC] StartPreview#deviceId : -215317999 3210 3240 Info Unity --------[QUVC] OnPreviewTextureReady: device: -215317999 3210 3240 Info Unity [QUVC]device: -215317999 3210 3240 Info Unity --------[QUVC]HandleOnStartPreviewEvent#info : Serenegiant.UVC.UVCManager+CameraInfo(1280x720,id=-215317999,activeId=-215317999,IsPreviewing=True) 3210 3240 Info Unity [QUVC]info.deviceSerenegiant.UVC.UVCDevice(id=-215317999,vid=3141,pid=25446,name=/dev/bus/usb/002/006,deviceClass=239,deviceSubClass=2,deviceProtocol=1) 3210 3240 Info Unity [QUVC]previewTexture (UnityEngine.Texture2D) 3210 3240 Info Unity [QUVC] OnUVCStartEvent: Device ID = -215317999, Texture = (UnityEngine.Texture2D) 3210 3240 Info Unity [QUVC] Drawing on RawImage for Camera ID: -215317999, RawImage Name: RawImage_R 3210 3240 Info Unity [QUVC]Connected Camera IDs: 3210 3240 Info Unity [QUVC] - Camera ID: 477407871, Device Name: /dev/bus/usb/002/003 3210 3240 Info Unity [QUVC] - Camera ID: -215317999, Device Name: /dev/bus/usb/002/006 3210 3240 Info Unity [QUVC]Connected Camera IDs: 3210 3240 Info Unity [QUVC] - Camera ID: 477407871, Device Name: /dev/bus/usb/002/003 3210 3240 Info Unity [QUVC] - Camera ID: -215317999, Device Name: /dev/bus/usb/002/006

I would appreciate any help you can provide. Thank you

kchanyou avatar Sep 04 '24 08:09 kchanyou

I have a similar issue. Have you had any progress? I couldn't really figure out how to start and stop individual cameras so I was taking the previews and setting them up to different raw images depending on the device id but only one of them seems to work. The other raw image just disappear - i assume becomes transparent.

mmmmmapplepie avatar Feb 20 '25 08:02 mmmmmapplepie

@mmmmmapplepie It has been so long since I stopped working on it that I don't remember the details exactly. However, at the time, I believed it was caused by a bottleneck in the rendering process. Therefore, it seems that introducing a delay in the process of loading textures in Unity allowed it to function normally.

kchanyou avatar Mar 10 '25 08:03 kchanyou