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


C# Point2f类代码示例

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


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

示例1: mapToSphere

    public void mapToSphere(Point point, Vector3f vector)
    {
        //Copy paramter into temp point
        Point2f tempPoint = new Point2f(point.X, point.Y);

        //Adjust point coords and scale down to range of [-1 ... 1]
        tempPoint.x = (tempPoint.x * this.adjustWidth) - 1.0f;
        tempPoint.y = 1.0f - (tempPoint.y * this.adjustHeight);

        //Compute the square of the length of the vector to the point from the center
        float length = (tempPoint.x * tempPoint.x) + (tempPoint.y * tempPoint.y);

        //If the point is mapped outside of the sphere... (length > radius squared)
        if (length > 1.0f)
        {
            //Compute a normalizing factor (radius / sqrt(length))
            float norm = (float) (1.0 / Math.Sqrt(length));

            //Return the "normalized" vector, a point on the sphere
            vector.x = tempPoint.x * norm;
            vector.y = tempPoint.y * norm;
            vector.z = 0.0f;
        }
        else    //Else it's on the inside
        {
            //Return a vector to a point mapped inside the sphere sqrt(radius squared - length)
            vector.x = tempPoint.x;
            vector.y = tempPoint.y;
            vector.z = (float) Math.Sqrt(1.0f - length);
        }
    }
开发者ID:jesantana,项目名称:RSAGenerator,代码行数:31,代码来源:ArcBall.cs

示例2: Line

 public Line(Graphics gs, Pen pen, Point2f x, Point2f y)
     : base(gs)
 {
     this.pen = pen;
     this.b = x;
     this.e = y;
 }
开发者ID:TheProjecter,项目名称:somscode,代码行数:7,代码来源:Line.cs

示例3: DrawSpot

        public void DrawSpot(Point2f spot)
        {
            using (var graphics = Graphics.FromImage(streamBox.Image))
            {
                graphics.DrawEllipse(Pens.CornflowerBlue, spot.X - 2, spot.Y - 2, 4, 4);

                //streamBox.Image = new Bitmap(bitmap, streamBox.Size);
            }
        }
开发者ID:mmcs-robotics,项目名称:mapping_2015,代码行数:9,代码来源:MainForm.cs

示例4: Run

        public void Run()
        {

            Console.WriteLine("===== FlannTest =====");

            // creates data set
            using (Mat features = new Mat(10000, 2, MatType.CV_32FC1))
            {
                Random rand = new Random();
                for (int i = 0; i < features.Rows; i++)
                {
                    features.Set<float>(i, 0, rand.Next(10000));
                    features.Set<float>(i, 1, rand.Next(10000));
                }

                // query
                Point2f queryPoint = new Point2f(7777, 7777);
                Mat queries = new Mat(1, 2, MatType.CV_32FC1);
                queries.Set<float>(0, 0, queryPoint.X);
                queries.Set<float>(0, 1, queryPoint.Y);
                Console.WriteLine("query:({0}, {1})", queryPoint.X, queryPoint.Y);
                Console.WriteLine("-----");

                // knnSearch
                using (Index nnIndex = new Index(features, new KDTreeIndexParams(4)))
                {
                    const int Knn = 1;
                    int[] indices;
                    float[] dists;
                    nnIndex.KnnSearch(queries, out indices, out dists, Knn, new SearchParams(32));

                    for (int i = 0; i < Knn; i++)
                    {
                        int index = indices[i];
                        float dist = dists[i];
                        Point2f pt = new Point2f(features.Get<float>(index, 0), features.Get<float>(index, 1));
                        Console.Write("No.{0}\t", i);
                        Console.Write("index:{0}", index);
                        Console.Write(" distance:{0}", dist);
                        Console.Write(" data:({0}, {1})", pt.X, pt.Y);
                        Console.WriteLine();
                    }
                    Knn.ToString();
                }
            }
            Console.Read();
        }
开发者ID:jorik041,项目名称:opencvsharp,代码行数:47,代码来源:FlannSample.cs

示例5: Points

        /// <summary>
        /// returns 4 vertices of the rectangle
        /// </summary>
        /// <returns></returns>
        public Point2f[] Points()
        {
            double angle = Angle * Cv.PI / 180.0;
            float b = (float)Math.Cos(angle) * 0.5f;
            float a = (float)Math.Sin(angle) * 0.5f;

            Point2f[] pt = new Point2f[4];
            pt[0].X = Center.X - a * Size.Height - b * Size.Width;
            pt[0].Y = Center.Y + b * Size.Height - a * Size.Width;
            pt[1].X = Center.X + a * Size.Height - b * Size.Width;
            pt[1].Y = Center.Y - b * Size.Height - a * Size.Width;
            pt[2].X = 2 * Center.X - pt[0].X;
            pt[2].Y = 2 * Center.Y - pt[0].Y;
            pt[3].X = 2 * Center.X - pt[1].X;
            pt[3].Y = 2 * Center.Y - pt[1].Y;
            return pt;
        }
