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


C# PointF.Select方法代码示例

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


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

示例1: Calibrate

        public static ExtrinsicCameraParameters Calibrate(PointF[] locals, MCvPoint3D32f[] globals, Size pattern)
        {
            PointF[] pl = new PointF[]
            {
                locals[0 + (pattern.Height -1) * pattern.Width],
                locals[0 + 0 * pattern.Width],
                locals[(pattern.Width-1) + (pattern.Height -1) * pattern.Width],
            };

            MCvPoint3D32f[] pg = new MCvPoint3D32f[]
            {
                globals[0 + (pattern.Height -1) * pattern.Width],
                globals[0 + 0 * pattern.Width],
                globals[(pattern.Width-1) + (pattern.Height -1) * pattern.Width],
            };

            //f2 = (p1 - p0).Normalize(1);
            //f1 = (p2 - p0).Normalize(1);
            //f1 = (f1 - (f1.DotProduct(f2) * f2)).Normalize(1);
            //f3 = new DenseVector(new double[] { f1[1] * f2[2] - f1[2] * f2[1], f1[2] * f2[0] - f1[0] * f2[2], f1[0] * f2[1] - f1[1] * f2[0] });
            //f3 = f3.Normalize(1);

            var plv = pl.Select(row => new DenseVector(new double[] { row.X, row.Y })).ToArray();

            return null;
        }
开发者ID:virrkharia,项目名称:dynamight,代码行数:26,代码来源:ThreePointCalibration.cs

示例2: PolyRect

        public PolyRect(PointF[] points)
        {
            var rect = PolygonMath.GetBoundingBox(points);
            this.SetBounds(rect.X, rect.Y, rect.Width, rect.Height);

            // PolygonMath.IsUnrotated can tell us that the points follow a
            // particular pattern, but in order to represent 90-degree rotations
            // and flips, we want to consider them to be *non-rectangle* points.
            // Therefore, we use a much more strict definition: there can only
            // be 4 points, and they must be in the canonical order.
            var right = this.x + this.width;
            var bottom = this.y + this.height;

            this.rect = points.Length == 4 &&
                        points[0].X == this.x && points[0].Y == this.y &&
                        points[1].X == right && points[1].Y == this.y &&
                        points[2].X == right && points[2].Y == bottom &&
                        points[3].X == this.x && points[3].Y == bottom;

            this.points = points.Select(p => new float[] { p.X, p.Y }).ToArray();
        }
开发者ID:stukalin,项目名称:ImageResizer,代码行数:21,代码来源:PolyRect.cs

示例3: OnPaint


