I have a question about Aforge for IPCam (remote).
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.
Here's the script I'm using to get the stream
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;
}
The question is, does anyone know how to make the image to not stutter?
Is it a problem from the stream I'm getting or from ToArray() function of MemoryStream or maybe other problem that I'm not aware of?
Please note that this happen with different ipcam I got from online too