当前位置: 首页>>代码示例>>C#>>正文


C# Emgu.Count方法代码示例

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


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

示例1: GoodnessOfFit

    /// <summary>
    /// Evaluate goodness of fit.
    /// </summary>
    /// <remarks>
    /// Calculates the average distance of all contour points to the ellipse. The distance of point to
    /// an ellipse is given by calculating the point on the ellipse that is closest to the query. This calculation
    /// is performed by transforming the point into a coordinate system where the ellipse is in main-pose
    /// (x-axis points toward a, y-axis points toward b, the origin is the center of the ellipse). Additionally,
    /// the coordinate system is crafted in such a way (non-uniform scaling) that the ellipse becomes a circle.
    /// Then, the closest point is simply the closest point on the circle. This point is transformed back into 
    /// the world coordinate system where the distance between the query and the returned point is computed.
    /// </remarks>
    /// <param name="e">Ellipse</param>
    /// <param name="c">Contour points</param>
    /// <returns>Goodness of fit</returns>
    private double GoodnessOfFit(Emgu.CV.Structure.Ellipse e, Emgu.CV.Contour<System.Drawing.Point> c) {
      Matrix m = EllipseDetector.GetAffineFrame(e);
      Matrix inv = m.Inverse();
      List<double> distances = new List<double>();

      double avg_distance = 0.0;
      foreach (System.Drawing.Point p in c) {
        // Bring the point into the ellipse coordinate frame
        Vector x = p.ToParsley().ToHomogeneous(1.0);
        Vector r = (inv.Multiply(x.ToColumnMatrix())).GetColumnVector(0);
        // Find the closest point on the circle to r
        // From the above scaling construction the resulting circle has radius b
        Vector closest = r.ToNonHomogeneous().Normalize().Scale(e.MCvBox2D.size.Height);
        // Transform the closest point back
        Vector closest_in_world = (m.Multiply(closest.ToHomogeneous(1.0).ToColumnMatrix())).GetColumnVector(0);
        // Calculate the squared distance between the query and the point.
        avg_distance += (closest_in_world - x).ToNonHomogeneous().SquaredNorm();
      }
      return Math.Sqrt(avg_distance / c.Count());
    }
开发者ID:sivarajankumar,项目名称:dentalsmile,代码行数:35,代码来源:EllipseDetector.cs


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