First off, I already can integrate it with unity (2019.1.7), the problem is the image stream is stuttering like what you can see from the video attachment.
https://i.stack.imgur.com/FNI2j.gif
Here's the script I'm using to get the stream
- Code: Select all
private void OnEnable()
{
transform.eulerAngles = initRot;
if (mjpegStream != null)
mjpegStream.Start();
}
// Use this for initialization
void Start () {
camTexture = new Texture2D(2 , 2);
// create MJPEG video source
mjpegStream = new MJPEGStream(camIPAddress);
// set event handlers
mjpegStream.NewFrame += new NewFrameEventHandler(StreamImage);
// start the video source
mjpegStream.Start();
}
// Update is called once per frame
void Update()
{
if (dataGet)
{
camTexture.LoadImage(jpegstream.ToArray());
if(screenDisplay.texture != camTexture)
screenDisplay.texture = camTexture;
counter = 0;
dataGet = false;
}
}
void StreamImage(object sender, NewFrameEventArgs eventArgs)
{
jpegstream = eventArgs.Frame;
dataGet = true;
}
I only change the bitmap to memory stream in the MJPEGStream and give a param dataGet for workaround for the thread
The question is, does anyone know how to make the image to not stutter?
Is it a problem from the stream I'm getting? It works fine if I access normally from web browser
Please note that this happen with different ipcam I got from online too