Ejemplo n.º 1
0
        public void OnUpdate(Dictionary<string, object> bundle)
        {
            Image<Bgr, byte> image = bundle.GetImage("source");
              Image<Bgr, byte> smoothed = image.SmoothGaussian(3);
              _detector.Update(smoothed);

              Image<Gray, Byte> fg_mask = _detector.ForgroundMask;
              Image<Gray, Byte> fg_mask_morph = fg_mask.Erode(1).Dilate(1);

              // Fetch the interactor from the bundle
              IDataInteractor idi = bundle.GetInteractor();
              idi.Show("forground", fg_mask_morph);

              // Find contours
              _blobs.Clear();
              for (Contour<Point> c = fg_mask_morph.FindContours(); c != null; c = c.HNext) {
            Rectangle r = c.BoundingRectangle;
            int area = r.Width * r.Height;
            if (area > 20) {
              _blobs.Add(r);
            }
              }

              while (MergeTwoRectangles()) {
            ;
              }
        }
Ejemplo n.º 2
0
        public void GetInteractor()
        {
            Dictionary<string, object> d = new Dictionary<string, object>();
              d["interactor"] = new NullInteractor();

              Assert.DoesNotThrow(new TestDelegate(() => d.GetInteractor()));
        }
Ejemplo n.º 3
0
        public void Execute(Dictionary<string, object> bundle)
        {
            Image<Bgr, byte> image = bundle.GetImage("source");
              image.Draw(new Rectangle(Point.Empty, image.Size), new Bgr(_color), _thickness);

              IDataInteractor idi = bundle.GetInteractor();
              idi.Show("camera input", image);
              idi.ExecutePendingEvents(this, bundle);
        }
Ejemplo n.º 4
0
        public void OnPrintGreeting(Dictionary<string, object> bundle)
        {
            IDataInteractor idi = bundle.GetInteractor();
              Name n = new Name();

              if (idi.Query("What's your name?", n)) {
            // User positively responded to our query
            Console.WriteLine(String.Format("Hello {0} {1}", n.FirstName, n.LastName));
              }
        }
Ejemplo n.º 5
0
 public void Execute(Dictionary<string, object> bundle)
 {
     if (_sw.IsRunning) {
     _sw.Stop();
     IDataInteractor idi = bundle.GetInteractor();
     idi.Show("DisplayingValues.FPS", 1.0 / _sw.Elapsed.TotalSeconds);
     _sw.Reset();
       }
       _sw.Start();
 }
Ejemplo n.º 6
0
        public void OnSaveImage(Dictionary<string, object> bundle)
        {
            IDataInteractor idi = bundle.GetInteractor();

              FilePathInfo fni = new FilePathInfo();
              if (idi.Query("Choose the filename", fni)) {
            string path = System.IO.Path.Combine(fni.Directory, fni.Filename);
            bundle.GetImage("source").Save(path);
            idi.Show("Last Image Saved", path);
              }
        }
Ejemplo n.º 7
0
        public void Execute(Dictionary<string, object> b)
        {
            IDataInteractor idi = b.GetInteractor();
              // Process all pending events, supplying them with the current bundle information
              idi.ExecutePendingEvents(this, b);

              Image<Bgr, byte> image = b.GetImage("source");
              foreach (Rectangle r in _blobs) {
            image.Draw(r, new Bgr(Color.Green), 2);
              }
        }
Ejemplo n.º 8
0
        public void Execute(Dictionary<string, object> b)
        {
            while (_hc == null) {
            bool query_result = b.GetInteractor().Query("Please specify a correct cascade file", this);
            bool should_cancel = b.GetRuntime().StopRequested;

            if (!query_result || should_cancel) {
              b.GetRuntime().RequestStop();
              return;
            }
              }

              Image<Bgr, byte> i = b.GetImage("source");
              Image<Gray, byte> gray = i.Convert<Gray, byte>();

              foreach(MCvAvgComp comp in gray.DetectHaarCascade(_hc)[0]) {
            i.Draw(comp.rect, new Bgr(Color.Red), 4);
              }
        }
Ejemplo n.º 9
0
 public void Execute(Dictionary<string, object> bundle)
 {
     IDataInteractor idi = bundle.GetInteractor();
       // Process all pending events, supplying them with the current bundle information
       idi.ExecutePendingEvents(this, bundle);
 }
Ejemplo n.º 10
0
        public void Execute(Dictionary<string, object> bundle)
        {
            // For illustration purposes, we detect the chessboard in each frame
              Image<Gray, byte> image = bundle.GetImage("source").Convert<Gray, byte>();
              PointF[] corners = null;

              bool found = CameraCalibration.FindChessboardCorners(
            image, _nr_corners,
            Emgu.CV.CvEnum.CALIB_CB_TYPE.ADAPTIVE_THRESH |
            Emgu.CV.CvEnum.CALIB_CB_TYPE.FILTER_QUADS |
            Emgu.CV.CvEnum.CALIB_CB_TYPE.NORMALIZE_IMAGE,
            out corners
              );
              if (found) {
            image.FindCornerSubPix(
              new System.Drawing.PointF[][] { corners },
              new System.Drawing.Size(5, 5),
              new System.Drawing.Size(-1, -1),
              new MCvTermCriteria(0.001));
              }

              bundle["pattern_found"] = found;
              bundle["pattern_corners"] = corners;

              bundle.GetInteractor().ExecutePendingEvents(this, bundle);

              QCV.Toolbox.Draw.OrderedPointList(bundle.GetImage("source"), corners, found ? Color.Green : Color.Red);
              if (found && bundle.ContainsKey("intrinsics")) {
            IntrinsicCameraParameters icp = bundle.Get<IntrinsicCameraParameters>("intrinsics");

            ExtrinsicCameraParameters ecp = CameraCalibration.FindExtrinsicCameraParams2(
              GenerateObjectCorners(),
              corners,
              icp);

            QCV.Toolbox.Draw.DrawExtrinsicFrame(bundle.GetImage("source"), ecp, icp);
              }
        }
Ejemplo n.º 11
0
 public void OnTakeImage(Dictionary<string, object> bundle)
 {
     if (bundle.Get<bool>("pattern_found")) {
     _image_points.Add(bundle.Get<PointF[]>("pattern_corners"));
     _object_points.Add(GenerateObjectCorners());
     bundle.GetInteractor().Show("Number of correspondences", _image_points.Count);
       }
 }
Ejemplo n.º 12
0
Archivo: ShowFPS.cs Proyecto: qida/qcv
 /// <summary>
 /// Execute the filter.
 /// </summary>
 /// <param name="b">Bundle of information</param>
 public void Execute(Dictionary<string, object> b)
 {
     _iterations += 1;
       DateTime now = DateTime.Now;
       double elapsed = (now - _last_update).TotalSeconds;
       if (elapsed > _update_interval) {
     b.GetInteractor().Show("FPS", _iterations / elapsed );
     _last_update = now;
     _iterations = 0;
       }
 }
Ejemplo n.º 13
0
 /// <summary>
 /// Execute the filter.
 /// </summary>
 /// <param name="b">Bundle of information</param>
 public void Execute(Dictionary<string, object> b)
 {
     Image<Bgr, byte> i = b.GetImage(_bundle_name);
       Base.IDataInteractor ii = b.GetInteractor();
       ii.Show(_show_name, i);
 }
Ejemplo n.º 14
0
 public void Execute(Dictionary<string, object> bundle)
 {
     bundle.GetInteractor().Show("video", bundle.GetImage("source"));
 }