• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Emgu类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Emgu的典型用法代码示例。如果您正苦于以下问题:C# Emgu类的具体用法?C# Emgu怎么用?C# Emgu使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Emgu类属于命名空间,在下文中一共展示了Emgu类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: PreQuantization

        protected override void PreQuantization(Emgu.CV.Image<Color, byte> image)
        {
            this.image = image;

            // If only there is one, do nothing
            if (this.palettes.Length == 1) {
                base.PreQuantization(image);
                return;
            }

            // Extract a palette from the image removing transparent colors (not approximated)
            this.compareQuantization.TileSize = this.TileSize;
            this.compareQuantization.Quantizate(image);
            Color[] comparePalette = this.compareQuantization.Palette.
                Where(c => c.Alpha == 255).ToArray();
            LabColor[] compareLabPalette = ColorConversion.ToLabPalette<Color>(comparePalette);

            // Compare all possible palettes to get the similar one
            double minDistance = Double.MaxValue;
            for (int i = 0; i < palettes.Length && minDistance > 0; i++) {
                double distance = PaletteDistance.CalculateDistance(
                    compareLabPalette, this.labPalettes[i]);
                if (distance < minDistance) {
                    this.SelectedPalette = i;
                    minDistance = distance;
                }
            }

            // Set the palette...
            this.Palette = this.palettes[this.SelectedPalette];

            // ... and run the FixedPaletteQuantization
            base.PreQuantization(image);
        }
开发者ID:pleonex,项目名称:ninoimager,代码行数:34,代码来源:ManyFixedPaletteQuantization.cs


示例2: CalibrationError

    public static void CalibrationError(
      Emgu.CV.ExtrinsicCameraParameters ecp,
      Emgu.CV.IntrinsicCameraParameters icp,
      System.Drawing.PointF[] image_points,
      Vector[] reference_points,
      out double[] deviations,
      out Vector[] isect_points) 
    {
      // Shoot rays through image points,
      // intersect with plane defined by extrinsic
      // and measure distance to reference points
      Matrix inv_ecp = Matrix.Identity(4, 4);
      inv_ecp.SetMatrix(0, 2, 0, 3, ecp.ExtrinsicMatrix.ToParsley());
      inv_ecp = inv_ecp.Inverse();

      Ray[] rays = Ray.EyeRays(icp, image_points);
      Plane p = new Plane(ecp);
      isect_points = new Vector[rays.Length];

      deviations = new double[rays.Length];
      for (int i = 0; i < rays.Length; ++i) {
        double t;
        Intersection.RayPlane(rays[i], p, out t);
        Vector isect = rays[i].At(t);
        Vector x = new Vector(new double[]{isect[0],isect[1],isect[2],1});
        x = (inv_ecp * x.ToColumnMatrix()).GetColumnVector(0);
        Vector final = new Vector(new double[]{x[0], x[1], x[2]});
        isect_points[i] = final;
        deviations[i] = (final - reference_points[i]).Norm();
      }
    }
开发者ID:sivarajankumar,项目名称:dentalsmile,代码行数:31,代码来源:ExtrinsicCalibration.cs


示例3: ExtractBriefFeatureDescriptors

 public static Matrix<byte> ExtractBriefFeatureDescriptors(Emgu.CV.Image<Gray, byte> im, MKeyPoint kp)
 {
     var f = new VectorOfKeyPoint();
     f.Push(new MKeyPoint[] { kp });
     //i'm are going to invoke this with a single point because otherwise I cannot tell which points failed to get descriptors
     return new BriefDescriptorExtractor().ComputeDescriptorsRaw(im, (Emgu.CV.Image<Gray, byte>)null, f);
 }
开发者ID:kamal-kr,项目名称:RGBLocalization,代码行数:7,代码来源:ImageFeatures.cs


