0

enter image description hereI am attempting to grab video feed from an mjpeg stream server. the client is in c#, Unity3D. Whenever I run it, I get a strange image of black and gold bands.

I know this is not a problem with the server because the Processing library IPCapture can get the image just fine.enter image description here

I attach the below c# code to a plane in Unity3D:

using UnityEngine; using System.Collections;

public class IPCapture : MonoBehaviour {
    string url = "http://192.168.0.106:8081/video.mjpg?q=30&fps=33&id=0.7494465354830027&r=1382760993848";
    // Use this for initialization
    void Start () {
        renderer.material.mainTexture = new Texture2D(4, 4, TextureFormat.DXT1, false);
        WWW www = new WWW(url);
        StartCoroutine(SetTextures(www));
    }

    public IEnumerator SetTextures(WWW www){
        yield return www;
        renderer.material.mainTexture = www.texture as Texture2D;
    }
    // Update is called once per frame
    void Update () {

    }
}
ThaHypnotoad
  • 165
  • 2
  • 5
  • 12
  • Did you try saving the byte data to a file and see what it looks like? And you might want to try a LoadImageIntoTexture call. http://docs.unity3d.com/Documentation/ScriptReference/WWW.LoadImageIntoTexture.html – Bart Oct 26 '13 at 19:44
  • The example code gives me an error telling me that the variable www already exists at the line that says yield www; – ThaHypnotoad Oct 26 '13 at 21:07

0 Answers0