//.........这里部分代码省略.........
                    heading += da;

                px += (float) dix*steerRadius/2;
                py += (float) diy*steerRadius/2;

                // Rotated polygon
                var carL = 12.0f;
                var carW = 2.5f;
                var hg = -heading; //
                PointF[] poly = new PointF[]
                {
                    new PointF(mX + px + carL/2*(float) Math.Cos(hg) - carW/2*(float) Math.Sin(hg),
                        mY + py + carL/2*(float) Math.Sin(hg) + carW/2*(float) Math.Cos(hg)),
                    new PointF(mX + px - carL/2*(float) Math.Cos(hg) - carW/2*(float) Math.Sin(hg),
                        mY + py - carL/2*(float) Math.Sin(hg) + carW/2*(float) Math.Cos(hg)),
                    new PointF(mX + px - carL/2*(float) Math.Cos(hg) + carW/2*(float) Math.Sin(hg),
                        mY + py - carL/2*(float) Math.Sin(hg) - carW/2*(float) Math.Cos(hg)),
                    new PointF(mX + px + carL/2*(float) Math.Cos(hg) + carW/2*(float) Math.Sin(hg),
                        mY + py + carL/2*(float) Math.Sin(hg) - carW/2*(float) Math.Cos(hg)),
                };
                foreach (var car in data.Cars)
                {
                    if (car.Valid && IsPolygonsIntersecting(car.Box, poly))
                    {
                        car.Tracked = true;
                        break;
                    }
                }

                var drx = targetW/2 + px/scale*targetW;
                var dry = targetH/2 + py/scale*targetH;

                var polyToDraw =
                    poly.Select(
                        x => new PointF(targetW/2 + (x.X - mX)/2/scale*targetW, targetH/2 + (x.Y - mY)/2/scale*targetH))
                        .ToArray();
                g.FillPolygon(Brushes.Tomato, polyToDraw);
                //g.DrawLine(new Pen(Color.DarkSalmon, 5.0f), drx, dry, drx + 1, dry);
            }

            g.FillRectangle(new SolidBrush(Color.FromArgb(25, 25, 25)), 0, 0, targetW, 32);
            var trafficColor = Brushes.BlueViolet;
            foreach (var car in data.Cars)
            {
                if (!car.Valid)
                    continue;
                var x = targetW/2 + (car.X - centerX)/2/scale*targetW;
                var y = targetH/2 + (car.Z - centerZ)/2/scale*targetH;

                var sz = 10*scale;
                if (sz > 10) sz = 10;
                var of = sz/2;

                var dx = car.X - centerX;
                var dy = car.Z - centerZ;
                var dv = data.MyTelemetry.Drivetrain.Speed - car.Speed; // m/s
                var distance = (float) Math.Sqrt(dx*dx + dy*dy) - 12;
                if (distance < 0.1f) distance = 0.1f;
                var tti = dv < 0 ? -1.0f : distance/dv;

                var tc = trafficColor;
                if (car.Tracked)
                {
                    g.DrawString("Track #" + car.ID + " SPD " + Math.Round(car.Speed*3.6) +
                                 "km/h (d=" + Math.Round(car.Speed*3.6 - data.MyTelemetry.Drivetrain.SpeedKmh,1) +
                                 "); distance " + Math.Round(distance, 1) + "m TTI " + ((tti==-1.0f)?"never":Math.Round(tti, 2) + "s"),
开发者ID:nlhans,项目名称:SimShift,代码行数:67,代码来源:dlDebugInfo.cs

示例4: OffsetPoints

 public PointF[] OffsetPoints(PointF[] Points)
 {
     return Points.Select(p => PointF.Subtract(p, Offset)).ToArray();
 }
开发者ID:floatas,项目名称:highsign,代码行数:4,代码来源:Surface.cs

示例5: PhineTune

        public static PointF[] PhineTune(Projector projector, Camera camera, PointF[] cameraCorners, PointF[] rough, int subdiv)
        {
            var color = Color.Green;
            projector.DrawBackground(Color.Black);
            var nolight = new Image<Bgr, byte>(camera.TakePicture(2)).Split()[1];
            projector.DrawBackground(color);
            var fulllight = new Image<Bgr, byte>(camera.TakePicture(2)).Split()[1];
            Func<int, bool, Image<Gray, byte>[]> takePics = (step, vertical) =>
            {
                Image<Gray, byte>[] pics = new Image<Gray, byte>[3];
                projector.DrawBackground(Color.Black);
                camera.TakePicture(5).Dispose();
                projector.DrawPhaseMod(step, (float)(-2.0f * Math.PI / 3.0f), vertical, color);
                pics[0] = new Image<Bgr, byte>(camera.TakePicture(2)).Split()[1];
                projector.DrawBackground(Color.Black);
                camera.TakePicture(5).Dispose();
                projector.DrawPhaseMod(step, 0f, vertical, color);
                pics[1] = new Image<Bgr, byte>(camera.TakePicture(2)).Split()[1];
                projector.DrawBackground(Color.Black);
                camera.TakePicture(5).Dispose();
                projector.DrawPhaseMod(step, (float)(2.0f * Math.PI / 3.0f), vertical, color);
                pics[2] = new Image<Bgr, byte>(camera.TakePicture(2)).Split()[1];
                return pics;
            };
            Func<Image<Gray, byte>[], double[]> itop = (pics) =>
            {
                return cameraCorners.Select(c =>
                {
                    var mini = nolight[(int)c.Y, (int)c.X].Intensity;
                    var maxi = fulllight[(int)c.Y, (int)c.X].Intensity;
                    var i1 = pics[0][(int)c.Y, (int)c.X].Intensity;
                    i1 = (i1 - mini) / (maxi - mini);
                    var i2 = pics[1][(int)c.Y, (int)c.X].Intensity;
                    i2 = (i2 - mini) / (maxi - mini);
                    var i3 = pics[2][(int)c.Y, (int)c.X].Intensity;
                    i3 = (i3 - mini) / (maxi - mini);
                    return PhaseModulation.IntensityToPhase(i1, i2, i3);
                }).ToArray();
            };

            int w = projector.Size.Width;
            int h = projector.Size.Height;
            var xphs = itop(takePics(subdiv, true));
            var yphs = itop(takePics(subdiv, false));

            var ids = new int[cameraCorners.Length];
            int idx = 0;
            ids = ids.Select(i => idx++).ToArray();

            return ids.Select(i =>
                {
                    var v = rough[i];
                    var denom = (double)subdiv;
                    var xph = xphs[i] * (w / denom);
                    var yph = yphs[i] * (h / denom);
                    var phsx = Math.Floor(v.X / denom) * denom;
                    var phsy = Math.Floor(v.Y / denom) * denom;
                    double apx = v.X / w;
                    double phx = xphs[i];

                    apx = Math.Floor(apx / (1.0 / denom)) * (1.0 / denom) + (phx < 1 ? phx / denom : 0);
                    apx = Math.Round(apx, 5) * w;

                    double apy = v.Y / h;
                    double phy = yphs[i];

                    apy = Math.Floor(apy / (1.0 / denom)) * (1.0 / denom) + (phy < 1 ? phy / denom : 0);
                    apy = Math.Round(apy, 5) * h;

                    return new PointF((float)(apx), (float)(apy));

                }).ToArray();
        }
开发者ID:virrkharia,项目名称:dynamight,代码行数:73,代码来源:StereoCalibration.cs

示例6: PhaseCalib

        public static PointF[] PhaseCalib(Projector projector, Camera camera, PointF[] cameraCorners, int steps = 7)
        {
            var color = Color.Green;
            projector.DrawBackground(Color.Black);
            var nolight = new Image<Bgr, byte>(camera.TakePicture(2)).Split()[1];

            projector.DrawBackground(color);
            var fulllight = new Image<Bgr, byte>(camera.TakePicture(2)).Split()[1];
            Func<int, bool, Image<Gray, byte>[]> takePics = (step, vertical) =>
            {
                Image<Gray, byte>[] pics = new Image<Gray, byte>[3];
                projector.DrawBackground(Color.Black);
                camera.TakePicture(5).Dispose();
                projector.DrawPhaseMod(step, (float)(-2.0f * Math.PI / 3.0f), vertical, color);
                pics[0] = new Image<Bgr, byte>(camera.TakePicture(2)).Split()[1];
                projector.DrawBackground(Color.Black);
                camera.TakePicture(5).Dispose();
                projector.DrawPhaseMod(step, 0f, vertical, color);
                pics[1] = new Image<Bgr, byte>(camera.TakePicture(2)).Split()[1];
                projector.DrawBackground(Color.Black);
                camera.TakePicture(5).Dispose();
                projector.DrawPhaseMod(step, (float)(2.0f * Math.PI / 3.0f), vertical, color);
                pics[2] = new Image<Bgr, byte>(camera.TakePicture(2)).Split()[1];
                return pics;
            };
            Func<Image<Gray, byte>[], double[]> itop = (pics) =>
            {
                return cameraCorners.Select(c =>
                {
                    var mini = nolight[(int)c.Y, (int)c.X].Intensity;
                    var maxi = fulllight[(int)c.Y, (int)c.X].Intensity;
                    var i1 = pics[0][(int)c.Y, (int)c.X].Intensity;
                    i1 = (i1 - mini) / (i1 - maxi);
                    var i2 = pics[1][(int)c.Y, (int)c.X].Intensity;
                    i2 = (i2 - mini) / (i2 - maxi);
                    var i3 = pics[2][(int)c.Y, (int)c.X].Intensity;
                    i3 = (i3 - mini) / (i3 - maxi);
                    return PhaseModulation.IntensityToPhase(i1, i2, i3);
                }).ToArray();
            };

            int w = projector.Size.Width;
            int h = projector.Size.Height;
            int subdiv = 1;
            int[] xs = new int[cameraCorners.Length];
            int[] ys = new int[cameraCorners.Length];
            int[] ids = Range.OfInts(cameraCorners.Length).ToArray();
            for (int i = 0; i < steps; i++)
            {
                var xpics = takePics(subdiv, true);
                var xphs = itop(xpics);
                var xh = ids.Select(id => xphs[id] > 0.5).ToArray();

                var qd = QuickDraw.Start(xpics[1].Bitmap);
                var thrash = ids.Select(id =>
                {
                    qd.Color(xh[id] ? Color.White : Color.Gray);
                    qd.DrawPoint(cameraCorners[id].X, cameraCorners[id].Y, 5);
                    return id;
                }).ToArray();
                qd.Finish();
                DebugWindow.DrawBitmap(xpics[1].Bitmap);

                var ypics = takePics(subdiv, false);
                var yphs = itop(ypics);
                var yh = ids.Select(id => yphs[id] > 0.5).ToArray();

                qd = QuickDraw.Start(ypics[1].Bitmap);
                thrash = ids.Select(id =>
                {
                    qd.Color(yh[id] ? Color.White : Color.Gray);
                    qd.DrawPoint(cameraCorners[id].X, cameraCorners[id].Y, 5);
                    return id;
                }).ToArray();
                qd.Finish();
                DebugWindow.DrawBitmap(ypics[1].Bitmap);

                xs = ids.Select(id => (xs[id] << 1) | (xh[id] ? 1 : 0)).ToArray();
                ys = ids.Select(id => (ys[id] << 1) | (yh[id] ? 1 : 0)).ToArray();

                subdiv = subdiv << 1;
            }
            var fxs = ids.Select(id => ((double)xs[id] / (double)subdiv) * w).ToArray();
            var fys = ids.Select(id => ((double)ys[id] / (double)subdiv) * h).ToArray();
            return fxs.Zip(fys, (x,y) => new PointF((float)x,(float)y)).ToArray();
        }
开发者ID:virrkharia,项目名称:dynamight,代码行数:86,代码来源:StereoCalibration.cs

示例7: FindHomography

 public static Func<PointF[], PointF[]> FindHomography(PointF[] ccs, PointF[] pcs)
 {
     var hg = Emgu.CV.CameraCalibration.FindHomography(ccs, pcs, HOMOGRAPHY_METHOD.DEFAULT, 2);
     var t = ccs.Select(c => new PointF(c.X, c.Y)).ToArray();
     hg.ProjectPoints(t);
     var tes = pcs.Zip(t, (a, b) => (b.X - a.X) * (b.X - a.X) + (b.Y - a.Y) * (b.Y - a.Y)).ToArray();
     var sum = tes.Sum();
     return (ps) =>
     {
         var psc = ps.Select(p => new PointF(p.X, p.Y)).ToArray();
         hg.ProjectPoints(psc);
         return psc;
     };
 }
开发者ID:virrkharia,项目名称:dynamight,代码行数:14,代码来源:StereoCalibration.cs

示例8: CalibrateProjector

        public static CalibrationResult CalibrateProjector(Projector projector, Camera camera, Size pattern, CalibrationResult cameraCalib, PointF[][] cacalibdata, Size cameraPattern, float checkerboardSize)
        {
            List<PointF[]> cameraCorners = new List<PointF[]>();
            List<PointF[]> projectorCorners = new List<PointF[]>();
            var cpattern = new Size(pattern.Width - 1, pattern.Height - 1);
            int steps = 15;
            double rotx = 0, roty = 0, rotz = 0;
            for (int i = 0; i < steps; i++)
            {
                var di = (double)i / (double)steps;
                rotx = 0;
                roty = Math.Sin(di * Math.PI / 2) * 0.8;
                rotz = Math.Sin(di * Math.PI / 2) * 0.6;
                var pcs = projector.DrawCheckerboard(pattern,
                    rotx,
                    roty,
                    rotz, 0.5);
                var img = camera.TakePicture(3);
                var ccs = GetCameraCorners(img, cpattern, false);
                if (ccs != null)
                {

                    projectorCorners.Add(pcs);
                    cameraCorners.Add(ccs);
                    var withCorners = camera.TakePicture(0);
                    if (DebugWindow != null)
                    {
                        QuickDraw.Start(withCorners)
                            .Color(Color.White)
                            .DrawPoint(ccs, 5)
                            .Finish();
                        DebugWindow.DrawBitmap(withCorners);
                    }
                }
            }
            //for (int i = 0; i < steps; i++)
            //{
            //    var di = (double)i / (double)steps;
            //    rotx += 0.04;
            //    roty *= 0.90;
            //    var pcs = projector.DrawCheckerboard(pattern,
            //        rotx,
            //        roty,
            //        rotz, 0.7);
            //    var ccs = GetCameraCorners(camera, cpattern, false);
            //    if (ccs != null)
            //    {

            //        projectorCorners.Add(pcs);
            //        cameraCorners.Add(ccs);
            //        var withCorners = camera.TakePicture(0);
            //        if (DebugWindow != null)
            //        {
            //            QuickDraw.Start(withCorners)
            //                .Color(Color.White)
            //                .DrawPoint(ccs, 5)
            //                .Finish();
            //            DebugWindow.DrawBitmap(withCorners);
            //        }
            //    }
            //}

            var hm = CreateHomography(cameraCorners.ToArray(), projectorCorners.ToArray());
            var globals = GenerateCheckerBoard(cameraPattern, checkerboardSize, 0);
            var globalCorners = cacalibdata.Select(row => globals).ToArray();
            var proj = cacalibdata.Select(cs => cs.Select(c => new PointF(c.X, c.Y)).ToArray()).ToArray();
            foreach (var p in proj)
                hm.ProjectPoints(p);
            IntrinsicCameraParameters projIntrin = new IntrinsicCameraParameters();
            ExtrinsicCameraParameters[] projExtrins;
            Emgu.CV.CameraCalibration.CalibrateCamera(globalCorners, proj, projector.Size, projIntrin, Emgu.CV.CvEnum.CALIB_TYPE.CV_CALIB_RATIONAL_MODEL, out projExtrins);

            return new CalibrationResult() { Intrinsic = projIntrin, Extrinsic = projExtrins.First() };
        }
开发者ID:virrkharia,项目名称:dynamight,代码行数:74,代码来源:StereoCalibration.cs

示例9: CalibrateCamera

 public static CalibrationResult CalibrateCamera(PointF[][] cameraCorners, Size cameraSize, Size pattern, float checkerBoardSize)
 {
     var globals = GenerateCheckerBoard(pattern, checkerBoardSize, 0);
     var globalCorners = cameraCorners.Select(row => globals).ToArray();
     var intrinsic = new IntrinsicCameraParameters();
     ExtrinsicCameraParameters[] cameraExtrinsicsArray;
     Emgu.CV.CameraCalibration.CalibrateCamera(globalCorners, cameraCorners, cameraSize, intrinsic, CALIB_TYPE.CV_CALIB_RATIONAL_MODEL, out cameraExtrinsicsArray);
     var extrinsic = cameraExtrinsicsArray.First();
     return new CalibrationResult() { Intrinsic = intrinsic, Extrinsic = extrinsic };
 }
开发者ID:virrkharia,项目名称:dynamight,代码行数:10,代码来源:StereoCalibration.cs

示例10: RenderMap

        public static int RenderMap(Rectangle clip, Graphics g, bool dedicated, ref float scale)
        {
            var ets2Tel = (Main.Data.Active == null)
                ? default(Ets2Telemetry)
                : ((Ets2DataMiner)Main.Data.Active).MyTelemetry;

            // Search the map
            var map = FrmMain.Ets2Map;

            g.FillRectangle(map.Loading ? Brushes.DarkOrange : Brushes.Black, clip);
            g.SmoothingMode = mapScale < 1000 ? SmoothingMode.AntiAlias : SmoothingMode.HighSpeed;
            g.InterpolationMode = InterpolationMode.NearestNeighbor;
            g.PixelOffsetMode = PixelOffsetMode.None;

            float tx = 0.0f;
            float ty = 0.0f;
            float baseScale = 0.0f;

            if (Main.Data.Active == null || (dedicated && locationOverride))
            {
                tx = location.X;
                ty = location.Y;
                baseScale = mapScale;
            }
            else
            {
                var d = GetLivePoint();
                tx = d.Item1.X;
                ty = d.Item1.Y;
                baseScale = d.Item2;
            }

            var totalX = 0.0f;
            var totalY = 0.0f;

            // Input scale value is max scale
            var maxScale = scale;
            if (baseScale > maxScale)
                baseScale = scale;
            scale = baseScale;

            if (clip.Width > clip.Height)
            {
                totalX = baseScale;
                totalY = (int)(baseScale * (float)clip.Height / clip.Width);
            }
            else
            {
                totalY = baseScale;
                totalX = (int)(baseScale * (float)clip.Width / clip.Height);
            }

            var startX = clip.X + tx - totalX;
            var endX = clip.X + tx + totalX;
            var startY = clip.Y + ty - totalY;
            var endY = clip.Y + ty + totalY;

            var scaleX = clip.Width / (endX - startX);
            var scaleY = clip.Height / (endY - startY);

            if (float.IsInfinity(scaleX) || float.IsNaN(scaleX))
                scaleX = clip.Width;
            if (float.IsInfinity(scaleY) || float.IsNaN(scaleY))
                scaleY = clip.Height;

            var nodesNearby =
                map.Nodes.Values.Where(
                    x => x.X >= startX - 1500 && x.X <= endX + 1500 && x.Z >= startY -1500 && x.Z <= endY + 1500);
            var itemsNearby = nodesNearby.SelectMany(x => x.GetItems()).Where(x => x.HideUI == false).ToList();

            var roads = itemsNearby.Where(x => x.Type == Ets2ItemType.Road);
            var prefabs = itemsNearby.Where(x => x.Type == Ets2ItemType.Prefab);

            var gpsPen = new Pen(Brushes.MediumPurple, 22*scaleX);
            var localPen = new Pen(Brushes.Orange, 7.5f * scaleX);
            var prefabLane = new Pen(Brushes.Yellow, 3 * scaleX);
            var expressPen = new Pen(Brushes.Yellow, 19 * scaleX);
            var highwayPen = new Pen(Brushes.Red, 22*scaleX);

            List<ulong> nodesPassed = new List<ulong>();
            List<List<PointF>> roadPoints = new List<List<PointF>>();
            var nodesToFollow = prefabs.SelectMany(x => x.NodesList.Values).Distinct();

            // Gather all prefabs, and issue a drawing command
            foreach (var node in nodesToFollow)
            {
                if (node == null)
                    continue;

                bool isHighway = false;
                bool isExpress = false;
                bool isLocal = false;

                // Nodes from prefab are always like:
                // Prefab = Forward
                // Road=backward
                var road = node.ForwardItem != null && node.ForwardItem.Type == Ets2ItemType.Prefab
                    ? node.BackwardItem
                    : node.ForwardItem;
                var roadStart = road;
//.........这里部分代码省略.........
开发者ID:nlhans,项目名称:SimShift,代码行数:101,代码来源:dlMap.cs

示例11: OctavePlot

 public OctavePlot(PointF[] points)
 {
     dataX = Embrace(String.Join(",", points.Select(d => d.X.ToString(cul))));
     dataY = Embrace(String.Join(",", points.Select(d => d.Y.ToString(cul))));
 }
开发者ID:bellal89,项目名称:cqa_medical,代码行数:5,代码来源:OctavePlot.cs


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