Hello community,
I have a webpage which shows MJPG-streamer images from a Raspberry Pi webcam which I want to display inside Unity using a texture. Here’s the “/stream” page html code:
<p id="streamwrap" class="xform-p">
<img id="streamimage" class="xform" src="http://192.168.1.2:8080/?action=stream">
</p>
I can’t use standard ‘get’ WWW.texture with this because a stream of images can’t be pointed to with a “/stream/image.jpg”. I can only access the stream via a “/stream” or “/?action=stream” URI. I have tried the code below, but no luck:
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class GET_Stream : MonoBehaviour {
public string url = "http://192.168.1.2:8080/?action=stream";
IEnumerator Start() {
WWW www = new WWW(url);
yield return www;
RawImage renderer = GetComponent<RawImage>();
renderer.texture = www.texture;
}
void Update () {
Start ();
}
}
Another alternative to WWW I know is HttpWebRequest. It may contain something I could use (I’m currently researching this), because when I get the stream grab to work, I’ll make it work over SSL (using a similar code to this).
Then I began looking for Unity HTML viewers, but the best one I found was for Unity 3.4 - Awesomium. I did try to install it on Unity 5.4 64-bit (where I got DllNotFoundException) and 32-bit (where I got EntryPointNotFoundException). (I’m surprised that App Inventor has a WebViewer, but Unity doesn’t). I’m looking for free options. Any suggestions?
Awesomium error on Unity 5 32-bit:
EntryPointNotFoundException: awe_string_create_from_utf16
AwesomiumMono.StringHelper..ctor (System.String val)
AwesomiumMono.WebCore.Start ()
AwesomiumMono.WebCore.Initialize (AwesomiumMono.WebCoreConfig config, Boolean start)
WebTexture.Start () (at Assets/WebTexture.cs:32)
Thank you.