示例4: FastFeatureExtRaw

 public static IEnumerable<MKeyPoint> FastFeatureExtRaw(Emgu.CV.Image<Gray, byte> image, FeatureExtractionOptions options)
 {
     return new FastDetector(options.threshold, true)
                         .DetectKeyPointsRaw(image, (Emgu.CV.Image<Gray, byte>) null).ToArray()
                         .OrderByDescending(kp => kp.Response)
                         .Take(options.numPoints);
 }
开发者ID:kamal-kr,项目名称:RGBLocalization,代码行数:7,代码来源:ImageFeatures.cs


示例5: ProcessImage

    public virtual void ProcessImage(Emgu.CV.Image<Emgu.CV.Structure.Bgr, byte> image) {
      Emgu.CV.Image<Gray, byte> gray = image.Convert<Gray, byte>();
      gray._ThresholdBinary(new Gray(_threshold), new Gray(255.0));
      gray._Not();

      Parsley.Core.EllipseDetector ed = new Parsley.Core.EllipseDetector();
      ed.MinimumContourCount = _min_contour_count;

      List < Parsley.Core.DetectedEllipse > ellipses = 
        new List<Parsley.Core.DetectedEllipse>(ed.DetectEllipses(gray));

      List < Parsley.Core.DetectedEllipse > finals = 
        new List<Parsley.Core.DetectedEllipse>(
          ellipses.Where(e => { return e.Rating < _distance_threshold; })
        );

      finals.Sort(
        (a, b) => {
          double dista = a.Ellipse.MCvBox2D.center.X * a.Ellipse.MCvBox2D.center.X + a.Ellipse.MCvBox2D.center.Y * a.Ellipse.MCvBox2D.center.Y;
          double distb = b.Ellipse.MCvBox2D.center.X * b.Ellipse.MCvBox2D.center.X + b.Ellipse.MCvBox2D.center.Y * b.Ellipse.MCvBox2D.center.Y;
          return dista.CompareTo(distb);
        }
      );

      Bgr bgr = new Bgr(0, 255, 0);
      MCvFont f = new MCvFont(Emgu.CV.CvEnum.FONT.CV_FONT_HERSHEY_PLAIN, 0.8, 0.8);
      int count = 1;
      foreach (Parsley.Core.DetectedEllipse e in finals) {
        image.Draw(e.Ellipse, bgr, 2);
        image.Draw(count.ToString(), ref f, new System.Drawing.Point((int)e.Ellipse.MCvBox2D.center.X, (int)e.Ellipse.MCvBox2D.center.Y), bgr);
        count++;
      }
    }
开发者ID:sivarajankumar,项目名称:dentalsmile,代码行数:33,代码来源:EllipseDetection.cs


示例6: ExtractPoints

    private List<System.Drawing.PointF> ExtractPoints(Emgu.CV.Image<Gray, byte> channel) {
      int[] max_intensities = new int[channel.Width];
      float[] range = new float[channel.Width];
      // Note that default float is zero.

      // Search per row
      byte[] d = channel.Bytes;
      int stride = d.Length / channel.Height;
      int h = channel.Height; // This one here is a huge, HUGE timesaver!
      int w = channel.Width; // This one here is a huge, HUGE timesaver!

      unchecked {
        for (int r = 0; r < h; ++r) {
          int offset = stride * r;
          for (int c = 0; c < w; ++c) {
            byte i = d[offset + c];
            if (i > max_intensities[c]) {
              max_intensities[c] = i;
              range[c] = r;
            }
          }
        }
      }
      // Update output: set -1 for invalid laser line poses
      List<System.Drawing.PointF> pixels = new List<System.Drawing.PointF>();
      for (int i = 0; i < w; ++i) {
        if (max_intensities[i] >= _threshold) {
          pixels.Add(new System.Drawing.PointF(i, range[i]));
        }
      }
      return pixels;
    }
开发者ID:guozanhua,项目名称:parsley,代码行数:32,代码来源:BrightestPixel.cs


