Ejemplo n.º 1
0
 public Coorespondence(SolveProjector left, SolveProjector right, EdgePoint point)
 {
     this.left  = left;
     this.right = right;
     this.point = point;
 }
 public Coorespondence(SolveProjector left, SolveProjector right, EdgePoint point)
 {
     this.left = left;
     this.right = right;
     this.point = point;
 }
Ejemplo n.º 3
0
        private void AddPointToTree()
        {
            if (PointTree.SelectedNode == null)
            {
                return;
            }

            if (Align.Selected)
            {
                // Code to build sets of points

                //if (Control.ModifierKeys == Keys.Alt || Control.ModifierKeys == (Keys.Alt | Keys.Shift))
                //{
                //    bool North = Control.ModifierKeys == (Keys.Alt | Keys.Shift);

                //    if (PointTree.SelectedNode.Tag is ProjectorEntry)
                //    {
                //        Random rnd = new Random();

                //        ProjectorEntry pe = PointTree.SelectedNode.Tag as ProjectorEntry;

                //        for (double alt = 0; alt < 90; alt+=15)
                //        {

                //            //double alt = alts[i];
                //            double steps = 25;

                //            //if (i == 3)
                //            //{
                //            //    steps = 5;
                //            //}

                //            for (double az = 0; az < 360; az += 360 / steps)
                //            {
                //                GroundTruthPoint pnt = new GroundTruthPoint();

                //                int cX = pe.Width / 2;
                //                int cY = pe.Height / 2;
                //                cY = 120;

                //                double rad = pe.Height / 2;
                //                rad = pe.Width / 2;

                //                double az2 = az - 90;
                //                pnt.X = cX + (float)Math.Cos(az2 / 180 * Math.PI) * ((90 - alt) / 90) * rad;
                //                pnt.Y = cY - (float)Math.Sin(az2 / 180 * Math.PI) * ((90 - alt) / 90) * rad;

                //                pnt.X += rnd.NextDouble() / 1000f;
                //                pnt.Y += rnd.NextDouble() / 1000f;
                //                //pnt.X = pe.Width / 2;
                //                //pnt.Y = pe.Height / 2;

                //                pnt.Alt = alt;
                //                pnt.Az = az;
                //                pnt.AxisType = AxisTypes.Both;

                //                if (pnt.Y > 0)
                //                {
                //                    pe.Constraints.Add(pnt);
                //                    pe.SelectedGroundTruth = pe.Constraints.Count - 1;

                //                    TreeNode child = PointTree.SelectedNode.Nodes.Add(pnt.ToString());
                //                    child.Tag = pnt;
                //                }

                //            }
                //        }
                //    }

                if (ModifierKeys == Keys.Alt || ModifierKeys == (Keys.Alt | Keys.Shift))
                {
                    if (PointTree.SelectedNode.Tag is ProjectorEntry)
                    {
                        var pe = PointTree.SelectedNode.Tag as ProjectorEntry;

                        for (var i = 0; i < 4; i++)
                        {

                            var alt = alts[i];
                            double steps = 25;

                            if (i == 3)
                            {
                                steps = 5;
                            }

                            for (var az = 7.2; az < 360; az += 360 / steps)
                            {
                                var pnt = new GroundTruthPoint
                                {
                                    X = pe.Width/2.0,
                                    Y = pe.Height/2.0,
                                    Alt = alt,
                                    Az = az,
                                    AxisType = AxisTypes.Both
                                };

                                if (altCenter[pe.ID - 1] < 70)
                                {
                                    if (((Math.Abs(az - centers[pe.ID - 1]) < 55) || (Math.Abs((az - 360) - centers[pe.ID - 1]) < 55)) && alt < 75)
                                    {
                                        pe.Constraints.Add(pnt);
                                        pe.SelectedGroundTruth = pe.Constraints.Count - 1;

                                        var child = PointTree.SelectedNode.Nodes.Add(pnt.ToString());
                                        child.Tag = pnt;
                                    }
                                }
                                else if (altCenter[pe.ID - 1] == 70)
                                {
                                    if (((Math.Abs(az - centers[pe.ID - 1]) < 95) || (Math.Abs((az - 360) - centers[pe.ID - 1]) < 95)) && alt > 25)
                                    {
                                        pe.Constraints.Add(pnt);
                                        pe.SelectedGroundTruth = pe.Constraints.Count - 1;

                                        var child = PointTree.SelectedNode.Nodes.Add(pnt.ToString());
                                        child.Tag = pnt;
                                    }
                                }

                            }
                        }
                    }

                    return;
                }

                if (PointTree.SelectedNode.Tag is ProjectorEntry)
                {
                    var pe = PointTree.SelectedNode.Tag as ProjectorEntry;

                    var props = new GroundTruthPointProperties();

                    var pnt = new GroundTruthPoint {X = pe.Width/2.0, Y = pe.Height/2.0};

                    props.Target = pnt;
                    if (props.ShowDialog() == DialogResult.OK)
                    {

                        pe.Constraints.Add(pnt);

                        pe.SelectedGroundTruth = pe.Constraints.Count - 1;

                        var child = PointTree.SelectedNode.Nodes.Add(pnt.ToString());
                        child.Tag = pnt;
                        PointTree.SelectedNode = child;
                    }
                    return;
                }
                var groundTruthPoint = PointTree.SelectedNode.Tag as GroundTruthPoint;
                if (groundTruthPoint != null)
                {
                    var pe = PointTree.SelectedNode.Parent.Tag as ProjectorEntry;

                    var props = new GroundTruthPointProperties();

                    var pnt = new GroundTruthPoint {X = pe.Width/2.0, Y = pe.Height/2.0};

                    props.Target = pnt;
                    if (props.ShowDialog() == DialogResult.OK)
                    {
                        var index = pe.Constraints.IndexOf(groundTruthPoint) + 1;

                        pe.Constraints.Insert(index, pnt);

                        var child = PointTree.SelectedNode.Parent.Nodes.Insert(PointTree.SelectedNode.Index + 1, pnt.ToString());
                        child.Tag = pnt;
                        PointTree.SelectedNode = child;
                    }
                    return;
                }

                if (PointTree.SelectedNode.Tag is Edge)
                {
                    var edge = PointTree.SelectedNode.Tag as Edge;

                    var ep = new EdgePoint {Left = new GroundTruthPoint(), Right = new GroundTruthPoint()};

                    ep.Left.X = CalibrationInfo.ProjLookup[edge.Left].Width / 2.0;
                    ep.Left.Y = CalibrationInfo.ProjLookup[edge.Left].Height / 2.0;
                    ep.Right.X = CalibrationInfo.ProjLookup[edge.Left].Width / 2.0;
                    ep.Right.Y = CalibrationInfo.ProjLookup[edge.Left].Height / 2.0;
                    edge.Points.Add(ep);
                    var child = PointTree.SelectedNode.Nodes.Add(ep.ToString());
                    child.Tag = ep;
                    PointTree.SelectedNode = child;
                    return;
                }
                if (PointTree.SelectedNode.Tag is EdgePoint)
                {
                    var edge = PointTree.SelectedNode.Parent.Tag as Edge;

                    var ep = new EdgePoint {Left = new GroundTruthPoint(), Right = new GroundTruthPoint()};

                    ep.Left.X = CalibrationInfo.ProjLookup[edge.Left].Width / 2.0;
                    ep.Left.Y = CalibrationInfo.ProjLookup[edge.Left].Height / 2.0;
                    ep.Right.X = CalibrationInfo.ProjLookup[edge.Left].Width / 2.0;
                    ep.Right.Y = CalibrationInfo.ProjLookup[edge.Left].Height / 2.0;

                    edge.Points.Insert(PointTree.SelectedNode.Index + 1, ep);
                    var child = PointTree.SelectedNode.Parent.Nodes.Insert(PointTree.SelectedNode.Index + 1, ep.ToString());
                    child.Tag = ep;
                    PointTree.SelectedNode = child;
                    return;
                }

                if (PointTree.SelectedNode.Text == "Edges")
                {
                    var edge = new Edge(-1, -1);
                    var props = new EdgeProperties {Edge = edge};
                    edge.Owner = CalibrationInfo;

                    if (props.ShowDialog() == DialogResult.OK)
                    {
                        if (edge.Left != -1 && edge.Right != -1 && edge.Right != edge.Left)
                        {
                            CalibrationInfo.AddEdge(edge);
                            ReloadPointTree();
                        }
                    }
                }
            }
            else
            {
                if (PointTree.SelectedNode.Tag is ProjectorEntry)
                {
                    var pe = PointTree.SelectedNode.Tag as ProjectorEntry;
                    var pnt = new BlendPoint {X = pe.Width/2.0, Y = pe.Height/2.0};

                    pe.BlendPolygon.Add(pnt);

                    pe.SelectedBlendPoint = pe.BlendPolygon.Count - 1;

                    var child = PointTree.SelectedNode.Nodes.Add(pnt.ToString());
                    child.Tag = pnt;
                    PointTree.SelectedNode = child;
                    return;

                }

                if (PointTree.SelectedNode.Parent != null && PointTree.SelectedNode.Parent.Tag is ProjectorEntry)
                {
                    var bp = (BlendPoint)PointTree.SelectedNode.Tag;

                    var pe = PointTree.SelectedNode.Parent.Tag as ProjectorEntry;
                    var pnt = new BlendPoint {X = pe.Width/2.0, Y = pe.Height/2.0};

                    var index = pe.BlendPolygon.IndexOf(bp) + 1;
                    pe.BlendPolygon.Insert(index, pnt);

                    pe.SelectedBlendPoint = index + 1;

                    var child = PointTree.SelectedNode.Parent.Nodes.Insert(index, pnt.ToString());
                    child.Tag = pnt;
                    PointTree.SelectedNode = child;
                }
            }
        }