public Tracker() { InitializeComponent(); //UI label_RedBG.SendToBack(); label_BlueBG.SendToBack(); label_RedBG.Controls.Add(label_CarA); label_RedBG.Controls.Add(labelAScore); label_BlueBG.Controls.Add(label_CarB); int newX = label_CarB.Location.X - label_BlueBG.Location.X; int newY = label_CarB.Location.Y - label_BlueBG.Location.Y; label_CarB.Location = new System.Drawing.Point(newX, newY); label_BlueBG.Controls.Add(labelBScore); newX = labelBScore.Location.X - label_BlueBG.Location.X; newY = labelBScore.Location.Y - label_BlueBG.Location.Y; labelBScore.Location = new System.Drawing.Point(newX, newY); label_GameCount.Text = "上半场"; InitialCaiServer(); MessageBox.Show("TCP IP is " + server.getUsedIP().ToString() + " port is " + server.getPort().ToString()); udp = new CaiNetwork.CaiUDP(); MessageBox.Show("UDP IP is " + udp.broadcastIpEndPoint.Address.ToString() + " port is " + udp.broadcastIpEndPoint.Port.ToString()); // Init flags = new MyFlags(); flags.Init(); flags.Start(); ptsShowCorners = new Point2f[4]; cc = new CoordinateConverter(flags); localiser = new Localiser(); capture = new VideoCapture(); // threadCamera = new Thread(CameraReading); capture.Open(0); timeCamNow = DateTime.Now; timeCamPrev = timeCamNow; car1 = new Point2i(); car2 = new Point2i(); buttonStart.Enabled = true; buttonPause.Enabled = false; button_AReset.Enabled = false; button_BReset.Enabled = false; Game.LoadMap(); game = new Game(); if (capture.IsOpened()) { capture.FrameWidth = flags.cameraSize.Width; capture.FrameHeight = flags.cameraSize.Height; capture.ConvertRgb = true; timer100ms.Interval = 75; timer100ms.Start(); //Cv2.NamedWindow("binary"); } }
public Tracker() { InitializeComponent(); InitialCaiServer(); MessageBox.Show("TCP IP is " + server.getUsedIP().ToString() + " port is " + server.getPort().ToString()); udp = new CaiNetwork.CaiUDP(); MessageBox.Show("UDP IP is " + udp.broadcastIpEndPoint.Address.ToString() + " port is " + udp.broadcastIpEndPoint.Port.ToString()); tbsPoint = new TextBox[] { tbPoint1, tbPoint2, tbPoint3, tbPoint4 }; // Init flags = new MyFlags(); flags.Init(); flags.Start(); ptsShowCorners = new Point2f[4]; cc = new CoordinateConverter(flags); localiser = new Localiser(); capture = new VideoCapture(); // threadCamera = new Thread(CameraReading); /****************************************** 修改了此处,调用电脑自带摄像头 ******************************************/ capture.Open(0); //capture.Open(1); timeCamNow = DateTime.Now; timeCamPrev = timeCamNow; car1 = new Point2i(); car2 = new Point2i(); buttonStart.Enabled = true; buttonPause.Enabled = false; button_reset.Enabled = false; Game.LoadMap(); game = new Game(); if (capture.IsOpened()) { capture.FrameWidth = flags.cameraSize.Width; capture.FrameHeight = flags.cameraSize.Height; capture.ConvertRgb = true; timer100ms.Interval = 75; timer100ms.Start(); //Cv2.NamedWindow("binary"); } portCB.Items.AddRange(System.IO.Ports.SerialPort.GetPortNames()); myID = 'A'; }