public Snapshot(StereoImage stereoImage, EyeWeb eyeWeb, int centerX, int centerY) { EyeWeb = eyeWeb; int resolution = eyeWeb.Resolution; int halfResolution = resolution / 2; int left = centerX - halfResolution; int top = centerY - halfResolution; Parallel.For(0, 3, i => { switch (i) { case 0: Left = eyeWeb.GetSnapshot(stereoImage.Left.GetIntensities(left, top, resolution, resolution), true, false); break; case 1: Mono = eyeWeb.GetSnapshot(stereoImage.Mono.GetIntensities(left, top, resolution, resolution), false, false); break; case 2: Right = eyeWeb.GetSnapshot(stereoImage.Right.GetIntensities(left, top, resolution, resolution), false, true); break; } }); size = eyeWeb.shapes.Count; }
private void SnapshotCapturerWork(object sender, DoWorkEventArgs e) { StereoImage previousStereoImage = null; EyeWeb previousEyeWeb = null; Point previousPoint = new Point(0, 0); while (!Stop) { bool changed = false; //input EyeWeb eyeWeb = ThreadControlCenter.Main.ActiveEyeWeb; Point point = ThreadControlCenter.Main.LeftPoint; StereoImage stereoImage = ThreadControlCenter.Main.ActiveStereoImage; //output Snapshot snapshot = ThreadControlCenter.Main.ActiveSnapshot; if (eyeWeb == null || stereoImage == null) { continue; } if (eyeWeb != previousEyeWeb || point != previousPoint || stereoImage != previousStereoImage) { changed = true; snapshot = new Snapshot(stereoImage, eyeWeb, point.X, point.Y); } previousStereoImage = stereoImage; previousEyeWeb = eyeWeb; previousPoint = point; if (changed) { ThreadControlCenter.Main.ActiveSnapshot = snapshot; } else { System.Threading.Thread.Sleep(1); } } }
private void ImagePainterWork(object sender, DoWorkEventArgs e) { Snapshot previousSnapshot = null; EyeWeb previousEyeWeb = null; Image previousImage = null; Point previousPoint = new Point(0, 0); while (!Stop) { bool changed = false; //input Snapshot snapshot = ThreadControlCenter.Main.ActiveSnapshot; Image originalImage = ThreadControlCenter.Main.OriginalImage; Point point = ThreadControlCenter.Main.LeftPoint; EyeWeb eyeWeb = ThreadControlCenter.Main.ActiveEyeWeb; //output Bitmap editedOriginal = ThreadControlCenter.Main.EditedOriginal; Bitmap left = ThreadControlCenter.Main.OutputBitmapLeft; Bitmap right = ThreadControlCenter.Main.OutputBitmapRight; Bitmap mono = ThreadControlCenter.Main.OutputBitmapMono; if (eyeWeb == null) { System.Threading.Thread.Sleep(1); continue; } Parallel.For(0, 4, i => { switch (i) { case 0: { if (point != previousPoint || eyeWeb != previousEyeWeb || originalImage != previousImage) { changed = true; if (DrawOriginal) { editedOriginal = eyeWeb.DrawOn(originalImage, point); } else { editedOriginal = eyeWeb.DrawOn(originalImage, point, true); } } } break; case 1: if (snapshot != previousSnapshot) { changed = true; left = eyeWeb.DrawSnapshot(snapshot.Left); } break; case 2: if (snapshot != previousSnapshot) { changed = true; right = eyeWeb.DrawSnapshot(snapshot.Right); } break; case 3: if (snapshot != previousSnapshot) { changed = true; mono = eyeWeb.DrawSnapshot(snapshot.Mono); } break; } }); if (changed) { ThreadControlCenter.Main.OutputBitmapLeft = left; ThreadControlCenter.Main.OutputBitmapMono = mono; ThreadControlCenter.Main.OutputBitmapRight = right; ThreadControlCenter.Main.EditedOriginal = editedOriginal; previousSnapshot = snapshot; previousImage = originalImage; previousEyeWeb = eyeWeb; previousPoint = point; } else { System.Threading.Thread.Sleep(1); } } }