HowTo: Unity and THETA V Live Streaming - Mac OS X

The THETA V streams a 4K equirectangular video over USB. It appears to Unity as a normal webcam called RICOH THETA V. The video is already stitched. You just need to attach a WebCamTexture to a 3D sphere and you’ll have a simple VR application.

To get started with live streaming an equirectangular video from the THETA V, first create a new project in Unity.

Add A Sphere

Scale the sphere to a reasonable size such as 8 8 8.

You’ll have a simple scene like this. It just has a sphere in it.

Add Script

In the Inspector panel, Add Component → New Script → C Sharp.

Call the script testScriptBasic.

In MonoDevelop-Unity, paste this script in.

using UnityEngine;
using System.Collections;

public class testScriptBasic : MonoBehaviour {

	void Start () {
		WebCamDevice[] devices = WebCamTexture.devices;
		Debug.Log("Number of web cams connected: " + devices.Length);
		Renderer rend = this.GetComponentInChildren<Renderer>();

		WebCamTexture mycam = new WebCamTexture();
		string camName = devices[0].name;
		Debug.Log("The webcam name is " + camName);
		mycam.deviceName = camName;
		rend.material.mainTexture = mycam;

		mycam.Play();
	}    	
}

Identify RICOH THETA V webcam

Press Play.

Verify that you are getting the webcam name as RICOH THETA V. If you are getting another cam name, adjust the devices[0] line to devices[1]. If that doesn’t work, try devices[2]. You can also just loop through the array and print out all the devices to find the correct webcam.

Change Y Rotation

Press your mouse over the Y in the Transform → Rotation for the Sphere. Move your mouse left or right. The THETA V view will rotate.

Change Camera View to Inside of Sphere

You can add different assets inside of your VR world. This tutorial shows you how to add a house plant to your VR world and navigate around the world.

Showing inside of sphere view on Mac OS X

Sphere made in blender with flip normals. (Download)

2 Likes

Any chance you’ll upload this unity project to a github? Finally got my hands on the V and you’ve already saved me some time :slight_smile:

2 Likes

Megan, sorry for the delay in response. I’m going to try and put this on GitHub, but I’m having these challenges and want to resolve a few of them before I put up a skeleton example:

  • I’m still learning Unity and need to figure out how to export projects
  • Last time I tried Windows 10, I was not able to get the stream inside of Windows 10 on Unity. This was with Windows 10 1703 build, not the current 1709 Fall Creators Build. It’s possible that it will just work with the new version of Windows. I have not tried.
  • I was not able to get the flip normals sphere built with Blender on Mac. It would come out distorted. I used Blender on a Windows 10 PC to create the ico sphere with flip normals, I then moved the sphere to the Mac.
  • I’m not sure if the resolution inside of Unity is 4K. It looks lower than 4K to me, but I have not confirmed this. Would be nice to improve the resolution.

This article was quickly created as support for the MIT Reality Virtuality Hackathon several weeks ago. We’re still collecting information on using THETA V live streaming with Unity. If you make any progress, please share it. :slight_smile:

Thanks!

I tried with Windows 10 1709, and it did not work. So I guess the problem is not the version :no_mouth:

N

Thanks. I tried and failed with Windows 10 1709 too. Are you getting the same error message I am?

Could not connect pins - RenderStream()

Hello, yes the same one. Do you know what is the problem?

N

Thanks for the confirmation of the error message. I do not know how to solve the problem.

I saw this:
https://answers.unity.com/questions/1350852/could-not-connect-pins-renderstream-unityengineweb.html

The guy, BytesCrafter thinks it might be related to a conflict with another camera, either physical or a virtual device.

I have one diagnoses for this because it work like a charm when I was in Unity 5 not 5.6. I think something in the Device PID, I need to force any connection to the camera device which is not unity to terminate and connect unity to that camera device. I forgot to shutdown something that is using that PID or hardware device.

This guy, Zapan15 got a webcam (not the THETA V) to work by forcing the camera to play even when there is an error. It only works when compiled, not inside of the editor.

 try
 {
        wct.Play();
 }
 catch ( Exception e )
 {
        wct.Play();
 }

I’d like to personally try the following :

  • try to force the webcamtexture to play even when there is an error. Then, test it compiled for Windows 10 (not in the Unity editor)
  • if that doesn’t work, then try an old version of Unity, like 5.0.

Hi Guys,

I’m new to the forum but couldn’t help but notice that you’re doing the same sort of thing us my team and I. We’ve made some changes to the project form GOROman’s github repository and currently have a Ricoh Theta S rendering reliably the the sphere on window systems. We simply selected a device number and the theta s mounted as device number 1 (number 0 was our laptop’s webcam). Our code maps each of the hemispheres separately.

The camera number is changed on another scene and stored under player prefs

using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;

public class ThetaWebCamTexture : MonoBehaviour {

public int cameraNumber;
public GameObject sphere1;
public GameObject sphere2;

public WebCamTexture webcamTexture;

void Start() 
{
	WebCamDevice[] devices = WebCamTexture.devices;
    cameraNumber = PlayerPrefs.GetInt("CameraNumber");
    if (devices.Length > cameraNumber)
    {
		webcamTexture = new WebCamTexture(devices[cameraNumber].name, 1280, 720);

        sphere1.GetComponent<Renderer>().material.mainTexture = webcamTexture;
        sphere2.GetComponent<Renderer>().material.mainTexture = webcamTexture;

        webcamTexture.Play();
	}
    else
    {
		Debug.Log("no camera");
	}
}

public void BackBtn(string LoadTarget)
{
    if (webcamTexture.isPlaying)
    {
        webcamTexture.Stop();
    }
    SceneManager.LoadScene(LoadTarget);
}

public void ExitBtn(string LoadTarget)
{
    if (webcamTexture.isPlaying)
    {
        webcamTexture.Stop();
    }
    Application.Quit();
}

}

1 Like

Hello, sorry for my late response.

Thank you for these indications.

  • I just tried with Unity 5.6, it still does not work.
  • I also tried to force the webcamtexture and tested compiled, it did not work too :confused:

N

1 Like

Thanks for these test results. I’ve been trying to contact Unity to see if
they have any ideas.

1 Like