示例7: addImage

 public void addImage( string imageId, string imageType, Emgu.CV.Image<Emgu.CV.Structure.Gray, byte> image )
 {
     ensureImageBoxNamesUpdated( imageType );
     ImageBox ib = new ImageBox();
     ib.Image = image;
     ib.Width = 100;
     ib.Height = 100;
     ib.SizeMode = PictureBoxSizeMode.Zoom;
     ib.HorizontalScrollBar.Visible = false;
     ib.VerticalScrollBar.Visible = false;
     if ( _imageBoxNames[ 0 ].CompareTo( imageType ) == 0 )
     {
         flowPanel1.Controls.Add( ib );
         return;
     }
     if ( _imageBoxNames[ 1 ].CompareTo( imageType ) == 0 )
     {
         flowPanel2.Controls.Add( ib );
         return;
     }
     if ( _imageBoxNames[ 2 ].CompareTo( imageType ) == 0 )
     {
         flowPanel3.Controls.Add( ib );
     }
     return;
 }
开发者ID:vegazrelli,项目名称:GazeTracker2.0,代码行数:26,代码来源:VisualDisplay.cs


示例8: ProcessImage

    public void ProcessImage(Emgu.CV.Image<Emgu.CV.Structure.Bgr, byte> image) {
      MCvBox2D mybox = new MCvBox2D(new System.Drawing.PointF(100, 100), new System.Drawing.Size(50, 30), 110);
      MCvBox2D mybox2 = new MCvBox2D(new System.Drawing.PointF(100, 100), new System.Drawing.Size(50, 30), 0);

      image.Draw(new Ellipse(mybox), new Bgr(0,0,255), 2);
      image.Draw(new Ellipse(mybox2), new Bgr(0, 255, 0), 2);
    }
开发者ID:sivarajankumar,项目名称:dentalsmile,代码行数:7,代码来源:TestEllipse.cs


示例9: ConvertCVImageToPixbuf

 public static Pixbuf ConvertCVImageToPixbuf(Emgu.CV.Image<Bgr, byte> img)
 {
     System.Drawing.Bitmap bmp = img.Bitmap;
     MemoryStream ms = new MemoryStream();
     bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp);
     return new Pixbuf(ms.GetBuffer());
 }
开发者ID:kanitw,项目名称:facespot,代码行数:7,代码来源:ImageTypeConverter.cs


示例10: OnFrame

    protected override void OnFrame(Parsley.Core.BuildingBlocks.FrameGrabber fp, Emgu.CV.Image<Emgu.CV.Structure.Bgr, byte> img) {
      /*
      if (_take_ref_image) {
        _ref_image = img.Copy();
        _take_ref_image = false;
      }

      // 1. Extract laser-line
      Context.Setup.World.Laser.FindLaserLine(img);
      PointF[] laser_points = Context.Setup.World.Laser.ValidLaserPoints.ToArray();

      if (_acc != null) {
        img.Draw(_acc.ROI, new Bgr(Color.Green), 1);
      }

      if (laser_points.Length < 3 || _ref_image == null || _acc == null) {
        return;
      }

      Core.Ray[] eye_rays = Core.Ray.EyeRays(Context.Setup.World.Camera.Intrinsics, laser_points);
      Core.Plane laser_plane;
      if (Context.Setup.World.Laser.LaserPlaneAlgorithm.FindLaserPlane(
            eye_rays,
            Context.Setup.World.ReferencePlanes, out laser_plane)) 
      {
        Vector z = Vector.Create(new double[] { 0, 0, 1 });
        if (Math.Abs(laser_plane.Normal.ScalarMultiply(z)) < 0.3) {
          Console.WriteLine(laser_plane.Normal);
          return;
        }

        lock (Context.Viewer) {
          for (int i = 0; i < laser_points.Length; ++i) {
            Point lp = new Point((int)laser_points[i].X, (int)laser_points[i].Y);

            if (_acc.ROI.Contains(lp)) {

              double t;
              Core.Intersection.RayPlane(eye_rays[i], laser_plane, out t);

              img[lp.Y, lp.X] = new Bgr(Color.Red);
              Bgr bgr = _ref_image[lp.Y, lp.X];
              Vector color = new Vector(new double[] { bgr.Red / 255.0, bgr.Green / 255.0, bgr.Blue / 255.0, 1.0 });

              //_pointcloud.AddPoint(final.ToInterop(), color.ToInterop());
              Point p_in_roi = _acc.MakeRelativeToROI(lp);
              bool first;
              _acc.Accumulate(p_in_roi, eye_rays[i], t, out first);
              if (first) {
                _acc.SetId(p_in_roi, _pointcloud.AddPoint(_acc.Extract(p_in_roi).ToInterop(), color.ToInterop()));
              } else {
                _pointcloud.UpdatePoint(_acc.GetId(p_in_roi), _acc.Extract(p_in_roi).ToInterop(), color.ToInterop());
              }
            }
          }
        }
      }
       * */
    }