开发者ID:0sv,项目名称:opencvsharp,代码行数:21,代码来源:RotatedRect.cs

示例6: SaveCallibration

        public void SaveCallibration(string path, Point2f[] src, Point2f[] dst)
        {
            this.srcx = new List<float>();
            this.srcy = new List<float>();
            this.dstx = new List<float>();
            this.dsty = new List<float>();

            foreach (var p in src)
            {
                this.srcx.Add(p.X);
                this.srcy.Add(p.Y);
            }
            foreach (var q in dst)
            {
                this.dstx.Add(q.X);
                this.dsty.Add(q.Y);
            }
            this.Save(path);
        }
开发者ID:0tsukq,项目名称:LabLife,代码行数:19,代码来源:CallibrationData.cs

示例7: LoadCallibration

        public void LoadCallibration(string path, Point2f[] src, Point2f[] dst)
        {
            this.Load(path);

            src[0].X = srcx[0];
            src[1].X = srcx[1];
            src[2].X = srcx[2];
            src[3].X = srcx[3];
            src[0].Y = srcy[0];
            src[1].Y = srcy[1];
            src[2].Y = srcy[2];
            src[3].Y = srcy[3];

            dst[0].X = dstx[0];
            dst[1].X = dstx[1];
            dst[2].X = dstx[2];
            dst[3].X = dstx[3];
            dst[0].Y = dsty[0];
            dst[1].Y = dsty[1];
            dst[2].Y = dsty[2];
            dst[3].Y = dsty[3];
        }
开发者ID:0tsukq,项目名称:LabLife,代码行数:22,代码来源:CallibrationData.cs

示例8: MinEnclosingCircle

 /// <summary>
 /// Finds the minimum area circle enclosing a 2D point set.
 /// The input is 2D point set, represented by CV_32SC2 or CV_32FC2 matrix.
 /// </summary>
 /// <param name="center">The output center of the circle</param>
 /// <param name="radius">The output radius of the circle</param>
 public void MinEnclosingCircle(out Point2f center, out float radius)
 {
     Cv2.MinEnclosingCircle(this, out center, out radius);
 }
开发者ID:MJunak,项目名称:opencvsharp,代码行数:10,代码来源:Mat_CvMethods.cs

示例9: ON_Mesh_SetTextureCoordinates

 internal static extern bool ON_Mesh_SetTextureCoordinates(IntPtr pMesh, int count, ref Point2f tcs, [MarshalAs(UnmanagedType.U1)]bool append);
开发者ID:kalvo,项目名称:rhinocommon,代码行数:1,代码来源:AutoNativeMethods.cs

示例10: FindCirclesGrid

        /// <summary>
        /// Finds centers in the grid of circles.
        /// </summary>
        /// <param name="image">grid view of input circles; it must be an 8-bit grayscale or color image.</param>
        /// <param name="patternSize">number of circles per row and column ( patternSize = Size(points_per_row, points_per_colum) ).</param>
        /// <param name="centers">output array of detected centers.</param>
        /// <param name="flags">various operation flags that can be one of the FindCirclesGridFlag values</param>
        /// <param name="blobDetector">feature detector that finds blobs like dark circles on light background.</param>
        /// <returns></returns>
        public static bool FindCirclesGrid(
            InputArray image,
            Size patternSize,
            out Point2f[] centers,
            FindCirclesGridFlag flags = FindCirclesGridFlag.SymmetricGrid,
            FeatureDetector blobDetector = null)
        {
            if (image == null)
                throw new ArgumentNullException("image");
            image.ThrowIfDisposed();

            using (var centersVec = new VectorOfPoint2f())
            {
                int ret = NativeMethods.calib3d_findCirclesGrid_InputArray(
                image.CvPtr, patternSize, centersVec.CvPtr, (int)flags, ToPtr(blobDetector));
                centers = centersVec.ToArray();
                return ret != 0;
            }
        }
开发者ID:kaorun55,项目名称:opencvsharp,代码行数:28,代码来源:Cv2_calib3d.cs

