private void stream()
{
image = new VisionImage();
try
{
imaqdxSession.ConfigureGrab();
}
catch (ObjectDisposedException e)
{
MessageBox.Show(e.Message);
return;
}
for (; ; )
{
lock (streamStopLock)
{
try
{
imaqdxSession.Grab(image, true);
if (analyse)
{
PixelValue2D pval = image.ImageToArray();
byte[,] u8array = Getthearray.convertToU8(pval.Rgb32);
max = Getthearray.Findthemaximum(u8array);
imageWindow.WriteToConsole(max.ToString("F6"));
}
}
catch (InvalidOperationException e)
{
MessageBox.Show("Something bad happened. Stopping the image stream.\n" + e.Message);
state = CameraState.FREE;
return;
}
try
{
if (windowShowing)
{
imageWindow.AttachToViewer(image);
}
}
catch (InvalidOperationException e)
{
MessageBox.Show("I have a leftover image without anywhere to display it. Dumping...\n\n" + e.Message);
imaqdxSession.Acquisition.Stop();
state = CameraState.FREE;
return;
}
if (state != CameraState.STREAMING)
{
imaqdxSession.Acquisition.Stop();
state = CameraState.FREE;
return;
}
}
}
}