开发者ID:sivarajankumar,项目名称:dentalsmile,代码行数:59,代码来源:ScanningAttempt.cs


示例11: OnFrame

    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);
      }
    }
开发者ID:sivarajankumar,项目名称:dentalsmile,代码行数:59,代码来源:ExtrinsicCalibrationSlide.cs


示例12: DetectedEllipse

 /// <summary>
 /// Construct from values.
 /// </summary>
 /// <param name="contour"></param>
 /// <param name="ellipse"></param>
 /// <param name="rating"></param>
 public DetectedEllipse(
   Emgu.CV.Contour<System.Drawing.Point> contour,
   Emgu.CV.Structure.Ellipse ellipse,
   double rating) {
   _contour = contour;
   _ellipse = ellipse;
   _rating = rating;
 }
开发者ID:sivarajankumar,项目名称:dentalsmile,代码行数:14,代码来源:EllipseDetector.cs


示例13: HoughLineTransform

 /// <summary>
 /// Hough Line Transform, as in OpenCV (EmguCv does not wrap this function as it should be)
 /// </summary>
 /// <param name="img">Binary image</param>
 /// <param name="type">type of hough transform</param>
 /// <param name="threshold">how many votes is needed to accept line</param>
 /// <returns>Lines in theta/rho format</returns>
 public static PointF[] HoughLineTransform(Image<Gray, byte> img, Emgu.CV.CvEnum.HOUGH_TYPE type, int threshold)
 {
     using (MemStorage stor = new MemStorage())
     {
         IntPtr linePtr = CvInvoke.cvHoughLines2(img, stor.Ptr, type, 5, Math.PI / 180 * 15, threshold, 0, 0);
         Seq<PointF> seq = new Seq<PointF>(linePtr, stor);
         return seq.ToArray(); ;
     }
 }
开发者ID:rAum,项目名称:auton_net,代码行数:16,代码来源:VisionToolkit.cs


示例14: ExtrinsicCalibration

 public ExtrinsicCalibration(Vector[] object_points, Emgu.CV.IntrinsicCameraParameters intrinsics)
   : base(object_points) 
 {
   _intrinsics = intrinsics;
   // Since object points remain constant, we can apply their conversion right here
   _converted_object_points = Array.ConvertAll<Vector, MCvPoint3D32f>(
     this.ObjectPoints, 
     new Converter<Vector, MCvPoint3D32f>(Extensions.ConvertFromParsley.ToEmguF)
   );
 }
开发者ID:sivarajankumar,项目名称:dentalsmile,代码行数:10,代码来源:ExtrinsicCalibration.cs


示例15: SURFEngine

        public SURFEngine(Emgu.CV.Image<Gray, byte> roi)
        {
            surfDetector = new SURFDetector(500, false);
            itemImage = roi;

            itemKP = surfDetector.DetectKeyPointsRaw(itemImage, null);
            itemDescriptors = surfDetector.ComputeDescriptorsRaw(itemImage, null, itemKP);

            matcher = new BruteForceMatcher<float>(DistanceType.L2);
            matcher.Add(itemDescriptors);
        }
