- Home /
Can't open front camera while using ARCore with the back camera on some devices
I'm developing an Open Source App to play around with ARCore. In it I use the following code to display video being capture from the front facing camera on a plane placed in the environment of the user in AR.
public class MirrorController : MonoBehaviour
{
private WebCamTexture webCamTexture;
public void Play()
{
if (webCamTexture == null)
{
WebCamDevice[] devices = WebCamTexture.devices;
foreach (WebCamDevice device in devices)
{
if (device.isFrontFacing)
{
webCamTexture = new WebCamTexture(device.name);
GetComponent<Renderer>().material.mainTexture = webCamTexture;
webCamTexture.Play();
break;
}
}
}
}
}
This worked fine when I tested it on a Pixel 2, but when I tried the app on a Samsung Galaxy S8, I got the following warning in the log:
W/CameraBase: An error occurred while connecting to camera 1: Status(-8): '8: connectHelper:1647: Too many cameras already open, cannot open camera "1"'
It seems to be raised when calling webCamTexture.Play()
.
I couldn't find anything about this error on the internet. I find it especially weird, because the S8's camera app has a feature where you can take a picture using both cameras at the same time.
Does anyone know how this could be resolved?