Search Unity

[Solved] WebCamTexture.Play() stops SteamVR tracking

Discussion in 'AR/VR (XR) Discussion' started by BorisTI, Jan 16, 2017.

  1. BorisTI

    BorisTI

    Joined:
    Apr 21, 2012
    Posts:
    19
    Hello,

    Whenever I call WebCamTexture.Play(), my headset stops tracking.

    I have a simple scene, all it contains is the camera rig, a ground plane, and a plane intended to be textured with the front facing camera. I have the following attached to the second plane:

    Code (CSharp):
    1.     void Start () {
    2.        WebCamTexture webCamTexture = new WebCamTexture();
    3.  
    4.        MeshRenderer mr = this.GetComponent<MeshRenderer>();
    5.  
    6.        mr.material.mainTexture = webCamTexture;
    7.  
    8.        webCamTexture.Play();
    9.     }
    When it executes "webCamTexture.Play();" the headset and controllers stop tracking, and SteamVR goes to "Not Ready" status. To regain tracking, I have to reboot the headset.

    Any thoughts?
     
  2. MathiasCiarlo

    MathiasCiarlo

    Joined:
    Oct 19, 2016
    Posts:
    9
    I just did this, and figured that you can't both use SteamVR_TrackedCamera or something at the same time, as the usb device's camera feed is occupied. If you do not use any of the SteamVR examples. If you are not using that code, I have had a similar issue, solved it by unplugging the usb to the headset out of the lighthouse box and then replug it before running. The webCamTexture seems kind of unstable. If you look at SteamVR_TrackedCamera in the Samples folder, this is a much better way to use the front facing camera.
     
  3. BorisTI

    BorisTI

    Joined:
    Apr 21, 2012
    Posts:
    19
    I tried loading the SteamVR_TestTrackedCamera scene and I'm not seeing the camera feed outputting to the material that was created for it, it just remains white. Is SteamVR_TestTrackedCamera working for you?

     
  4. MathiasCiarlo

    MathiasCiarlo

    Joined:
    Oct 19, 2016
    Posts:
    9
    Yes, the SteamVR_TestTrackedCamera scene works for me. Try another usb 3.0 port, that's my last suggestion
     
    BorisTI likes this.
  5. BorisTI

    BorisTI

    Joined:
    Apr 21, 2012
    Posts:
    19
    Thank you. Apparently the issue was indeed the port I was using.

    The HMD would stop tracking if the camera was streaming 60hz, but worked if I dropped it to 30hz in the SteamVR settings, so I assume WebCamTexture was attempting to stream at 60hz. SteamVR_TestTrackedCamera wouldn't stream the camera because I didn't have the camera enabled on SteamVR explicitly, and when I tried to test the camera with SteamVR, it would also lose tracking while streaming the camera at 60hz. On the current port, dropping the camera stream to 30hz allowed both tracking and camera streaming, and switching ports allowed for 60hz streaming and tracking.