示例11: GetVoronoiFacetList

        /// <summary>
        /// 
        /// </summary>
        /// <param name="idx"></param>
        /// <param name="facetList"></param>
        /// <param name="facetCenters"></param>
        public void GetVoronoiFacetList(IEnumerable<int> idx, out Point2f[][] facetList, out Point2f[] facetCenters)
        {
            if (disposed)
                throw new ObjectDisposedException("Subdiv2D", "");

            IntPtr facetListPtr, facetCentersPtr;
            if (idx == null)
            {
                NativeMethods.imgproc_Subdiv2D_getVoronoiFacetList(ptr, IntPtr.Zero, 0, out facetListPtr, out facetCentersPtr);
            }
            else
            {
                int[] idxArray = EnumerableEx.ToArray(idx);
                NativeMethods.imgproc_Subdiv2D_getVoronoiFacetList(ptr, idxArray, idxArray.Length, out facetListPtr, out facetCentersPtr);
            }

            using (VectorOfVectorPoint2f facetListVec = new VectorOfVectorPoint2f(facetListPtr))
            {
                facetList = facetListVec.ToArray();
            }
            using (VectorOfPoint2f facetCentersVec = new VectorOfPoint2f(facetCentersPtr))
            {
                facetCenters = facetCentersVec.ToArray();
            }
        }
开发者ID:0sv,项目名称:opencvsharp,代码行数:31,代码来源:Subdiv2D.cs

示例12: FindNearest

 /// <summary>
 /// 
 /// </summary>
 /// <param name="pt"></param>
 /// <returns></returns>
 public int FindNearest(Point2f pt)
 {
     Point2f nearestPt;
     return FindNearest(pt, out nearestPt);
 }
开发者ID:0sv,项目名称:opencvsharp,代码行数:10,代码来源:Subdiv2D.cs

示例13: Insert

 /// <summary>
 /// 
 /// </summary>
 /// <param name="ptvec"></param>
 public void Insert(Point2f[] ptvec)
 {
     if(disposed)
         throw new ObjectDisposedException("Subdiv2D", "");
     if(ptvec == null)
         throw new ArgumentNullException("ptvec");
     NativeMethods.imgproc_Subdiv2D_insert(ptr, ptvec, ptvec.Length);
 }
开发者ID:0sv,项目名称:opencvsharp,代码行数:12,代码来源:Subdiv2D.cs

示例14: CalcOpticalFlowPyrLK

        /// <summary>
        /// computes sparse optical flow using multi-scale Lucas-Kanade algorithm
        /// </summary>
        /// <param name="prevImg"></param>
        /// <param name="nextImg"></param>
        /// <param name="prevPts"></param>
        /// <param name="nextPts"></param>
        /// <param name="status"></param>
        /// <param name="err"></param>
        /// <param name="winSize"></param>
        /// <param name="maxLevel"></param>
        /// <param name="criteria"></param>
        /// <param name="flags"></param>
        /// <param name="minEigThreshold"></param>
        public static void CalcOpticalFlowPyrLK(
            InputArray prevImg, InputArray nextImg,
            Point2f[] prevPts, ref Point2f[] nextPts,
            out byte[] status, out float[] err,
            Size? winSize = null,
            int maxLevel = 3,
            TermCriteria? criteria = null,
            OpticalFlowFlags flags = OpticalFlowFlags.None,
            double minEigThreshold = 1e-4)
        {
            if (prevImg == null)
                throw new ArgumentNullException("prevImg");
            if (nextImg == null)
                throw new ArgumentNullException("nextImg");
            if (prevPts == null)
                throw new ArgumentNullException("prevPts");
            if (nextPts == null)
                throw new ArgumentNullException("nextPts");
            prevImg.ThrowIfDisposed();
            nextImg.ThrowIfDisposed();

            Size winSize0 = winSize.GetValueOrDefault(new Size(21, 21));
            TermCriteria criteria0 = criteria.GetValueOrDefault(
                TermCriteria.Both(30, 0.01));

            using (var nextPtsVec = new VectorOfPoint2f())
            using (var statusVec = new VectorOfByte())
            using (var errVec = new VectorOfFloat())
            {
                NativeMethods.video_calcOpticalFlowPyrLK_vector(
                    prevImg.CvPtr, nextImg.CvPtr, prevPts, prevPts.Length,
                    nextPtsVec.CvPtr, statusVec.CvPtr, errVec.CvPtr, 
                    winSize0, maxLevel, criteria0, (int)flags, minEigThreshold);
                nextPts = nextPtsVec.ToArray();
                status = statusVec.ToArray();
                err = errVec.ToArray();
            }
        }
开发者ID:healtech,项目名称:opencvsharp,代码行数:52,代码来源:Cv2_video.cs

示例15: video_calcOpticalFlowPyrLK_vector

 public static extern void video_calcOpticalFlowPyrLK_vector(
     IntPtr prevImg, IntPtr nextImg,
     Point2f[] prevPts, int prevPtsSize,
     IntPtr nextPts, IntPtr status, IntPtr err,
     Size winSize, int maxLevel, TermCriteria criteria,
     int flags, double minEigThreshold);
开发者ID:JiphuTzu,项目名称:opencvsharp,代码行数:6,代码来源:NativeMethods_video.cs


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