IP Camera and 2D Texture
Hello,
I'm using Unity 4.5 and Oculus Rift DK1. My team and I have succeeded in importing a live IP cam view into unity using this code:
The last thing we are trying to get is the Oculus Rift to look through the camera itself. But when we launch the .exe, it seems to override any settings we gave it to use the OVR. Any idea what is happening?
I'm using Unity 4.5 and Oculus Rift DK1. My team and I have succeeded in importing a live IP cam view into unity using this code:
using UnityEngine;
using System.Collections;
public class SEMTEX : MonoBehaviour {
public string uri = "http://192.168.1.101/snapshot.cgi";
public string username = "admin";
public string password = "admin";
public Texture2D cam;
public void Start() {
cam=new Texture2D(1, 1, TextureFormat.RGB24, true);
StartCoroutine(Fetch());
}
public IEnumerator Fetch() {
while(true) {
Debug.Log("fetching... "+Time.realtimeSinceStartup);
WWWForm form = new WWWForm();
form.AddField("dummy", "field"); // required by WWWForm
WWW www = new WWW(uri, form.data, new System.Collections.Generic.Dictionary<string,string>() { // using www.headers is depreciated by some odd reason
{"Authorization", "Basic " + System.Convert.ToBase64String(System.Text.Encoding.ASCII.GetBytes(username+":"+password))}
});
yield return www;
if(!string.IsNullOrEmpty(www.error))
throw new UnityException(www.error);
www.LoadImageIntoTexture(cam);
}
}
public void OnGUI() {
GUI.DrawTexture(new Rect(0,0,Screen.width,Screen.height), cam);
}
}
The last thing we are trying to get is the Oculus Rift to look through the camera itself. But when we launch the .exe, it seems to override any settings we gave it to use the OVR. Any idea what is happening?
