protected override void OnFrame(Parsley.Core.BuildingBlocks.FrameGrabber fp, Emgu.CV.Image <Emgu.CV.Structure.Bgr, byte> img) { Parsley.Core.ExtrinsicCalibration ec; ExtrinsicCameraParameters ecp; bool pattern_found = false; Core.CalibrationPattern p = _pattern; if (p != null) { Image <Gray, Byte> gray = img.Convert <Gray, Byte>(); pattern_found = p.FindPattern(gray); p.DrawPattern(img, p.ImagePoints, p.PatternFound); // if pattern has been found ==> find extrinsics and draw the corresponding coordinate frame if (pattern_found == true && Context.Setup.Camera.Intrinsics != null) { ec = new Parsley.Core.ExtrinsicCalibration(p.ObjectPoints, Context.Setup.Camera.Intrinsics); ecp = ec.Calibrate(p.ImagePoints); if (ecp != null) { Core.Drawing.DrawCoordinateFrame(img, ecp, Context.Setup.Camera.Intrinsics); } } } base.OnFrame(fp, img); }
protected override void OnFrame(Parsley.Core.BuildingBlocks.FrameGrabber fp, Emgu.CV.Image <Emgu.CV.Structure.Bgr, byte> img) { // Constraint checking if (!Context.Setup.Camera.HasIntrinsics) { _on_roi = false; return; } if (_interactor.State == Parsley.UI.InteractionState.Interacting) { _interactor.DrawIndicator(_interactor.Current, img); } else { _interactor.DrawIndicator(_r, img); } if (_on_roi && _pattern != null) { Image <Gray, Byte> gray = img.Convert <Gray, Byte>(); _pattern.IntrinsicParameters = Context.Setup.Camera.Intrinsics; try { _pattern.FindPattern(gray, _r); if (_pattern.PatternFound) { Parsley.Core.ExtrinsicCalibration ec = new Parsley.Core.ExtrinsicCalibration(_pattern.ObjectPoints, Context.Setup.Camera.Intrinsics); ExtrinsicCameraParameters ecp = ec.Calibrate(_pattern.ImagePoints); double[] deviations; Vector[] points; Core.ExtrinsicCalibration.CalibrationError(ecp, Context.Setup.Camera.Intrinsics, _pattern.ImagePoints, _pattern.ObjectPoints, out deviations, out points); double max_error = deviations.Max(); if (max_error < _last_error) { _last_detected_plane = ecp; _last_error = max_error; this.Logger.Info(String.Format("Extrinsics successfully calculated. Maximum error {0:F3}", _last_error)); } } else if (!_pattern.PatternFound & _last_detected_plane == null) { this.Logger.Warn("Pattern not found."); } } catch (System.Exception e) { this.Logger.Warn(String.Format("Failed to determine extrinsic calibration: {0}", e.Message)); } } if (_last_detected_plane != null) { Core.Drawing.DrawCoordinateFrame(img, _last_detected_plane, Context.Setup.Camera.Intrinsics); } }
protected override void OnFrame(Parsley.Core.BuildingBlocks.FrameGrabber fp, Emgu.CV.Image <Emgu.CV.Structure.Bgr, byte> img) { Core.CalibrationPattern pattern = _pattern; if (pattern != null) { Image <Gray, Byte> gray = img.Convert <Gray, Byte>(); pattern.FindPattern(gray); this.UpdateStatusDisplay(pattern.PatternFound); this.HandleCalibrateRequest(); this.HandleTakeImageRequest(); this.DrawCoordinateFrame(img); pattern.DrawPattern(img, pattern.ImagePoints, pattern.PatternFound); } }
protected override void OnFrame(Parsley.Core.BuildingBlocks.FrameGrabber fp, Emgu.CV.Image <Emgu.CV.Structure.Bgr, byte> img) { Core.CalibrationPattern pattern = _pattern; if (pattern != null) { //cari pola kalibrasi jika marker kalibrasi tersedia Image <Gray, Byte> gray = img.Convert <Gray, Byte>(); //convert image to grayscale pattern.FindPattern(gray); //cari pola kalibrasi this.UpdateStatusDisplay(pattern.PatternFound); this.HandleCalibrateRequest(); this.HandleTakeImageRequest(); this.DrawCoordinateFrame(img); pattern.DrawPattern(img, pattern.ImagePoints, pattern.PatternFound); //gambar AR pada marker jika pattern ditemukan } }