开发者ID:gussmith23,项目名称:ThirdEyeVIDemo,代码行数:11,代码来源:SURFEngine.cs


示例16: Detect

        public static Rectangle[] Detect(Image<Bgr, Byte> image, string cascadeFile,
            double scaleFactor = 1.3, int minNeighbors = 10,
            Emgu.CV.CvEnum.HAAR_DETECTION_TYPE detectionType = Emgu.CV.CvEnum.HAAR_DETECTION_TYPE.DO_CANNY_PRUNING,
            int minSize = 20, int maxSize = 0)
        {
            string cascadeFilePath = CascadeManager.GetCascade(cascadeFile);

            Size minimumSize;
            if (minSize == 0)
            {
                minimumSize = Size.Empty;
            }
            else
            {
                minimumSize = new Size(minSize, minSize);
            }

            Size maximumSize;
            if (maxSize == 0)
            {
                maximumSize = Size.Empty;
            }
            else
            {
                maximumSize = new Size(maxSize, maxSize);
            }

            if (GpuInvoke.HasCuda)
            {
                using (GpuCascadeClassifier cascade = new GpuCascadeClassifier(cascadeFilePath))
                using (GpuImage<Bgr, Byte> gpuImage = new GpuImage<Bgr, byte>(image))
                using (GpuImage<Gray, Byte> gpuGray = gpuImage.Convert<Gray, Byte>())
                {
                    return cascade.DetectMultiScale(gpuGray, scaleFactor, minNeighbors, minimumSize);
                }
            }
            else
            {
                using (HaarCascade cascade = new HaarCascade(cascadeFilePath))
                using (Image<Gray, Byte> gray = image.Convert<Gray, Byte>())
                {
                    gray._EqualizeHist();

                    MCvAvgComp[] detected = cascade.Detect(gray,
                        scaleFactor, minNeighbors,
                        detectionType,
                        minimumSize, maximumSize);

                    return (from x in detected
                            select x.rect).ToArray();
                }
            }
        }
开发者ID:seevent,项目名称:HaarDetection,代码行数:53,代码来源:Detector.cs


示例17: OnFrame

 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);
   }
 }
开发者ID:guozanhua,项目名称:parsley,代码行数:12,代码来源:IntrinsicCalibrationSlide.cs


示例18: EmguImage2Bool

 public static bool[][] EmguImage2Bool(Emgu.CV.Image<Gray, byte> img)
 {
     bool[][] booleanMap = new bool[img.Height][];
     for (int y = 0; y < img.Height; y++)
     {
         booleanMap[y] = new bool[img.Width];
         for (int x = 0; x < img.Width; x++)
         {
             booleanMap[y][x] = (img[x, y].Intensity < 0.3);
         }
     }
     return booleanMap;
 }
开发者ID:lekd,项目名称:XNAStickyNoteDetector,代码行数:13,代码来源:Utilities.cs


示例19: FrameGrabber_OnFramePrepend

 void FrameGrabber_OnFramePrepend(Parsley.Core.BuildingBlocks.FrameGrabber fp, Emgu.CV.Image<Emgu.CV.Structure.Bgr, byte> img) {
   UI.I2DInteractor i = _current;
   if (i != null) {
     if (i.State == Parsley.UI.InteractionState.Interacting) {
       _current.DrawIndicator(i.Current, img);
     } else {
       GridItem e = _pg_config.SelectedGridItem;
       GridItem p = e.Parent;
       if (p != null) {
         _current.DrawIndicator(e.PropertyDescriptor.GetValue(p.Value), img);
       }
     }
   }
 }
开发者ID:sivarajankumar,项目名称:dentalsmile,代码行数:14,代码来源:PropertyPane.cs


示例20: OnFrame

 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
     }
 }
开发者ID:sivarajankumar,项目名称:dentalsmile,代码行数:14,代码来源:IntrinsicCalibrationSlide.cs



注:本文中的Emgu类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# EmitContext类代码示例发布时间:2022-05-24
下一篇:
C# EmfType类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap