private void onCapture(ImageDeviceArgs e) { EventHandler<ImageDeviceArgs> imageCaptured = ImageCaptured; if (imageCaptured != null) { imageCaptured(this, e); } }
/// <summary> /// Draws targets to the image and displays it to the screen. /// if there are no targets it simply displays the image. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void updatIimage(object sender, ImageDeviceArgs e) { lock (e.Frame) { if (targets != null) { Image<Bgr, byte> tmp = new Image<Bgr, byte>(new Bitmap((Image)e.Frame.Clone())); foreach (Target t in targets) { if (t.IsFriend) { tmp.Draw(new Cross2DF(t.Point, 15, 15), new Bgr(Color.Blue), 5); } else { tmp.Draw(new Cross2DF(t.Point, 15, 15), new Bgr(Color.Orange), 5); } } displayImage.Image = tmp.Copy().ToBitmap(); } else { displayImage.Image = (Image)e.Frame.Clone(); } } }
private void captureLoop() { img = capture.QueryFrame().Copy().ToBitmap(); //so img isn'y null for the lock ImageDeviceArgs e; while (true) { lock (img) { img = capture.QueryFrame().Copy().ToBitmap(); e = new ImageDeviceArgs(img); } onCapture(e); } }