private ColourTrackingPanTiltOutput ProcessColour(CameraProcessInput input) { _colourDetectorInput.Captured = input.Captured; _colourTrackingController.Settings = _colourDetectorInput.Settings; var colourOutput = _colourTrackingController.Process(_colourDetectorInput); colourOutput.CapturedImage = GetBgr(colourOutput.ThresholdImage); return(colourOutput); }
public override void ImageGrabbedHandler(object sender, EventArgs e) { if (_calibrationInProgress) { return; } using (var matCaptured = new Mat()) { CameraCapture.Retrieve(matCaptured); var statusAccumulation = new StringBuilder(); var bgrImage = matCaptured.ToImage <Bgr, byte>(); DrawReticle(bgrImage, _centre, Color.Red); if (UserReticle != null) { DrawReticle(bgrImage, UserReticle.Value, Color.Green); } var input = new CameraProcessInput(); input.SetCapturedImage = true; input.Captured = matCaptured; CameraPanTiltProcessOutput output = null; if (chkBoxColourTracking.Checked) { var result = _colourTrackingController.Process(input); output = result; if (result.IsDetected) { DrawReticle(bgrImage, result.Target, Color.Yellow); } imageBoxFiltered.Image = result.ThresholdImage; statusAccumulation.AppendFormat("{0} moment area", result.MomentArea); // WriteText(bgrImage, _captureConfig.Resolution.Height - 10, "Colour Tracking"); } if (chkBoxFaceTracker.Checked) { // WriteText(bgrImage, _captureConfig.Resolution.Height - 50, "Face Tracking"); var result = _faceTrackingController.Process(input); output = result; if (result.IsDetected) { foreach (var face in result.Faces) { bgrImage.Draw(face.Region, new Bgr(Color.Yellow), 2); } DrawReticle(bgrImage, result.Target, Color.Yellow); } statusAccumulation.AppendFormat("{0} faces detected", result.Faces.Count); } if (chkBoxMotionTracking.Checked) { // WriteText(bgrImage, _captureConfig.Resolution.Height - 75, "Motion Tracking"); var result = _motionTrackingController.Process(input); output = result; if (result.IsDetected) { foreach (var motionSection in result.MotionSections) { bgrImage.Draw(motionSection.Region, new Bgr(Color.Green)); } if (result.TargetedMotion != null) { bgrImage.Draw(result.TargetedMotion.Region, new Bgr(Color.Red), 2); } } statusAccumulation.AppendFormat("{0} motions", result.MotionSections.Count); imageBoxFiltered.Image = result.ForegroundImage; } if (chkMultimode.Checked) { var multimodeOutput = _multimodePanTiltController.Process(input); output = multimodeOutput; if (output.Target != Point.Empty) { DrawReticle(bgrImage, output.Target, Color.Yellow); } } if (output != null) { if (output.IsServoInMotion) { statusAccumulation.AppendFormat(", Waiting for servo"); } else { statusAccumulation.AppendFormat(", tracking took {0}", output.Elapsed.ToHumanReadable()); } NotifyStatus(statusAccumulation.ToString()); } imageBoxCaptured.Image = bgrImage; } }