- Home /
Webcam with no name
I'm currently experiencing an issue attempting to support multiple webcams.
When I call WebCamTexture.devices
I get a list of 2 devices (one for each webcam I have plugged in) but one of the names is blank (as in, string.Empty).
This causes an issue because when I create a new WebCamTexture with a blank name it doesn't seem to grab the webcam that Unity thinks has no name, and instead fails (it might be attempting to grab the other webcam which is already in use).
This is not a problem if I only have one webcam plugged in (even if it's the one with the blank name) in this case, creating the WebCamTexture with a blank name is successful and starts recording from the camera.
Has anyone else encountered this? I'm not sure why Unity thinks the camera has no name, Windows/Device Manager think it has one!
3 years later, I have the same issue. Anyone find a workaround?
Answer by Aeregon · Oct 02, 2017 at 07:26 AM
@Pyroka I have the same problem. I believe this happens when the full name of the device has a special character in it. The device page on windows only shows the short name. Example: devices show Kinect. full name is Kinect Microsoft(r).
the (r) is actually the copyright symbol which is unknown to the compiler and thuss shows an empty string.
The problem is, that you cannot replace the symbols to somethign that is readable, because when you do that you first have to load the name in a string, which will be empty. I've had to problem for a long time and I try to work around it. The best thing is to just use a webcam that has a valid name.
Trust webcams dont have special symbols and are usable by device name. So you might want to avoid every microsoft webcam at all costs.
Please let me know if you found another way around this problem. I will ofcourse also update you when I found a better solution.
@Pyroka I found that if you request the device names, and wait a second they are not empty. IEnumerator Init() { yield return new WaitForSeconds(1f);
WebCamDevice[] devices = WebCamTexture.devices;
yield return new WaitForSeconds(1f);
if (devices.Length > 0)
{
foreach (WebCamDevice wcd in devices)
{
Debug.Log(wcd.name);
}
}
}
I am not sure about the special character though.
Answer by kartikeya · Mar 24, 2018 at 11:54 AM
I tried that with wait for a Second, but still no luck to get names, Top of that only front cam is accessible (which has name "1"). Rear cam has no name and doesn't even accessible.
Do you have any other solution?
Answer by SimRuJ · Jul 23, 2018 at 10:11 AM
@Pyroka I'm experiencing the same problem. The webcam is a new Microsoft LifeCam HD-3000 I bought just for Unity (didn't know about this problem :/) and it's the only camera connected to the PC. The "camera" app in Win 10 shows the image just fine but Unity won't get a name.
I can't use the above code (using C# 6), so I just created a button that sets the "devices" array and then check the name in "Update" ("if(devices!=null)") but there's no name, even after a couple of seconds.
Has anyone found a solution for this yet?
Your answer
Follow this Question
Related Questions
Could not connect pins - RenderStream() UnityEngine.WebCamTexture:Play() 0 Answers
Show a WebCamTexture with alpha 1 Answer
WebcamTexture not refreshing 0 Answers
Web Cam Texture on UI Panel 0 Answers
how to track object motion with webcam 0 Answers